Two questions

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Thu Jun 2 10:52:58 EDT 2005


Richard Lewis wrote:
> On 2 Jun 2005 06:45:18 -0700, qscomputing at gmail.com said:
>> Hi,
>> 
>> 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 range(0, 2):
>     do stuff

Eh, no. range(0, 3) would be correct, since the Python range function
generates a list from start to stop-1.

> The range([start], stop, [step]) function generates a sequence of
> numbers which the the for loop iterates over.
> 
> (You can also use xrange() for a more memory efficient solution for very
> large ranges).
>
>> 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 a binary representation of bytecode, just like in Java. They can be
reverse-engineered more easily than machine code, but it still is no no-brainer.
Btw, they are created automatically...

Reinhold



More information about the Python-list mailing list