ok thanks
On Mon, Mar 11, 2013 at 6:35 PM, Bill Freeman <ke1g...@gmail.com> wrote: > I wouldn't call that "compiling", but it is a step that many people take > in order to make it slightly more convenient to run. > > While "compiling" does happen, it is done automatically as a side effect > of running the program. > > You are apparently not on Windows, since you have a chmod command. > > You can always run the program using: > > python filename.py > > As the python interpreter reads filename.py, it is "compiled" into "byte > codes" which is actually what the python interpreter interprets. > > If the user running the program has permission to write the directory, > then, when a .py file is imported, the "compiled" byte codes are written to > a file with the same base name, but with the extension .pyc . Upon > subsequent runs, the import will notice that there is a .pyc file, and, so > long as the .pyc file is newer than any like named .py file (it is legit to > remove the .py file once there is a .pyc file), will read the "compiled" > byte codes from the .pyc file, rather than reading a re-parsing the .py > file. > > Note: this isn't done for the file mentioned on the command line. If you > want a .pyc file for it, start the python interpreter and type: > > import filename > > There are projects that attempt to convert python source to machine code. > They have limitations and require stylized coding, and are only used when > people need improved performance, but don't want to profile their code, > reorganize as necessary, and recode the hot spots in C (since the latter > will yield performance that is better yet), or to recode the entire app in > a truly compiled langage. See also some of what are effectively packaging > tools like py2exe. > > Back to chmod +x, that simply tells the operating system (and the shell) > that this is a file that is allowed t be executed. That's not actually > true of a python file, but another trick of the *nix world helps out: If > the first two bytes of a file are the ASCII codes for '#' and '!', then the > rest of the line (again ASCII) are taken as the absolute path of a program > to run instead, plus any flags and arguments to pass to it, and the path to > this file will be added as a last argument. A suitable first lines for .py > files would be: > > #!/usr/bin/python > > (assuming that /usr/bin/python is where python live on your system). The > OS sees the #! and actually runs: > > /usr/bin/python /path/to/your/filename.py > > Bill > > > > On Mon, Mar 11, 2013 at 8:15 AM, Harjot Mann <harjotmann1...@gmail.com>wrote: > >> anyone knows how to compile a python program??? >> im doing it as >> chmod +x filename.py >> ./filename.py??? >> Am i right??/ >> thanks in advance >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/django-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.