On Fri, Jan 15, 2016 at 09:30:57PM -0600, boB Stepp wrote:

> Pythonic style/preference question:  For strictly Python 3 code, is
> there any preference for
> 
> class MyClass:
>     pass
> 
> versus the more explicit
> 
> class MyClass(object):
>     pass
> 
> ?

For *purely* Python 3 code, where your audience (readers, maintainers, 
developers etc) are all familiar with, and expect, Python 3 semantics, 
not really. Maybe if you are writing introspection code which explicitly 
works with the class MRO or base-classes, you might prefer to be 
explicit. Otherwise, do whatever you feel best. For quick and dirty 
throw-away code, feel free to leave out the base class.

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.


-- 
Steve
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to