File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Jython/Python and the fly likes Greenhorn needs a little help with class declaration in Jython Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Greenhorn needs a little help with class declaration in Jython" Watch "Greenhorn needs a little help with class declaration in Jython" New topic
Author

Greenhorn needs a little help with class declaration in Jython

Alexandra Wett
Greenhorn

Joined: Jun 18, 2013
Posts: 3
Hi everybody ,
as Iam completely new to Jython and also not well experienced in Java my big boss wants me to be a software tester using a certain software which is based on jython.
Therefore I tried to find some helpful books and links online. I use for training now " the definitiv guide to jython" from Josh Juneau, Jim Baker, Victor Ng,
Leo Soto, Frank Wierzbicki.

for coding I have the tygerjython.jar and jdk1.6_45

So far so good enough of the background.

Following the steps in this book I tried to declare a class and used first some own namings.
But because I got Error messages i switched to the code and naming from the book. But still I'll get the following error message :Traceback (most recent call last):
File"<string>", line 09, in <module> Type Error: this constructor takes no arguments

Here is the code :


have I done something wrong ? I can't see my mistake and searching the web doesn't helped me a lot except finding this forum here

Thank you for helping me

Alex
Alexandra Wett
Greenhorn

Joined: Jun 18, 2013
Posts: 3
OK FOUND The place wich causes the errors

I didn't saw that the def __init__ comes with TWO Underscores I only inserted one to each side

In the book the underscores looked like being one and not two so it took me some nerves to find it out !!

But for sure THIS I will always remember
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1873
    
  16

Hi Alexandra,

Welcome to JavaRanch, and congratulations on solving your own problem so quickly! Seems like you've also discovered Rubber Ducking - by explaining your problem, you see how to fix it.

This double-underscore ("dunder") trick is common in Python as a way of indicating "magic methods" i.e. built-in or special methods that you wouldn't normally call directly. It also occurs when you want to have a "main()" method that runs (as in Java) when you execute your Python class file from the command line. You include a check to see if the built-in "__name__" property is equal to "__main__", which means the file is being executed directly. Then you can tell Python to call a different function e.g. as a simple way to test your script:



No more Blub for me, thank you, Vicar.
Alexandra Wett
Greenhorn

Joined: Jun 18, 2013
Posts: 3
Hi Chris,

thank you for this additional hints I am sure that sooner or later I will hit them and so I know how to use them

Concerning the Rubber Duck people normally think I'm crazy because I talk to myself instead of a duck / bear hmm maybe I should buy a duck then people will say the duck is crazy - listening to me

Anyway - it was a pleasure getting a reply even if nothing has to be fixed concerning the problem


Bye
Alex
 
jQuery in Action, 2nd edition
 
subject: Greenhorn needs a little help with class declaration in Jython