I was wondering if it's frowned upon to use the decorator module that comes with python. Should I be creating decorators using the original means or is it considered okay practice to use the module?
This is happening in python files.
For example, I want to do type "fC" in normal mode, and instead of finding the first "C" character, it is just doing code fold toggling.
How would you write a list comprehension in python to generate a series of n-1 deltas between n items in an ordered list?
Example:
L = [5,9,2,1,7]
RES = [5-9,9-2,2-1,1-7] = [4,7,1,6] # absolute values
Im trying to count how many repeated lists there are inside a list. But it doesnt work the same way I could count repeated elements in just a list. Im fairly new to python, so apologies if it sounds too easy.
this is what i did
x= [["coffee", "cola", "juice" "tea" ],["coffee", "cola", "juice" "tea"]
["cola", "coffee", "juice" "tea" ]]
dictt= {}
for item in x:
dictt[item]= dictt.get(item, 0) +1
return(dictt)
hey dudes,
my first question anyway,
i have made a single user dungeon and am looking to change it in to a multi user dungoen how can i do this by the way im using python to make the sud in to a mud lol
In Python 2.6, I can run the following fine to strip out chars like -()
'(123) 456-7890'.translate(None, '-(), ')
Python2.5 translate does not accept None, how can I do the above in 2.5?
isk-daemon software permits setting feature parameters?
I download desktop version and apparently not!
There are alternative libraries or software which is not all automatic?
I have a set of images and i only want to pick up an image, extract some features and compare them with this set of image, basing on a similarity metric that give me a percentage result like isk-daemon but with more freedom in settings, better in python!
I need to run a lot of Django management commands in the crontab and want to log the output of each run to a special timestamped file. Is there a Django or Python module to help me do this or do I just have to roll my own?
Hi all,
i am quite new in python.
I am receiving (through pyserial) string with data values.
How can I parse these data to particular data structure?
I know that
0-1 byte : id
2-5 byte : time1 =>but little endian (lsb first)
6-9 byte : time2 =>but little endian (lsb first)
and I looking for a function:
def parse_data(string):
data={}
data['id'] = ??
data['time1'] = ??
data['time2'] = ??
return data
thanks
I'm using Pisa/XHTML2PDF to generate PDFs on the fly in Django. Unfortunately, I need to include SVG images as well, which I don't believe is an easy task.
What's the best way to go about either a) converting the SVGs to PNG / JPG (in Python) or b) including SVGs in the PDF export from Pisa?
Hello,
I would like to know if there are some libraries/algorithms/techniques (python, if at all possible) that help to extract features from accelerometer data (extracted from and android phone, btw), like periodicity of movements, energy of acceleration and the like. Has anyone done this kind of task before?
Thank you very much in advance :)
Hi all,
I recently installed twython, a really sleek and awesome twitter API wrapper for Python. I installed it and it works fine from the interpreter, but when I try to import it via Eclipse, it says that twython is an invalid import.
How do I "tell" eclipse where twython is so that it will let me import and use it?
Thanks!
It looks like Google hasn't updated the results section since the Q4 2009 posting. I've been wondering when it will be put in the Python trunk, and if it's, in any way, production ready.
Also, "We aspire to do no original work" is in the Q4 plan. Did Google bite off more than what they could handle, or does anyone know what the real story is?
I have the following file like this:
2 qid:1 1:0.32 2:0.50 3:0.78 4:0.02 10:0.90
5 qid:2 2:0.22 5:0.34 6:0.87 10:0.56 12:0.32 19:0.24 20:0.55
...
he structure is follwoing like that:
output={}
rel=2
qid=1
features={} # the feature list "1:0.32 2:0.50 3:0.78 4:0.02 10:0.90" output.append([rel,qid,features])
...
How can I write my python code to load the data, thanks
Can any one tell me which MySQL version is suitable for Python2.6.1 to connect MySQLdb,
I am using MySQL4.0.23 and MySQLdb of MySQL-python-1.2.3c1.win32-py2.6 after successfully installation also its showing No module named MySQLdb and I sent the Environment Variables also properly for Python2.6, using Windows XP, tested import MySQLdb through command prompt its not showing any errors
then what could be the problem, I am straggling on this since last 2days, Please tell what could be the problem
I know about os.nice() it works perfect for parent process, but I need to do renice of my child subprocesses. I found way to do this, but it seems to be not very handy and too excessive:
os.system("renice -n %d %d" % ( new_nice, suprocess.pid ) )
And it isn't return resulting nice level after renicing.
Is there more clean way to renice subprocesses in python?
Hello,
I have the following code in Python:
linkHTML = "<a href=\"page?q=%s\">click here</a>" % strLink
The problem is that when strLink has spaces in it the link shows up as
<a href="page?q=with space">click here</a>
I can use strLink.replace(" ","+")
But I am sure there are other characters which can cause errors. I tried using
urllib.quote(strLink)
But it doesn't seem to help.
Thanks!
Joel
I have been given data which cannot be interpreted by my software unless it has a lowercase letter at the end. The data was delivered with an uppercase letter at the end.
Somehow I need to first recursively loop through all folders and find whether the filename ends with a letter and then change it to lowercase.
I think python could do this, but I don´t know how,. Any help would be great!
yours,
Rob
Hey,
Im wondering, how can i get a SUM of a rating entity i get from the datastore (python)?
should i:
ratingsum = 0
for rating in ratings:
ratingsum + rating
print ratingsum
?
https://search.twitter.com/search.json?q=doug
How do I read this like VIEW SOURCE, so that I know what I'm looking at?
Is there a website that can prettify it for me?
BTW, I use python
I would like to use Python's tempfile module to create a temporary file that I will use for communication between processes (use of pipes is awkward).
The documentation I've linked to above shows two functions that almost do what I want:
tempfile.NamedTemporaryFile # For creating named tempfiles
tempfile.SpooledTemporaryFile # For creating tempfiles in memory
but actually I want a tempfile that is both named AND in memory. Any ideas?
I am using python and would like a simple api or regex to check for a domain name's validity. By validity I am the syntactical validity and not whether the domain name actually exists on the Internet or not.