[Tutor] regex to promote Py 2 to Py 3?

Michael Weylandt michael.weylandt at gmail.com
Wed Apr 17 03:35:48 CEST 2013


On Apr 16, 2013, at 21:02, Jim Mooney <cybervigilante at gmail.com> wrote:

> I already tried an example I copied from something online, in Py 2,
> that had a ton of print statements. So I did some fast search and
> replace to make them Py 3 with (), since I'm using Py 3. (Except Wing
> 101 won't do Replace All for some reason I haven't figured out, so
> it's a bit tedious)
> 
> So for online progs, examples, ebooks, etc, that still have Py 2
> examples I can copy, has anyone come up with a nice regex package to
> do most of the conversions and produce a mostly Py3 from a Py2? That
> might make some things a bit easier. I use Clipmate, which has a regex
> option so I could just copy a Py2 script, run the regex, and paste
> back a Py3. I could probably work one out but since I don't know Py
> yet, that could be problematic ;')

Much ink has been spilled on just such a translation, but you may as well start with the 2to3 script and see if that suffices for your needs:

http://docs.python.org/2/library/2to3.html


Michael

> 
> Jim
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130416/6f0c1241/attachment.html>


More information about the Tutor mailing list