I will agree that it seems odd, but here is a sample run from my system. I
promise I am not pulling anyone's leg! :-))
wallenpb@Ubuntu-D810:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.
I am going through the book mentioned in the subject line, and I have found a
couple of things that don't seem to work the way the author shows in the book.
So, either I am doing something wrong, or what he is saying isn't quite right.
I am using Python 2.7.1 on Mac OS X Leopard.
The first
On 01/13/2011 08:50 PM, Elwin Estle wrote:
I am going through the book mentioned in the subject line, and I have found a
couple of things that don't seem to work the way the author shows in the
book. So, either I am doing something wrong, or what he is saying isn't
quite right.
I am
That is correct about the difference between Python 2 and Python 3 syntax.
However, I am surprised that with 2.7.1 these do not work. I have found
that on my Ubuntu system with Python 2.6.5 these Python 3 syntax items do
seem to work properly. I am assuming they were back ported or something.
On 01/13/2011 10:29 PM, Bill Allen wrote:
That is correct about the difference between Python 2 and Python 3
syntax. However, I am surprised that with 2.7.1 these do not work. I
have found that on my Ubuntu system with Python 2.6.5 these Python 3
syntax items do seem to work properly. I
I will agree that it seems odd, but here is a sample run from my system. I
promise I am not pulling anyone's leg! :-))
wallenpb@Ubuntu-D810:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.
Bill,
Try this:
print(hello, Bill)
('Hello', 'Bill')
x = input(Your name?)
Your name?Bill
Traceback (most recent call last):
File stdin, line 1, in module
File string, line 1, in module
NameError: name 'Bill' is not defined
and see if those work (my results on 2.6 shown). In Python 3 the
Vern,
Quite right! I see what you mean. I quite inadvertently stumbled into
examples that would work without realizing it. I typically program in
Python 3, so not as familiar with the limitations on Python 2x. I've had
quite a chuckle over this!
Thanks,
Bill
On Thu, Jan 13, 2011 at
input() must be avoided at all costs in Python 2.x. if you find any
Python (2.x) book which employs that, consider the author uninformed.
it is a huge security risk and the main reason why in Python 3
raw_input() is renamed to and replaces input().
cheers,
-- wesley
- - - - - - - - - - - - - - -