关于Python的问题 [英] Question about Python

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

问题描述

大家好,


我最近开始使用Python,我必须说我喜欢它。

语言和库都可用。


背景:我编写了一个用于跟踪的应用程序

我的个人经济我是用Java编写的,因为我想学习我大学编程课程的

语言。现在我已经获得了Python的interrest,我正在考虑将我的程序移植到Python上。



然后呢发生在我身上..我开始用Java编写我的程序

pre-1.5。然后来了1.5,我升级了,我的程序仍然会编译

然后运行,虽然我确实得到了三个警告。语言改变了一点点b $ b;我必须为三个数组分配一个类型。那并不是那么糟糕。


但是,当我查看各种Python模块/库时,我看到

它们有多个版本,对于不同版本的

python。我已经看过for python 1.5中的所有内容。最多为for python

2.4中间有所有版本。这让我有点害怕。我假设

不同版本的原因是因为新语言

功能?


Python显示出任何迹象"稳定" ;? (是的,我知道对于一种不断发展的语言来说,有一些优点。)是否曾经有一段时间新的主要版本的python并不意味着获得新版本的模块?

对于我的经济计划,我使用DB2作为数据库后端。我可以确定将始终存在DB2 API for Java。但是,我已经找到了一个用于Python的DB2模块,但是我甚至不知道它是否适用于Python 2.4,并且如果我编译并使用它,据我所知,我不能确定它会在下一个python版本中运行



我想问一下经验丰富的Python开发人员:

- 您是否适合升级到最新版本的Python,或者

您是否担心在现有程序中需要修复的内容?

- 抛开对Python的任何无条件的爱,并坚持:

诚实:你有没有碰到版本相关的问题?

- 你有没有依赖在一个模块上,为一些新的
重要功能升级了python版本,但是意识到你所依赖的模块还没有更新吗?如果没有,你是否考虑过这种可能性?

- 一般来说,模块开发人员是否跟上了python的开发版本,因此你可以期待新发现更新模块为

python的新版本出现在街头?

- 当你开始使用Python时,你有类似的担忧吗?


老实说..我现在发现任何潜在的问题比现在更好,而不是六个月内对它们的咆哮。


提前感谢愿意回答的任何人。

Hello all,

I recently started using Python, and I must say I like it. Both the
language and libraries available for it.

Background: I have written an application which I use to keep track
of my personal economy. I wrote it in Java because I wanted to learn the
language for a course in programming at my university. Now that I have
acquired an interrest in Python I was thinking about porting my program
to Python.

But then it occured to me.. I started writing my program in Java
pre-1.5. Then came 1.5, I upgraded, and my program would still compile
and run, though I did get three warnings. The language had changed a
little bit; I had to assign a type to three arrays. That wasn''t so bad.

However, when I look at the various Python modules/libraries, I see
that there are several versions of them, for different versions of
python. I''ve seen everything from "for python 1.5" up to "for python
2.4" with all versions in between. This scares me a little bit. I assume
that the reason for the different versions is because of new language
features?

Is Python showing any signs of "stabilizing"? (Yes, I know there are
pros to an evolving language). Will there ever be a time when a new
major version of python won''t mean getting new versions of the modules?
For my economy program, I used DB2 as a database backend. I can be
reasonable sure that there will always be a DB2 API for Java. However, I
have found a DB2 module for Python, but I don''t even know if it works
with Python 2.4, and if I compile and use it, I can''t be sure it''ll work
with the next python release, as far as I can tell.
I''d like to ask seasoned Python developers:
- Are you comfortable in upgrading to the latest version of Python, or
are you worried about what you have to fix in your existing programs?
- Put aside any unconditional love for Python for a second, and be
honest: Have you ever run into version related problems?
- Have you ever relied on a module, upgraded python version for some new
important feature, but realized that the module you rely on hasn''t been
updated yet? If not, do you consider a possibility?
- Do the module developers, in general, keep up with the development
versions of python, so you can expect to find newly updated modules as
new versions of python hits the streets?
- Did you have similar worries to mine when you started working with Python?

Please be honest.. It''s better that I find out any potential problems
now, than rant about them in six months.

Thanks in advance to anyone willing to answer.

推荐答案

Jan Danielsson写道:
Jan Danielsson wrote:
然后它发生在我身上。我开始用Java编写我的程序
1.5之前的版本。然后来了1.5,我升级了,我的程序仍然会编译并运行,尽管我确实得到了三个警告。语言已经改变了一点点;我必须为三个数组分配一个类型。这并不是那么糟糕。

但是,当我查看各种Python模块/库时,我看到
它们有多个版本,对于不同版本的
python。我已经看过for python 1.5中的所有内容。最多为for python
2.4中间有所有版本。这让我有点害怕。我假设
不同版本的原因是因为新语言的功能?
But then it occured to me.. I started writing my program in Java
pre-1.5. Then came 1.5, I upgraded, and my program would still compile
and run, though I did get three warnings. The language had changed a
little bit; I had to assign a type to three arrays. That wasn''t so bad.

