Article View: pl.comp.lang.python
Article #508Re: reverse na stringu
From: Adam Przybyla
Date: Thu, 02 Jan 2003 19:04
Date: Thu, 02 Jan 2003 19:04
29 lines
1742 bytes
1742 bytes
Wojtek Walczak <gminick@hacker.pl> wrote: > Jak myslicie, jak najlepiej to wykonac ? > W 2.3a1 jest taka mozliwosc: > reversed_string = string[::-1] > W starszych mozna tak: > lista = list(string) > lista.reverse() > reversed_string = "".join(lista) > ale to ostatnie rozwiazanie jest b. brzydkie (i dlatego ciesza mnie > te rozszerzone wykrojenia). > Pytam, bo napisalem prostego patcha dodajacego metode reverse() do > stringow i nie jestem do konca przekonany, ze taki patch ma sens ;) ... moze tak: castle:/home/adam>python Python 2.2.2 (#1, Oct 18 2002, 10:58:50) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> reduce(lambda k,z: z+k,"ala ma kota") 'atok am ala' >>> reduce(lambda k,z: z+k,"atok am ala") 'ala ma kota' >>> Z powazaniem Adam Przybyla
Technical Details
Message-ID:
<av22gl$akf$1@news.tpi.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.ipartners.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mailReferences:
<av20qa$49h$1@news.tpi.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.ipartners.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
From: Adam Przybyla <adam@gliwice.pl>
Newsgroups: pl.comp.lang.python
Subject: Re: reverse na stringu
Date: Thu, 2 Jan 2003 19:04:55 +0000 (UTC)
Organization: tp.internet - http://www.tpi.pl/
Lines: 29
Sender: Adam Przybyla <adam@castle.ertel.com.pl>
Message-ID: <av22gl$akf$1@news.tpi.pl>
References: <av20qa$49h$1@news.tpi.pl>
NNTP-Posting-Host: castle.ertel.com.pl
X-Trace: news.tpi.pl 1041534295 10895 195.116.54.3 (2 Jan 2003 19:04:55 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Thu, 2 Jan 2003 19:04:55 +0000 (UTC)
User-Agent: tin/1.5.12-20020427 ("Sugar") (UNIX) (Linux/2.4.18 (i686))
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit