"Temporary" Variable

Jeffrey Schwab jeff at schwabcenter.com
Fri Feb 24 07:50:18 EST 2006


Steven D'Aprano wrote:
> On Fri, 24 Feb 2006 00:24:25 +0000, Jeffrey Schwab wrote:
> 
> 
>>Steven D'Aprano wrote:
>>
>>>On Thu, 23 Feb 2006 12:05:59 -0800, darthbob88 wrote:
>>>
>>>My comments inserted inline.
>>>
>>>
>>>
>>>
>>>>#!/usr/bin/python
>>>>#simple guessing game, with numbers
>>>>import random
>>>>spam = random.randint(1, 100)
>>>
>>>
>>>It is bad programming practice to give variables uninformative joke names.
>>
>>Lighten up.  This isn't the middle of a 100-KLOC corporate monstrosity, 
>>it's a 1/2-page usenet post.
> 
> 
> The original poster is also a newbie who was having trouble with the
> difference between strings and ints. If Guido called a variable spam,
> I wouldn't presume to correct him. When Newbie McNew does it, it might
> very well be because he doesn't know any better.

Sorry if I snapped at you.  But you didn't "correct" him, as he what he 
did wasn't wrong.  You just talked down to him.

> Just out of curiosity, when do you think is the right time to begin
> teaching programmers good practice from bad? Before or after they've
> learnt bad habits?

I'm not convinced the OP has a "bad habit."  Frankly, I prefer postings 
that have a sense of humor.  I wouldn't want to see this turned into a 
purely techical forum.

import random
print ", ".join(['spam' for i in range(random.randint(1, 9))] +
	['bacon', 'eggs', 'and']), 'spam'



More information about the Python-list mailing list