FAQ
The commonly recommended resource is http://python3porting.com/


Also make sure to get to 100% test coverage!




On Mon, Apr 21, 2014 at 12:31 PM, Santiago Basulto wrote:

Hello everyone. I'm writing a library that I'd like to be usable from
both, Python 2 and Python 3. Actually, there's a library that works just
for python2 and I want to make it work for 3.

I know it's not really hard to make it work for both versions, but
sometimes I have doubts. For example. If I define a simple class:

class A:
def __init__(self):
pass

It will have different meanings if it's run with Python 2 or Python 3
(lacking 'object' inheritence for python2).

Is there any guide, blog post, anything?

Thank you very much.

--
Santiago Basulto.-

_______________________________________________
Baypiggies mailing list
Baypiggies at python.org
To change your subscription options or unsubscribe:
https://mail.python.org/mailman/listinfo/baypiggies





--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20140421/265a677c/attachment.html>

Search Discussions

  • Aaron Meurer at Apr 21, 2014 at 8:13 pm
    For Python 2 compatible code, you should always be explicit and
    subclass every class from object, like


    class A(object):
         def __init__(self):
             pass


    This is one of the easy things for writing cross compatible code. The
    hard things are dealing with the str/bytes differences, and the little
    tricks you have to do to support metaclasses and exec.


    Aaron Meurer



    On Mon, Apr 21, 2014 at 2:36 PM, Guido van Rossum wrote:
    The commonly recommended resource is http://python3porting.com/

    Also make sure to get to 100% test coverage!


    On Mon, Apr 21, 2014 at 12:31 PM, Santiago Basulto
    wrote:
    Hello everyone. I'm writing a library that I'd like to be usable from
    both, Python 2 and Python 3. Actually, there's a library that works just for
    python2 and I want to make it work for 3.

    I know it's not really hard to make it work for both versions, but
    sometimes I have doubts. For example. If I define a simple class:

    class A:
    def __init__(self):
    pass

    It will have different meanings if it's run with Python 2 or Python 3
    (lacking 'object' inheritence for python2).

    Is there any guide, blog post, anything?

    Thank you very much.

    --
    Santiago Basulto.-

    _______________________________________________
    Baypiggies mailing list
    Baypiggies at python.org
    To change your subscription options or unsubscribe:
    https://mail.python.org/mailman/listinfo/baypiggies



    --
    --Guido van Rossum (python.org/~guido)

    _______________________________________________
    Python-porting mailing list
    Python-porting at python.org
    https://mail.python.org/mailman/listinfo/python-porting

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-porting @
categoriespython
postedApr 21, '14 at 7:36p
activeApr 21, '14 at 8:13p
posts2
users2
websitepython.org

2 users in discussion

Guido van Rossum: 1 post Aaron Meurer: 1 post

People

Translate

site design / logo © 2018 Grokbase