Seems like there should be a method in networkx to export the json graph format, but I don't see it. I imagine this should be easy to do with nx.to_dict_of_dicts(), but would require a bit of manipulation. Anyone know of a simple and elegant solution?
...
I'm running the Google App Engine devserver 1.3.3 on Windows 7.
Usually, this method works fine, but this time it gave an error:
def _deleteType(type):
results = type.all().fetch(1000)
while results:
db.delete(results)
results = type.all().fetch(1000)
The error:
File "src\modelutils.py", line 38, in _delete...
The documentation for xlrd here
http://www.python-excel.org/
mentions that it is now possible in latest version, but does not say how.
...
Hey Guys,
I want to migrate my system from Active Python 2.4 to Python 2.6.5. However I face some problem in parsing XML files. The I/O is very slow.
My sample xml file
<config><dicts><dictName>EnvDict</dictName><dictElems><key>AppServerIP</key> <value>localhost</value><key>DBServerIP</key> <value>localhost</value><key>DBServerName...
What is the best way to escape a string for safe usage as a command-line argument? I know that using subprocess.Popen takes care of this using list2cmdline(), but that doesn't seem to work correctly for paramiko. Example:
from subprocess import Popen
Popen(['touch', 'foo;uptime']).wait()
This creates a file named literally foo;uptime,...
I'm parsing a string that doesn't have a delimiter but does have specific indexes where fields start and stop. Here's my list comprehension to generate a list from the string:
field_breaks = [(0,2), (2,10), (10,13), (13, 21), (21, 32), (32, 43), (43, 51), (51, 54), (54, 55), (55, 57), (57, 61), (61, 63), (63, 113), (113, 163), (163, 213...
I am trying to install Python 2.6.5 on my web server running Debian 4.3.2.1-1. I unpacked the tarball, ran "./configure --prefix /usr/", then ran "make". I saw this message.
Failed to find the necessary bits to build these modules:
_bsddb _hashlib _ssl
_tkinter bsddb185 bz2 ...
I have a huge grammar developed for pyparsing as part of a large, pure python application.
I have reached the limit of performance tweaking and I'm at the point where the diminishing returns make me start to look elsewhere. Yes, I think I know most of the tips and tricks and I've profiled my grammar and my application to dust.
What next...
can anyone recommend a resource (book,tutorial,etc.) that focuses on application development in python? something similar to Practical Django Projects, but for stand alone applications instead of web apps (for now).
...
I'm looking for an answer that scales, but for my specific purpose, I have a 48th dimension vector. This could be represented as an array of 48 integers all between 0 and 255.
I have a large dictionary of these vectors, approximately 25 thousand of them.
I need to be able to take a vector that may or may not be in my database, and qui...
Hi everybody,
I am implementing a python application that will connect to our different servers and computers. They all have different logins and passwords. I want to store all these information in the app directly and ask for one master login/password only. How can I store all these sensitive data in the application so that someone who...
I've got a script that downloads and then converts videos. I'm trying to do all of the downloads at once(a lot of wgets) and then when they're done, convert them. Right now I have to wait while each file downloads individually and then convert when done. I want all the download requests to run concurrently.
Here's the part in my 'downlo...
I've read through the documentation on threading for python and as I've pereceived it the following should hold true:
You can access (read) any PoD or python specific object (such as an array) without causing failure in a multi-threaded program trying the same thing at the same time, but you can not change them and accept thread integrit...
Here is the code, in python:
# function for pentagonal numbers
def pent (n): return int((0.5*n)*((3*n)-1))
# function for generalized pentagonal numbers
def gen_pent (n): return pent(int(((-1)**(n+1))*(round((n+1)/2))))
# array for storing partitions - first ten already stored
partitions = [1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42]
#...
Hello, how can I handle post request in python script? Somewhere I want to send it from ajax to the python script with given params. What's correct way to handle that data in python?
...
I do know that cherrypy is a multithreaded and also has a threadpool implementation.
So I wanted to try an example showing multithreaded behaviour.
Now lets say I've my some function in the root class and rest all things are configured
def testPage(self, *args, **kwargs):
current = threading.currentThread()
print 'Starting ' , c...
Hello,
I'm new to web development using python. I've good amount of experience in building dynamic websites using PHP. Also, I've never used MVC on PHP. For the first time I'm using MVC (or MTV to be more correct). I'm following
One thing different from PHP world is that. URLs doesn't point to files but to functions. This single point...
I'm trying to open a .pcap file in python. can anyone help with this? each time I try this, it gives an error message that "IOError: [Errno 2] No such file or directory: 'test.pcap'"
import dpkt
f = open('test.pcap')
pcap = dpkt.pcap.Reader(f)
...
I have a generator that yields nodes from a Directed Acyclic Graph (DAG), depth first:
def depth_first_search(self):
yield self, 0 # root
for child in self.get_child_nodes():
for node, depth in child.depth_first_search():
yield node, depth+1
I can iterate over the nodes like this
for node, depth in graph.d...
Dear all,
I need to store a binary file with a 12 byte header composed of 4 fields. They are namely: sSamples (4-bytes integer), sSampPeriod (4-bytes integer), sSampSize (2-bytes integer), and finally sParmKind (2-bytes integer).
I'm using 'struct' to my variables to the desired fields. Now that I have them defined separately, how could...