🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Formatowanie napisów w nowym stylu.

#27144
From: Łukasz Rekucki
Date: Tue, 05 Jan 2010 23:46
32 lines
2776 bytes
On Jan 6, 12:13 am, "Jan Kaliszewski" <z...@chopin.edu.pl> wrote:
> Łukasz Rekucki <lreku...@gmail.com> napisał:
>
> > Albo żeby się nie myliło, korzystając z nowego formatowania:
> > query = """INSERT INTO {table:s} VALUES(10, %s, 3)""".format(table=
> > nazwa_tabeli)
>
> Rozumiem, że chodziło Ci o {table!s} -- z dwukropkiem nie ma chyba  
> większego sensu (choć, jak widzę, w przypadku napisów Python jakoś to  
> łyka).
>
> Pozdr.
> *j
>
> --
> Jan Kaliszewski (zuo)

Nie, chodziło mi o {table:s}. Jak teraz patrzę, to dokumentacja
rzeczywiście nie podaję tego jako typu. Ale z drugiej strony mówi ona,
że: "Each formattable type may define how the format specification is
to be interpreted". Stringi akceptują typ wyświetlania "s" - pewnie
jedyny, choć mogę sobie wyobrazić inne, np. wyświetl jako tytuł
(titlecase). Myślę, że to niedopatrzenie w dokumentacji.

Przykład:

>>> "#{:s}#".format(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Unknown format code 's' for object of type 'int'
>>> "#{!s:s}#".format(5)
'#5#'
Technical Details
Message-ID: <178f9ae7-e594-4ac4-94b6-81afaae72b7a@35g2000yqa.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!35g2000yqa.googlegroups.com!not-for-mail
References: <hhvlil$cso$1@achot.icm.edu.pl> <e40b5499-a692-4d1d-bd6d-8dd80f5ae900@c3g2000yqd.googlegroups.com> <hhvp29$gld$1@achot.icm.edu.pl> <slrnhk6q4e.6d2.beorn@pino.cyberdeck.pl> <hhvrc6$6fe$1@news.onet.pl> <slrnhk70lt.6v8.beorn@pino.cyberdeck.pl> <hi00a7$l52$1@news.onet.pl> <0c4a8a92-fcab-4c8f-8e51-6a865b220086@h9g2000yqa.googlegroups.com> <op.u521gxj6fvx12t@jerzozwiesz.home.aster.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!35g2000yqa.googlegroups.com!not-for-mail
From: Łukasz Rekucki <lrekucki@gmail.com>
Newsgroups: pl.comp.lang.python
Subject: Formatowanie napisów w nowym stylu.
Date: Tue, 5 Jan 2010 15:46:54 -0800 (PST)
Organization: http://groups.google.com
Lines: 35
Message-ID: <178f9ae7-e594-4ac4-94b6-81afaae72b7a@35g2000yqa.googlegroups.com>
References: <hhvlil$cso$1@achot.icm.edu.pl> <e40b5499-a692-4d1d-bd6d-8dd80f5ae900@c3g2000yqd.googlegroups.com>  <hhvp29$gld$1@achot.icm.edu.pl> <slrnhk6q4e.6d2.beorn@pino.cyberdeck.pl>  <hhvrc6$6fe$1@news.onet.pl> <slrnhk70lt.6v8.beorn@pino.cyberdeck.pl>  <hi00a7$l52$1@news.onet.pl> <0c4a8a92-fcab-4c8f-8e51-6a865b220086@h9g2000yqa.googlegroups.com>  <op.u521gxj6fvx12t@jerzozwiesz.home.aster.pl>
NNTP-Posting-Host: 212.76.62.207
Mime-Version: 1.0
X-Trace: posting.google.com 1262735214 30103 127.0.0.1 (5 Jan 2010 23:46:54 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 5 Jan 2010 23:46:54 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 35g2000yqa.googlegroups.com; posting-host=212.76.62.207;  posting-account=5fpXZwoAAADF-CUdCuJ-FpYxG8__-wRx
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US)  AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.43 Safari/532.5,gzip(gfe),gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit