How to derive from datetime.timezone class?

Baptiste Lepilleur baptiste.lepilleur at gmail.com
Thu Nov 10 05:51:15 EST 2011


Hi,
I want to sub-class the datetime.timezone class, but when I derive from
datetime.timezone I get an error message "TypeError: type
'datetime.timezone' is not an acceptable base type".

Why do I get this error? Is there something specific to do to avoid it?

Below is an example of code:

Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.timezone
<class 'datetime.timezone'>
>>> class Utc(datetime.timezone):
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type 'datetime.timezone' is not an acceptable base type

Baptiste.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111110/a6c9ffde/attachment.html>


More information about the Python-list mailing list