Re: do you fail at FizzBuzz? simple prog test

2008-05-12 Thread Max Erickson
r >> i (or perhaps >>      print (('' if i%3 else 'Fizz') + ('' if i%5 else 'Buzz')) >> or i to save looking up the precedence rules) ? > > Stuff clarity! How about > > for i in xrange(1, 101): > print 'FizzBuzz'[4*(i%3>0):4+4*(i%5<1)] or i > > -- > Arnaud > > -- > http://mail.python.org/mailman/listinfo/python-list > > With no loop: i=1 exec"print'FizzBuzz'[4*(i%3>0):4+4*(i%5<1)]or i;i+=1;"*100 max -- http://mail.python.org/mailman/listinfo/python-list

Re: Literate programs in Python

2008-05-13 Thread Max M
xample.html -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: send yield

2008-05-15 Thread Max Erickson
castironpi <[EMAIL PROTECTED]> wrote: > Why can't I write this? > -- > http://mail.python.org/mailman/listinfo/python-list > > Because you don't know how? max -- http://mail.python.org/mailman/listinfo/python-list

Re: New chairman

2008-05-27 Thread Max M
/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Flash Decoder

2008-05-28 Thread Max Erickson
t; -- > http://mail.python.org/mailman/listinfo/python-list > > It even already exists. There is a binary interface that is maintained alongside pyglet: http://code.google.com/p/avbin/ and then ctypes wrapper for that interface in pyglet: http://code.google.com/p/pyglet/source/browse/

Re: Handling some isolated iso-8859-1 characters

2008-06-04 Thread Max M
t.com/2008/03/python-unicode-lessons-from-school-of.html -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: Sydebar 1.0 - A browser sidebar generator for Python documentation

2008-06-04 Thread Max M
This looks great. I have been missing my chm based docs since moving to Python. This goes a long way. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: expanding a variable to a dict

2008-04-03 Thread Max M
/usr/src' for a in ['dictFoo','dictBar','dictFrotz']: if not 'srcdir' in a: a['srcdir'] = '/usr/src' for a in ['dictFoo','dictBar','dictFrotz']: a.setdefault('srcdir') = '/usr/src' -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: expanding a variable to a dict

2008-04-09 Thread Max M
John Machin skrev: > On Apr 4, 9:44 am, Max M <[EMAIL PROTECTED]> wrote: > Ummm ... excessive apostrophes plus bonus gross syntax error, dood. > Did you try running any of these snippets??? No I just wanted to quickly show different ways to do it. The dicts in the original

Re: [ANN]: Python-by-Example updates

2008-04-12 Thread Max Erickson
thanks, > The second set of examples on the page for decimal doesn't look quite right. The first couple of lines: getcontext().prec = 6 # Decimal('3.0') Decimal("3.0") # Decimal('3.1415926535') I would assume that the "

Re: urllib2 Basic authentication, what am I doing wrong?

2008-04-13 Thread Max Erickson
bly, between the realm and uri that you are providing to the password manager, it isn't providing a password for the page you want to load. I've had success just explicitly setting the authorization header, using the method discussed in the comments on this page: http://aspn.activestate.

Re: Python Success stories

2008-04-22 Thread Max M
mply gone quiet. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Little novice program written in Python

2008-04-25 Thread Max M
a feel for the language. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Little novice program written in Python

2008-04-25 Thread Max M
e c family of languages where there is a lot more algorithms due to the low level coding. Memory handling, list, dicts etc. qickly becomes more like math algorithms than in Python. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Python equivalent to PHP's SPL __autoload() ??

2008-04-27 Thread Max Erickson
t in the box, but most of what you need is built in, you just have to do a little work to use it. See the "Loading and reloading modules" section on this page: http://effbot.org/librarybook/builtin.htm max -- http://mail.python.org/mailman/listinfo/python-list

Re: Given a string - execute a function by the same name

2008-04-28 Thread Max M
e dict of functions is a bit safer. You don't risk calling a built in method on your object . Which you risk doing with something like: getattr(obj, 'join') -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Given a string - execute a function by the same name

