Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16519
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| 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; 'python,': 0.01; 'ascii': 0.07; 'subject:code': 0.07; 'python': 0.08; '(int': 0.09; 'am,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; '(lambda': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'other)': 0.16; 'versus': 0.16; 'wrote:': 0.18; 'string,': 0.18; '(which': 0.19; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'code': 0.25; 'function': 0.27; 'fact': 0.27; '(and': 0.28; 'message-id:@mail.gmail.com': 0.28; 'subject:?': 0.31; 'value.': 0.32; 'list': 0.32; 'actual': 0.32; 'fri,': 0.34; 'to:addr:python-list': 0.34; 'probably': 0.34; 'integer': 0.34; 'received:google.com': 0.37; 'steven': 0.38; 'received:209.85': 0.38; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'double': 0.61; 'happen': 0.61; 'instantly': 0.67; 'heart': 0.68; 'size.': 0.71; 'clearer': 0.84; 'subject:hack': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=EAH24q9pss5fV8jfy2FfjB0JKPfDkfHQCMCop9WAImo=; b=CDEBu/D2rXwEVTq+ICd8/0t00umy5IQ5lVcxwfKrkJoMAPa9rg4CWxaPq1ZH+vbKa4 UD+QQKHpWpsuSGVIWLcvVXVHccMPfwPVkhQATqYgOzIizF9iihoSTnCw3xpxOJaRvG6G RtF36kHGQMLQMSkjsarnBVsdA9PODKgnCdQF8= |
| MIME-Version | 1.0 |
| In-Reply-To | <4ed818bb$0$29988$c3e8da3$5496439d@news.astraweb.com> |
| References | <roy-A03C06.22152730112011@news.panix.com> <jb8qmd$56l$1@dont-email.me> <4ed818bb$0$29988$c3e8da3$5496439d@news.astraweb.com> |
| Date | Fri, 2 Dec 2011 13:07:57 +1100 |
| Subject | Re: Clever hack or code abomination? |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| 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.3211.1322791680.27778.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1322791680 news.xs4all.nl 6911 [2001:888:2000:d::a6]:41906 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:16519 |
Show key headers only | View raw
On Fri, Dec 2, 2011 at 11:15 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Try this on for size.
>
>
> f = type(q)(c[c.index(chr(45))+1:])+type(q)(1)
> c = str.join('\n', list(map(chr, (45, 48))) + [c])[::2]
> c = (lambda a,b: a+b)(c[:c.index(chr(45))+1], type(c)(f))
I would consider integer representations of ASCII to be code smell.
It's not instantly obvious that 45 means '-', even if you happen to
know the ASCII table by heart (which most people won't). This is one
thing that I like about C's quote handling; double quotes for a
string, or single quotes for an integer with that character's value.
It's clearer than the Python (and other) requirement to have an actual
function call:
for (int i=0;i<10;++i) {
digit[i]='0'+i;
letter[i]='A'+i;
}
versus
for i in range(10):
digit[i]=chr(ord('0')+i)
letter[i]=chr(ord('A')+i)
Ignoring the fact that you'd probably use a list comp in Python, this
is imho a win for C.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Clever hack or code abomination? Roy Smith <roy@panix.com> - 2011-11-30 22:15 -0500
Re: Clever hack or code abomination? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-01 03:38 +0000
Re: Clever hack or code abomination? Matt Joiner <anacrolix@gmail.com> - 2011-12-01 14:49 +1100
Re: Clever hack or code abomination? Chris Angelico <rosuav@gmail.com> - 2011-12-01 19:21 +1100
Re: Clever hack or code abomination? John Ladasky <ladasky@my-deja.com> - 2011-12-06 11:19 -0800
Re: Clever hack or code abomination? Arnaud Delobelle <arnodel@gmail.com> - 2011-12-01 08:35 +0000
Re: Clever hack or code abomination? Vito 'ZeD' De Tullio <zak.mc.kraken@libero.it> - 2011-12-01 21:35 +0100
Re: Clever hack or code abomination? "Martin P. Hellwig" <martin.hellwig@gmail.com> - 2011-12-01 21:13 +0000
Re: Clever hack or code abomination? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-02 00:15 +0000
Re: Clever hack or code abomination? Chris Angelico <rosuav@gmail.com> - 2011-12-02 13:07 +1100
Re: Clever hack or code abomination? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-02 05:34 +0000
Re: Clever hack or code abomination? Chris Angelico <rosuav@gmail.com> - 2011-12-02 17:02 +1100
Re: Clever hack or code abomination? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-02 08:54 +0000
Re: Clever hack or code abomination? Chris Angelico <rosuav@gmail.com> - 2011-12-02 20:16 +1100
Re: Clever hack or code abomination? Terry Reedy <tjreedy@udel.edu> - 2011-12-01 21:49 -0500
Re: Clever hack or code abomination? Matt Joiner <anacrolix@gmail.com> - 2011-12-02 16:11 +1100
Re: Clever hack or code abomination? Chris Hulan <chris.hulan@gmail.com> - 2011-12-02 09:20 -0800
csiph-web