Message1809
There doesn't seem to be anything suitable in types to verify is an object a Java class or instance. As the code below demonstrates, there's ClassType and InstanceType but they only match Python classes and instances (which is probably a good thing).
Adding something like JavaClassType and JavaInstanceType to types would probably be a good idea. Adding Jython specific types ought to be ok since there's ArrayType already.
Jython 2.2rc3 on java1.6.0
Type "copyright", "credits" or "license" for more information.
>>> import types
>>> from java.lang import String
>>> class C:
... pass
...
>>> type(C)
<type 'class'>
>>> type(C())
<type 'instance'>
>>> type(String)
<type 'javaclass'>
>>> type(String())
<type 'javainstance'>
>>> type(C) is types.ClassType
1
>>> type(C()) is types.InstanceType
1
>>> type(String) is types.ClassType
0
>>> type(String()) is types.InstanceType
0
>>> max([ type(String) is getattr(types, name) for name in dir(types) ])
0>>> max([ type(String()) is getattr(types, name) for name in dir(types) ])
0
>>> dir(types)
['ArrayType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MethodType', 'ModuleType', 'NoneType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType', '__doc__', 'classDictInit']
|
|
Date |
User |
Action |
Args |
2008-02-20 17:17:57 | admin | link | issue1768876 messages |
2008-02-20 17:17:57 | admin | create | |
|