python-2.5

cx_Oracle: distutils.errors.DistutilsSetupError: cannot locate Oracle include files

孤者浪人 提交于 2019-12-03 09:53:35
I need install cx_Oracle for Python 2.5 on Linux (Linux 2.6.18-371.1.2.el5 i686). I have installed Oracle client 10.2.0.4. I have tried following: 1. Download cx_Oracle tar.gz from http://sourceforge.net/projects/cx-oracle/files/ . I don't know which of listed version are suitable for python 2.5 and Oracle client 10.2.0.4, so try cx_Oracle-5.1.tar.gz. Unpacked tar, go to unpacked folder and run python setup.py install. I got error: Traceback (most recent call last): File "setup.py", line 187, in <module> raise DistutilsSetupError("cannot locate Oracle include files") distutils.errors

How can I list the methods in a Python 2.5 module?

我是研究僧i 提交于 2019-12-03 09:12:43
问题 I'm trying to use a Python library written in C that has no documentation of any kind. I want to use introspection to at least see what methods and classes are in the modules. Does somebody have a function or library I can use to list the functions (with argument lists) and classes (with methods and member variables) within a module? I found this article about Python introspection, but I'm pretty sure it doesn't apply to Python 2.5. Thanks for the help. 回答1: Here are some things you can do at

Merge nested dictionaries, by nested keys?

拈花ヽ惹草 提交于 2019-12-03 07:36:50
I have several dictionaries with different and common keys, plus different and common keys in the nested dictionary. Below is a simplified example, the actual dictionaries have thousands of keys. {1:{"Title":"Chrome","Author":"Google","URL":"http://"}} {1:{"Title":"Chrome","Author":"Google","Version":"7.0.577.0"}} {2:{"Title":"Python","Version":"2.5"}} Which I'd like to merge into a single dictionary. {1:{"Title":"Chrome","Author":"Google","URL":"http://","Version":"7.0.577.0"}, 2:{"Title":"Python","Version":"2.5"}} I can iterate over both dictionaries, compare keys and update the nested

How can I list the methods in a Python 2.5 module?

余生颓废 提交于 2019-12-02 22:03:44
I'm trying to use a Python library written in C that has no documentation of any kind. I want to use introspection to at least see what methods and classes are in the modules. Does somebody have a function or library I can use to list the functions (with argument lists) and classes (with methods and member variables) within a module? I found this article about Python introspection, but I'm pretty sure it doesn't apply to Python 2.5. Thanks for the help. Here are some things you can do at least: import module print dir(module) # Find functions of interest. # For each function of interest: help

Python 2.5: ElementTree and UML in XML

跟風遠走 提交于 2019-12-02 07:40:35
问题 I'm working with an XML file which represent an UML model. Here is an example of what it is: <?xml version="1.0" encoding="utf-8"?> <XMI xmi.version="1.1" xmlns:UML="omg.org/UML13"> <XMI.content> <UML:Model name="Model" xmi.id="_0"> <UML:Namespace.ownedElement> <UML:Package name="Standard" xmi.id="_5"> </UML:Package> </UML:Namespace.ownedElement> </UML:Model> </XMI.content> </XMI> It is a Rhapsody import format. I want to modify this XML file by using ElementTree in Python 2.5. I have at

Python 2.5: ElementTree and UML in XML

 ̄綄美尐妖づ 提交于 2019-12-02 05:14:12
I'm working with an XML file which represent an UML model. Here is an example of what it is: <?xml version="1.0" encoding="utf-8"?> <XMI xmi.version="1.1" xmlns:UML="omg.org/UML13"> <XMI.content> <UML:Model name="Model" xmi.id="_0"> <UML:Namespace.ownedElement> <UML:Package name="Standard" xmi.id="_5"> </UML:Package> </UML:Namespace.ownedElement> </UML:Model> </XMI.content> </XMI> It is a Rhapsody import format. I want to modify this XML file by using ElementTree in Python 2.5. I have at least one problem but I found 2 consequences, here they are: With this simple code: import xml.etree

Can I get a reference to the 'owner' class during the __init__ method of a descriptor?

烈酒焚心 提交于 2019-12-02 04:44:42
Is it possible to access the 'owner' class inside a descriptor during the __init__ function of that descriptor, without passing it in manually as in this example? class FooDescriptor(object): def __init__(self, owner): #do things to owner here setattr(owner, 'bar_attribute', 'bar_value') class BarClass(object): foo_attribute = FooDescriptor(owner=BarClass) One way to do something like that is with a metaclass. Just make sure it's really what you want, and don't just copy blindly if you don't understand how it works. class Descriptor(object): pass class Meta(type): def __new__(cls, name, bases,

Python dictionary creation error

99封情书 提交于 2019-12-01 17:58:57
I am trying to create a Python dictionary from a stored list. This first method works >>> myList = [] >>> myList.append('Prop1') >>> myList.append('Prop2') >>> myDict = dict([myList]) However, the following method does not work >>> myList2 = ['Prop1','Prop2','Prop3','Prop4'] >>> myDict2 = dict([myList2]) ValueError: dictionary update sequence element #0 has length 3; 2 is required So I am wondering why the first method using append works but the second method doesn't work? Is there a difference between myList and myList2 ? Edit Checked again myList2 actually has more than two elements. Updated

Class decorators in Python 2.5?

ぐ巨炮叔叔 提交于 2019-12-01 17:48:27
问题 Is there a way I can make class decorators work on Google App Engine , which is limited to Python 2.5 ? Or let me rephrase that: is it possible to alter the behavior of Python's parser from the same process that it is already executing? Example: good.py: alter_python_parser() import bad bad.py: @decorated class Foo(object): pass Or is this maybe just plainly impossible. Explanation: I want to use a third party library that heavily uses class decorators, and don't want to fork it and maintain

Class decorators in Python 2.5?

China☆狼群 提交于 2019-12-01 17:47:43
Is there a way I can make class decorators work on Google App Engine , which is limited to Python 2.5 ? Or let me rephrase that: is it possible to alter the behavior of Python's parser from the same process that it is already executing? Example: good.py: alter_python_parser() import bad bad.py: @decorated class Foo(object): pass Or is this maybe just plainly impossible. Explanation: I want to use a third party library that heavily uses class decorators, and don't want to fork it and maintain my own version. An alternative would be to run my code on Typhoon App Engine with a newer python, but I