LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-01-2007, 05:49 AM   #1
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: The Tropics
Distribution: Slackware & Derivatives
Posts: 2,472
Blog Entries: 1

Rep: Reputation: 128Reputation: 128
Does Python 2.4 compile?


If I write a program in Python, can it compile?
 
Old 03-01-2007, 08:08 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
you just run your script using the Python interpreter
Code:
/usr/bin/python yourscript.py
 
Old 03-01-2007, 08:24 AM   #3
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
I believe you can compile a python script. Don't really know the particulars, though.
 
Old 03-01-2007, 02:40 PM   #4
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
Basically, no.
 
Old 03-01-2007, 03:04 PM   #5
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Quote:
Originally Posted by uselpa
Basically, no.
You can compile python programs into c type files. Unfortunately I don't know how to do this, so can't be of much help.
 
Old 03-01-2007, 03:22 PM   #6
rshaw
Senior Member
 
Registered: Apr 2001
Location: Perry, Iowa
Distribution: Mepis , Debian
Posts: 2,692

Rep: Reputation: 45
http://www.python.org/ftp/python/wpy/freeze.txt

not sure why you would bother though.

Last edited by rshaw; 03-01-2007 at 03:23 PM.
 
Old 03-01-2007, 03:31 PM   #7
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Define "Compile"

Technically, every time you run a Python program, it's compiled into bytecodes which are then interpreted by the virtual machine. When modules are called from scripts, they are oftentimes compiled and then their bytecodes are written to .pyc files for fast loading later on. Googling turns up a page about this straight away. The idea is similar to byte-compiling Lisp code. Perl works this way as well, it's just that Perl doesn't write its bytecodes to files (by default).

But you're probably thinking more along the lines of native binary compilation?
 
Old 03-01-2007, 04:45 PM   #8
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: The Tropics
Distribution: Slackware & Derivatives
Posts: 2,472

Original Poster
Blog Entries: 1

Rep: Reputation: 128Reputation: 128
OK-but I want to write programs that I can open later. I have had some (as in very little) experience with C++ and know HTML pretty well. (I know HTML isn't really a programming language but I thought I'd throw it in...)
 
Old 03-01-2007, 04:56 PM   #9
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Oh, you mean as opposed to typing them into the REPL? (In other words, the interactive prompt?) Yes, just type your program into a file (use a .py extension) and then run `python name-of-file` to run the program. Or, alternatively, at the start of the file write "#!/usr/bin/env python" and make the file executable with `chmod +x name-of-file` and run it like any other command from the shell (not available in Windows). You'll probably have to put the directory in front of it, like so: `./name-of-file`
 
Old 03-01-2007, 05:30 PM   #10
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: The Tropics
Distribution: Slackware & Derivatives
Posts: 2,472

Original Poster
Blog Entries: 1

Rep: Reputation: 128Reputation: 128
What is Ruby like? And is KDevelop: Ruby the actual program in which to create it?
 
Old 03-01-2007, 08:54 PM   #11
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Ruby is a fantastical programming language. To sum up its virtues in one word: abstraction. I'd say, the best way to decide if you like it is to give it a shot.

And by the way, decent programming languages are not tied to IDEs -- if you want to write Ruby in KDevelop, go ahead. I use Emacs for editing everything and then run stuff from the shell (or actually, from Emacs' shell mode, but they're still standalone commands). You can really learn a lot about how stuff works by doing things from the CLI instead of relying on IDE magick.
 
Old 03-01-2007, 09:02 PM   #12
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: The Tropics
Distribution: Slackware & Derivatives
Posts: 2,472

Original Poster
Blog Entries: 1

Rep: Reputation: 128Reputation: 128
Where can I get a tutorial on it?
 
Old 03-02-2007, 12:48 AM   #13
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
Quote:
Originally Posted by reddazz
You can compile python programs into c type files. Unfortunately I don't know how to do this, so can't be of much help.
I suppose you talk about Shed Skin.

There are various attempts at compiling Python to machine code, but they are either incomplete, or they package the interpreter with the Python program in one way or another.

That's why I say basically, No.
AFAIK, the same goes for Ruby.
 
Old 03-02-2007, 03:10 AM   #14
billiejoex
Member
 
Registered: Oct 2005
Posts: 31

Rep: Reputation: 15
You can use py2exe on Windows and PyInstaller on Linux.
Both programs 'compiles' python scripts into 'stand alone executables'.
 
Old 03-02-2007, 04:43 AM   #15
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
Quote:
Originally Posted by billiejoex
You can use py2exe on Windows and PyInstaller on Linux.
Both programs 'compiles' python scripts into 'stand alone executables'.
True, but then again if you use that on more than one program you end up installing multiple partial copies of the Python interpreter. Doesn't make any sense IMHO.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i compile in ubuntu python? phantom_cyph Programming 10 02-16-2007 10:28 PM
How do u compile python? sduffy89 Programming 3 02-26-2006 10:18 PM
trying to compile Python Lung-Dart Linux - Newbie 1 10-27-2004 09:46 AM
compile python progs abs Programming 13 04-05-2004 09:05 PM
compile Python in Linux? pandasuit Programming 2 12-13-2003 05:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration