Howdy, codeboys and codegirls!
I have came across a simple problem with seemingly easy solution. But being a Python neophyte I feel that there is a better approach somewhere.
Say you have a list of mixed strings. There are two basic types of strings in the sack - ones with "=" in them (a=potato) and ones without (Lady Jane). What you n...
If you had switched from php + (framework of choice) to python + (framework of choice) as your development platform, what would you say have been the upsides/gains of the switch?
What I want to know is if there were any significant improvements in the following aspects:
Speed of development
Maintainability of the finished solutions
...
I try to avoid "global" statements in python and http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python suggests this is a common view. Values go into a function through its arguments and come out through its return statement (or reading/writing files or exceptions or probably something else I'm forgetting)....
I have a 2 processes:
the first process is manager.py starts in backgroung:
from multiprocessing.managers import SyncManager, BaseProxy
from CompositeDict import *
class CompositeDictProxy(BaseProxy):
_exposed_ = ('addChild', 'setName')
def addChild(self, child):
return self._callmethod('addChild', [child])
def ...
First of all, the problem is that program fails with double memory freeing ...
The deal is:
I have
FooCPlusPlus *obj;
and I pass it to my script. It works fine. Like this:
PyObject *pArgs, *pValue;
pArgs = Py_BuildValue("((O))", obj);
pValue = PyObject_CallObject(pFunc, pArgs);
where pFunc is a python function...
So, my script ha...
hi, I'm trying to make a small mac flood tool in python to fill my switches cam tables but i cant make the magic happen? can you see what im doing wrong?
from scapy.all import *
while 1:
dest_mac = RandMAC()
src_mac = RandMAC()
sendp(Ether(src=src_mac, dst=dest_mac)/ARP(op=2, psrc="0.0.0.0", hwsrc=src_mac, hwdst=dest_mac)/Padding...
I would like to write a small script that does the following (and that I can then run using my crontab):
Look into a directory that contains directories whose names are in some date format, e.g. 30-10-09.
Convert the directory name to the date it represents (of course, I could put this information as a string into a file in these direc...
Hello!
How to add strings to the axes in Axes3D instead of numbers?
I just started using the matplotlib. I have used Axes3dD to plot similar to the example given on their website (http://matplotlib.sourceforge.net/examples/mplot3d/bars3d%5Fdemo.html). Note that one must use the last verson (matplotlib 0.99.1), otherwise the axis gets a...
Hi,
I am getting an error in the following code. The Error message is "Error: Inconsistent indentation detected!"
s=[30,40,50]
a=[5e6,6e6,7e6,8e6,8.5e6,9e6,10e6,12e6]
p=[0.0,0.002,0.004,0.006,0.008,0.01,0.015,0.05,0.1,0.15,0.2]
j=0
b=0
x=0
for j in s:
h=s[j]
print "here is the first loop" +h
for b in a:
c=a[b] ...
Is it possible to extract type of object or class name from message received on a udp socket in python using metaclasses/reflection ?
The scenario is like this:
Receive udp buffer on a socket.
The UDP buffer is a serialized binary string(a message). But the type of message is not known at this time. So can't de-serialize into appropri...
Thanks to this answer I managed to come up with a temporary solution to my problem.
However, with a list of 6000 points that grows everyday it's becoming slower and slower.
I can't use a third party service* therefore I need to come up with my own solution.
Here are my requirements:
Clustering of the coordinates need
to work with ...
Hi,
besides from using a completely integrated IDE with debugger for python (like with Eclipse), is there any little tool for achieving this:
when running a program, i want to be able to hook somewhere into it (similar to inserting a print statement) and call a window with an object inspector (a tree view)
after closing the window, t...
Hi all,
I face a problem in scipy 'leastsq' optimisation routine, if i execute the following program it says
raise errors[info][1], errors[info][0]
TypeError: Improper input parameters.
and sometimes index out of range for an array...
from scipy import *
import numpy
from scipy import optimize
from numpy import asarray
from math...
Hi all,
I started on a little toy project in C lately and have been scratching my head over the best way to mimic the strip() functionality that is part of the python string objects.
Reading around for fscanf or sscanf says that the string is processed upto the first whitespace that is encountered.
fgets doesn't help either as I still...
What are good python libraries for the following needs:
MVC
Domain Abstraction
Database Abstraction
Video library (just to create thumbnails)
I already know that SQLAlchemy is really good for Database Abstraction so don't bother with it unless you want to suggest a better one.
Edit: This might seem stupid to mention but I'm talk...
I have a very simple model:
class Artist(models.Model):
name = models.CharField(max_length=64, unique=False)
band = models.CharField(max_length=64, unique=False)
instrument = models.CharField(max_length=64, unique=False)
def __unicode__ (self):
return self.name
that I'm using as a model form:
from django.forms import ModelForm...
Perl habits die hard. Variable declaration, scoping, global/local is different between the 2 languages. Is there a set of recommended python language idioms that will render the transition from perl coding to python coding less painful.
Subtle variable misspelling can waste an extraordinary amount of time.
I understand the variable de...
I have seen conflicting advice on whether the following code is better
def function():
ret_val = 0
if some_condition():
ret_val = 2
else:
ret_val = 3
return ret_val
or whether this is better:
def function():
if some_condition():
return 2
else:
return 3
This is a simple example...
I extended django.utils.feedgenerator.Atom1Feed for my own needs and am trying to write some tests for it. It works fine from runserver and mod_wsgi.
Basically, when feeds are accessed from the testrunner I'm running into these problems:
1) The item_title() and item_description() methods are never called, but item_pubdate(), item_link(...
How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (or the interactive shell)?
...