I have a problem with a durable client on ActiveMQ. I am using stomp.py in Python.
conn.start()
conn.connect(wait=True, header = {'client-id': 'myhostname' })
conn.subscribe(
'/topic/testTopic', ack='auto',
headers = {
'activemq.subscriptionName': 'myhostname',
'selector': "cli...
Is there a way to convert a given Python abstract syntax tree (AST) to a source code?
Here is a good example of how to use Python's ast module, specifically a NodeTransformer. I was looking for a way to convert the resulting AST back to source, so the changes can be inspected visually.
...
What is a good book for python for someone already familiar with programming. I know C# very well and looking to learn a new language and picked python to learn. The books that I have looked at assume the reader has no programming experience or knowledge. What python book assumes some programming knowledge
...
I've recently updated to celery 2.0 and I'm trying to use the new (to me) decorators for periodic tasks:
@periodic_task(run_every=timedelta(days=1))
def some_task(**kwargs):
#task here
I also have some other code is my site that lists periodic tasks and how often they run using
from celery.registry import tasks
to get the list ...
I am trying to name what I think is a new idea for a higher-order function. To the important part, here is the code in Python and Haskell to demonstrate the concept, which will be explained afterward.
Python:
>>> def pleat(f, l):
return map(lambda t: f(*t), zip(l, l[1:]))
>>> pleat(operator.add, [0, 1, 2, 3])
[1, 3, 5]
Haskell...
I'm working on making my first Python C extension, which defines a few functions and custom types. The strange thing is that the custom types are working, but not the regular functions. The top-level MyModule.c file looks like this:
static PyMethodDef MyModule_methods[] = {
{"doStuff", MyModule_doStuff, METH_VARARGS, ""},
{NUL...
An statistical accumulator allows one to perform incremental calculations. For instance, for computing the arithmetic mean of a stream of numbers given at arbitrary times one could make an object which keeps track of the current number of items given, n and their sum, sum. When one requests the mean, the object simply returns sum/n.
An ...
I have to open a file-like object in python (it's a serial connection through /dev/) and then close it. This is done several times in several methods of my class. How I WAS doing it was opening the file in the constructor, and then closing it in the destructor. I'm getting weird errors though and I think it has to do with the garbage col...
I have a package with two modules in it. One is the __init__ file, and the other is a separate part of the package. If I try from mypackage import separatepart, the code in the __init__ module is run, which will run unneeded code, slowing down the importing by a lot. The code in separate part won't cause any errors, and so users should b...
I am trying to read the description from the meta tag and this is what I used
soup.findAll(name="description")
but it does not work, however, the code below works just fine
soup.findAll(align="center")
How do I read the description from the meta tag in the head of a document?
...
when i try to use cron to execute my python script in a future time,i found there is a command at,AFAIK,the cron is for periodly execute,but what my scenario is only execute for once in specificed time.
and my question is how to add python script to at command,
also it there some python package for control the at command
my dev os is ub...
I've been searching on this but can't seem to figure out how I can delete a specific cookie using Google Apps Engine, Python version. I am setting the cookie like below and I need to update its value, I figure I may not be able to update and just need to delete and re-create but can't seem to find the way to do that, I am creating it as ...
I have all objects which get looked up to provide interpreter with both parents objects and object subobjects. I hope to do this without recursion for zope not appreciating this conventional recursion.
I set the view context as root object for recursion to start attaching object on then iterate across this filtered list of intid/objects...
Hello. I am adding a feature to my current project that will allow network admins to install the software to the network. I need to code a DNS server in Python that will allow me to redirect to a certain page if the request address is in my list. I was able to write the server, just not sure how to redirect.
Thank you. I am using Python...
what can i do to print the url on the browser http://localhost:5001/index.php?s=yd
...
Given:
x = ['a','b','c','d','e']
y = ['1','2','3']
I'd like iterate resulting in:
a, 1
b, 2
c, 3
d, 1
e, 2
a, 3
b, 1
... where the two iterables cycle independently until a given count.
Python's cycle(iterable) can do this w/ 1 iterable. Functions such as map and itertools.izip_longest can take a function to handle None, but do n...
Ok I have an application I am coding and am trying to get a layout simpler to this:
Notice how the text is left justified and the input boxes are all aligned, I see this in the wxPython demo code, but they all use the flexgrid sizer and I am trying to only use BoxSizers (due to them being simpler and because I only understand a little ...
I have a nested function where I am trying to access variables assigned in the parent scope. From the first line of the next() function I can see that path, and nodes_done are assigned as expected. distance, current, and probability_left have no value and are causing a NameError to be thrown.
What am I doing wrong here? How can I acce...
Hi I have an application that works fine when I type the url from the browser. it works something like http://mysite/service?id=1234, if I type that on the browser it works fine, however we have another service that accepts parameters from a mobile phone, this service would then call the same url, and post the parameter onto it.
I know...
I am learning Perl at my work and enjoying it. I usually do my work in Python but boss wants Perl.
Most of the concepts in Python and Perl match nicely: Python dictionary=Perl hash; Python tuple=Perl list; Python list=Perl array; etc.
Question: Is there a Perl version of the Python form of an Iterator / Generator?
An example: A Cla...