2008-04-29 Thread Max M
note: What you will be doing is a variation of the factory pattern. So this search might give you some new ideas: http://www.google.dk/search?hl=en&q=python+factory+pattern -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: tool to calculate color combination

2008-05-01 Thread Max M
0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59] if not transparent: template[13:16] = self.bytes() # set rgb values template[22] = 0 # remove transparency return ''.join(map(chr, template)) if __name__==&#

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Max M
Perhaps csound can help with this. It has a lot of midi, realtime and python stuff. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: ISBN Barecode reader in Python?

2008-05-05 Thread Max Erickson
an email with the Amazon price in response would be way easier than typing the isbn into Google or whatever. max -- http://mail.python.org/mailman/listinfo/python-list

Re: Python MIDI in 2008

2008-05-06 Thread Max M
it on Windows and I found it to be a bore to get real time midi working. It would probably be easier now that I am on Linux. Well I just thought I would mention that it is not dead. Merely middle aged. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://ma

Re: Am I missing something with Python not having interfaces?

2008-05-06 Thread Max M
ace. Just use: "easy_install zope.interface" And you have interfaces. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the purpose of ptyhon in Windows

2008-05-07 Thread Max Erickson
ier interpretation(i.e., tell me how I can use python instead of tell me why I should use python). The other question might be more like "I already know VBS, what do I gain by learning python?". (the answers could be "lots of things, including full applications" and

Re: Mathematics in Python are not correct

2008-05-11 Thread Max M
ut Python being broken. You will probably get better responses if you just state that there are things you do not understand, and ask why it works that way. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

multiprocessing eats memory

2008-09-25 Thread Max Ivanov
I'm playing with pyprocessing module and found that it eats lot's of memory. I've made small test case to show it. I pass ~45mb of data to worker processes and than get it back slightly modified. At any time in main process there are shouldn't be no more than two copies of data (one original data a

Re: New python.org website

2006-03-08 Thread Max M
projecktzero wrote: > I think the new site is great. I really don't understand all the nit > picking that's going on from the armchair web designers. It's a nice site. It is not ugly, and its easy to navigate. *much* better than the old site, -- hilsen/regards

Re: New python.org website

2006-03-08 Thread Max M
Comparing: http://www.python.org/ http://www.perl.org/ http://www.java.org/ http://www.ruby-lang.org/en/ http://java.sun.com/ http://www.php.net/ It is pretty easy to see that http://www.python.org/ is both prettier than the rest, and has a far better structure. -- hilsen/regards Max M

Re: Simple questions on use of objects (probably faq)

2006-03-08 Thread Max M
> What I hoped I could do: > class Foo: > def __init__(self,self.x): > continue > y=[] > y.append(Foo(10.0)) > y.append(Foo(110.0)) > y.append(Foo(60.0)) > > ys=([y[].x]) > y_max=max(y[].x) > y_min=min(y[].x) > > yz=[y[:-1].x-y[1:].x]

Re: Simple questions on use of objects (probably faq)

2006-03-08 Thread Max M
Brian Elmegaard wrote: > "Matt Hammond" <[EMAIL PROTECTED]> writes: > > >>y_max = max([e.x for e in y]) > > > Would there be a way to refer back to the e with maximum x, or how > could I find other attributes of it? In that case a common idiom is to

Re: PyCon2006 - will the content be available for download?

2006-03-08 Thread Max M
udioVideoRecording/HomePage -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: PyCon2006 - will the content be available for download?

2006-03-08 Thread Max M
lkFlags - audio-yes): http://us.pycon.org/zope/talks/talksRoster?year%3Alist=&day%3Alist=&track%3Alist=&title=&authors=&abstract=&flags%3Alist=audio-yes&order=Sequence Then most presentations with audio has several audio formats you can download. -- hilsen/regards

Re: PyCon2006 - will the content be available for download?

2006-03-08 Thread Max M
John Salerno wrote: > Max M wrote: > >> abcd wrote: >> >>> well actually, the site looked promising...only problem is no talks >>> have audio, video or handouts available (at least right now). >>> >>> oh well. >>> >> >&

Re: Hashtables in pyhton ...

2006-03-09 Thread Max M
;key2'] = 'value 2' >>> a_hash_is_a_dict['key'] 'value' -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96 -- http://mail.python.org/mailman/listinfo/python-list

Re: Cheese Shop: some history for the new-comers

2006-03-13 Thread Max M
es are bad in programming, whay are they good in general communication. "Python Packages" is too obvious perhaps? When we start using eggs will it then be renamed to "Dairy Shop" or perhaps "Daisy" to make it obscure? Or the "Chickens Nest"? Please. If it is

Re: MS word document generator

2006-03-15 Thread Max M
Raja Raman Sundararajan wrote: > I was wondering if there was any library as reportlab to generate word > documents. If you are on Windows, why dont you use word for it? You can call it from Python. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +

Re: Markov process representation

2006-03-16 Thread Max M
2003, 00:49:11) >> >>generator comprehensions are new in 2.4. Try: >> >> self._all_states |= set([key[i] for key in probabilities]) > > > And sets aren't a builtin in 2.3 > > try: > set() > except NameError: > import sets > set = set

