On Tue, Feb 11, 2014 at 12:13 PM, Travis Griggs wrote:
> So here’s my basic question. Is there anyway to programatically query that
> information in python code?
>
> inspect.signature(datetime.datetime.now)
>
> just gives a ValueError. inspect must only be good for the python code that I
> write
The discussion about niladic functions, made me want to follow a segue and do
some reflection/introspective programming in Python. I’ve not done a lot of
that yet, and it seemed like an educational (well, at least entertaining) goose
chase.
If I run the following code:
import datetime
datetime
Steve Menard wrote:
> I have a need to create class instance without invokking the class' __init__
> method.
>
> Were I using old-style classes, I'd use new.instance() function. However, I
> am using new-style classes and new.instance() complain "TypeError:
> instance() argument 1 must be clas
Steve Menard wrote:
> So my question is, how to replicate new.instance() functionality with new
> classes?
class A(object):
def __init__(self):
print "Class A"
A()
A.__new__(A) # <- this one
Regards,
Jordan
--
http://mail.python.org/mailman/listinfo/python-list
I have a need to create class instance without invokking the class' __init__
method.
Were I using old-style classes, I'd use new.instance() function. However, I
am using new-style classes and new.instance() complain "TypeError:
instance() argument 1 must be classobj, not type" ...
So my quest