Support
Quality
Security
License
Reuse
kandi has reviewed builderator and discovered the below as its top functions. This is intended to give you an instant insight into builderator implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
Test data builder generator for Java
See all related Code Snippets
QUESTION
isinstance and type between modules
Asked 2018-Aug-02 at 13:25I'm trying to check the type of base_geo in this setter.
@base_geo.setter
def base_geo(self, base_geo):
test_geo = Geo(self.data_node, "foo_geo")
print "inspect module base_geo: %s" % inspect.getmodule(base_geo)
print "inspect module Geo: %s" % inspect.getmodule(Geo)
print "type base_geo: %s" % type(base_geo)
print "base_geo: %s" % base_geo
print "base_geo.__class__: %s" % base_geo.__class__
print "Geo: %s" % Geo
print "type(base_geo) == Geo: %s" % str(type(base_geo) == Geo)
print "isinstance(base_geo, Geo): %s" % isinstance(base_geo, Geo)
print "base_geo.__class__ == Geo: %s\n" % str(base_geo.__class__ == Geo)
print "___TEST__GEO___"
print "inspect module test_geo: %s" % inspect.getmodule(test_geo)
print "inspect module Geo: %s" % inspect.getmodule(Geo)
print "type test_geo: %s" % type(test_geo)
print "test_geo: %s" % test_geo
print "test_geo.__class__: %s" % test_geo.__class__
print "Geo: %s" % Geo
print "type(test_geo) == Geo: %s" % str(type(test_geo) == Geo)
print "isinstance(test_geo, Geo): %s" % isinstance(test_geo, Geo)
print "test_geo.__class__ == Geo: %s" % str(test_geo.__class__ == Geo)
if not isinstance(base_geo, Geo):
raise TypeError, ("%s is not of type \"Geo\"" % base_geo)
self._base_geo = base_geo
Which outputs the following
inspect module base_geo: <module 'deformator.builderator.data_types.geo' from 'Q:\tools\Maya\grinder\scripts\deformator\builderator\data_types\geo.py'>
inspect module Geo: <module 'deformator.builderator.data_types.geo' from 'Q:\tools\Maya\grinder\scripts\deformator\builderator\data_types\geo.py'>
type base_geo: <class 'deformator.builderator.data_types.geo.Geo'>
base_geo: <deformator.builderator.data_types.geo.Geo object at 0x0000016DFD0E77B8>
base_geo.__class__: <class 'deformator.builderator.data_types.geo.Geo'>
Geo: <class 'deformator.builderator.data_types.geo.Geo'>
type(base_geo) == Geo: False
isinstance(base_geo, Geo): False
base_geo.__class__ == Geo: False
___TEST__GEO___
inspect module test_geo: <module 'deformator.builderator.data_types.geo' from 'Q:\tools\Maya\grinder\scripts\deformator\builderator\data_types\geo.py'>
inspect module Geo: <module 'deformator.builderator.data_types.geo' from 'Q:\tools\Maya\grinder\scripts\deformator\builderator\data_types\geo.py'>
type test_geo: <class 'deformator.builderator.data_types.geo.Geo'>
test_geo: <deformator.builderator.data_types.geo.Geo object at 0x0000016DFD3E7A90>
test_geo.__class__: <class 'deformator.builderator.data_types.geo.Geo'>
Geo: <class 'deformator.builderator.data_types.geo.Geo'>
type(test_geo) == Geo: True
isinstance(test_geo, Geo): True
test_geo.__class__ == Geo: True
# Error: TypeError: file Q:\tools\Maya\grinder\scripts\deformator\builderator\data_types\channels.py line 236: <deformator.builderator.data_types.geo.Geo object at 0x0000016DFD0E77B8> is not of type "Geo" #
Any ideas as to why the test_geo case is working as expected while base_geo is not? The only difference i can think of is that base_geo is constructed in a different module. Other examples of people having similar issues seems to have been resolved by keeping the imports the same between modules, which they already are in this case.
ANSWER
Answered 2018-Aug-02 at 13:25isinstance(base_geo, deformator.builderator.data_types.geo.Geo)
instead of
isinstance(base_geo, Geo)
solved it
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
See Similar Libraries in
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source