Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32756
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'subject:Python': 0.05; 'try:': 0.07; 'python': 0.09; 'grep': 0.09; 'nameerror:': 0.09; 'def': 0.10; 'anatoly': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'item:': 0.16; 'reload': 0.16; 'subject:ideas': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'subject:] ': 0.19; 'import': 0.21; 'received:209.85.214.174': 0.21; 'universal': 0.22; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; "d'aprano": 0.29; 'steven': 0.29; 'function': 0.30; 'code': 0.31; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'nov': 0.35; 'todo': 0.35; 'received:209.85': 0.35; 'except': 0.36; 'item': 0.37; 'ones': 0.37; 'received:209': 0.37; 'comment': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'takes': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'bring': 0.62; 'back': 0.62; 'language!': 0.84; 'obvious.': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=2zeaaqjjj8XUcw2XiEiPgFGYc6Q+0OPoSHXnkYt/QW0=; b=cKgzEOfYm8cQ0vUA2wNmeg68GXoQNhaJDrk8/+Z98EVvchChksN52IPP1XlPpKO0aG U/lw/1IK04on7H0yg3Y+HiBE5I0GhtPl9tbZYR4ZcpRMZgvSUH1mE9vIj37PBFPg5O2O MdLt7GbXOGaeQJ9SblUq7An4yWbebTFcALJ8hCFaUiXDtgqcxigbukIOasGUbCzihb2k oGPTiTWNgsVOOHSJ2bIED3ruAjbbeIyE62i0auodblecH8+NJONsn2XD5t0dD9WD1lMq ivqgh6f3C/LTgb8djmdIGYBdv7DundKeRU3PqcnRbBpbg+cOqvRs6t0epUhxJUHlsQ/q O8Xw== |
| MIME-Version | 1.0 |
| In-Reply-To | <5096ED46.20502@pearwood.info> |
| References | <CAPkN8xL1Hh72_cur91xTPVcyxMLzMVPpZcUp_oumUFKhMZZTDg@mail.gmail.com> <5096ED46.20502@pearwood.info> |
| Date | Mon, 5 Nov 2012 18:36:59 +1100 |
| Subject | Re: [Python-ideas] sys.py3k |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.3273.1352101022.27098.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1352101022 news.xs4all.nl 6911 [2001:888:2000:d::a6]:50111 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:32756 |
Show key headers only | View raw
On Mon, Nov 5, 2012 at 9:33 AM, Steven D'Aprano <steve@pearwood.info> wrote:
> On 05/11/12 08:49, anatoly techtonik wrote:
>>
>> if sys.py3k:
>> # some py2k specific code
>> pass
>
> # Bring back reload in Python 3.
> try:
> reload
> except NameError:
> from imp import reload
>
> try:
> any
> except NameError:
> # Python 2.4 compatibility.
> def any(items):
> for item in items:
> if item:
> return True
> return False
Take the best of both worlds:
try: # py3k
reload
except NameError:
from imp import reload
Now you can grep your code for py3k without changing the language!
Never underestimate the value of comment tokens. Universal ones like
TODO or private ones like NULLSAFE, all it takes is grep or your
editor's Find function to make them all obvious.
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: [Python-ideas] sys.py3k Chris Angelico <rosuav@gmail.com> - 2012-11-05 18:36 +1100
csiph-web