Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 I模块之间的状态和类型_Python 2.7 - Fatal编程技术网

Python 2.7 I模块之间的状态和类型

Python 2.7 I模块之间的状态和类型,python-2.7,Python 2.7,我正在检查这台setter中的base_geo类型 @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" % ins

我正在检查这台setter中的base_geo类型

    @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
哪个输出以下内容

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" # 
检查模块基座\u geo:
检查模块Geo:
键入base_geo:
基本地理位置:
基本地理等级:
地理:
类型(基本地理)=地理:假
isinstance(基本地理位置,地理位置):False
基本地理。uuuuuu类uuuu==geo:False
___测试地球同步轨道___
检查模块测试单元:
检查模块Geo:
型式试验:
测试地点:
测试地理等级:
地理:
类型(test_geo)=geo:True
isinstance(test_geo,geo):真
test\u geo.\uuuuu class\uuuu==geo:True
#错误:类型错误:文件Q:\tools\Maya\grinder\scripts\deformator\builderator\data\u types\channels.py第236行:不是“Geo”类型
关于为什么test_geo案例按预期工作,而base_geo没有工作,有什么想法吗?我能想到的唯一区别是,base_geo是在不同的模块中构建的。其他有类似问题的人的例子似乎已经通过保持模块之间的导入相同得到了解决,在本例中,他们已经做到了这一点

isinstance(base_geo, deformator.builderator.data_types.geo.Geo)
而不是

isinstance(base_geo, Geo)
解决了