I'm using MySQLdb and can connect and issue queries that return result sets,
but I how do I get the column names for those result sets?
>>> c = MySQLdb.connect(*creds)
>>> k = c.cursor()
>>> k.execute("select * from account")
3L
>>> k.fetchall()
((1L, 'test', -1L), (2L, 'Test', -1L), (3L, 'Test2'
(joins are merely indexes into
other structures).
-j
Steve Holden wrote:
> Jason Nordwick wrote:
>> I use reduce to also do indexing, hashing with upsert semantics of lists of
>> key-value pairs, transitioning through a state table, etc...
>>
>> Somebody else poin
t timing reduce
against a hand coded loop, but instead the operator '+' against the function
add, as the function symbol lookup and call seem to have a heavy price. Reduce
was one of the nice ways to eliminate some of those lookups.
-j
[EMAIL PROTECTED] wrote:
> Jason N
opadd(v):
sum = 0
for x in v:
sum = add(sum, x)
return sum
(Yes, I know there are better ways to sum up a list, but I just wanted to test
the performance of the loop against reduce. In most of my reduce usages, the
function passed to reduce is much mor
Stargaming wrote:
>
> Also note that reduce will be removed in Python 3000.
What will replace it?
-j
--
http://mail.python.org/mailman/listinfo/python-list
Somehow my other response to the list got lost. I'm still learning Python, but
this seems much better than my first attempt:
def pr(x): print x
def cross(x,y): return [a+b for a in x for b in y]
x=map(pr, reduce(cross, [map(str,range(1,6))]*5))
-j
Stargaming wrote:
> Jason Nordwick
better (sorry, still learning Python):
def cross(x,y): return [a+b for a in x for y in b]
Jason Nordwick wrote:
> Or without filter:
>
> from operator import add
> def pr(x): print x
> def cross(x,y): return reduce(add, [[a+b for b in y] for a in x])
> x=map(pr, reduce(cross,
Or without filter:
from operator import add
def pr(x): print x
def cross(x,y): return reduce(add, [[a+b for b in y] for a in x])
x=map(pr, reduce(cross, [map(str,range(1,6))]*5))
mike_wilson1333 wrote:
> I would like to generate every unique combination of numbers 1-5 in a 5
> digit number and
def pr(x): print(x)
>>> x=map(pr,[x for x in xrange(11,56) if '1'<=min(str(x)) and
>>> max(str(x))<='5'])
11
12
13
14
15
21
22
23
24
25
31
32
33
34
35
41
42
43
44
45
51
52
53
54
55
mike_wilson1333 wrote:
> I would like to generate every unique combination of numbers 1-5 in a 5
> digit number an
Use os.system to execute a string and os.walk to get a recursive list of files
>>> def processdir(curdir,subdirs,files):
... map(lambda f:os.system('\\cygwin\\bin\\wc -l "%s"' % f),
[curdir+os.sep+x for x in files])
...
>>> map(lambda x:processdir(*x), os.walk('\\dev\qclient'));
6 \dev\qclie
>>> pats = ['abcdef', 'defgef', 'effwer']
>>> reps = ['highway', 'news', 'monitor']
>>> s = 'defgefabcdefy\n\n\n effwerbyuuuterrfr'
>>> reduce(lambda x,y: x.replace(*y), zip(pats,reps), s)
'newshighwayy\n\n\n monitorbyuuuterrfr'
f pemberton wrote:
> I have a string (xdata) and theres a
11 matches
Mail list logo