Strange, simple Jython problem

Oliver Rutherfurd oliver at rutherfurd.net
Thu Feb 20 17:01:36 EST 2003


Hi Chris,

Just a stab, but are you trying to call instance methods of classes without
creating an instance of the class?

    Jython 2.1 on java1.4.1 (JIT: null)
    Type "copyright", "credits" or "license" for more information.
    >>> from java.lang import Math
    >>> print Math.random()
    0.4088084432947816
    >>> from java.util import Vector
    >>> print Vector.size()
    Traceback (innermost last):

      File "<console>", line 1, in ?

    TypeError: size(): expected 1 args; got 0

    >>> v = Vector()
    >>> print v.size()
    0

-Ollie

--
Ollie Rutherfurd
http://www.rutherfurd.net/

"Clueless Chris" <chris at ooc2000.com> wrote in message
news:<e9270fab.0302201242.4f10103f at posting.google.com>...
> Hi all,
>
> I'm an experienced Java guy who's messing around with Java a little. I
> can call regular Java classes just fine, such as Math.random() to get
> a random number -- the "Hello World" of Jython programs -- but calling
> my own classes, it complains that I'm an argument short. I get syntax
> errors saying "expecting 3 args; got 2", etc etc. I assume this is a
> 'this' issue, especially since when I try giving it a 3rd arg, it
> complains that my first arg, saying "self can't be coerced to" and
> then the type of the arg I tried to pass in.
>
> What's strange is that the normal JDK classes work fine.
>
> What am I missing here?
>
> Thanks,
> CC
> --
> http://mail.python.org/mailman/listinfo/python-list
>






More information about the Python-list mailing list