python-2.6

Change windows user password with python

我只是一个虾纸丫 提交于 2019-12-24 14:13:01
问题 I am looking for a way to change the windows password throgh a python script. somthing like a win32api that can help me? Thanks! 回答1: You can do this with the Win32 function NetUserChangePassword. From Python you can access that with win32net.NetUserChangePassword. Although as the documentation points out this won't work if you are using active directory. But in that case you are surely not in a position to change user passwords programmatically. 来源: https://stackoverflow.com/questions

Python asynchronous processing in existing loop

天涯浪子 提交于 2019-12-24 06:45:26
问题 I'm creating a module for OpenERP in which I have to launch an ongoing process. OpenERP runs in a continuous loop. My process has to be launched when I click on a button, and it has to keep running without holding up OpenERP's execution. To simplify it, I have this code: #!/usr/bin/python import multiprocessing import time def f(name): while True: try: print 'hello', name time.sleep(1) except KeyboardInterrupt: return if __name__ == "__main__": count = 0 while True: count += 1 print "Pass %d"

error importing numpy

删除回忆录丶 提交于 2019-12-24 01:26:07
问题 I have strange error, when I try to import numpy: Traceback (most recent call last): File "/home/timo/malltul/mafet/src/mafet/core/pattern.py", line 7, in <module> import numpy as np File "/usr/lib/python2.6/dist-packages/numpy/__init__.py", line 147, in <module> import ma File "/usr/lib/python2.6/dist-packages/numpy/ma/__init__.py", line 44, in <module> import core File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 4850, in <module> all = _frommethod('all') File "/usr/lib/python2

How do I escape colons in an attribute name with Python's ElementTree?

£可爱£侵袭症+ 提交于 2019-12-23 15:26:37
问题 Background I am using ElementTree in Python version 2.6 to create an XML file (using data retrieved from a database). Code The following line of code is the problem area, as I keep getting a syntax error because of the colons within my attribute names. # Please ignore any errors the "^" characters would cause if they were # actually part of my code - just using them as placeholders. root = ET.Element("databaseConfiguration", xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance", ^ xsi

Installing Numpy and Scipy - Can't find system python 2.6

霸气de小男生 提交于 2019-12-23 11:56:11
问题 I"m trying to install numpy and scipy for a data analysis class I have this semester. I'm trying to install it from the package on sourceforge.net, but as I follow the wizard I can't select my HD. There is a message saying numpy.1.5.1 requires System Python 2.6. I know it is there as when I type $ python version 2.6.1 comes up. I've done a bit of snooping under the hood and it looks like python 2.6 is under usr/bin where as python3 is in usr/local/bin . I'm a bit new with the terminal so I'm

Check maxlen of deque in python 2.6

痞子三分冷 提交于 2019-12-23 09:55:56
问题 I have had to change from python 2.7 to 2.6. I've been using a deque with the maxlen property and have been checking what the maxlen is. Apparently you can use maxlen in python 2.6, but in 2.6 deques do not have a maxlen attribute. What is the cleanest way to check what the maxlen of a deque is in python 2.6? In 2.7: from collections import deque d = deque(maxlen = 10) print d.maxlen In 2.6 the deque can be used and the maxlen works properly, but maxlen is not an attribute that can be

Fastest way to merge n-dictionaries and add values on 2.6 [duplicate]

ⅰ亾dé卋堺 提交于 2019-12-23 07:36:41
问题 This question already has answers here : Is there any pythonic way to combine two dicts (adding values for keys that appear in both)? (18 answers) Python: Elegantly merge dictionaries with sum() of values [duplicate] (4 answers) Closed 6 years ago . I have a list of dictionaries that I would like to combine into one dictionary and add the values from each dictionary in the list. For example: ds = [{1: 1, 2: 0, 3: 0}, {1: 2, 2: 1, 3: 0}, {1: 3, 2: 2, 3: 1, 4: 5}] The final results should be a

Urllib2 runs fine if i run the program independently but throws error when i add it to a cronjob

人走茶凉 提交于 2019-12-23 01:28:17
问题 url = "www.someurl.com" request = urllib2.Request(url,header={"User-agent" : "Mozilla/5.0"}) contentString = urllib2.url(request).read() contentFile = StringIO.StringIO(contentString) for i in range(0,2): html = contentFile.readline() print html The above code runs fine from commandline but if i add it to a cron job it throws the following error: File "/usr/lib64/python2.6/urllib2.py", line 409, in _open '_open', req) File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain result =

Python 2.6 ImportError: No module named argparse

大兔子大兔子 提交于 2019-12-22 08:34:15
问题 I'm trying to run git-cola from Red Hat Enterprise Linux Server release 6.5 and receive: Traceback (most recent call last): File "....../bin/git-cola", line 24, in <module> from argparse import ArgumentParser ImportError: No module named argparse I think I have all of the required packages installed: * git-1.7.1-3.el6_4.1.x86_64 * python-2.6.6-51.el6.x86_64 * PyQt4.x86_64 0:4.6.2-9.el6 * /usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg I read in other blogs that there may be a

Python efficiency: lists vs. tuples

我们两清 提交于 2019-12-21 10:41:31
问题 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. 回答1: If you have a tuple