Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-03-2006, 01:57 AM
|
#1
|
Member
Registered: Jun 2005
Location: England, Cheam
Distribution: Fedora Core 6
Posts: 96
Rep:
|
Need Help with python 2.3
I have started to learn python. However I am very confused how to use the python 2.3 application. When I open the app I get a konsole window which allows me to type in python code and then it immidately gets 'converted' to real world language. However how would I enter long scripts into this console window which go below one line? Everytime I try going below one line by pressing enter the app converts my first line of code.
Also, how can I read a .py file?
Thanks
Mike
|
|
|
03-03-2006, 03:07 AM
|
#2
|
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298
Rep:
|
Use a text editor like KATE, EMACS or VIM to read and write *.py files (You can also use IDLE pythons built in IDE). You can then execute the *.py files from the command line by doing something like "python myfile.py". I find it better to write python programs as seperate scripts than entering long programs in the command line intepreter, but if you can use \ at the end of your lines, if you need to enter code on more than one line.
|
|
|
03-03-2006, 03:08 AM
|
#3
|
Senior Member
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495
Rep:
|
That's easy  Just create your python program in a separate file, using any text editor. Don't forget to get the indentation right. e.g.
Code:
for i in range(10):
print 'Hello'
If you save this in a file called hello.py then you can run it from the command line with
$ python hello.py
There's lots more twists and turns, but that will get you started. To read a *.py file just open it in a text editor.
Last edited by maroonbaboon; 03-03-2006 at 03:11 AM.
|
|
|
03-04-2006, 01:45 AM
|
#4
|
Member
Registered: Jun 2005
Location: England, Cheam
Distribution: Fedora Core 6
Posts: 96
Original Poster
Rep:
|
Thanks. My knowlage has once again increased with geeky stuff!
One more (maybe silly) question. How can the python programming language be used? eg. Games, Programs?
|
|
|
03-04-2006, 02:00 AM
|
#5
|
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298
Rep:
|
Quote:
Originally Posted by Mikesoft
Thanks. My knowlage has once again increased with geeky stuff!
One more (maybe silly) question. How can the python programming language be used? eg. Games, Programs?
|
It can be used for a lot of stuff including games, utilities and web development. Many Redhat and Ubuntu config tools are written in python. Its best to take a look at the info on the python website because it will answer many of your questions. 
|
|
|
03-04-2006, 06:34 AM
|
#6
|
Member
Registered: Jun 2005
Location: England, Cheam
Distribution: Fedora Core 6
Posts: 96
Original Poster
Rep:
|
Thanks again!
|
|
|
03-04-2006, 06:46 AM
|
#7
|
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337
Rep:
|
If you want to use python to write games, check this link out:
www.pygame.org
it's a wrap for sdl library and works great 
|
|
|
All times are GMT -5. The time now is 01:07 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|