Hello,

Consider the following code:

  class MyClass(Basic):
    def __init__(self, argument):
      print argument

I can create an instance of MyClass in this way:

  MyClass("something")

However, I cannot do

  MyClass(argument="something")

because of

  TypeError: __new__() got an unexpected keyword argument 'argument'

I don't really know much about the intricacies of Python inheritance,
but I can see that Basic.__new__ does indeed not accept any keyword
arguments and I think that may be the origin of my problem.

When I don't subclass Basic, both ways work nicely.

Now, I can achieve what I want by doing

  class MyClass(Basic):
    def __new__(cls, argument):
      print argument
      return Basic.__new__(cls)

I *think* this doesn't break anything, but could anyone confirm it?

Also, is there a serious reason to not have Basic accept keyword
arguments?  That's likely a noobistic question, so I beg your patience
to bear with me :-)

Sergiu

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to