[Tutor] Is there a preference of "class MyClass:" or "class MyClass(object):" for Py3?

boB Stepp robertvstepp at gmail.com
Sat Jan 16 01:10:42 EST 2016


On Fri, Jan 15, 2016 at 11:47 PM, Steven D'Aprano <steve at pearwood.info> wrote:

>
> If there's any chance that the code might be used in Python 2, or copied
> into a Python 2 module, or read by people expecting Python 2 semantics,
> then you ought to be explicit about the base class.

Hmm.  I *try* to keep Python 3 at home and Python 2 at work (OT aside:
 Hey!  I no longer have to worry about Python 2.4.  I'm up to Python
2.6.4 on all platforms that I do projects for at work!).  But I can
imagine learning something studying at home:  "Hey!  What I just
learned will be really useful at work!  I'll just copy this class to
my thumb drive and ..."  Perhaps for all too easily confused boB
explicit might be better than implicit?  Seems I read that somewhere
recently ...

Thanks, Steve!

-- 
boB


More information about the Tutor mailing list