sets in python problem
I want to use sets as data structure. how should i make it possible? what are the commands I need? Like closedset = set() is this ok? And in a set, if i want to get some value out, what is the command for that one? ...
I want to use sets as data structure. how should i make it possible? what are the commands I need? Like closedset = set() is this ok? And in a set, if i want to get some value out, what is the command for that one? ...
I have a python script that takes a number of variables. I also have a html page that can receive post values. How can I start a browser from python and point it to the html page I have above and send those post variables to the html url? The problem I have is that if I use urllib/urllib2 to do the post, it doesn't load the browser win...
This is a question prompted by another question from me. Django provides Abstract base classes functionality (which are not to same as ABC classes in Python?) so that one can make a Model (Django's models.Model) from which one can inherit, but without that Model having an actual table in the database. One triggers this behavior by setti...
I got a problem: keys here is a list. keys = [(6,4) , (6,8)] The entries in the keys can be 4,5...or watever Now, I have to pick up only 1 from it.So I used: root = keys[0] print root output: (6,4) Now I have to make a set which is empty, say,... closed = set() for u,v of root: if v not in closed: closed.add(v) ...
Hi All, I am having two python files as 1.py and 2.py. **1.py is as** class A: def __init__(self): x = 5 y = 7 NUMBERS = self fp = open(filePath) temp = fp.read() exec(temp) fp.close() ADD_METHOD() **2.py is as** ...
How to write a program to test another program/script? I need to test a ruby script that is an echo server; how should I write a program to validate the correct working of the echo server script ? ...
Hi. I am trying to create a line-by-line filter in python. However, stdin.readlines() reads all lines in before starting to process, and python runs out of memory (MemoryError). How can I have just one line in memory at a time? The kind of code I have: for line in sys.stdin.readlines(): if( filter.apply( line ) ): print(...
My question is whether or not there are situations in which sys.stdout.write() is preferable to print. Such as it having better performance or resulting in code that makes more sense. ...
I'm trying to create a matrix or a contingency table from a file that has this format: Species Date Data 1 Dec 3 2 Jan 4 2 Dec 6 2 Dec 3 Result 1 2 Dec 3 9 Jan 4 More that I'd like to know how to turn myfile into an array that numpy will like. Basically I'm trying to recreate reshape from R...
I want to install the new Python 2.7 on my Windows XP 32bit PC. having CDO (thats OCD with initials sorted in alphabetical order) I want to install it multiple times on the same computer (to different TARGETDIRs). how do i do that ? double clicking on the installer, or running msiexec multiple times did not work for me Coincidentally,...
Hello everybody, I am working on a loginMiddleware class for Django. This middleware class must send a user to the login page when it's not logedin. But there are a few exceptions. Because i run the build-in django server i had to make a media url. But know is de problem that when the login page loads a javascript file, the javascript...
Basically I am coding websites in PHP from last year. But now I want to use something else and GAE looks a good option. So I want to know if GAE is good for making a little website to share favorite youtube videos ? I have done single website in Python+Django few months back, it looks good to me. But JAVA is the language that I want t...
Hello. I am running in ubuntu and I can code in python, without problem. I have tried to install pygame and to do make it so, I did: sudo apt-get instal python-pygame When I go into the python IDLE and write: import pygame I get: Traceback (most recent call last): File "", line 1, in ImportError: No module name...
Hey Guys, I'm having problems displaying nested blocks in a template. eg. {% for category in categories %} //code to display category info {% products = products.object.filter(category = category) %} {% for product in products%} //code to display product info {% endfor %} {% ...
there is a script that expects keyboard input, i can call that script with os.system('./script') in python, how is it possible to send back an input to the script from another calling script? update: the script is: $ cat script #!/usr/bin/python for i in range(4): name=raw_input('enter your name') print 'Welcome %s :...
Hello, In perl, to get a list of all strings from "a" to "azc", to only thing to do is using the range operator: perl -le 'print "a".."azc"' What I want is a list of strings: ["a", "b", ..., "z", "aa", ..., "az" ,"ba", ..., "azc"] I suppose I can use ord and chr, looping over and over, this is simple to get for "a" to "z", eg: >...
suppose i a have a multiplicative expression with lots of multiplicands (small expressions) expression = a*b*c*d*....*w where for example c is (x-1), d is (y**2-16), k is (x*y-60)..... x,y are numbers and i know that c,d,k,j maybe zero Does the order i write the expression matters for faster evaluation? Is it better to write c*d*...
i want to get the content of the geo-rss any python lib to do this ? thanks ...
Hi I created a list in Python: mylist=os.listdir("/User/Me/Folder") now I have a list of files in a List. What I would like to do is: Take one file name after the other and add a URL to it: /myurl/ + each item in mylist And then I would like to write the result in a html template from Django. So that it display all the images in...
Hi, I've some lists and more complex structures containing floats. When printing them, I see the floats with a lot of decimal digits, but when printing, I don't need all of them. So I would like to define a custom format (e.g. 2 or 3 decimals) when floats are printed. I need to use floats and not Decimal. Also, I'm not allowed to trunca...