Mauricio Villegas <mauricio_vi...@yahoo.com> added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44618>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to