Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 20th, 2005, 3:05 PM   #1
clanotheduck
Newbie
 
Join Date: Sep 2005
Posts: 6
Rep Power: 0 clanotheduck is on a distinguished road
Question Convert Python script to C++ code

Ok, I have been programming in C++ for a while, and I recently started learning Python because Blender uses it as its script language.

As I have been learning Python, I have been making silly little programs I would like to share with my firends, yet many of them do not have Python installed.

I've seen all of these things that say that they turn your Python scripts into .exe files. Yet none of them actually DO that, it always has some sort of confusing system that is rather anouying.

I have a C++ compiler that makes .exe files. And thats really all I want, a pure and simple .exe file.

So I was wondering if there was anyway to turn Python script into C++ code for me to compile into a .exe file. Perhaps some sort of program might do this.

If there is no way for that to happen, is there any simple way for a noob Python programmer to make a pure and simple .exe file?

If you want to know how noobish I am, I just finished learning the "while" and "if" statements... yeah.

Thanks to anyone who helps!

I'm farely sure this belongs in the Python forum.
clanotheduck is offline   Reply With Quote
Old Sep 20th, 2005, 3:10 PM   #2
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Converting a python file to a C++ file? Forget it.. python is high level, C++ is low level.. that's a huge difference.

the trick of creating an automatically running python file is including the interpretter and the python files in one file. There are probably lots of tool on the net for that.
Polyphemus_ is offline   Reply With Quote
Old Sep 20th, 2005, 3:16 PM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,472
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
That's the problem with Python, you have to distribute the interpreter with your code.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Sep 20th, 2005, 3:23 PM   #4
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
Quote:
Originally Posted by Polyphemus_
Converting a python file to a C++ file? Forget it.. python is high level, C++ is low level.. that's a huge difference.
That's the easiest type of conversion to do, from a high level language to a lower level. As opposed to making assembly, or binary, into C/C++, or dare i say it BASIC. I'm sure there is a way to write a program in C/C++ that could take the open source python interpreter and combine it with C++ resources so that instead of loading the source from a file it would already be loaded into the program. Has to be possible, just hasn't been done yet.
__________________

tempest is offline   Reply With Quote
Old Sep 20th, 2005, 3:30 PM   #5
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Quote:
Originally Posted by tempest
That's the easiest type of conversion to do, from a high level language to a lower level. As opposed to making assembly, or binary, into C/C++, or dare i say it BASIC.
i have to agree with you on that partly.. assembly to C/C++ is indeed far from easy - but with much effort it is possible. But take this example writtin in php:
<?php
$var = 3;
$var = "echo (\"5\" + \"10\");";
eval($var);
?>
Big man who can convert that into the same code in a low level language
Polyphemus_ is offline   Reply With Quote
Old Sep 20th, 2005, 3:35 PM   #6
clanotheduck
Newbie
 
Join Date: Sep 2005
Posts: 6
Rep Power: 0 clanotheduck is on a distinguished road
I was thinking there must be some way for it to happen, as usually the same actions are being done, just different syntax.
clanotheduck is offline   Reply With Quote
Old Sep 20th, 2005, 3:39 PM   #7
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
it all depends on the code you are using. The example i gave in the last post, is a quite unusual piece of code - i just wanted to make clear you can't convert everything back to low-level.
Polyphemus_ is offline   Reply With Quote
Old Sep 20th, 2005, 4:01 PM   #8
clanotheduck
Newbie
 
Join Date: Sep 2005
Posts: 6
Rep Power: 0 clanotheduck is on a distinguished road
I personaly have no freaking clue about anything in PHP so I don't know what the result of that would be, but I'm sure there would be some way to emulate that in a low level language.

I always thought that low level languages gave you more freedom then high level.
clanotheduck is offline   Reply With Quote
Old Sep 20th, 2005, 4:18 PM   #9
LegionZero
Newbie
 
LegionZero's Avatar
 
Join Date: Jul 2005
Location: Tijuana, B.C.
Posts: 19
Rep Power: 0 LegionZero is on a distinguished road
Send a message via MSN to LegionZero Send a message via Yahoo to LegionZero
Quote:
Originally Posted by clanotheduck
... is there any simple way for a noob Python programmer to make a pure and simple .exe file?
What you need to do is read and understand the distutils, it is a small setup file that tells python which modules you want to distribute, follow this link to learn more.
http://www.python.org/doc/current/dist/dist.html

Next what you want to do is get py2exe, I am noob to python also and I have found it to be usefull, go to this link http://starship.python.net/crew/theller/py2exe/ to get documentation and the py2exe modules. It does take a bit of reading but it isn't all that hard to use and implement.
__________________
War cannot be avoided until the physical cause
for its recurrence is removed and this, in the last analysis,
is the vast extent of the planet on which we live. ~ Nikola Tesla
LegionZero is offline   Reply With Quote
Old Sep 20th, 2005, 4:26 PM   #10
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Quote:
Originally Posted by clanotheduck
I always thought that low level languages gave you more freedom then high level.
again, it all depends on what kind of code you are writing.
Polyphemus_ is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:22 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC