🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #27651

Re: "print" do zmiennej string

#27651
From: Łukasz Rekucki
Date: Thu, 26 Aug 2010 12:08
35 lines
2212 bytes
On Aug 26, 1:24 pm, Bart Ogryczak <b.ogryc...@gmail.com> wrote:
> On Aug 24, 2:19 pm, Jacek Czerwinski <x...@y.z.pl> wrote:
>
>
>
>
>
> > W dniu 2010-08-24 13:49, Mariusz Kruk pisze:
>
> > > epsilon$ while read LINE; do echo \>"$LINE"; done<  "max"
> > >> # poczatek
> > >> str1 = "test str"
> > >> print(str1)
> > >> str2 = print(str1)
> > >> print(str2)
> > >> # koniec
>
> > >> Dlaczego funkcja print nie zwraca wartości ?
>
> > > Bo tak ma.
>
> > Sporo juz nie obcowalem z formalizmem Pythona, czy 'print' to na pewno
> > funkcja?
>
> Od 3.0 funkcja, wcześniej statement.http://www.python.org/dev/peps/pep-3105/
W 2.6+ też jest ta funkcja jako builtin:

>>> mprint = getattr(__builtins__, "print")
>>> mprint(1, 2, 3)
1 2 3

Oczywiście nie da się jej używać bezpośrednio jako "print", bo "print"
jest słowem kluczowym, ale można to zmienić:

from __future__ import print_function
Technical Details
Message-ID: <650976c8-52ce-457f-878a-7299fbda8c8b@l20g2000yqm.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!l20g2000yqm.googlegroups.com!not-for-mail
References: <i509he$aas$1@portraits.wsisiz.edu.pl> <slrni77cev.na5.Mariusz.Kruk@epsilon.rdc.pl> <i50dcj$8r4$2@news.onet.pl> <4e3a8480-a8cd-46a9-a42f-382d9c8f355c@q22g2000yqm.googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!l20g2000yqm.googlegroups.com!not-for-mail
From: Łukasz Rekucki <lrekucki@gmail.com>
Newsgroups: pl.comp.lang.python
Subject: Re: "print" do zmiennej string
Date: Thu, 26 Aug 2010 05:08:23 -0700 (PDT)
Organization: http://groups.google.com
Lines: 37
Message-ID: <650976c8-52ce-457f-878a-7299fbda8c8b@l20g2000yqm.googlegroups.com>
References: <i509he$aas$1@portraits.wsisiz.edu.pl> <slrni77cev.na5.Mariusz.Kruk@epsilon.rdc.pl> <i50dcj$8r4$2@news.onet.pl> <4e3a8480-a8cd-46a9-a42f-382d9c8f355c@q22g2000yqm.googlegroups.com>
NNTP-Posting-Host: 83.3.35.82
Mime-Version: 1.0
X-Trace: posting.google.com 1282824503 27791 127.0.0.1 (26 Aug 2010 12:08:23 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 26 Aug 2010 12:08:23 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l20g2000yqm.googlegroups.com; posting-host=83.3.35.82; posting-account=5fpXZwoAAADF-CUdCuJ-FpYxG8__-wRx
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.36 Safari/534.3,gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit