Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'broken': 0.04; 'expected.': 0.09; 'python': 0.11; 'thread': 0.14; 'andy': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header :User-Agent:1': 0.23; 'basis,': 0.24; 'certainly': 0.24; 'documented': 0.24; 'cheers,': 0.24; "i've": 0.25; 'logging': 0.26; 'mention': 0.26; 'header:In-Reply-To:1': 0.27; "d'aprano": 0.31; 'steven': 0.31; 'another': 0.32; 'but': 0.35; 'there': 0.35; 'described': 0.36; 'object,': 0.36; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'content- disposition:inline': 0.62; 'safe.': 0.84; 'system!': 0.84 Date: Tue, 12 Aug 2014 07:53:11 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: Is print thread safe? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <53e8ea27$0$29981$c3e8da3$5496439d@news.astraweb.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <53e8ea27$0$29981$c3e8da3$5496439d@news.astraweb.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=BdjhjNd2 c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=PzczSypyshMA:10 a=gyjTKktfeJ0A:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=kZ7UWmmPAAAA:8 a=8nmYFzhLAAAA:8 a=HT8Xwple0xI3hFoARK4A:9 a=CjuIK1q_8ugA:10 a=pyH5b1fOeEsA:10 a=dVHdXv-K6tQA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407795799 news.xs4all.nl 2866 [2001:888:2000:d::a6]:58171 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76082 On 12Aug2014 02:07, Steven D'Aprano wrote: >INADA Naoki wrote: > >> On Python 3, print is thread safe. >> But Python 2 has broken scenario: > >Is this documented somewhere? In python/2.7.6/reference/simple_stmts.html#index-22, "print" is described in terms of a "write" for each object, and a "write" for the separators. There is no mention of locking. On that basis, I would find the interleaving described normal and expected. And certainly not "broken". Just use a lock! And rebind "print"! Or use the logging system! Cheers, Cameron Simpson Wow! Yet another place that I've been quoted... - Andy Beals