class SortedDict(dict):
def __init__(self, data=None):
if data is None:
data = {}
super(SortedDict, self).__init__(data)
and
class SortedDict(dict):
def __init__(self, data={}):
dict(data)
I think they are same.
...
Hi,
I am trying to generate a 3d histogram using python.. i tried the following code but i am getting an error too many values to unpack.
from matplotlib import pyplot
import pylab
from mpl_toolkits.mplot3d import Axes3D
import numpy
fig = pylab.figure()
ax = Axes3D(fig)
data_filename = 'C:\csvfiles\luxury.txt'
data_file = numpy...
i need a python script to run open vpn automaticaly
but i use sudo for run the open vpn
sudo openvpn --cd /etc/openvpn --config openvpn.conf &
thats my terminal command. i have to give the password for sudo, can i use pexpect to run that command?
and i have to get the exit code because i want to know that the openvpn is run succesful...
Here's my code, I'm looking for a way to count the images in the pdfs while I extract the text.
import pyPdf
import os
import csv
class UnicodeWriter:
"""
A CSV writer which will write rows to CSV file "f",
which is encoded in the given encoding.
"""
def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwd...
Hi
I've setup a post commit script found at http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook to associate changesets with tickets
When I try to commit, I get the following error
'post-commit' hook failed with error output:
File "/var/www/svn/repo/hooks/trac-post-commit-hook", line 101
(options, args) = par...
class SortedDict(dict):
def __new__(cls, *args, **kwargs):
instance = super(SortedDict, cls).__new__(cls, *args, **kwargs)
instance.keyOrder = []
return instance
def __setitem__(self, key, value):
super(SortedDict, self).__setitem__(key, value)#@1
if key not in self.keyO...
I'm using Boost Python library to create python extensions to my C++ code. I'd like to be able to invoke from python the 'greet' function from the C++ code shown below:
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(hello_ext)
{
using namespa...
Is there a good python module to convert .xls file to PDF?
...
Is there a way to dynamically update the name of regex groups in Python?
For example, if the text is:
person 1: name1
person 2: name2
person 3: name3
...
person N: nameN
How would you name groups 'person1', 'person2', 'person3', ..., and 'personN' without knowing beforehand how many people there are?
...
I know this is a borderline case whether it really belongs to stackoverflow or superuser, but as it seems there are quite a few 'editing code' questions over here, I am posting it on SO.
I have a pile of XML files that someone in their infinite wisdom have decided to explode to a multiple files using the tags, which in result makes deb...
Hi all,
I have objects A witch has many to many relation ship to object b.
Is it possible to save objects A with it's B collection in a bulk ' I mean not to save B objects one by one then add them to A.
for b in b_objects :
A.b_objs.add(b)
A.save()
Thanks
...
I have to use a custom build python libraries inside PHP and is considering using PiP. Any other recomendations?
...
I wrote the following code trying to figure out how to instantiate the subclasses within the main class.. I came up with something that doesn't feel right.. at least for me.
Is there something wrong with this type of instancing? Is there a better way to call subclasses?
class Family():
def __init__(self):
self.Father = self.Fat...
Hi All
I would like to use python webbrowser to access a secure https page and save it into a file.
Am I right if I say that with webbrowser control is not possible to save an entire web page but only opening a URL? I didn't see any 'save' method.
Other than this, the page I want to use is a secure http page and I don't know how to aut...
my code(i was unable to use 'pickle'):
class A(object):
def __getstate__(self):
print 'www'
return 'sss'
def __setstate__(self,d):
print 'aaaa'
import pickle
a = A()
s = pickle.dumps(a)
e = pickle.loads(s)
print s,e
print :
www
aaaa
ccopy_reg
_reconstructor
p0
(c__main__
A
p1
c__builtin__
object
p2
Nt...
Hello,
I am trying to obtain a variable from a different file type and import it into a Python script. The file is version.mk, it has a variable called VARIABLE_ID. The import module does not work as normally, is there any way to call variables from other file types?
Thanks for any help
import os
from version import VERSION_ID
def v...
Hi, I'm trying to bundle some egg dependencies when using py2exe and as stated on the py2exe site, it doesn't work with those and I need to unzip them first. I've tried to first run easy_install -m lxml and then easy_install --always-unzip lxml==2.2.2, but it didn't work. Then I tried to set the unzipping behaviour to default by putting ...
I have a CSV file that looks like this:
"Company, Inc.",,,,,,,,,,,,10/30/09
A/R Summary Aged Analysis Report,,,,,,,,,,,,10:35:01
All Clients,,,,,,,,,,,,USER
Client Account,Customer Name,15-Jan,16 - 30,31 - 60,61 - 90,91 - 120,120 - Over,Total,Status,Credit Limit
1000001111,CLIENT A,0,0,"3,711.32",0,0,"18,629.64","22,340.96",COD,"20,000...
The // "integer division" operator of Python surprised me, today:
>>> math.floor(11/1.1)
10.0
>>> 11//1.1
9.0
The documentation reads "(floored) quotient of x and y". So, why is math.floor(11/1.1) equal to 10, but 11//1.1 equal to 9?
...
i am currently using php as backend language in webdevelopment. but im wondering what you need to install to get running with python and java.
with php i need apache and mysql.
can i use those for java and python too?
i cant find good guides equivalent to LAMP/MAMP/WAMP so i understand the parts when using either java or python. would...