From: Aurelien M. <aur...@fr...> - 2003-09-01 13:36:30
|
You got an error because in your script, obj2 is not an instance of the =20= java class ImportTester, but a reference to the class; it's a common =20 mistake in python. You must type: obj2 =3D ImportTester() and it should work. Aur=E9lien (not: the error message said you that if you want to call a method of a =20= non-instanciated class, you must provide at least one argument: a =20 instance of this class) Le lundi, 1 sep 2003, =E0 15:14 Europe/Paris, Rubin, Dani a =E9crit : > Hello, > I am trying to write a simple script to call a method on the java =20 > imported > superclass: > class Inheritor: > > def __init__(self, name): > self.name =3D name > > def show(self): > print 'Inheritor -- name: %s' % self.name > > obj1 =3D Inheritor('Apricot') > obj1.show() > import ImportTester > obj2 =3D ImportTester > obj2.pr() > > public class ImportTester { > public void pr(){ > System.out.println("Inside printer"); > }=09 > =09 > > } > when I run the script I get: > C:\jython\Lib>jython Inheritor.py > Inheritor -- name: Apricot > Traceback (innermost last): > File "Inheritor.py", line 15, in ? > TypeError: pr(): expected 1 args; got 0 > > Can you help? > Regards > Dani > > = _______________________________________________________________________=20= > ____________________________ > > > The views expressed in this email are, unless otherwise stated, those =20= > of the author and not those > of the FirstRand Banking Group or its management. The information in =20= > this e-mail is confidential > and is intended solely for the addressee. Access to this e-mail by =20 > anyone else is unauthorised. > If you are not the intended recipient, any disclosure, copying, =20 > distribution or any action taken or > omitted in reliance on this, is prohibited and may be unlawful. > Whilst all reasonable steps are taken to ensure the accuracy and =20 > integrity of information and data > transmitted electronically and to preserve the confidentiality =20 > thereof, no liability or > responsibility whatsoever is accepted if information or data is, for =20= > whatever reason, corrupted > or does not reach its intended destination. > > ________________________________ > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |