Re: [Tutor] __getattr__ can't be a staticmethod?

2008-05-23 Thread Kent Johnson
On Fri, May 23, 2008 at 7:52 PM, inhahe <[EMAIL PROTECTED]> wrote: > why doesn't this work? > class a: > ... @staticmethod > ... def __getattr__(attr): > ... return "I am a dork" > ... f = a() f.hi > Traceback (most recent call last): > File "", line 1, in > TypeError: 'sta

Re: [Tutor] python 2D list

2008-05-23 Thread Kent Johnson
On Fri, May 23, 2008 at 5:22 PM, Yuanxin Xi <[EMAIL PROTECTED]> wrote: > I'm a Python newbie and still exploring, just surprised to see this 2D list > assignment while debugging. http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list Kent __

[Tutor] __getattr__ can't be a staticmethod?

2008-05-23 Thread inhahe
why doesn't this work? >>> class a: ... @staticmethod ... def __getattr__(attr): ... return "I am a dork" ... >>> f = a() >>> f.hi Traceback (most recent call last): File "", line 1, in TypeError: 'staticmethod' object is not callable ___ Tuto

Re: [Tutor] python 2D list

2008-05-23 Thread Alan Gauld
"Yuanxin Xi" <[EMAIL PROTECTED]> wrote I'm a Python newbie and still exploring, just surprised to see this 2D list assignment while debugging. >>> a = [[0] *3] *4 This creates a list with 3 zeros then creates a second list with 4 references to the first list. Remember that in Python all var

[Tutor] Fwd: python 2D list

2008-05-23 Thread W W
Oops! Forgot to "Reply to All" I'm not sure but take a look at this: >>> a = [[0]*3]*4 >>> a [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> a[1] [0, 0, 0] >>> a[0][0] = 4 >>> a [[4, 0, 0], [4, 0, 0], [4, 0, 0], [4, 0, 0]] >>> b = [[0,0,0],[0,0,0],[0,0,0]] >>> b [[0, 0, 0], [0,

[Tutor] python 2D list

2008-05-23 Thread Yuanxin Xi
I'm a Python newbie and still exploring, just surprised to see this 2D list assignment while debugging. >>> a = [[0] *3] *4 >>> a [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> a[1][2] = 1 >>> a [[0, 0, 1], [0, 0, 1], [0, 0, 1], [0, 0, 1]] why is that a[0][2] a[1][2] a[2][2] a[3][2] are all a

Re: [Tutor] Fwd: syntax question

2008-05-23 Thread Kent Johnson
On Fri, May 23, 2008 at 2:25 PM, Moishy Gluck <[EMAIL PROTECTED]> wrote: > I came in python around 2.5. So I've been using "Boolean and 1 or 2". For Python 2.5 you should use the new syntax 1 if Boolean or 2 It doesn't have the problems of the unofficial syntax you quote. Kent

[Tutor] Readability, in general: was Re: Reading only a few specific lines of a file

2008-05-23 Thread Marilyn Davis
On Fri, May 23, 2008 10:06 am, Alan Gauld wrote: > "Marilyn Davis" <[EMAIL PROTECTED]> wrote > > >> (I'm sorry for the duplicate, Alan.) >> > > I didn't see a duplicate! ;-) > > >>> linecount = 0 for line in file("itemconfig.txt", 'rU'): if line == >>> objectToLoad or linecount > 0: if linecount =

Re: [Tutor] Reading only a few specific lines of a file

2008-05-23 Thread Alan Gauld
"Marilyn Davis" <[EMAIL PROTECTED]> wrote (I'm sorry for the duplicate, Alan.) I didn't see a duplicate! ;-) linecount = 0 for line in file("itemconfig.txt", 'rU'): if line == objectToLoad or linecount > 0: if linecount == 0: linecount = 5 itemList.append(line.split()[:5

Re: [Tutor] Decompyle and python 2.4 (2.5)

2008-05-23 Thread Alan Gauld
"dnr" <[EMAIL PROTECTED]> wrote are there any volunteer who'd like to do some good for the python community? To be short - Decompyle package currently only supports python versions prior to 2.4. These sort of requests are probably better targetted at the main comp.lang.python list rather than

Re: [Tutor] Reading only a few specific lines of a file

2008-05-23 Thread Marilyn Davis
(I'm sorry for the duplicate, Alan.) On Fri, May 23, 2008 3:49 am, Alan Gauld wrote: > "Jason Conner" <[EMAIL PROTECTED]> wrote > > >> building a program that will take a text file, search for a string in >> that text file. Once it finds the string its looking for, I want to put >> the next five

[Tutor] Decompyle and python 2.4 (2.5)

2008-05-23 Thread dnr
Hello, are there any volunteer who'd like to do some good for the python community? To be short - Decompyle package currently only supports python versions prior to 2.4. After small tuning it seems to support 2.4 and 2.5partly Some tuning is required in parser.py which maps disassembled op

Re: [Tutor] Equivalent 'case' Statement

2008-05-23 Thread Kinuthia Muchane
Hi, I messed in earlier message, my apologies. Message: 1 Date: Fri, 23 May 2008 00:25:23 +0100 From: "Alan Gauld" <[EMAIL PROTECTED]> Subject: Re: [Tutor] Equivalent 'case' statement To: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; format=flowed; charset="iso-8859-1

Re: [Tutor] Reading only a few specific lines of a file

2008-05-23 Thread Alan Gauld
"Jason Conner" <[EMAIL PROTECTED]> wrote building a program that will take a text file, search for a string in that text file. Once it finds the string its looking for, I want to put the next five lines of text into a variable. Here's what I have so far: def loadItem(self, objectToLoad):

Re: [Tutor] changin two lines in a single python script

2008-05-23 Thread Kent Johnson
On Wed, May 21, 2008 at 10:51 AM, jatinder Singh <[EMAIL PROTECTED]> wrote: > Hi . > >I am trying to change two lines in a single file (etc/php.ini) but my > script is not doing this in one time . See my answer to your almost identical question last week about modifying httpd.conf. Kent

Re: [Tutor] Tutor Digest, Vol 51, Issue 51

2008-05-23 Thread Kinuthia Muchane
[EMAIL PROTECTED] wrote: Send Tutor mailing list submissions to tutor@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/tutor or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can