Onecore

  • Home
  • About
  • Advertise
  • Archives
  • Privacy Policy
  • Contact

How To: Python Programming Under Ubuntu

software templates

If you are new to python programming and if you’re using ubuntu linux as your operating system then you can start programming easily as Ubuntu comes up with the command line version of python pre-installed. Ubuntu community develops its own tools and scripts under python,so you can learn a lot from the community. Official Community also offers bounties on some of its python projects. So in that way you can also get in touch with the experienced python developers.

In python you have two choices to learn how to program, one is with command line version and another is IDLE. I’ll explain both these methods one by one.

Command Line

Command line version of python is already installed in Ubuntu. To get into python’s interactive mode,Click on Appliations>Accesorries>Terminal. Then type ‘python’ without quotes,that will open up the interactive mode of the python.Now you can test your python scripts.

You can also write the program with help of text editor like gedit or Emacs. Then save it with extension .py. Now if you want to execute that file,then open the terminal, move yourself to the directory where that .py file exists. Then type the following commands in terminal.
python hello.py
this will execute the program. Once program is executed you’ll return back to the command prompt.To exit from the python interpreter type the following:
import sys;sys.exit();

or  you can use exit(); or CTRL-D
This will exit from the interpreter and return back to the terminal.
IDLE

If you don’t want to use the command line version of python then there is another choice “IDLE”. IDLE means interactive developement envirement. IDLE is a Python IDE that includes a GUI debugger based on pdb. IDLE is not installed in ubuntu by default, you have to install it from DVD. To install the IDLE,follow these steps.
Click on Application>Add-remove applications.

In Add-remove applcations select categary > Programming >then Select “IDLE” check-box point.Click OK. Then it will ask for the install disk and then installs it from there.

Now you can write your program with help of text editor like emacs/gedit. Once you’re done with it,save it with extension .py. Now right click “Open with” then  select >IDLE. OR you can open the file from IDLE. IDLE shows the colored syntax of your program. Now to run your program,follow these steps:
Click>RUN>Run Module.

This will execute the program in the IDLE.

(Graphical user interface-GUI for Python)

Once you learn the techniques of the text processing in python. Then you need to learn how to program applications in GUI. To program GUI based applcations you have many option like Wxpython,Tkinter,Pyqt etc.

Tkinter is a GUI widget set for Python.There are many introductory tutorials for the Tkinter on the web. Some of them are :

[1] Introduction to python

[2] Python and Tkinter Programming by John Grayson (Manning, 2000, ISBN 1-884777-81-3)

[3] Tkinter reference [Here]

WxPython is another GUI toolkit for the Python programming language which allows easy creation of graphical user interfaces.You can obtain more information about Wxpython from official wxpython website.

You can learn more from python community so check out the activestate’s “CookBook” where you can learn a lot about the python coding.

More Python Tutorials

  • Python Dictionaries
  • Python Tuples
  • Python Lists
  • Python Date and Time
  • SQlite Python
  • Python easy_install modules

I hope above information helps.If you have any quesstion & suggestion or errors.Then please don’t hesitate to post it over here.

