Re: List mutation method gotcha - How well known?

2008-03-16 Thread Lie
On Mar 15, 1:01 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Fri, 14 Mar 2008 11:32:41 -0700, Lie wrote: No, there is no need for void return type, what I meant is that everything that's not said in the documentation should be assumed to be an implementation detail, a method or

Re: List mutation method gotcha - How well known?

2008-03-15 Thread Marc 'BlackJack' Rintsch
On Fri, 14 Mar 2008 11:32:41 -0700, Lie wrote: No, there is no need for void return type, what I meant is that everything that's not said in the documentation should be assumed to be an implementation detail, a method or a function that doesn't say anything about its return type should be

Re: List mutation method gotcha - How well known?

2008-03-15 Thread Hendrik van Rooyen
On Thu, Mar 13, 2008 at 8:36 AM, Hendrik van Rooyen [EMAIL PROTECTED] wrote: foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 1) [1,2,3,4] 2) [1,2,3,4,5] 3) That famous picture of Albert Einstein sticking out his tongue 4) Nothing - no output

Re: List mutation method gotcha - How well known?

2008-03-14 Thread Jarek Zgoda
Lie napisał(a): foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 1) [1,2,3,4] 2) [1,2,3,4,5] 3) That famous picture of Albert Einstein sticking out his tongue 4) Nothing - no output 5) None of the above I undertake to summarise answers posted to

Re: List mutation method gotcha - How well known?

2008-03-14 Thread Dustan
On Mar 13, 1:56 pm, yoz [EMAIL PROTECTED] wrote: This will cause a hidden feature of python and the OS, known as the 'python easter egg', to activate - erasing all data on the hard disk and then reporting how many bytes of data are left. Usually None ;-} - This really is a 'gotcha'

Re: List mutation method gotcha - How well known?

2008-03-14 Thread Lie
On Mar 14, 4:57 pm, Jarek Zgoda [EMAIL PROTECTED] wrote: Lie napisa³(a): foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 1)  [1,2,3,4] 2)  [1,2,3,4,5] 3)  That famous picture of Albert Einstein sticking out his tongue 4)  Nothing - no output

List mutation method gotcha - How well known?

2008-03-13 Thread Hendrik van Rooyen
Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the interactive prompt: Given the following three lines of code at the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread cokofreedom
On Mar 13, 8:36 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Peter Otten
Hendrik van Rooyen wrote: I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the interactive prompt: Given the following

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Chris
On Mar 13, 9:36 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Diez B. Roggisch
Hendrik van Rooyen wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the interactive prompt: Given the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Paul Rubin
Hendrik van Rooyen [EMAIL PROTECTED] writes: Given the following three lines of code at the interactive prompt: foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 4) Nothing - no output By Python convention, methods that mutate the object return None, and

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Bruno Desthuilliers
Hendrik van Rooyen a écrit : Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the interactive prompt: Given the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Roel Schroeven
Hendrik van Rooyen schreef: So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the interactive prompt: Given the following three lines of code at the interactive prompt: foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 1)

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Paul Rubin
Paul Rubin http://[EMAIL PROTECTED] writes: Hendrik van Rooyen [EMAIL PROTECTED] writes: Given the following three lines of code at the interactive prompt: foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 4) Nothing - no output Correction, it

Re: List mutation method gotcha - How well known?

2008-03-13 Thread cokofreedom
Still, I suppose this is a gotcha for a lot of people, just follow the good advice Paul said; By Python convention, methods that mutate the object return None, and also stuff that returns None doesn't generate output at the interactive prompt. And you should survive most. --

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Dustan
On Mar 13, 2:36 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread BJörn Lindqvist
On Thu, Mar 13, 2008 at 8:36 AM, Hendrik van Rooyen [EMAIL PROTECTED] wrote: foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 1) [1,2,3,4] 2) [1,2,3,4,5] 3) That famous picture of Albert Einstein sticking out his tongue 4) Nothing - no output

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Lie
On Mar 13, 2:36 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread yoz
Dustan wrote: On Mar 13, 2:36 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 10:42 am, Paul Rubin http://[EMAIL PROTECTED] wrote: [...] By Python convention, methods that mutate the object return None, and also stuff that returns None doesn't generate output at the interactive prompt. A convention that does not always hold: l = [1, 2, 3] l.pop() 3 l [1,

Re: List mutation method gotcha - How well known?

2008-03-13 Thread John Machin
On Mar 14, 6:13 am, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Mar 13, 10:42 am, Paul Rubin http://[EMAIL PROTECTED] wrote: [...] By Python convention, methods that mutate the object return None, and also stuff that returns None doesn't generate output at the interactive prompt. A

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Erik Max Francis
Chris wrote: No output because x is a NoneType... That's behavior of the interactive interpreter when printing results of expressions, not of print. It will print None. -- Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/ San Jose, CA, USA 37 18 N 121 57 W AIM, Y!M