I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.
The best way of describing what I want would be "itertools for Java".
...
So, I was playing around with Python while answering this question, and I discovered that this is not valid:
o = object()
o.attr = 'hello'
due to an AttributeError: 'object' object has no attribute 'attr'. However, with any class inherited from object, it is valid:
class Sub(object):
pass
s = Sub()
s.attr = 'hello'
Printing s....
I have a web service with Django Framework.
My friend's project is a WIN32 program and also a MS-sql server.
The Win32 program currently has a login system that talks to a MS-sql for authentication.
However, we would like to INTEGRATE this login system as one.
Please answer the 2 things:
I want scrap the MS-SQL to use only the Djang...
the html that I am receiving from urllib2 is missing dozens of fields of data that I can see when I view the source of the URL in Firefox. Any advice would be much appreciated. Here is what it looks like:
from FireFox view source:
# ...<td class=td6>as</td></tr></thead>|ManyFields|<br></div><div id="c1">...
from urllib2 return html...
author_A = [['book_x',1,10],['book_y',2,20],['book_z',3,30]]
author_B = [['book_s',5,10],['book_t',2,20],['book_z',3,30]]
author_A AND author_B = ['book_z',3,30]
author_A = [['book_x',1,10],['book_y',2,20]]
author_B = [['book_s',5,10],['book_t',2,20]]
---------------------------------------------
...
I am working on a windows vista machine in python 3.1.1. I am trying to insert a large number of rows into a SQLite3 db. The file exists, and my program properly inserts some rows into the db. However, at some point in the insertion process, the program dies with this message:
sqlite3.OperationalError: unable to open database file...
Is there a way to get python to print extremely large longs in scientific notation? I am talking about numbers on the order of 10^1000 or larger, at this size the standard print "%e" % num fails.
For example:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" f...
how can i create new file in /var/log directory using python language in OSX leopard? i tried to do it using os.open function but i get "permission denied"
thanks in advance
...
I've been working through the Tkinter chapters in Programming Python and encountered a problem where the foreground and background colours of a button will not change. I am working on a Mac OS X 10.6 system with Python 2.6.1. The colours of a label will change, but not the colours of a button. For example:
from Tkinter import *
Label(N...
I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.
I am wondering how to do debugging.
At present the steps I follow is,
I complete a large script,
Comment everything but the portion I
want to check
Execute the script
Though it works, I am not able to deb...
In python I can use this to check if the element in list a:
>>> a = range(10)
>>> 5 in a
True
>>> 16 in a
False
How this can be done in Ruby?
...
This is my list:
biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ]
print random.shuffle(biglist)
that doesn't work! It returns none.
...
& g t ; Welcome
How do I show the actual symbol instead? Is it a template filter?
Thanks.
...
I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?
...
I have a float: 1.2333333
How do I change it into a two decimal number with a comma as a decimal point separator, eg 1,23?
...
It seems my previous description was not clear, so rewriting it.
Using python urllib2, I am automating fileupload task in my webapp. And am using Cookielib to store session information, and also I could able to successfully automate the fileupload task. Problem is, when I change the login credentials and did not supply those or supply ...
I would like to provide "all" mathematical functions for the number-like objects created by a module (the uncertainties.py module, which performs calculations with error propagation)—these objects are numbers with uncertainties.
What is the best way to do this?
Currently, I redefine most of the functions from math in the module uncerta...
One thing I hate about distutils (I guess he is the evil who does this) is that it changes the shebang line. In other words, the more rational and environment-vars decided scripture
#!/usr/bin/env python
gets magically converted into
#!/whatever/absolute/path/is/my/python
This is seen also with grok: I used grokproject in a virtua...
I just installed pyme on my ubuntu system. it was easy (thanks apt-get) and I can reproduce the example code (encrypting using a public key in my keyring). now I would like to sign some data and I didn't manage to find any example code nor much documentation.
this is what I've been doing:
>>> plain = pyme.core.Data('this is just some...
I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:
As the number of rows is unknown at the beginning of the loading, how can
a very large numpy array be most efficiently built, row by...