[Tutor] errors in "Python Programming for the Absolute Beginner"??

Bill Allen wallenpb at gmail.com
Fri Jan 14 05:38:14 CET 2011


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 10:31 PM, Vern Ceder <vceder at gmail.com> wrote:

> 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 results
> are:
>
> >>> print ("Hello", "Bill")
> Hello Bill
> >>> x = input("Your name?")
> Your name?Bill
> >>>
>
> Cheers,
> Vern
> The two examples you show would work on any Python 2.x (or even 1.5)
> system. The  parens around the single string won't cause an error nor will
> using input to get an integer.
>
> Cheers,
> Vern
>
> On Thu, Jan 13, 2011 at 11:18 PM, Bill Allen <wallenpb at gmail.com> wrote:
>
>> 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 at 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.
>> >>> print("hello world")
>> hello world
>> >>> x = input("how many?")
>> how many?5
>> >>> x
>> 5
>>
>> On Thu, Jan 13, 2011 at 9:31 PM, Corey Richardson <kb1pkl at aim.com> wrote:
>>
>>> 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 am assuming they were back
>>> > ported or something.  I would have expected the same for 2.7.1.
>>> >
>>> > --Bill
>>>
>>> I'm using Python 2.6.6 and I have a feeling you are not using python
>>> 2.6.5 with Python3 syntax working. I could be very wrong, but just a
>>> hunch ;)
>>>
>>> ~Corey
>>>
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
>
> --
> Vern Ceder
> vceder at gmail.com, vceder at dogsinmotion.com
> The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110113/531f13fc/attachment-0001.html>


More information about the Tutor mailing list