Re: def X(l=[]): weirdness. Python bug ?

2008-08-28 Thread Andrew Lee
Bart van Deenen wrote: Hi all. I've stumbled onto a python behavior that I don't understand at all. Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) # function def X(l=[]): l.append(1) print l # first call of X X() [1] #second call of X X() [1, 1] Where does the list parameter 'l'

Re: can python do some kernel stuff?

2008-05-23 Thread Andrew Lee
Diez B. Roggisch wrote: Andrew Lee schrieb: Diez B. Roggisch wrote: Jimmy schrieb: On May 23, 3:05 pm, Andrew Lee <[EMAIL PROTECTED]> wrote: Jimmy wrote: Hi to all python now has grown to a versatile language that can accomplish tasks for many different purposes. However, AFAIK, lit

Re: can python do some kernel stuff?

2008-05-23 Thread Andrew Lee
Diez B. Roggisch wrote: Jimmy schrieb: On May 23, 3:05 pm, Andrew Lee <[EMAIL PROTECTED]> wrote: Jimmy wrote: Hi to all python now has grown to a versatile language that can accomplish tasks for many different purposes. However, AFAIK, little is known about its ability of kernel coding

Re: can python do some kernel stuff?

2008-05-23 Thread Andrew Lee
Jimmy wrote: On May 23, 3:05 pm, Andrew Lee <[EMAIL PROTECTED]> wrote: Jimmy wrote: Hi to all python now has grown to a versatile language that can accomplish tasks for many different purposes. However, AFAIK, little is known about its ability of kernel coding. So I am wondering if pyth

Re: php vs python

2008-05-23 Thread Andrew Lee
notbob wrote: I'm not posting this just to initiate some religious flame war, though it's the perfect subject to do so. No, I actaully want some serious advice about these two languages and since I think usenet is the best arena to find it, here ya' go. So, here's my delimna: I want to start a

Re: [Regexes] Stripping puctuation from a text

2008-05-23 Thread Andrew Lee
shabda raaj wrote: I want to strip punctuation from text. So I am trying, p = re.compile('[a-zA-Z0-9]+') p.sub('', 'I love tomatoes!! hell yeah! ... Why?') ' !! ! ... ?' Which gave me all the chars which I want to replace. So Next I tried by negating the regex, p = re.compile('^[a-zA-Z0

Re: can python do some kernel stuff?

2008-05-23 Thread Andrew Lee
Jimmy wrote: Hi to all python now has grown to a versatile language that can accomplish tasks for many different purposes. However, AFAIK, little is known about its ability of kernel coding. So I am wondering if python can do some kernel coding that used to be the private garden of C/C++. For e

Re: Write bits in file

2008-05-23 Thread Andrew Lee
Tim Roberts wrote: Monica Leko <[EMAIL PROTECTED]> wrote: I have a specific format and I need binary representation. Does Python have some built-in function which will, for instance, represent number 15 in exactly 10 bits? For the record, I'd like to point out that even C cannot do this. You

Re: MVC

2008-05-22 Thread Andrew Lee
George Maggessy wrote: Hi Gurus, I'm a Java developer and I'm trying to shift my mindset to start programming python. So, my first exercise is to build a website. However I'm always falling back into MVC pattern. I know it's a standard, but the implementation language affects the use of design p

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Andrew Lee
Dan Upton wrote: On Thu, May 22, 2008 at 2:53 PM, Mensanator <[EMAIL PROTECTED]> wrote: On May 22, 11:32 am, "Dutton, Sam" <[EMAIL PROTECTED]> wrote: I've noticed that the value of math.pi -- just entering it at the interactive prompt -- is returned as 3.1415926535897931, whereas (as every pi-

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Andrew Lee
Mensanator wrote: On May 22, 11:32 am, "Dutton, Sam" <[EMAIL PROTECTED]> wrote: I've noticed that the value of math.pi -- just entering it at the interactive prompt -- is returned as 3.1415926535897931, whereas (as every pi-obsessive knows) the value is 3.1415926535897932... (Note the 2 at the

Re: Python is slow

2008-05-22 Thread Andrew Lee
cm_gui wrote: Python is slow.Almost all of the web applications written in Python are slow. Zope/Plone is slow, sloow, so very slooow. Even Google Apps is not faster. Neither is Youtube. Facebook and Wikipedia (Mediawiki), written in PHP, are so much faster than Python. Okay, they probab

Re: Markov Analysis Help

2008-05-22 Thread Andrew Lee
dave wrote: Hi Guys, I've written a Markov analysis program and would like to get your comments on the code As it stands now the final input comes out as a tuple, then list, then tuple. Something like ('the', 'water') ['us'] ('we', 'took')..etc... I'm still learning so I don't know any ad

Re: MatplotLib errors

2008-04-29 Thread Andrew Lee
Thomas Philips wrote: I have just started using MatPlotLib, and use it to generate graphs from Python simulations. It often happens that the graph is generated and a Visual C++ Runtime Library error then pops up: Runtime Error! Program C:\Pythin25\Pythonw.exe This application has requested the

Re: help needed with classes/inheritance

2008-04-23 Thread Andrew Lee
barbaros wrote: Hello everybody, I am building a code for surface meshes (triangulations for instance). I need to implement Body objects (bodies can be points, segments, triangles and so on), then a Mesh will be a collection of bodies, together with their neighbourhood relations. I also need Ori

Re: Checking if a text file is blank

2008-04-20 Thread Andrew Lee
David wrote: >> import os >> print os.lstat("friends.txt")[6] >> > > I prefer os.lstat("friends.txt").st_size MUCH easier to remember Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking if a text file is blank

2008-04-19 Thread Andrew Lee
[EMAIL PROTECTED] wrote: > Greetings! > > I've just started learning python, so this is probably one of those > obvious questions newbies ask. > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") >

Re: Can't do a multiline assignment!

2008-04-17 Thread Andrew Lee
[EMAIL PROTECTED] wrote: >> Yuck! No way!! If you *want* to make your code that hard to read, I'm >> sure you can find lots of ways to do so, even in Python, but don't >> expect Python to change to help you toward such a dubious goal. >> > > Well, my actual code doesn't look like that. Trust me,