两个问题 [英] Two questions

查看:63
本文介绍了两个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我用其他几种语言开发并且最近发现了

Python并且我正在尝试使用它形状的PythonCard

应用程序开发工具。


我的两个问题:


1.什么是最简单的我用的风格创建一个for循环的方法
来自Delphi的
即:

我:= 0到2确实开始

//代码

结束;


2. Philospohy(sp?)除外,我可能想创建一个

我已完成的应用程序的二进制分发。我注意到关于.pyc文件的

文档:我如何创建这些文件,除了

基本上是只读的,它们就像普通的.py源一样使用

文件?它们是否可以轻松进行逆向工程?


谢谢,

- QS计算。

解决方案



2005年6月2日06:45:18 -0700, qs ********* @ gmail.com 说:



我用其他几种语言开发并且最近发现了Python,我正试图以PythonCard
应用程序开发工具的形式使用它。

我的两个问题:

对于我:= 0到2开始
//代码
结束;

我在范围内(0,2):

做的东西


范围( [start],stop,[step])函数生成一系列

数字,for循环迭代过来。


(你也可以使用xrange ()为一个更大的内存效率解决方案非常好b / b
范围)。

2.除了Philospohy(sp?)之外,我可能想要创建一个仅完成二进制分发的已完成的应用程序。我注意到.pyc文件的
文档:我如何创建这些文件,除了
基本上是只读的,它们是否像普通的.py源文件一样使用?它们是否可以轻松进行逆向工程?



要为Windows创建仅二进制分发版,可以使用py2exe。它的b $ b发行版文件可以很容易地进行逆向工程。


干杯,

Richard


qs*********@gmail.com 写道:< blockquote class =post_quotes>我已经开发了其他几种语言,最近发现了Python,我正试图以PythonCard
应用程序开发工具的形式使用它。 />
我的两个问题:

1.从Delphi使用的样式中创建for循环的最简单方法是什么,即:
对于I:= 0到2确实开始
//代码
结束;

$ x $ b for x in xrange(0,3):

#code


请阅读教程。我很确定这个以及更多的东西

你想知道的是否足够了。

2. Philospohy(sp?)除外,我可能想要创建一个仅完成二进制的已完成应用程序分发。我注意到.pyc文件的
文档:我如何创建这些文件,除了
基本上是只读的,它们是否像普通的.py源文件一样使用?它们可以很容易地进行逆向工程吗?




它们是.py文件的编译版本,所以绝对不一样。

他们导入.py

模块时会自动且透明地创建,所以通常你不会关注它们。他们可以很容易地进行逆向工程,如果用你的意思转回

源代码。参见decompyle和decompyle。例如。使用compileall

模块,你可以手动编译.py到.pyc,但是,再次,这通常不需要
。如果您不想分发源代码,通常建议使用像py2exe这样的工具包装

和distibution,尽管现有工具很少包装比包装更多

档案中的.pyc文件,捆绑运行时库,并添加包装代码,使

执行透明。


哲学不完全放在一边,你应该注意到任何

语言中的目标代码都可以轻松地以相同的方式进行逆向工程,

唯一的区别在于所涉及的轻松程度。如果代码值得给某人他们愿意冒着违反许可证的风险,那么他们*将*能够恢复足够的源代码(无论是否是

Python,C或汇编)来做他们需要的事情。唯一可靠的保护是将有价值的代码保存在服务器上并使用某种

Web服务(或其他)来控制对其执行的访问。 (这里有很多* b $ b已经过多次讨论所有这些在论坛中了 - 这是一个非常累的话题,现在已经很累了所以请随时仔细阅读档案

通过谷歌小组再次提出很多相同的问题。

你会帮自己一个忙。)


-Peter


qs ***** **** @gmail.com 写道:



我已经用其他几种语言开发并且最近发现了Python我正试图以PythonCard
应用程序开发工具的形式使用它。

我的两个问题:

1.最简单的方法是什么用Delphi创建一个for循环的for循环,即:
for I:= 0到2 do begin
// code
end;


嗯,假设这循环数字0到2并将它们分配给变量I,然后在代码中用I做一些事情。分配了
,等价的python是:

我在范围内的
(0,3):

/ / code


(打开for循环后注意空格?)

然后打破缩进以完成for循环。那你就是下一个

一段代码(不管你有什么结果;)会去这里:


//更多代码。

2.除了Philospohy(sp?)之外,我可能想要创建一个仅完成二进制的已完成应用程序的分发。我注意到.pyc文件的
文档:我如何创建这些文件,除了
基本上是只读的,它们是否像普通的.py源文件一样使用?他们可以轻松进行逆向工程吗?


只要您对该目录有写入权限,即.py文件

所在,当您运行python时,它将生成.pyc文件为你

它们被加载。

在主发行版中还有一个名为

py_compile.py的实用程序脚本。 br />
例如编译.py文件的整个目录:


python /path/to/main/install/py_compile.py * .py


和将它们编译为优化的二进制文件(.pyo):

python -O /path/to/main/install/py_compile.py * .py


它们像普通的.py源文件一样使用。 (Python实际上是从.py文件构建的.pyc文件中执行
。)

它们可以进行逆向工程,但Java / C ++ / Assembler也是如此。有一些关于能够分发

你的modules.pyc作为zipfile的内容,请看看
a:我记得能够

通过将它们作为密码的zip文件来做一些额外的保护。

谢谢,
- QS Computing。




欢迎。


Joal


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;

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?

Thanks,
- QS Computing.

解决方案


On 2 Jun 2005 06:45:18 -0700, qs*********@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

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?


To create binary only distributions for Windows you can use py2exe. Its
distributions files can be fairly easily reverse engineered.

Cheers,
Richard


qs*********@gmail.com 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


qs*********@gmail.com wrote:

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;
Um, assuming that this loops through the numbers 0 to 2 and assigns them
to the variable I, and then does something in code with I after it''s
been assigned, the python equivalent is:

for I in range(0,3):
//code

(Note the whitespace after opening the for loop?)
And then break the indenting to finish the for loop. So you''re next
piece of code (Whatever you had after end;) would go here:

//morecode.
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?
As long as you have write access to the directory that you''re .py files
are in, when you run python, it will generate the .pyc files for you as
they are loaded.
There is also a utility script in the main distribution called
py_compile.py.
E.g. compiling a whole directory of .py files:

python /path/to/main/install/py_compile.py *.py

And to compile them as optimised binary files (.pyo):
python -O /path/to/main/install/py_compile.py *.py

They are used like ordinary .py source files. (Python actually executes
from the .pyc files it builds from your .py files.)
They can be reverse-engineered, but then so can Java/C++/Assembler. Have
a look through the group for something about being able to distribute
your modules.pyc as a zipfile - I remember something about being able to
do a -tiny- bit of extra protection by having them as a passworded zip file.
Thanks,
- QS Computing.



Welcome.

Joal


这篇关于两个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