[Python-bugs-list] [ python-Bugs-720908 ] datetime types don't work as bases
SourceForge.net
noreply@sourceforge.net
Mon, 14 Apr 2003 15:02:30 -0700
Bugs item #720908, was opened at 2003-04-14 00:58
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=720908&group_id=5470
Category: Extension Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: datetime types don't work as bases
Initial Comment:
This is probably shallow. Assigned to Guido in case
it's very shallow <wink>:
>>> from datetime import *
>>> class C(date):
... def whatever(self):
... return "oops"
>>> c = C(2002, 1, 1)
>>> c.whatever()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'datetime.date' object has no
attribute 'whatever'
>>> type(c)
<type 'datetime.date'>
>>>
Was reported on c.l.py.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2003-04-14 18:02
Message:
Logged In: YES
user_id=31435
I think the date enhancement is fine -- check it in! I'd leave off
removing the basetype flag on the other types, though -- I
expect we'll need to make them subclassable too.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2003-04-14 13:26
Message:
Logged In: YES
user_id=6380
Here's a strawman fix. It makes 'date' a properly
subclassable type, and makes all the other types (except
tzinfo) non-subclassable.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2003-04-14 08:04
Message:
Logged In: YES
user_id=6380
Well, one shallow thing becomes obvious when you write
c.__class__: it's date, not C! Back to Tim...
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=720908&group_id=5470