Talk:Python Programming/Variables and Strings

I just downloaded Python 2.5.1 and there's one thing: the input-function doesn't work the way you describe it. Pyhton states, that fish (my answer) is not defined. If I use raw_input instead it works.


 * I get the same thing (version 2.3.5). It works if I put quotation marks around the response. -- 77.100.119.107 14:51, 5 December 2007 (UTC)

This is due to a small confusion with this functions. input. When the user finish entering the input Python proceeds to evaluate the entered string. So number get evaluate into there proper value without the need to call the int. For user input is more appropriates to use raw_input since you we don't have to worry for error handling.

Style Guide
According to "PEP 8 -- Style Guide for Python Code" http://python.org/dev/peps/pep-0008/ section "Whitespace in Expressions and Statements", the preferred style is

print(lucky)

But you have

print (lucky)

or sometimes

print( lucky )

Personally, i find either of your styles more readable than the what the Guide says. So, what's the message here, ignore the Guide and use my own style? 174.6.64.79 (discuss) 14:44, 21 April 2011 (UTC)