From: D-Man <ds...@ri...> - 2001-07-18 13:16:17
|
On Wed, Jul 18, 2001 at 10:10:47AM +0000, Mark Robinson wrote: | Hi, | | can anyone tell me how I should convert a Graphics object to a Graphics2D | object in jython.This is what I get: | | Traceback (innermost last): | (no code object) at line 0 | File "drawing.py", line 32 | g2 = (Graphics2D)g | ^ | SyntaxError: invalid syntax Hehe, you're trying to do a C/C++/Java cast in Python :-). Those languages are all statically typed so you must tell the compiler that you really have a Graphics2D object because it can't figure that out for itself. Python, on the other hand, is dynamically typed. Since you know you have a Graphics2D object, just use it! :-). Python/Jython will check to make sure it really is the right object when you call methods on it and it will just work! This is one of the features of Python that make it so easy and fun to use. -D |