python-2.5

Pydev and *.pyc Files

谁说我不能喝 提交于 2019-12-19 06:23:52
问题 I am using Eclipse 4.2.1 with the pydev Plugin (version 2.7.1) for python development. It seems that pydev has problems with precompiled python files (*.pyc files). I am using a package which is only provided with such precompiled files. When importing a module, pydev shows "unresolved import" error. And also tool tips are not provided for such precompiled modules. But the code can be executed without any errors. Is there any way to "teach" pydev, how to deal with *.pyc files? 回答1: It seems

Pydev and *.pyc Files

强颜欢笑 提交于 2019-12-19 06:22:54
问题 I am using Eclipse 4.2.1 with the pydev Plugin (version 2.7.1) for python development. It seems that pydev has problems with precompiled python files (*.pyc files). I am using a package which is only provided with such precompiled files. When importing a module, pydev shows "unresolved import" error. And also tool tips are not provided for such precompiled modules. But the code can be executed without any errors. Is there any way to "teach" pydev, how to deal with *.pyc files? 回答1: It seems

How to check if a string contains only characters from a given set in python

ε祈祈猫儿з 提交于 2019-12-18 16:32:49
问题 I have a a user-inputted polynomial and I only want to use it if it only has characters in the string 1234567890^-+x . How can I check if it does or not without using external packages? I only want to use built-in Python 2.5 functions. I am writing a program that runs on any Mac without needing external packages. 回答1: Here are some odd ;-) ways to do it: good = set('1234567890^-+x') if set(input_string) <= good: # it's good else: # it's bad or if input_string.strip('1234567890^-+x'): # it's

Access to errno from Python?

允我心安 提交于 2019-12-18 11:45:13
问题 I am stuck with a fairly complex Python module that does not return useful error codes (it actually fails disturbingly silently). However, the underlying C library it calls sets errno. Normally errno comes in over OSError attributes, but since I don't have an exception, I can't get at it. Using ctypes, libc.errno doesn't work because errno is a macro in GNU libc. Python 2.6 has some affordances but Debian still uses Python 2.5. Inserting a C module into my pure Python program just to read

How to install Python ssl module on Windows?

戏子无情 提交于 2019-12-17 21:54:40
问题 The Google App Engine Launcher tells me: WARNING appengine_rpc.py:399 ssl module not found. Without the ssl module, the identity of the remote host cannot be verified, and connections may NOT be secure. To fix this, please install the ssl module from http://pypi.python.org/pypi/ssl . I downloaded the package and it contained a setup.py file. I ran: python setup.py install and then: Python was built with Visual Studio 2003; blablabla use MinGW32 Then I installed MinGW32 and now the compilation

What does from __future__ import absolute_import actually do?

岁酱吖の 提交于 2019-12-17 17:19:31
问题 I have answered a question regarding absolute imports in Python, which I thought I understood based on reading the Python 2.5 changelog and accompanying PEP. However, upon installing Python 2.5 and attempting to craft an example of properly using from __future__ import absolute_import , I realize things are not so clear. Straight from the changelog linked above, this statement accurately summarized my understanding of the absolute import change: Let's say you have a package directory like

NameError from Python input() function [duplicate]

橙三吉。 提交于 2019-12-17 06:53:41
问题 This question already has answers here : error in python d not defined. [duplicate] (3 answers) Closed 5 years ago . input_var = input ("Press 'E' and 'Enter' to Exit: ") NameError: name 'e' is not defined I am using Python 2.5. How I can overcome this error? 回答1: input reads and evaluates a Python expression. When it tries to evaluate it, it looks for a variable e , which is not defined, and fails. You almost always want to use raw_input instead. (And in Python3, input has this behaviour.)

How to: Macports select python

こ雲淡風輕ζ 提交于 2019-12-17 05:48:30
问题 When I enter: port select --list python This is the result: Available versions for python: none python25 (active) python25-apple python26-apple python27 python27-apple I thought when I use python I would be using version 2.5 . Instead when I enter "python", version 2.7 seems to be active. How do I change that to version 2.5? Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or

How to support different handlers for incoming GAE e-mails?

ⅰ亾dé卋堺 提交于 2019-12-13 16:24:09
问题 In accordance with GAE docs, several handlers could be support for incoming e-mails. I would like to support two: string@appid.appspotmail.com should go to Handler1; string+something@appid.appspotmail.com should go to Handler2; Looks like I should have something like: - url: /_ah/mail/<???>your_app_id\.appspotmail\.com script: handler2.app login: admin - url: /_ah/mail/.+ script: handler1.app login: admin How the regex (?) should look like to route messages sent to e-mail with plus sign to

string of kwargs to kwargs

ε祈祈猫儿з 提交于 2019-12-13 13:26:29
问题 I have a string like s = "title='bah' name='john and jill' purple='haze' none=None i=1" I am looking for a pythonic way of putting that into a dictionary (and a solution that does not choke on extra white spaces)? Suggestions ? 回答1: >>> from ast import literal_eval >>> s = "title='bah' name='john' purple='haze' none=None i=1" >>> dict((k, literal_eval(v)) for k, v in (pair.split('=') for pair in s.split())) {'purple': 'haze', 'i': 1, 'none': None, 'name': 'john', 'title': 'bah'} (This won't