python-2.6

Installing MySQLdb for Django on Mac OS X 10.6 Snow Leopard with MAMP

这一生的挚爱 提交于 2019-12-04 11:14:53
So I know this is not a new topic, but its one that nobody has seemed to be able to solve, at least not for Python 2.6 / Snow Leopard. (The Leopard fixes I've found aren't applicable to Snow Leopard.) Situation: I'm trying to get Django installed locally on my Mac OS X Snow Leopard laptop. (10.6.7) I have Python 2.6.1, which is what came preinstalled with Snow Leopard, MySQL-python 1.2.3, and MAMP 1.9.6. All are latest current versions. Without making any changes to the MySQLdb package, if I run python setup.py build I get hundreds or more errors, the first of which are: $ python setup.py

Problem with loading win32file.pyd on python 2.6

a 夏天 提交于 2019-12-04 09:32:34
问题 I can't make py2exe to pack correctly even a simple script that uses win32file I'm constantly getting the following error message: Traceback (most recent call last): File "dependency_checker.py", line 1, in <module> File "win32file.pyc", line 12, in <module> File "win32file.pyc", line 10, in __load ImportError: DLL load failed: The specified procedure could not be found. The script looks as follows: import win32file print "Hello world!" And here is the setup.py: from distutils.core import

undefined symbol: clapack_sgesv

落花浮王杯 提交于 2019-12-04 03:47:19
问题 I have this little code: from numpy import * from scipy import signal, misc import matplotlib.pyplot as plt path="~/pics/" band_1 = misc.imread(path + "foo.tif"); H = array((1/2.0, 1/4.0, 1/2.0)); signal.convolve2d(band_1.flatten(), H) plt.figure() plt.imshow(band_1) plt.show() then I execute this code python foo.py and it throws this error: Traceback (most recent call last): File "foo.py", line 2, in <module> from scipy import signal File "/usr/lib/python2.6/site-packages/scipy/signal/__init

Python efficiency: lists vs. tuples

℡╲_俬逩灬. 提交于 2019-12-04 03:38:05
I have a medium-amount of base objects. These base objects will be put in collections, and these collections will be munged around: sorted, truncated, etc. Unfortunately, the n is large enough that memory consumption is slightly worrisome, and speed is getting concerning. My understanding is that tuples are slightly more memory-efficient, since they are deduplicated. Anyway, I would like to know what the cpu/memory tradeoffs of lists vs. tuples are in Python 2.6/2.7. If you have a tuple and a list with the same elements, the tuple takes less space. Since tuples are immutable, you can't sort

Determine season given timestamp in Python using datetime

青春壹個敷衍的年華 提交于 2019-12-04 03:24:28
问题 I'd like to extract only the month and day from a timestamp using the datetime module (not time) and then determine if it falls within a given season (fall, summer, winter, spring) based on the fixed dates of the solstices and equinoxes. For instance, if the date falls between March 21 and June 20, it is spring. Regardless of the year. I want it to just look at the month and day and ignore the year in this calculation. I've been running into trouble using this because the month is not being

How to set up a resource shared by several unit tests?

痴心易碎 提交于 2019-12-04 02:55:31
In Python, how can I have one setup (which may contain expensive function calls) for a whole set of unit tests? Example: import unittest class Test1(unittest.TestCase): def setUp(self): print "expensive call" def test1(self): self.assertEqual(1, 1) def test2(self): self.assertEqual(1, 1) if __name__ == "__main__": unittest.main() Will run the expensive call twice: $ python unittest.py expensive call .expensive call . ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK How can I change it so the expensive call is made only once and its resources

How do I access an Oracle db without installing Oracle's client and cx_Oracle?

三世轮回 提交于 2019-12-04 01:38:09
I have two RHEL servers running Python 2.4 and 2.6 separately. There is an Oracle database on the other server I need to access. I was trying to install cx_oracle on my RHEL server but found out that the Oracle client must be installed first. The problem is, I don’t have permission to install Oracle's client on both RHEL servers. On the same servers, a Perl program can connect to the Oracle db using: DBI->connect("dbi:Oracle:host=myhost.prod.com;sid=prddb",'username','password') Can Python do the same without installing cx_oracle and the Oracle client? Or are there any suggestions about how to

Python 2.6.1 : expected path separator ([)

点点圈 提交于 2019-12-04 00:45:55
I am getting a path separator error in python 2.6.1. I have not found this issue with python 2.7.2 version, but unfortunately I need this in 2.6.1 only. Is there any another way to achieve the same? :( my code :- import xml.etree.ElementTree as ET #version 1.2.6 import sys class usersDetail(object): def __init__(self, users=None): self.doc = ET.parse("test.xml") self.root = self.doc.getroot() def final_xml(self,username): r = self.root.find("user[@username='user1']") #not working in 2.6.1 :( self.root.remove(r) print r tree = ET.ElementTree(self.root) tree.write("msl.xml") if __name__ == '_

ElementTree's iter() equivalent in Python2.6

本小妞迷上赌 提交于 2019-12-03 23:43:41
问题 I have this code with ElementTree that works well with Python 2.7. I needed to get all the nodes with the name "A" under "X/Y" node. from xml.etree.ElementTree import ElementTree verboseNode = topNode.find("X/Y") nodes = list(verboseNode.iter("A")) However, when I tried to run it with Python 2.6, I got this error. ionCalculateSkewConstraint.py", line 303, in getNodesWithAttribute nodes = list(startNode.iter(nodeName)) AttributeError: _ElementInterface instance has no attribute 'iter' It looks

Why did Python 2.6 add a global next() function?

自闭症网瘾萝莉.ら 提交于 2019-12-03 18:01:16
问题 I noticed that Python2.6 added a next() to it's list of global functions. next(iterator[, default]) Retrieve the next item from the iterator by calling its next() method. If default is given, it is returned if the iterator is exhausted, otherwise StopIteration is raised. What was the motivation for adding this? What can you do with next(iterator) that you can't do with iterator.next() and an except clause to handle the StopIteration? 回答1: It's just for consistency with functions like len() .