[Tutor] when is a generator "smart?"

Chris “Kwpolska” Warrick kwpolska at gmail.com
Mon Jun 3 20:47:15 CEST 2013


On Mon, Jun 3, 2013 at 8:13 PM, Jim Mooney <cybervigilante at gmail.com> wrote:
>
> On 3 June 2013 07:22, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
>
> > If you put "from __future__ import print_function" at the top of your
> > module you can use the same print function in Python 2.6/2.7 and 3.x.
> > I recommend doing this rather than bothering with the 2.x print
> > statement.
>
> Using Python 2.7 on Windows 7
>
> That's handy. When I went backward from 3.3 to 2.7, one of the few
> things I missed at my level was end= and sep= in print()  .format()
> was already backported since I'd learned that. I do like it .format()
> better unless you get too fancy with those {}s. I dislike the % format
> for some reason. It just looks ugly to me. And as it says in  first
> sentence of The Zen of Python from this.py: "Ornhgvshy vf orggre guna
> htyl."
>
> As a programming exercise I've been trying to translate Ancient
> Pythonaic back to English, but I don't follow Tim Peter's obfuscated
> little program yet. Ancient Pythonaic will probably never rival
> Klingon ;')

It is just rot13.  In Python 2, `str.decode('rot13')` would be enough.
 In Python 3, it doesn’t seem to happen so easily.  (If anyone knows
how to do it, please share!)

> Ah, question just came up. Since I have two pys, when a module is
> ported from 2.7 to 3.2 does it always have a different name?

It never does.  And in case it does, the developers are idiots.

> If the names are the same i can see where I can get confused with a pip
> install. Unless it is true that if I use pip-3.3 it will always
> install a 3.3 module, and if I use pip-2.7 it will always install a
> 2.7 module. I'd get rid of Py 3.3 for now to avoid confusion, but at
> some point, since a lot has not been ported to 3.3

http://python3wos.appspot.com/ seems to think otherwise.  60.5% of the
top 200 packages are ported, and two more are getting close
(werkzeug+flask[0]).

[0]: http://www.reddit.com/r/Python/comments/1fd69b/werkzeug_and_flask_git_repositories_have_early/

--
Kwpolska <http://kwpolska.tk> | GPG KEY: 5EAAEA16
stop html mail                | always bottom-post
http://asciiribbon.org        | http://caliburn.nl/topposting.html


More information about the Tutor mailing list