Comments

  1. Henk Dafour says

    February 28, 2007 at 5:22 PM

    I am just learning to program with Python and found IDLE a bit counter intuitive. My professor advised me SPE: http://pythonide.stani.be I am very happy with it as especially the uml gives a nice overview of my program. There are still a lot of features to explore, but I am sure one day I’ll know more about them.

  2. Harish says

    December 22, 2007 at 7:41 PM

    i’ve just started off with python. the above info was exactly what i was lookin for. thanks

  3. Roy says

    January 12, 2008 at 11:54 AM

    Thank you very much, this really helped me to start with programming in Python. I look for forward for more tutorials of you. Keep ’em comin’!

  4. Thura says

    July 3, 2008 at 1:19 PM

    Thanks

  5. kirubakaran says

    July 13, 2008 at 1:23 PM

    really thanks…..

  6. Paddy says

    August 5, 2008 at 2:02 PM

    Thanks, this was exactly what I was looking for 😉

  7. Madlib says

    September 8, 2008 at 11:50 PM

    Thanks for the info. This is exactly what python beginners need. Thanks for the useful info.

  8. leegurus says

    October 12, 2008 at 12:49 PM

    thanks dude!!

  9. Offrocker says

    November 11, 2008 at 4:47 AM

    I just discovered Ubuntu 2 weeks ago and am interested in using python,…much thanks.

  10. razorxpress says

    December 7, 2008 at 3:25 PM

    Another nice option for python ide is eclipse. Installing eclipse and adding pydev(without any additional features) plugin helps to write python programs with features of eclipse as in other languages

  11. silvio says

    January 20, 2009 at 12:48 PM

    thank you, very useful

  12. Chris says

    February 2, 2009 at 8:38 PM

    Thanks for the info although I would like to develop Gnome apps in Python, how would I go about doing this?

  13. Rishiraj says

    February 9, 2009 at 9:44 PM

    Great info for a beginner with Linux and Python.It really helped

  14. sup says

    February 13, 2009 at 1:38 AM

    thanks so much. very useful and easy for a beginner.

  15. dave00 says

    March 28, 2009 at 7:02 PM

    Hi!

    This is a simple and very useful article. Thank you!

  16. sreenivasrao says

    April 12, 2009 at 12:15 AM

    Simple and effective for newbie, nice stuff

  17. Karn Chandra says

    May 10, 2009 at 7:02 PM

    Thanks! 🙂

  18. bob says

    May 24, 2009 at 12:19 AM

    There is another option to try –
    using Netbeans Python early access:
    http://dlc.sun.com.edgesuite.net/netbeans/6.5/python/ea/

  19. Sol says

    June 4, 2009 at 10:09 PM

    With python I can build a program for many platforms.. almost!
    This article is helpful… Thanks a lot!

  20. Brad Blosser says

    July 20, 2009 at 9:24 PM

    Thank you so much for this.
    I’m looking to start a Computer Science degree and I found a wonderful book through MIT called Think Python.

    IT was originally titled Think like a Computer Scientist – Python.

    He charges 90 for it on Amazon so Thank God he believes in open source and open GL because he provides it for free. He even lists your name in his book if you come up with a helpful change and he replies to your comments, a very nice Computer Science teacher.

    Any way…. one thing he forgot in chapter two is how to get your script to work after you create a “simple.py” script, how do you run it.
    I could find nothing that made sense in a windows environment after two days of researching over the weekend. Now I start looking up in the Linux enivronment and (DOH DOH DOH) first try I find the answers to my questions.

    Sigh, I just wish it was easier to play windows games in linux environment and I’d give up windows altogether.
    You’ve almost got me.
    Brad

  21. black scorpio says

    July 27, 2009 at 2:03 PM

    Thank you for this nice information as a beginer like me.

  22. mastr0 says

    October 3, 2009 at 6:25 PM

    thanx for that man

  23. Nattyspats says

    April 4, 2010 at 4:49 PM

    Thank you! Quite helpful.

  24. Abhinav says

    April 11, 2010 at 3:15 PM

    python kicks a** . I thot C++ was easiest but hey pythons more logical and easier 😛

  25. Tobin says

    April 27, 2010 at 11:45 PM

    Exactly what I was looking for. Thanks heaps 😀

  26. Avinash T M says

    July 8, 2010 at 9:17 AM

    Thanks for nice introduction regarding python,

software templates

Featured Articles

  • Sample Test Cases for Calendar App
  • Sample Test Cases for Dialog Box
  • Test Cases for Amazon Login Screen Page
  • Sample Test Cases for Online Editor
  • Sample Test Cases for Online Book Shopping

WPForms

ENDORSEMENT DISCLOSURE: In order for us to support our website activities, we may receive monetary compensation or other types of remuneration for our endorsement, recommendation, testimonial and/or link to any products or services from this website.

Copyright © 2021 . This website uses cookies to ensure you get the best experience on our website.