This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
TypeError for unbound method
Webmaster4o last edited by
At first look not really as when I instantiate I have passed
selfas the first paramater and use python2.x new objects ie
class x(object): pass
However thankyou for the response. For now I have do the long way around of just copying the class instead of instantiation.
JonB last edited by
Is it poseible you forgot the self when defining LookObject.init?
Are you able to instantiate a LookObject?
This is how I instantiate the LookObject
class PhysicsCamera(LookObject): def __init__(self, *args, **kwargs): LookObject.__init__(self, *args, **kwargs)
But this raises
TypeError unbound method __init__() must be called with LookObject as first argument (got PhysicsCamera instead).
I also noticed that when I run this from the python file it was created in
LightsCameras.py(New file yet to add it to repo) it works fine but when I use it from
main.pythen the above issue is raised
Further test show that it is just that file as I just tried to use a XMLModel object in it. When testing from
LightsCameras.pyit works fine but as soon as I test it from
main.pyan TypeError is raised. Is this a bug in python/pythonista or have I missed something. I will upload it to the repo.
Webmaster4o last edited by Webmaster4o
Will it ever be run from
main.pyin the module, or just from
It will be used in
main.pyhowever I always try to make it so that classes can be tested from their own file...
Webmaster4o last edited by
Right. Makes sense. (Btw typing this through SlideOver on my iPad and NodeBB does a great job adapting to the weird size.
ywangd last edited by
I have seen this type of error before. It is caused by the
reload()statements in your
Reload will define a new class object for the same class. To Python interpreter, this new class object is considered as a different class from the old class object. If you have a subclass instance of the old class object, it will not be compatible with the new class object. In your case, it is most likely that the
PhysicsCamerais still a subclass of the old
You could try replace
super(PhysicsCamera, self).__init__(*args, **kwargs). The
super()function should get the correct parent class. But it also means any changes to the parent class via reload are not honored.
More info http://stackoverflow.com/questions/9394282/unbound-method-init-must-be-called-with-localeregexprovider-instance-as-fi
@ywangd that has resolved the issue, thank you for the infomation about it