distributing resources within a module folder

2006-03-18 Thread Max Kubierschky
I want to access some static (non changing) files from within a module (e.g icons, style sheets) and distribute them together with the module. Can I place the inside the module folder? If so, how can I access them? If not so, what is the best thing to do? Max -- http://mail.python.org/mailman

epydoc: links to other methods/classes with reStructuredText

2006-03-18 Thread Max Kubierschky
Hi, I try to use epydoc with reStructuredText. It works fine, my only problem is that I couldn't figure out the syntax for links to other methods or classes. Any hints? Max P.S: Where is the correct platform for discussing epydoc? -- http://mail.python.org/mailman/listinfo/python-list

Re: doctest, unittest, or if __name__='__main__'

2006-03-22 Thread Max M
ey combine two brilliant ideas that are hard to do in practice. "Testing" and "Literate Programming" In the process it even manages to make both a lot easier. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96 -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-27 Thread Max M
t;> 100+1 is 101 False They don't have the same id. (Think of id as memory adresses.) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96 -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-29 Thread Max M
unction: def somefunc(val=None): if val is None: val = [] do_stuff(val) Or if None is a possible parameter you can use your own object as a marker:: _marker = [] def somefunc(val=_marker): if val is marker: val = [] do_stuff(val) -- hilsen/regards M

Re: datetime: the date of the day one month ago...how?

2006-04-12 Thread Max M
lly don't want to calculate it by myself :-)) It is application specific. So how *do* you want one-month-ago(31.mar.2006) or one-month-ago(28.feb.2006) to work? No one can know but you. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96 -- http://mail.python.org/mailman/listinfo/python-list

HTTPS - HTTPPasswordMgrWithDefaultRealm

2009-12-11 Thread Max Slimmer
ret except URLError: log = logging.getLogger() log.warn("problem connecting") raise thanks, -- Max Slimmer -- http://mail.python.org/mailman/listinfo/python-list

RotatingFileHandler issue

2009-09-30 Thread Max Lynch
data. What gives? Am I doing something wrong? Thanks, Max -- http://mail.python.org/mailman/listinfo/python-list

Re: RotatingFileHandler issue

2009-10-14 Thread Max Lynch
I never got a response back from this, but I'm noticing even more odd behavior, see inline: On Wed, Sep 30, 2009 at 4:38 PM, Max Lynch wrote: > Hi. > I have a RotatingFileHandler for my logging system. I have it set to > rotate once the file becomes 5MB in size. Here is the co

while True or while 1

2010-12-12 Thread Max Countryman
I'm sure this has been brought up many times, but a quick Googling didn't yield the decisive results I was hoping for, so I apologize if this has already been addressed in great detail somewhere else. I am wondering what the rationale is behind preferring while True over while 1? For me, it see

Re: Python programming

2010-12-22 Thread Max Countryman
>>> 5 in [2, 6, 5] True Sent from my iPhone On Dec 22, 2010, at 20:22, Maurice Shih wrote: > Dear [email protected], > Thank you for taking the time to listen to my request. I'm a beginner > programmer and I se python 2.6. I am making a program that needs a command > that can check if a

fcntl, serial ports and serial signals on RS232.

