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


Groups > comp.lang.python > #22204

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

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject: ?': 0.05; "subject:' ": 0.07; 'subject:Python': 0.07; 'from:addr:web.de': 0.09; 'python': 0.11; 'print': 0.15; '__future__': 0.16; 'executed': 0.16; 'output?': 0.16; 'received:80.91': 0.16; 'received:80.91.229': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:gmane.org': 0.16; 'received:list': 0.16; 'received:t-dialin.net': 0.16; 'subject:between': 0.16; 'wrote:': 0.21; 'produces': 0.22; 'statement': 0.22; 'header:User-Agent:1': 0.23; 'import': 0.24; 'question': 0.30; 'two': 0.35; 'there': 0.35; 'really': 0.36; 'header:X-Complaints-To:1': 0.36; 'received:org': 0.38; 'wanted': 0.39; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'is:': 0.61; "here's": 0.61; 'between': 0.64; 'different': 0.65; "'3'": 0.84; 'subject:there': 0.84; 'email addr:163.com': 0.97
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Is there any difference between print 3 and print '3' in Python ?
Date Mon, 26 Mar 2012 19:20:10 +0200
Organization None
References <5128580.32.1332762326119.JavaMail.geo-discussion-forums@pbom7>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084a42d.dip.t-dialin.net
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.1015.1332782388.3037.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332782388 news.xs4all.nl 6915 [2001:888:2000:d::a6]:50340
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22204

Show key headers only | View raw


redstone-cold@163.com wrote:

> 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 ?

The question you really wanted to ask is: under what circumstances will the 
two statements produce different output? Here's what I found:

$ PYTHONIOENCODING=hex python -c'from __future__ import unicode_literals
print 3'
3
$ PYTHONIOENCODING=hex python -c'from __future__ import unicode_literals 
print "3"'
33
$

:)

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


Thread

Is there any difference between print 3 and print '3' in Python ? redstone-cold@163.com - 2012-03-26 04:45 -0700
  Re: Is there any difference between print 3 and print '3' in Python ? Chris Angelico <rosuav@gmail.com> - 2012-03-26 23:01 +1100
  Re: Is there any difference between print 3 and print '3' in Python ? Kiuhnm <kiuhnm03.4t.yahoo.it> - 2012-03-26 14:07 +0200
  Re: Is there any difference between print 3 and print '3' in Python ? Robert Kern <robert.kern@gmail.com> - 2012-03-26 13:10 +0100
  Re: Is there any difference between print 3 and print '3' in Python ? Dave Angel <d@davea.name> - 2012-03-26 08:11 -0400
    Re: Is there any difference between print 3 and print '3' in Python ? redstone-cold@163.com - 2012-03-26 07:28 -0700
      Re: Is there any difference between print 3 and print '3' in Python ? Stefan Behnel <stefan_ml@behnel.de> - 2012-03-26 17:03 +0200
    Re: Is there any difference between print 3 and print '3' in Python ? redstone-cold@163.com - 2012-03-26 07:28 -0700
    Re: Is there any difference between print 3 and print '3' in Python ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-27 03:43 +0000
      Re: Is there any difference between print 3 and print '3' in Python ? rusi <rustompmody@gmail.com> - 2012-03-26 22:00 -0700
  Re: Is there any difference between print 3 and print '3' in Python ? Terry Reedy <tjreedy@udel.edu> - 2012-03-26 11:45 -0400
  Re: Is there any difference between print 3 and print '3' in Python ? "J. Cliff Dyer" <jcd@sdf.lonestar.org> - 2012-03-26 13:06 -0400
  Re: Is there any difference between print 3 and print '3' in Python ? Peter Otten <__peter__@web.de> - 2012-03-26 19:20 +0200

csiph-web