I'm working on a graphical model project with python using NetworkX. NetworkX provides simple and good functionality using dictionaries:
import networkx as nx
G = nx.DiGraph() # a directed graph
G.add_edge('a', 'b')
print G['a'] # prints {'b': {}}
print G['b'] # prints {}
I want to use directed graphs because I am coding dependencies ...
I just installed matplotlib and am trying to run one of there example scripts. However I run into the error detailed below. What am I doing wrong?
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z, 16, ...
I've been searching on this but can't seem to find an exact answer (most get into more complicated things like multithreading, etc), I just want to do something like a Try, Except statement where if the process doesn't finish within X number of seconds it will throw an exception.
EDIT: The reason for this is that I am using a website te...
I am having trouble managing cache keys in my project.
Currently we use a define-at-wish strategy and uniqueness of keys are not guaranteed.
Every time some one want to cache a kind of object, a constant is defined in the module in a form like this:
BOOK_NOTE_KEY = "BKNT%d"
An BookNote object's cache key is like BOOK_NOTE_KEY % note...
Sorry, I know this is probably a duplicate but having searched for 'python regular expression match between' I haven't found anything that answers my question!
The document (which to make clear, is a long HTML page) I'm searching has a whole bunch of strings in it (inside a JavaScript function) that look like this:
link: '/Hidden/Side...
I m using shutil.copy from python to copy a list of files. But when i copy the files to /usr/lib/ location, i m getting permission denied as i need to be an administrator to do that.
So How could i copy files with admin permission or
how could i get the admin password from the user to copy the files?
Ideas would be appreciated
...
i implemented an internal intranet system recently that uses mysql as a dbms and python as the main programming language . i was thinking about deploying it over apache , but my fried came to me this morning and advised me to use MySQL server community.
this system will be handling the assets of a maximum 500 user daily ( we are talki...
I'm using MySQLdb and run into the following problem:
STMT="""INSERT INTO test_table VALUES (%s, %s, %s, %s, %s)"""
rows=[('Wed Apr 14 14:00:00 2010', 23L, -2.3, 4.41, 0.83923)]
conn.cursor().executemay(STMT, rows)
results in:
Traceback (most recent call last):
File "run.py", line 122, in <module>
File "C:\Python25\lib\site-pack...
Hello there
I'm building a high performance webapp, it needs
a) good team scaling i.e. new team member needs to be able to quickly get started
b) good app scaling, so the request load can grow
I was thinking between RoR and ruby + postgres vs Python and some framework;
I would like to avoid windows server administration and also I had...
As a Python developer using mostly Django, I've grown accustomed to have a built-in test server for my projects, which spares me from setting up Apache for every single project I'm working on my local development machine. Is there something similar for PHP which let's me say "serve this directory as PHP project on localhost:8080"?
I'm n...
Hi,
I am using Flask (based on Werkzeug) which uses Python.
So the user can download a file, I'm using the send_from_directory function: http://flask.pocoo.org/docs/api/?highlight=send_from_directory#flask.send_from_directory
However when actually downloading the file, the HTTP header content-length is not set. So the user has no idea...
For a customer I have to install a django webserver on SUSE Linux Enterprise Server 11, 64 bit (short: SLES 11).
When I add repositories from http://software.opensuse.org I can install python-lxml:
sudo zypper install python-lxml
The result is that the site-packages are installed in /usr/lib/python2.6/site-packages. However when I tr...
What is the fastes way of determening which point q out of n points in 2D space is the closest (smallest euclidian distance) to point p, see attached imgage.
My current method of doing this in Python is storing all the distances in a list and then running
numpy.argmin(list_of_distances)
This is however a bit slow when calculating ...
I was reading a description of a project on Github that is a Python-based content delivery network.
Why is it important that it uses a "reverse caching proxy" - and what does that mean in this context?
...
There is the URL of page on the Internet. I need to get a screenshot of this page (no matter in which browser).
I need a script (PHP, Python (even Django framework)) that receives the URL (string) and output screenshot-file at the exit (file gif, png, jpg).
UPD:
I need dynamically create a page where opposite to URL will be placed sc...
here is some code:
>>> p = re.compile(r'\S+ (\[CC\] )+\S+')
>>> s1 = 'always look [CC] on the bright side'
>>> s2 = 'always look [CC] [CC] on the bright side'
>>> s3 = 'always look [CC] on the [CC] bright side'
>>> m1 = p.search(s1)
>>> m1.group()
'look [CC] on'
>>> p.findall(s1)
['[CC] ']
>>> itr = p.finditer(s1)
>>> for i in itr:
... ...
Quick background: we have a large source base written in Python. It is a compiler for a domain specific language, and internally everything is represented as directed graphs. These digraphs are built up from sets, and so we use the builtin set type in Python.
The problem is that we didn't originally realise that Python actively uses the...
Hello there,
first off, im new to python and pyqt so please bear with me.
Im using a QTableView with a QSqlTableModel everything works as intended.
The last column of the view contains only 0 and 1 as value which i want to display as checkbox and this column should be editable.
Ive read that you should subclass QItemDelegate which i d...
When running Pip with a requirements.txt file which has fixed versions, we get the following error (or similar):
VersionConflict: (solrpy 0.9.1
(.../lib/python2.6/site-packages/solrpy-0.9.1-py2.6.egg),
Requirement.parse('solrpy==0.9.3'))
because the version conflicts. Using pip install -U -r requirements.txt fixes this, but it al...
The question arose when answering to another SO question (there).
When I iterate several times over a python set (without changing it between calls), can I assume it will always return elements in the same order? And if not, what is the rationale of changing the order ? Is it deterministic, or random? Or implementation defined?
And whe...