Which are the most advanced frameworks and tools there are available for python for practicing Behavior Driven Development? Especially finding similar tools as rspec and mocha for ruby would be great.
Hi all
I have the following 4 arrays ( grouped in 2 groups ) that I would like to merge in ascending order by the keys array.
I can use also dictionaries as structure if it is easier.
Has python any command or something to make this quickly possible?
Regards
MN
# group 1
[7, 2, 3, 5] #keys
[10,11,12,26] #values
[0, 4] #keys
[20, 33] #values
# I would like to have
[ 0, 2, 3, 4, 5, 7 ] # ordered keys
[20, 11,12,33,26,33] # associated values
Hi,
I'm trying to send a Python list in to client side (encoded as JSON), this is the code snippet which I have written:
array_to_js = [vld_id, vld_error, False]
array_to_js[2] = True
jsonValidateReturn = simplejson.dumps(array_to_js)
return HttpResponse(jsonValidateReturn, mimetype='application/json')
So my question is how to access it form client side, can I access it like this:
jsonValidateReturn[0]
or how I assign a name to the returned JSON array in order to access it?
I'm cocking this up and it should be really simple but the value of sortdate is none (note im only doing this because converting a string to a date in Python is a bugger).
DateToPass = str(self.request.get('startdate'))
mybreak.startdate = DateToPass
faf = DateToPass.split('-')
sortdate = str(faf[2] + faf[1] + faf[0])
That should work? but its just being stored as null though the datetopass is being stored fine.
I want to print in the terminal with colors ? how can I do that in python ?
Another questions what is the best character that when it is printed it look like a box [brick] ?
I want to print colored blocks, it is part of game :)
I am trying to create my own class of dictionary in python 3 which has a field of dict variable and setitem and getitem methods. Though, it doesnt work for some reason. Tried to look around but couldn't find the answer.
class myDictionary:
def __init(self):
self.myDic={}
def __setitem__(self, key, value):
self.myDic[key]=value
I'm getting:
'myDictionary' object has no attribute 'myDic'
Any ideas? :)
I have a shell that runs CentOS
For a project I'm doing I need python 2.5+ but centOS is pretty dependent on 2.4
From what I've read a number of things will break if you upgrade to 2.5
I wan't to install 2.5 separately from 2.4 but I'm not sure how to do it. So far I've downloaded the source tarball, untarred it and did a ./configure --prefix=/opt which is where I want it to end up. can I now just make, make install ? or is there more?
To learn from good examples, what are the best open source Google App Engine applications out there?
I don't care if it is Java or Python based.
Please one app per answer. Feel free to add a link to the live app (if there is) and to the project page.
I am looking for a good Tree data structure class. I have come across this package, but since I am relatively new to Python (not programming), I dont know if there are any better ones out there.
I'd like to hear from the Pythonistas on here - do you have a favorite tree script that you regularly use and would recommend?
I would like to know if there is something similar to PHP natsort function in python?
l = ['image1.jpg', 'image15.jpg', 'image12.jpg', 'iamge3.jpg']
l.sort()
gives:
['image1.jpg', 'image12.jpg', 'image15.jpg', 'iamge3.jpg']
but I would like to get:
['image1.jpg', 'iamge3.jpg', 'image12.jpg', 'image15.jpg']
How can I combine 2 ints to a single 32bit IEEE floating point ? (each of the 2 ints represent 16 bit)
And in the opposite direction: How can I transform a python float into 2 16 bit ints?
(I need this because of modbus protocol - where 2x16 bit registers are treated as single 32 floating point number)
I want certain functions in my application to only be accessible if the current user is an administrator.
How can I determine if the current user is in the local Administrators group using Python on Windows?
I am looking to make a python script be unique in the sense that it can only run once at a time. For example if I run the script and open another session of the same script a second time and the first session is still running, then the second session will just exit and do nothing. Anyone knows how I could implement this?
Is there any way to run one last command before a running Python script is stopped by being killed by some other script, keyboard interrupt etc.
Thanks for your help!
What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.
I am looking to make a python script be unique in the sense that it can only run once at a time. For example if I run the script and open another session of the same script a second time and the first session is still running, then the second session will just exit and do nothing. Anyone knows how I could implement this?
I'm working on a python class that is being shared between two products. 90% of the functionality applies to both products. For the 10% that's different the code is littered with this kind of thing:
#Start of file
project = 'B'
#Some line of code
if project == 'A':
import moduleA
elif project == 'B':
import moduleB
#Many lines of code
if project == 'A':
print moduleA.doA(2)
elif project == 'B':
print moduleB.doB(2)
This doesn't seem very elegant or very readable, has anyone encountered this sort of thing before? Are there better ways of doing it?
Hello,
I have a python program/file that I want to run repeatedly and calculate the averages of some variables over these runs. To do so, I thought it might be convenient to convert this program into a function or a class. One way I can think of is to add a
def Main():
line at the top and indent every line manually within it. Is there an easier way? I am using pydev on eclipse.
Thanks.
I am looking for a GUI python module that is best suited for the following job:
I am trying to plot a graph with many columns (perhaps hundreds), each column representing an individual. The user should be able to drag the columns around and drop them onto different columns to switch the two. Also, there are going to be additional dots drawn on the columns and by hovering over those dots, the user should see the values corresponding to those dots. What is the best way to approach this?
What is the best way to store the cards and suits in python so that I can hold a reference to these values in another variable?
For example, if I have a list called hand (cards in players hand), how could I hold values that could refer to the names of suits and values of specific cards, and how would these names and values of suits and cards be stored?
Starting a Perl script with alarm(3600) will make the script abort if it is still running after one hour (3600 seconds).
Assume I want to set an upper bound on the running time of a Python script, what is the easiest way to achieve that?
How would i get the current URL with Python,
I need to grab the current URL so i can check it for query strings e.g
requested_url = "URL_HERE"
url = urlparse(requested_url)
if url[4]:
params = dict([part.split('=') for part in url[4].split('&')])
also this is running in Google App Engine