2010-04-07 Thread Max Kotasek
ven taking the right approach by using the fcntl.ioctl call? The environment is a ubuntu 8.04 distribution. Unfortunately due to other limitations, I can't use/extend pyserial, though I would like to. I appreciate any advice on this matter, Max -- http://mail.python.org/mailman/listinfo/python-list

Re: fcntl, serial ports and serial signals on RS232.

2010-04-09 Thread Max Kotasek
On Apr 8, 11:17 am, Grant Edwards wrote: > On 2010-04-07, Max Kotasek wrote: > > > I'm trying to figure out how to parse the responses fromfcntl.ioctl() > > calls that modify the serial lines in a way that asserts that the line > > is now changed. > > Two c

Re: GDAL-1.7.1 : vcvarsall.bat missing

2010-06-25 Thread Max Erickson
r use with Python: http://www.develer.com/oss/GccWinBinaries He does note on the page that the MinGW project isn't quite so sure that GCC 4.x is ready for release. Max -- http://mail.python.org/mailman/listinfo/python-list

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread Max Erickson
x27; :u'\u00A0', '¡' >> :u'\u00A1', >> '¢':u'\u00A2', >> ^ You may want to try 2.6. Python 3.1 is not syntax compatible with 2.5 (so the u'' stuff won't work in 3.1): http://docs.python.org/dev/py3k/whatsnew/3.0.html#removed-syntax max -- http://mail.python.org/mailman/listinfo/python-list

Re: Python graphics / imaging library

2009-07-18 Thread Max Erickson
ain updates to the status of 1.1.7, it is headed towards a release. Preliminary tarballs and binaries are available on effbot.org: http://effbot.org/downloads/#imaging http://effbot.org/downloads/#pil max -- http://mail.python.org/mailman/listinfo/python-list

Re: base64 Incorrect Padding

2009-07-31 Thread Max Erickson
g" error then strip > out any whitespace and append extra ASCII '=' to make its length > a multiple of 3, then try decoding again. (Or you could just > repeatedly add one pad character and retry, up to 3 times.) The length of the encoded string should be a multiple of 4 (as you state in the second sentence of your post), not a multiple of 3. max -- http://mail.python.org/mailman/listinfo/python-list

Re: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread max bianco
On Sat, Aug 8, 2009 at 12:25 AM, Steven D'Aprano wrote: > On Fri, 07 Aug 2009 13:35:26 -0700, Kee Nethery wrote: > > >> > Why exactly is posting an open comment on a bug tracker somehow >> > inferior to posting an open comment on a wiki? >> >> It's a good question and deserves a good answer. >> >>

Re: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread max bianco
On Thu, Aug 6, 2009 at 2:36 PM, Kee Nethery wrote: > As someone trying to learn the language I want to say that the tone on this > list towards people who are trying to learn Python  feels like it has become > anti-newbies. > > Learning a new language is difficult enough without seeing other newbie

Re: httplib incredibly slow :-(

2009-08-12 Thread Max Erickson
Calling wget or curl using a subprocess is probably as easy as it is ugly, I use the wget build from here: http://gnuwin32.sourceforge.net/packages/wget.htm max -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-23 Thread Max Erickson
can handle different bases starts to make a lot of sense to me: >>> int('100', 8) 64 >>> int('100', 10) 100 >>> int('100', 16) 256 >>> int('100', 2) 4 >>> int('100', 3) 9 >>> int('100', 36) 1296 max -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Class implements Interface?

2009-08-27 Thread Max Landaeus
python+cookbook#v=onepage&q=&f=false <http://books.google.co.uk/books?id=Q0s6Vgb98CQC&printsec=frontcover&dq=python+cookbook#v=onepage&q=&f=false> Max -- http://mail.python.org/mailman/listinfo/python-list

Re: Python #ifdef

2013-06-02 Thread Erik Max Francis
hp files). But still, GNU M4 is a decent piece of technology. Agreed. The terror that most people feel when hearing "m4" is because m4 was associated with sendmail, not because m4 was inherently awful. It has problems, but you'd only encounter them when doing something _very_ abs

Re: Encapsulation, inheritance and polymorphism

2012-07-20 Thread Erik Max Francis
n Graham's Number but still inconceivably ginormous.) You don't even need to go that high. Even a run-of-the-mill googol (10^100) is far larger than the total number of elementary particles in the observable Universe. -- Erik Max Francis && [email protected] && http://w

Re: Encapsulation, inheritance and polymorphism

2012-07-21 Thread Erik Max Francis
On 07/20/2012 02:05 AM, Virgil Stokes wrote: On 20-Jul-2012 10:27, Steven D'Aprano wrote: The fellow looked relived and said "Oh thank god, I thought you said *million*!" How does this relate to the python list? It's also a seriously old joke. -- Erik Max Francis

Re: Encapsulation, inheritance and polymorphism

2012-07-21 Thread Erik Max Francis
On 07/20/2012 03:28 AM, BartC wrote: "Erik Max Francis" wrote in message news:[email protected]... On 07/20/2012 01:11 AM, Steven D'Aprano wrote: On Thu, 19 Jul 2012 13:50:36 -0500, Tim Chase wrote: I'm reminded of Graham's Number, whi

Re: Single leading dash in member variable names?

2012-09-11 Thread Erik Max Francis
as syntactic significance. Thank you! PEP 8 says this is bad form. What do you think? Where does it say that? -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Jabber erikmaxfrancis

Re: while True or while 1

2012-01-23 Thread Erik Max Francis
Giampaolo Rodolà wrote: Il 21 gennaio 2012 22:13, Erik Max Francis ha scritto: The real reason people still use the `while 1` construct, I would imagine, is just inertia or habit, rather than a conscious, defensive decision. If it's the latter, it's a case of being _way_ too defensi

Re: float("nan") in set or as key

2011-06-05 Thread Erik Max Francis
ite a different thing, not simply a Kronecker delta extended to the reals. Kronecker deltas are used all the time over the reals; for instance, in tensor calculus. Just because the return values are either 0 or 1 doesn't mean that their use is incompatible over reals (as integers

Re: break in a module

2011-06-14 Thread Erik Max Francis
onsist of mostly definitions. Modules can interact with each other, be called recursively, etc., and so at an arbitrary point saying, "break out of this module" doesn't have a great deal of meaning. -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis There is _never_ no hope left. Remember. -- Louis Wu -- http://mail.python.org/mailman/listinfo/python-list

Re: break in a module

2011-06-14 Thread Erik Max Francis
eak". To me, too -- too bad it doesn't work: c:\temp>\python32\python early_abort.py File "early_abort.py", line 7 return ^ SyntaxError: 'return' outside function Nor should it. There's nothing to return out of. -- Erik Max Francis && m.

Re: break in a module

2011-06-16 Thread Erik Max Francis
Eric Snow wrote: On Tue, Jun 14, 2011 at 5:51 PM, Erik Max Francis wrote: Ethan Furman wrote: To me, too -- too bad it doesn't work: c:\temp>\python32\python early_abort.py File "early_abort.py", line 7 return ^ SyntaxError: 'return' outside funct

Re: break in a module

2011-06-16 Thread Erik Max Francis
lookup where the keys are functions, and execute the value. Even then, unless there are quite a lot of cases, this may be overkill. -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxf

Re: break in a module

2011-06-16 Thread Erik Max Francis
Chris Angelico wrote: On Fri, Jun 17, 2011 at 8:07 AM, Erik Max Francis wrote: It's quite consistent on which control structures you can break out of -- it's the looping ones. Plus functions. No: >>> def f(): ... break ... File "", line 2 SyntaxError: 

Re: break in a module

2011-06-16 Thread Erik Max Francis
Chris Angelico wrote: On Fri, Jun 17, 2011 at 9:29 AM, Erik Max Francis wrote: Chris Angelico wrote: On Fri, Jun 17, 2011 at 8:07 AM, Erik Max Francis wrote: It's quite consistent on which control structures you can break out of -- it's the looping ones. Plus functions. N

Re: break in a module

2011-06-16 Thread Erik Max Francis
`. If you want to conditionally execute some code, use `if`. If you want to indicate an exceptional condition, raise an exception. -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype eri

Re: break in a module

2011-06-16 Thread Erik Max Francis
t you're just being difficult. -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis Winners are men who have dedicated their whole lives to winning. -- Woody Hayes -- http://mail.python.org/mailman/listinfo/python-list

Re: break in a module

2011-06-16 Thread Erik Max Francis
Ian Kelly wrote: On Thu, Jun 16, 2011 at 7:21 PM, Erik Max Francis wrote: Neither makes sense. `break` exits out of looping structures, which the top-level code of a module most certainly is not. Why does that matter? It seems a bit like arguing that the `in` keyword can't be use

Re: break in a module

2011-06-16 Thread Erik Max Francis
Ian Kelly wrote: On Thu, Jun 16, 2011 at 10:24 PM, Erik Max Francis wrote: True. So let's use `in` to represent breaking out of the top-level code of a module. Why not, it's not the first time a keyword has been reused, right? The point is, if it's not obvious already from

Re: break in a module

2011-06-17 Thread Erik Max Francis
Steven D'Aprano wrote: On Thu, 16 Jun 2011 22:20:50 -0700, Erik Max Francis wrote: [...] Yes, which could be rephrased as the fact that `break` and `continue` are restricted to looping control structures, so reusing `break` in this context would be a bad idea. You know, kind of like the

Re: Significant figures calculation

2011-06-27 Thread Erik Max Francis
ero sig figures value is ever useful.) Yes. They're order of magnitude estimates. 1 x 10^6 has one significant figure. 10^6 has zero. -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y

Re: Significant figures calculation

2011-06-27 Thread Erik Max Francis
igure would be an order of magnitude estimate only. These aren't usually done in the "e" scientific notation, but it would be something like 10^3 (if we assume ^ is exponentiation, not the Python operator). c^2 is 9 x 10^16 m^2/s^2 to one significant figure. It's 10^17 m^2/

Re: Significant figures calculation

2011-06-28 Thread Erik Max Francis
Mel wrote: Erik Max Francis wrote: Chris Angelico wrote: On Tue, Jun 28, 2011 at 12:56 PM, Steven D'Aprano wrote: Zero sig figure: 0 That's not really zero significant figures; without further qualification, it's one. Is 0.0 one sig fig or two? Two. (Just vaguely curiou

Re: Significant figures calculation

2011-06-28 Thread Erik Max Francis
t 2 x 10^-8 kg, or on the order of 10^-8 kg (zero significant figures). To convert to energy, multiply by c^2. c = 3 x 10^8 m/s, so c^2 = 9 x 10^16 m^2/s^2, or about 10^17 m^2/s^2, so the Planck energy is on the order of 10^9 J. That's a calculation to zero significant figures. --

Re: Significant figures calculation

2011-06-28 Thread Erik Max Francis
Mel wrote: Erik Max Francis wrote: Mel wrote: By convention, nobody ever talks about 1 x 9.97^6 . Not sure what the relevance is, since nobody had mentioned any such thing. If it was intended as a gag, I don't catch the reference. I get giddy once in a while.. push things to limits

Re: Is it bad practise to write __all__ like that

2011-07-28 Thread Erik Max Francis
f.append(obj.__name__) return obj __all__ = AllList() @__all__ def api(): pass @__all__ def db(): pass @__all__ def input(): pass @__all__ def output(): pass @__all__ def tcl(): pass Bravo! -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose,

Re: value of pi and 22/7

2011-03-17 Thread Erik Max Francis
quency. In all bases. -- Erik Max Francis && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis They love too much that die for love. -- (an English proverb) -- http://mail.python.org/mailman/listinfo/python-list

Re: float("nan") in set or as key

2011-05-28 Thread Erik Max Francis
nan} {nan} It's fundamentally because NaN is not equal to itself, by design. Dictionaries and sets rely on equality to test for uniqueness of keys or elements. >>> nan = float("nan") >>> nan == nan False In short, don't do that. -- Erik Max Francis &&

Re: float("nan") in set or as key

2011-05-28 Thread Erik Max Francis
Albert Hopkins wrote: On Sun, 2011-05-29 at 00:41 +0100, MRAB wrote: 1.0 == 1.0 True float("nan") == float("nan") False I can't cite this in a spec, but it makes sense (to me) that two things which are nan are not necessarily the same nan. It's part of t

Re: What is "self"?

2005-09-22 Thread Erik Max Francis
Ron Adam wrote: > When you call a method of an instance, Python translates it to... > > leader.set_name(leader, "John") It actually translates it to Person.set_name(leader, "John") -- Erik Max Francis && [EMAIL PROTECTED] && http://ww

Re: Human readable number formatting

2005-09-27 Thread Erik Max Francis
; formatting , so I've taken a stab at it: BOTEC at http://www.alcyone.com/software/botec/ contains a class called SI which does this formatting (and supports all SI prefixes). -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA,

Re: Where to find python c-sources

2005-09-29 Thread Erik Max Francis
research on Google? -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis The people are to be taken in very small doses. -- Ralph Waldo Emerson -- http://mail.python.org/mailman/listinfo/python-list

Re: Google Not Universal Panacea [was: Re: Where to find python c-sources]

2005-09-30 Thread Erik Max Francis
ing if I (and nobody else) answered his question and just rudely pointed him to Google. But since I actually answered his question, looks to me like someone just wanted to stand on his soapbox today. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.co

Re: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Erik Max Francis
made him change his mind? When the debates raged over PEP 308, he seemed pretty dead set against it (at least by proxy) ... -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis

Re: Google Not Universal Panacea [was: Re: Where to find python c-sources]

2005-10-01 Thread Erik Max Francis
a search engine won't be the most practical way to do research. This was _certainly_ not one of those cases. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis No mistaking / Just

Re: Python based unacceptable language filter

2005-10-03 Thread Erik Max Francis
the text, but then discards it. You meant: for badWord in badWords: textToFilter = textToFilter.replace(badWord, '<)!&%(#&)%>') -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 12

Re: check html file size

2005-10-04 Thread Erik Max Francis
Matt Garrish wrote: > Even if you weren't an incredibly offensive and petulant poster, what makes > you think anyone would write a script from you? Because in addition to being offensive and petulant, he's also an idiot. -- Erik Max Francis && [EMAIL PROTECTED] &

Re: dictionaries/pointers

2005-10-07 Thread Erik Max Francis
=None): self.value = value ...def get(self): return self.value ...def set(self, value): self.value = value ... >>> one = Container(1) >>> myDictionary = {} >>> myDictionary['a'] = one >>> myDictionary['b'] = one >>> myDictionary['b&#x

Re: piping out binaries properly

2005-10-11 Thread Erik Max Francis
he pbmplus library, and so forth. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Every human being is a problem in search of a solution. -- Ashley Montagu -- http://mail.python.org/mailman/listinfo/python-list

Re: TurboGears /.-ed, >new == True< or >new == "True"

2005-10-13 Thread Erik Max Francis
Andy Leszczynski wrote: > So how does it correspond to other piece of the code: > > 2 def notfound(self, pagename): > 3 return dict(pagename=pagename, data="", new=True) > > new is a boolean here? It comes through as a CGI query. -- Erik Max Francis

Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Erik Max Francis
ield 0 x = 1 while True: yield x yield -x x += 1 ... which is also not a bad demonstration of how the integers are countably infinite. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ S

Re: Problem splitting a string

2005-10-14 Thread Erik Max Francis
tr.split('_| '), but this gave me: > > ['this_NP is_VL funny_JJ'] > > It is not splitted at all. Use re.split: >>> re.split('_| ', s) ['this', 'NP', 'is', 'VL', 'funny', 'JJ']

Re: List of strings to list of floats ?

2005-10-17 Thread Erik Max Francis
Madhusudan Singh wrote: > Thanks. Now, a slightly more complicated question. > > Say I have two lists of floats. And I wish to generate a list of floats that > is a user defined function of the two lists. result = [sqrt(x**2 + y**2) for x, y in zip(xs, ys)] -- Erik

Re: Stripping ASCII codes when parsing

2005-10-17 Thread Erik Max Francis
chr(x) for x in range(32) + [124]) aNewString = aString.translate(IDENTITY_MAP, BAD_MAP) Note that ASCII 31 is also a control character (US). -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W &&

<    1   2   3   4   5   6   7   8   9   10   >