Message397484
> Doesn’t it do that with any built in function?
Sorry. I did not include what is the behavior for other classes. An example could be calendar.Calendar. In this case the signature gives:
>>> from calendar import Calendar
>>> import inspect
>>> print(inspect.signature(Calendar.__init__))
(self, firstweekday=0)
>>> print(inspect.signature(Calendar))
(firstweekday=0)
Note that the signature gives firstweekday which is the only init parameter. Calendar is not implemented with __new__ so getting the signature would be for object, that does not include named parameters.
It also works fine when you implement a class with __new__. For example:
>>> class MyClass:
def __new__(cls, paramA, paramB=1):
obj = object.__new__(cls)
obj.paramA = paramA
obj.paramB = paramB
return obj
>>> print(inspect.signature(MyClass.__new__))
(cls, paramA, paramB=1)
>>> print(inspect.signature(MyClass))
(paramA, paramB=1)
I do think it is a bug specific to the datetime classes. |
|
Date |
User |
Action |
Args |
2021-07-14 15:24:08 | mauvilsa | set | recipients:
+ mauvilsa, gvanrossum |
2021-07-14 15:24:08 | mauvilsa | set | messageid: <1626276248.41.0.624056641097.issue44618@roundup.psfhosted.org> |
2021-07-14 15:24:08 | mauvilsa | link | issue44618 messages |
2021-07-14 15:24:08 | mauvilsa | create | |
|