Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32913 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2012-11-08 10:14 +1100 |
| Last post | 2012-11-08 11:06 +1100 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [Python-ideas] sys.py3k Chris Angelico <rosuav@gmail.com> - 2012-11-08 10:14 +1100
Re: [Python-ideas] sys.py3k Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-07 23:56 +0000
Re: [Python-ideas] sys.py3k Chris Angelico <rosuav@gmail.com> - 2012-11-08 11:06 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-11-08 10:14 +1100 |
| Subject | Re: [Python-ideas] sys.py3k |
| Message-ID | <mailman.3401.1352330078.27098.python-list@python.org> |
On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik <techtonik@gmail.com> wrote:
> I thought of sys.py3k check as an explicit way to guard the code that should
> be maintained extra carefully for Python 3 compatibility, so that you can
> grep the source for this constant and remove all the hacks (such as bytes to
> string conversion) required to maintain the compatibility when the time
> comes to switch.
I agree about greppability, it's a huge help. Hence the code comment;
as long as you're consistent and you pick a keyword long enough or
unusual enough to not occur anywhere else, you can easily do a "find
across files" or "grep XYZ *" to find them all. And if you put the
comment on the most significant line of code, line-based tools will be
more useful.
# Unideal:
# py3k
try:
reload
except NameError:
from imp import reload
# Better:
try: # py3k
reload
except NameError:
from imp import reload
# Best:
try:
reload # py3k
except NameError:
from imp import reload
# Also best:
try:
reload
except NameError:
from imp import reload # py3k
Taking just the line with the keyword "py3k" on it will tell you
exactly what that file is doing.
ChrisA
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-11-07 23:56 +0000 |
| Message-ID | <509af533$0$29980$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #32913 |
On Thu, 08 Nov 2012 10:14:35 +1100, Chris Angelico wrote: > On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik <techtonik@gmail.com> > wrote: >> I thought of sys.py3k check ... Chris, you regularly reply to the wrong mailing list, and you've just done it again. This is not python-ideas. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-11-08 11:06 +1100 |
| Message-ID | <mailman.3411.1352333167.27098.python-list@python.org> |
| In reply to | #32922 |
On Thu, Nov 8, 2012 at 10:56 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Thu, 08 Nov 2012 10:14:35 +1100, Chris Angelico wrote: > >> On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik <techtonik@gmail.com> >> wrote: >>> I thought of sys.py3k check ... > > Chris, you regularly reply to the wrong mailing list, and you've just > done it again. This is not python-ideas. Ack! Sorry all. I was sure I checked.... whoops. Egg-on-face-ly yours... ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web