On Sun, Sep 9, 2012 at 11:33 PM, Dwight Hutto <dwightdhu...@gmail.com> wrote: > > > On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote <i...@feete.org> wrote: >> >> On 09/09/12 14:23, iMath wrote: >>> >>> 在 2012年3月26日星期一UTC+8下午7时45分26秒,iMath写道: >>>> >>>> I know the print statement produces the same result when both of these >>>> two instructions are executed ,I just want to know Is there any difference >>>> between print 3 and print '3' in Python ? >>> >>> thx everyone >> >> > > Here's a future import though I used,so I can use the planned 3 with a 2x > python version in the command line interpreter: > > Microsoft Windows [Version 6.1.7600] > Copyright (c) 2009 Microsoft Corporation. All rights reserved. > > C:\Users\david>c:\python26\python.exe > Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] > on > win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> exit() > > C:\Users\david>c:\python27_64\python.exe > Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on > win > 32 > Type "help", "copyright", "credits" or "license" for more information. >>>> import __future__ >>>> x = 3 >>>> y = '3' >>>> print(x) > 3 >>>> print(y) > 3 >>>> >>>> type(x) > <type 'int'> >>>> type(y) > <type 'str'> > >>>> z = '%i' % (3) >>>> type(z) > <type 'str'> >>>> > > In other words type(value), and find out the difference. > -- > Best Regards, > David Hutto > CEO: http://www.hitwebdevelopment.com >
Somewhat OT, but __future__ doesn't work like that. You have to import the specific features you want to use. Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> print 3 3 >>> import __future__ >>> print 3 3 >>> from __future__ import print_function >>> print 3 File "<stdin>", line 1 print 3 ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-list