python

Python matplotlib graph problem

import matplotlib import matplotlib.pyplot as plt import pylab as PL matplotlib.rcParams['axes.unicode_minus'] = False fig = plt.figure() ax = fig.add_subplot(111) PL.loglog(a, b,'o') ax.set_title('Graph Example') plt.show() 1) This displays the graph with points on the plot. Is there a way to join these points with a smooth curve. 2...

How can I create 1000 files that I can use to test a script?

I would like to create 1000+ text files with some text to test a script, how to create this much if text files at a go using shell script or Perl. Please could anyone help me. ...

Vim's Omnicompletion with Python just doesn't work.

I've searched around for an hour, both on Stack Overflow and elsewhere. Alas! Please help. Vim's omnicompletion just doesn't work. I have Vim 7.2 compiled with Python support. filetype plugin on is in my .vimrc. When a .py file is open, :echo &omnifunc prints pythoncomplete#Complete. I'm working with a large project and I have a tags f...

How to deploy highly iterative updates

I have a set of binary assets (swf files) each about 150Kb in size. I am developing them locally on my home computer and I want to periodically deploy them for review. My current strategy is: Copy the .swf's into a transfer directory that is also a hg (mercurial) repo. hg push the changes to my slicehost VPN ssh onto my slicehost VPN ...

Database password requested when running "manage.py test"

When I try to run manage.py test a database password prompt shows. Previously, tests would run without me having to enter the db password manaually. I just updated my database to postgres 8.4. I assume it's some setting I'm forgetting. How can I configure it to run tests without asking for the password? Additional Info: I create...

Error Handling in Python with SUDS

Hello, I have been trying to control a camera through a wsdl file using SUDS. I have got the code working but I want to place error handling into the script. I have tried different exceptions but am unable to get the script working. When I enter an invalid coordinate I get an error. The code I am using is below followed by the error I a...

Python: create graph based on degree correlation

I want to create a graph using networkx which has positive or negative degree correlation. Like a graph for a social network or citations in academic papers etc. Can you suggest some function for this? ...

When loading a dll in Python does the dir function shows its methods?

Does this code shows the methods from a dll? from ctypes import * x = cdll.LoadLibrary("olari.dll") dir(x) if not, how can we see the .dll methods in python? ...

Pylons Custom Middleware return 404

Hey all I have the following code as a middleware in an pylons application: import testing.model as model import re from pylons.controllers.util import abort class SubdomainCheckMiddleware(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): if 'subdomaincheck' in envir...

how-to apache 2.2 mod_fcgid set python path

Hello, i have trouble with seting the python path or any other enviroment variable for mod_fcgid (solaris 10, glassfish apache 2.2) I have it set in apache, but nothing in os.environ in the fcgi script: SetEnv PYTHONPATH "/opt/uusis/lib/python2.4/site-packages/:/usr/lib/python2.4/" And other stuff(for example ORACLE_HOME) and I need...

populating data from xml file to a sqlite database using python

Hi all, I have a question related to some guidances to solve a problem. I have with me an xml file, I have to populate it into a database system (whatever, it might be sqlite, mysql) using scripting language: Python. Does anyone have any idea on how to proceed? Which technologies I need to read further? Which environments I have to i...

How to read file headers in Python similar to C?

I am new to Python. I am a C programmer by profession. I have file, whose header has some specific data, that I need to extract. For example, Byte 0-5 has a magic, Byte 6-8 has offset etc. In C (An Example) : struct { int32_t payload_offset, int32_t len, char *magic, int32_t type int32_t header_size } file_hd...

Python : generate a graph for a social network

I have installed matplotlib and networkx packages. Can someone tell me the function present in these packages that can be used to generate a social network graph like graph for film actor collaborations, co-authorship or even a graph for a P2P network. ...

Windows file creation date/time using python

I need to get a file creation date&time using python. I tried: os.stat(r"path")[ST_CTIME] But it is returning: 1263538277 This is not the creation date time. Is there a way to do it? ...

Django Admin site TemplateSyntaxError at /admin/: name not defined

I have an issue where, when I log in to the Django admin site, I get a template syntax error in /Library/Python/2.6/site-packages/django/template/debug.py in render_node, line 81. I can't find out how to solve this as it is part of Django, I didn't write the code and I have no idea how it works. This did work fine up until a few days a...

specifying a list as a command line argument in python

I am using getopt to process a command line optional argument, which should accept a list. Something like this: foo.py --my_list=[1, 2, 3, 4,5] But this trims everything after "[1," My questions are: A) Is there a way to specify a list without converting it into a string? (using getopt) B) If I am to convert the list into a strin...

Is the new GIL in Python 3.2 sufficient to make the switch?

I was reading this page on the new GIL found/to be found in Python 3.2 and I was wondering if it is the "killer feature" that will trigger a transition from Python 2.x to 3.x. What do you guys think? ...

How can I determine if a python script is executed from crontab?

I would like to know how can I determine if a python script is executed from crontab? I don't want a solution that will require adding a parameter because I want to be able to detect this even from an imported module (not the main script). ...

Can I use `pip` instead of `easy_install` for `python setup.py install` dependency resolution?

python setup.py install will automatically install packages listed in requires=[] using easy_install. How do I get it to use pip instead? ...

Commit in git only if tests pass

I've recently started using git, and also begun unit testing (using Python's unittest module). I'd like to run my tests each time I commit, and only commit if they pass. I'm guessing I need to use pre-commit in /hooks, and I've managed to make it run the tests, but I can't seem to find a way to stop the commit if they tests fail. I'm ru...