[EMAIL PROTECTED] wrote:
> So I have lists that look like this: [1, 2, 3, 4, 5]. When I
> concatenate lists, I end up with a list of lists that looks like
> this: [[1, 2, 3. 4, 5]. [6, 7. 8, 9. 10]].
Really?
>>> [1, 2, 3, 4, 5] + [6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> Then, I aver
Alex Martelli wrote:
> You should probaby prepare before the loop a mapping from char to number
> of 1 bits in that char:
>
> m = {}
> for c in range(256):
> m[c] = countones(c)
Wouldn't a list be more efficient?
m = [countones(c) for c in xrange(256)]
--
http://mail.python.org/mailman/listin
Fabiano Sidler wrote:
> Have a look to the following lines of code:
> --- snip ---
> class Foo: pass
> def bar(): pass
> Foo.bar = bar
> --- snap ---
>
> Why does 'bar.__get__(Foo) is Foo.bar' evaluate to False here? Did I
> misunderstand the descriptor protocol?
bar.__get__(None, Bar) is what yo
chun ping wang wrote:
> i want to modify an iterator value.
>
> for x in someList
>x = 1
for index, value in enumerate(someList):
someList[index] = 1
--
http://mail.python.org/mailman/listinfo/python-list
Gary Wessle wrote:
> the example was an in-accuretlly representation of a the problem I am
> having. my apologies.
>
> a = []
> def prnt():
>print len(a)
>
prnt
>
>
> I expect to get 0 "the length of list a"
Python requires parenthesis to call a function.
>>> a = []
>>> def prnt(
John Salerno wrote:
> My initial feeling is that concatenation might take longer than
> substitution
Doesn't look that way:
[EMAIL PROTECTED]:~$ python -m timeit "'%s\n\n' % 'foobar'"
100 loops, best of 3: 0.6 usec per loop
[EMAIL PROTECTED]:~$ python -m timeit "'' + 'foobar' + '\n\n'"
1
fuzzylollipop wrote:
> niether .join() is the fastest
Please quote what you're replying to.
No, it's the slowest:
[EMAIL PROTECTED]:~$ python -m timeit "'%s\n\n' % 'foobar'"
100 loops, best of 3: 0.607 usec per loop
[EMAIL PROTECTED]:~$ python -m timeit "'' + 'foobar' + '\n\n'"
100 loops
Kaz Kylheku wrote:
> But suppose that the expression and the multi-line lambda body are
> reordered? That is to say, the expression is written normally, and the
> mlambda expressions in it serve as /markers/ indicating that body
> material follows. This results in the most Python-like solution.
I
Gregory Petrosyan wrote:
> Hello!
> I have a question for the developer[s] of enumerate(). Consider the
> following code:
>
> for x,y in coords(dots):
> print x, y
>
> When I want to iterate over enumerated sequence I expect this to work:
>
> for i,x,y in enumerate(coords(dots)):
> print
[EMAIL PROTECTED] wrote:
> I want to print number 0 to 9 in one line like this
> 0 1 2 3 4 5 6 7 8 9
>
> if I do like this, it prints in different lines
>
> for i in xrange(10):
> print i
for i in xrange(10):
print i,
> so i tried like this
>
> str = ""
> for i in xrange(10):
> st
Sandra-24 wrote:
> I'm not sure how complex this is, I've been brainstorming a little, and
> I've come up with:
from tokenize import generate_tokens, NL, NEWLINE
from cStringIO import StringIO
def code_lines(source):
"""Takes Python source code (as either a string or file-like
object) a
201 - 211 of 211 matches
Mail list logo