However, when I look at the various Python modules/libraries, I see
that there are several versions of them, for different versions of
python. I''ve seen everything from "for python 1.5" up to "for python
2.4" with all versions in between. This scares me a little bit. I assume
that the reason for the different versions is because of new language
features?




Python通常是向后兼容的


*纯Python模块在与较新版本一起使用时将保持不变.GB
(因此它几乎总是:对于Python 1.5及更高版本)。您可能会获得一些弃用警告,这些警告会在每次运行时显示一个(比较

到Java,它们仅在编译时出现)。但它们可以被禁用。


*用C语言编写的Python扩展模块大多可以使用新的头文件从

源代码重新编译,并且也可以正常工作/>

*二进制扩展通常不适用于较新的Python,这就是为什么

您经常会看到特定模块的多次下载。在Unix上,二进制

兼容性很好地达到2.2(意思是我可以使用模块

用1.5编译为1.5),但这只是巧合而我<
将来不会依赖它。


摘要:如果你能够自己编译所有需要的扩展,

然后新的Python版本并不是真正的问题。


Daniel



Python is generally backwards compatible

* pure Python modules will work unchanged when used with a newer version
of Python (so it''s almost always: for Python 1.5 and later). You might
get some deprecation warnings and these appear one every run (compared
to Java, where they appear only when compiling). But they can be disabled.

* Python extension modules written in C can mostly be recompiled from
source with the new headers and will work as well

* binary extensions generally won''t work with newer Python, that''s why
you often see several downloads for a specific module. On Unix, binary
compatibility worked pretty well up to 2.2 (Meaning I could use modules
compiled for 1.5 with Python 2.2), but that was just a coincidence and I
wouldn''t rely on it for future versions.

Summary: If you are able to compile all your needed extensions yourself,
then new Python versions aren''t really a problem.

Daniel


向后兼容性在几个Python增强中得到解决

提案(PEP):

http://www.python.org/peps/pep-0005.html
http://www.python.org/peps/pep-0236.html
http://www.python.org/peps/pep-0004.html
http://www.python.org/peps/pep-0291.html


您也可以查看clpy中的相关主题,例如
http:// tinyurl .com / d3lfx


HTH,

乔治

Backwards compatibility is addressed in several Python Enhancement
Proposals (PEPs):

http://www.python.org/peps/pep-0005.html
http://www.python.org/peps/pep-0236.html
http://www.python.org/peps/pep-0004.html
http://www.python.org/peps/pep-0291.html

You also may want to check related threads in c.l.py, e.g.
http://tinyurl.com/d3lfx.

HTH,
George


Jan Danielsson写道:
Jan Danielsson wrote:
但是,当我查看各种Python模块/库时,我看到
它们有多个版本,用于不同版本的
python。我已经看过for python 1.5中的所有内容。最多为for python
2.4中间有所有版本。这让我有点害怕。我假设
不同版本的原因是因为新语言的功能?
However, when I look at the various Python modules/libraries, I see
that there are several versions of them, for different versions of
python. I''ve seen everything from "for python 1.5" up to "for python
2.4" with all versions in between. This scares me a little bit. I assume
that the reason for the different versions is because of new language
features?




请注意,尽管Python试图兼容在

源级别,二进制级别的兼容性仅保证在次要修订级别(次级版本中的第三个数字
$ b $) b数。)


因此当大多数库具有for Python 1.5时和for Python 2.4

下载,这些通常用于预编译的二进制文件* *。如果您下载并编译源本身,则相同的文件可以在列出的所有

版本的Python上运行。无论好坏,Python都希望你能够访问源代码


但请注意,该程序利用了

更新版本的Python不会在旧版本上运行(显然),即使在源代码级别也是
。但是,它们通常会运行在任何较新的

版本上,除非作者利用了一个bug,或者做了一些不正常的事情,比如重新分配无。因此,当一个Python程序说Python

2.1 required时,通常意味着需要Python 2.1或更高版本。


无论如何,所有旧版本的Python仍然可以使用,并且

可能是为了可以预见的未来,而且多个(主要)版本可以在
的Python中相互愉快地共存机器,所以如果

你需要使用旧版本,你可以。



Please be aware that although Python tries to be compatible at the
source level, compatibility at the binary level is only guaranteed at
the minor revision level (the third number in the dotted triple version
number.)

So when most libraries have "for Python 1.5" and "for Python 2.4"
downloads, those are usually for precompiled binaries *only*. If you
download and compile the source itself, the same files can run on all
versions of Python listed. For good or bad, Python expects you to have
access to the source code

Note however, that programs taking advantage of features introduced in a
more recent version of Python won''t run on older versions (obviously),
even at the source level. They will, however, usually run on any newer
version, unless the author took advantage of a bug, or did something
perverse, like reassigning None. So when a Python program says "Python
2.1 required", that usually means "Python 2.1 or later required".

At any rate, all older versions of Python are still availible, and
probably will be for the forseable future, and multiple (major) versions
of Python can coexist happily with each other on the same machine, so if
you need to use an older version, you can.


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

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