Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28804

Re: Is there any difference between print 3 and print '3' in Python ?

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <bsk16@case.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'syntax': 0.03; 'subject:Python': 0.05; 'executed': 0.07; "subject:' ": 0.07; 'python': 0.09; '__future__': 0.09; 'sep': 0.09; 'thx': 0.09; 'aug': 0.13; '2.7.2': 0.16; '2.7.3': 0.16; 'exit()': 0.16; 'subject:between': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'windows': 0.19; 'bit': 0.21; 'import': 0.21; '"",': 0.22; 'planned': 0.22; 'produces': 0.22; 'statement': 0.23; 'command': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; '(3)': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; '>>>>': 0.29; 'words': 0.29; 'that.': 0.30; 'subject: ?': 0.30; 'file': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'everyone': 0.33; '(c)': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; '2010,': 0.38; 'to:addr:python.org': 0.39; 'between': 0.63; 'more': 0.63; 'subject:there': 0.65; 'reserved.': 0.67; "'3'": 0.84; 'difference.': 0.84; 'subject:any': 0.84; '8bit%:67': 0.93
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:x-gm-message-state; bh=m8Mje2NciCttAz1EwvpnKLzGxZELd3aliKS2cN5ug5c=; b=EkJpbrNBLuBNp0p/lnCZZjeZ9i3EWtpbWvyUURi1/vQpogvvdYrzEP4CGQXPIAhMi4 Q1hRp2ij8VBhBL9fmclLDHp+CDOO/EYcPsphn5u4e8mbxpO/IQyv9v4LGP0PqlME5P8o JFxZQMNQh8lNCErvFw25GYecXchFffOtRvb81Qj9FjzpnrE1JrnhLrmQupMn4N4+X+4o ksLcsuJ8cqFDjcv6NnndYozzJLnEmyK1lnUB25KBD6SSIOCSRhr0eCKihEJRvf/2gxUP q2zu2JDFZPEyBtC1PPZy81D7mLH2gbIBC66RLTrBpVypVNFAfF0PqKdnQ+dUfIArniZQ vduA==
MIME-Version 1.0
In-Reply-To <CA+vVgJX2xg4KQJq2eVSpj-PMax81mpUJ4BQpT-iPdB0FgP_0eQ@mail.gmail.com>
References <5128580.32.1332762326119.JavaMail.geo-discussion-forums@pbom7> <645baeaa-438e-4d30-a559-0db4231ede9c@googlegroups.com> <504CAAAA.3090905@feete.org> <CA+vVgJX2xg4KQJq2eVSpj-PMax81mpUJ4BQpT-iPdB0FgP_0eQ@mail.gmail.com>
Date Sun, 9 Sep 2012 23:55:58 -0700
Subject Re: Is there any difference between print 3 and print '3' in Python ?
From Benjamin Kaplan <benjamin.kaplan@case.edu>
To python-list@python.org
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Gm-Message-State ALoCoQlOikaGbDhcHOkHfXJyvuDbjY8OhWqYDCKVrZDjwFmAODWX+Si1EBZnmmzn9/zUF7EzwNwD
X-Junkmail-Whitelist YES (by domain whitelist at mpv1.tis.cwru.edu)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.434.1347260169.27098.python-list@python.org> (permalink)
Lines 84
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347260170 news.xs4all.nl 6851 [2001:888:2000:d::a6]:51568
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28804

Show key headers only | View raw


On Sun, Sep 9, 2012 at 11:33 PM, Dwight Hutto <dwightdhutto@gmail.com> wrote:
>
>
> On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote <ian@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Is there any difference between print 3 and print '3' in Python ? iMath <redstone-cold@163.com> - 2012-09-09 06:23 -0700
  Re: Is there any difference between print 3 and print '3' in Python ? Ian Foote <ian@feete.org> - 2012-09-09 15:41 +0100
  Re: Is there any difference between print 3 and print '3' in Python ? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-09-09 23:55 -0700
  Re: Is there any difference between print 3 and print '3' in Python ? Terry Reedy <tjreedy@udel.edu> - 2012-09-10 03:16 -0400

csiph-web