File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Greenhorn needs a little help with class declaration in Jython

 
Alexandra Wett
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 2359
31
Linux Oracle Postgres Database Python Scala
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
Alexandra Wett
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic