Following is the error that occurs in this part of the code. Although the path is valid, a RuntimeError occursstrange. What is happening, and how can I get this to work?
for root,dirs,files in os.walk(self.path):
for f in files :
if (f.split('.')[1] == "mb"):
z = utils.executeInMainTh...
I would like to be able to get the name of a variable as a string but I don't know if Python has that much introspection capabilities. Something like:
>>> print(my_var.__name__)
'my_var'
I want to do that because I have a bunch of vars I'd like to turn into a dictionary like :
bar=True
foo=False
>>> my_dict=dict(bar=bar, foo=foo)
>>>...
So, it seems one cannot do the following (it raises an error, since axes does not have a set_linewidth method):
axes_style = {'linewidth':5}
axes_rect = [0.1, 0.1, 0.9, 0.9]
axes(axes_rect, **axes_style)
and has to use the following old trick instead:
rcParams['axes.linewidth'] = 5 # set the value globally
... # some code
rcdefaul...
Hello,
I am using the WSDiscovery module for python. I have been able to search for services on my network. I am trying to discover a client and get the XAddress from this. The WSDiscovery module has very little documentation, actually so little the only piece is in the readme file of the module which is a few lines long. I have manged ...
I get an "unrecognized HTTP method" when trying to do a REPORT request using httplib and gae. Is there a workaround available? An httplib patch for gae? Do you I have to find another host in order to do this natively?
According to the docs, only certain fetch actions are valid: GET, POST, HEAD,
PUT, and DELETE: http://code.google.com/a...
I'm working in Django, and using urllib2 and simplejson to parse some information from an API.
The problem is that the API returns information in the Latin-1 encoding, and just once in a while there's a character in there that causes Django to crash horribly with an encoding error. This is my code:
get_person_id_url = "http://www.domai...
I'm using Python 2.6 and cx_Freeze 4.1.2 on a Windows system. I've created the setup.py to build my executable and everything works fine.
When cx_Freeze runs it movies everything to the build directory. I have some other files that i would like included in my build directory. How can i do this? Here's my structure.
src\
setup.py
...
how do i code a python program that return a json element that look like this
{1:{'name':foo,'age':xl}
2:{'name':vee,'age':xx}
....
}
What i meant is that i want return nested dictionaries
What i hoped to accomplish is something like this
var foo = 1.name # to the the value of name in the clientside
I hope all this made s...
What's the easiest way to draw a random number from an exponential distribution in Python?
...
Heya Everyone,
Forgive me if this seems like a stupid question, just so far no where on the internet can I find someone offering a solution to this and I just wanted to get some feedback from someone with more experience than myself (I've only been using python, pyGTK and Glade for 2 days now).
I have a UI window displaying and it upda...
To start, I'm very new to python, let alone Django and Piston.
Note: (I've updated this since the first two suggestions... you can view the old post in txt form here: http://bennyland.com/old-2554127.txt). The update I made was to better understand what was going wrong - and now I at least sort of know what's happening but I have no cl...
http://en.wikipedia.org/wiki/Relational_algebra#Semijoin
Let's say that I have two tables: A and B. I want to make a query that would work similarly to the following SQL statement using the SQLAlchemy orm:
SELECT A.*
FROM A, B
WHERE A.id = B.id
AND B.type = 'some type';
The thing is that I'm trying to separate out A and B's logic i...
Hi,
I am trying to get forward id from email obj.
from_address = rfc822.parseaddr(emailobj.get('from'))[1].strip().lower()
So from_address gives me the email id of the sender.
But my problem is when the email is forward how to get the email id of the forwarder.
I tried
test = rfc822.parseaddr(emailobj.get('fwd:'))[1].strip().lower(...
Hello! I'm running the micro framework Bottle on Google App Engine. I'm using Jinja2 for my templates. And I'm using Beaker to handle the sessions. I'm still a pretty big Python newbie and am pretty stoked I got this far :) My question is how do I access the session data within the templates? I can get the session data no problem w...
Is there a way in Python to access match groups without explicitely creating a match object (or another way to beautify the example below)?
Here is an example to clarify my motivation for the question:
Following perl code
if ($statement =~ /I love (\w+)/) {
print "He loves $1\n";
}
elsif ($statement =~ /Ich liebe (\w+)/) {
pri...
want to ask user to input something but not want to wait forever. There is a solution for Linux, http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python, but I am in windows environment. anybody can help me?
...
I would like to execute some program through ssh and redirect its input from a file. The behaviour of the following code:
channel.exec_command('cat')
with open('mumu', 'r') as f:
text = f.read()
nbytes = 0
while nbytes < len(text):
sent = channel.send(text[nbytes:])
if sent == 0:
break
nby...
I'm trying to parse the output from a tool into a data structure but I'm having some difficulty getting things right. The file looks like this:
Fruits
Apple
Auxiliary
Core
Extras
Banana
Something
Coconut
Vegetables
Eggplant
Rutabaga
You can see that top-level items are indented by one space, and it...
First of all, the overall problem I am solving is a bit more complicated than I am showing here, so please do not tell me 'use threads with blocking' as it would not solve my actual situation without a fair, FAIR bit of rewriting and refactoring.
I have several applications which are not mine to modify, which take data from stdin and po...
I'm processing a UTF-8 file in Python, and have used simplejson to load it into a dictionary. However, I'm getting a UnicodeDecodeError when I try to turn one of the dictionary values into a string:
f = open('my_json.json', 'r')
master_dictionary = json.load(f)
#some json wrangling, then it fails on this line...
mysql_string += " ('" + ...