3

I am new to Ubuntu. I formerly used to use python on windows, and now I am learning Ubuntu. When I open the command terminal, I type python and press Enter,the symbol (>>>) is shown and I am in IDLE. However, I want to know how I can create functions and classes and the stuff I used to to in Windows.

Thanks.

  • What were you using in Windows as a Python shell? If that's also IDLE, then there's no difference in Ubuntu. However, I think you should check out iPython if you find the time. It's a lot more powerful than IDLE. – gertvdijk Dec 24 '13 at 19:30
  • The difference is: in windows you can go to file-->new module and create what you want – XenonDragon Dec 24 '13 at 20:36
4

Creating functions using the CLI is very similar to creating functions in scripts. Type your function name and arguments on the first line and append a colon. After that the Pyhton interpreter asks for further input. Now you have to indent the next code you want write in the function body. You finish the function the a blank line.

It should look like:

>>> def fun(a,b):
...     print a,b
... 
>>> 
1

The difference is: in windows you can go to file-->new module and create what you want

I think what you mean is, that in Windows you're used to the IDLE GUI. In Ubuntu you'll have to install the necessary packages in order to run the Tkinter version of IDLE.

Installing the idle Install idle package will make sure you have all the necessary software to run the GUI.

Then run it:

idle

And it's also in your regular applications list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.