Issue1768876
Created on 2007-08-06.23:18:38 by pekka.klarck, last changed 2009-06-21.21:42:51 by pjenvey.
msg1809 (view) |
Author: Pekka Klärck (pekka.klarck) |
Date: 2007-08-06.23:18:38 |
|
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']
|
msg4830 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2009-06-21.21:42:51 |
|
I don't think these would have belonged in the types module anyway.
types.ArrayType was a mistake that was removed in 2.5. Java classes are
now new style types in 2.5 so this issue isn't really relevant any longer
anyway. closing out
|
|
Date |
User |
Action |
Args |
2009-06-21 21:42:51 | pjenvey | set | status: open -> closed resolution: fixed messages:
+ msg4830 nosy:
+ pjenvey |
2009-03-12 08:20:33 | zyasoft | set | versions:
+ 2.5.1 |
2008-12-15 19:01:43 | fwierzbicki | set | components:
+ Core, - None |
2008-11-03 21:07:26 | fwierzbicki | set | nosy:
+ fwierzbicki |
2008-11-03 21:07:05 | fwierzbicki | set | type: rfe |
2008-09-17 18:40:28 | zyasoft | set | nosy:
+ zyasoft |
2007-08-06 23:18:38 | pekka.klarck | create | |
|