Re: Two questions



qscomputing@xxxxxxxxx wrote:
I've developed in several other languages and have recently found
Python and I'm trying to use it in the shape of the PythonCard
application development tool.

My two questions:

1. What is the easiest way to create a for loop in the style I'm used
to from Delphi ie:
for I:=0 to 2 do begin
  //code
end;

for i in xrange(0, 3): # code

Please read the tutorial. I'm fairly sure this and many more things you'll want to know are covered adequately.

2. Philospohy(sp?) aside, I could potentially want to create a
binary-only distribution of my finished apps. I noticed the
documentation on .pyc files: how do I create these and, aside from
being basically read-only, are they used just like ordinary .py source
files? And can they be easily reverse-engineered?

They are compiled versions of the .py files, so definitely not the same. They are created automatically and transparently when you import .py modules, so normally you don't pay any attention to them. They can easily be reverse-engineered, if by that you mean turned back into source code. See "decompyle" for example. Using the "compileall" module you can manually compile .py to .pyc but, again, that's generally not needed. Use of tools like py2exe is generally advised for packaging and distibution if you don't want to distribute source, though few of the existing tools do much more than package up .pyc files inside archives, bundle the runtime library, and add wrapper code to make the execution transparent.


Philosophy not entirely aside, you should note that object code in any language can "easily" be reverse-engineered in the same way, with the only difference being the degree of ease involved. If the code is worth enough to someone that they are willing to risk violating your license terms, they *will* be able to recover enough source code (whether it was Python, C, or assembly) to do what they need. The only certain protection is to keep the valuable code on a server and use some kind of web service (or whatever) to control access to its execution. (There have been *many* past discussions of all this in the forum -- it's a very tired topic by now -- so please feel free to peruse the archives via Google Groups before asking lots of the same questions over again. You'll be doing yourself a favour.)

-Peter
.



Relevant Pages

  • Re: program deployment
    ... computers, the .pyc files ?? ... I now that with the "-m compileall ." ... So i suppose that if Python has to run a .pyc file, ... Python code is normally deployed as straight source code. ...
    (comp.lang.python)
  • Why the file mode of .pyc files has x?
    ... It is strange that the file mode of .pyc files are changed to ... have the follow python, which is compiled from source code by me. ...
    (comp.lang.python)
  • Re: Python un-plugging the Interpreter
    ... Python is a compiled language. ... It's compiled from source code to byte code. ... That's what the .pyc files are. ...
    (comp.lang.python)
  • Re: noob question: "TypeError" wrong number of args
    ... better understanding of Python's object model. ... def method: ... Python source code and outputs the same source code with only one change: ...
    (comp.lang.python)
  • Re: Python bytecode compatibility between interpreter versions
    ... Note that I specifically mentioned .pyc files vs. java class files, ... not Java the language/environment/platform vs. Python. ... > your platform. ... Perhaps one day .pyc files can work in such a manner. ...
    (comp.lang.python)