-debian-and-python-wiki-servers.html#_
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ith an error:
NameError: name 'subprocess' is not defined
You need to import the subprocess first.
If none of my guesses are correct, could we have some hints? Perhaps show
us the actual code you are using, and the actual results, copied and
pasted exactly.
Thank you.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 18 Jan 2013 03:38:08 +, Dan Sommers wrote:
> On Thu, 17 Jan 2013 15:21:08 +0000, Steven D'Aprano wrote:
>
>> On Thu, 17 Jan 2013 06:35:29 -0800, Mark Carter wrote:
>>
>>> I thought it would be interesting to try to implement Scheme SRFI 39
&
n infinite number of potential strings, which
must hash into a finite number of hash values. Although it is hard for me
to find hash collisions, I know that there must be some, because there
are more strings than hash values. This is not a design flaw in the hash
function, and can'
On Fri, 18 Jan 2013 20:15:26 -0800, Chris Rebert wrote:
> On Friday, January 18, 2013, Steven D'Aprano wrote:
>
>> I wish to add a key to a dict only if it doesn't already exist, but do
>> it in a thread-safe manner.
[...]
> I'm not entirely sure, but h
on.org/2/library/gc.html#gc.garbage
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 19 Jan 2013 16:24:37 +, Steven D'Aprano wrote:
> On Sat, 19 Jan 2013 14:47:16 +, Jens Thoms Toerring wrote:
>
>> Ok, the destrucor for the first instance of the X class is called only
>> after printing out "After", so the GC didn't delete th
> print() or before the method call returns. That, in turn might result in
> a crash of the script.
It would be a pretty crappy garbage collector that collected objects
while they were still being used.
> Is my assumption about this flawed and there are no potential dangers?
> Perh
int' is not
defined". So I expected to be able to fix it just as I did before:
g.__globals__['__builtins__'] = builtins
But it doesn't work -- I still get the same NameError. Why does this not
work here, when it works for a regular dict?
I can fix it by adding the
ge of irrelevant text they've already read.
Thank you.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
not.
In Python 2, if you fail to subclass object, you get an "old-style
class", and features like property, classmethod, staticmethod, super and
multiple inheritance may not work at all, or be buggy.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
f irrelevant comments that we've already read
before.
Thank you.
If there is more quoted text than new text you have written, or quoting
exceeds 3, maybe 4 levels deep, then there probably is too much
unnecessary quoting.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
"#define private public". Or pointer tricks, or using reflection in
Java.
Yes, the convention in Python is that names starting with a single
underscore should be considered private implementation details.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
nide response isn't the correct
> approach.
Alex, thank you for saying this. I can now delete my *much* less polite
version saying the same thing.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ause the output will be different. The first code will print:
0: first line
1: second line
2: third line
The second code will print:
0first line
1second line
2third line
You should really try these things and see what they do before asking.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
err as well:
[steve@ando ~]$ ls bar 2> /tmp/a
[steve@ando ~]$ cat /tmp/a
ls: bar: No such file or directory
Similarly, you can redirect stdin, or you can use a pipe | to turn the
output of one command into the input of another command. This is mostly
useful when using something like command.com in Windows, not so common in
Python.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
d store it
> pin = re.match( r'', firstline ).group(1)
>
> This is what i used to have.
>
> Now, can you pleas help me write the switch to filepath identifier? I'am
> having trouble writing it.
I don't understand the question.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ld, and it
will handle giving every path a unique number for you. You can then
forget all about that unique number, because it is completely irrelevant
to you, and safely use the path while the database treats it in the
fastest and most efficient fashion necessary.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
s around this specific issue,
> including what you suggest: a canonical rewrite of "python
> path\to\__main__.py" into "python -mpath\to". But it's not clear to me
> that this rewrite should be the responsibility of calling code.
I am a bit disturbed that you cannot distinguish between:
python C:\something\on\pythonpath\app\__main__.py
python -m app
by inspecting the command line. I consider it a bug, or at least a
misfeature, if Python transforms the command line before making it
available in sys.argv.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
need a way to eat my soup with a screwdriver. No I WONT use a
> spoon.
>
> Im starving
> HELP
Very well done :-)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
s is right
for x in sequence:
do_something_with(x)
if condition:
break
else:
print "condition was never true"
That's right. The `else` block *unconditionally* executes after the `for`
block. The only way to skip it is to use `break`, which skips all the way
out of the combined for...else statement.
This is a very useful feature, very badly named.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
need a way to eat my soup with a screwdriver. No I WONT use a
> spoon.
>
> Im starving
> HELP
Very well done :-)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ecades.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ng trolled.
I hate to admit it, but I kind of have to admire somebody who can play
dumb so well for so long for the lulz. Well played Ferrous Cranus, well
played. Now please go and play your silly games elsewhere.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 22 Jan 2013 23:40:24 +, Steven D'Aprano wrote:
[snip content]
Holy crap! Sorry for the flood of duplicated posts. That was out of my
control, honest.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
27;t understand me. If I answer again, in a slightly different way,
perhaps it will be more clear."
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 23 Jan 2013 00:53:21 +, Oscar Benjamin wrote:
> On 22 January 2013 23:46, Steven D'Aprano
> wrote: [SNIP]
>>
>> I am a bit disturbed that you cannot distinguish between:
>>
>> python C:\something\on\pythonpath\app\__main__.py
>>
>> p
printque[val] + 1
Another way of writing that is:
printque[val] = printque.get(val, 0) + 1
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
printque[val] + 1
Another way of writing that is:
printque[val] = printque.get(val, 0) + 1
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
printque[val] + 1
Another way of writing that is:
printque[val] = printque.get(val, 0) + 1
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
printque[val] + 1
Another way of writing that is:
printque[val] = printque.get(val, 0) + 1
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
[snip content]
Arrgggh, it's happened again. Sorry for the multiple posts folks, I *swear*
I only sent it once.
Trying this time with a different news client.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
s you give could possibly be different. If you are using a proxy,
what happens if you bypass it?
If you can reproduce this at will, with and without proxy, with multiple
sites, then I suppose it is conceivable that it could be some sort of bug.
But I wouldn't bet on it.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
, untested:
givenfile = sys.argv[1]
if givenfile == '-':
data = sys.stdin.read()
else:
data = open(givenfile).read()
Adding error checking etc. is left as an exercise.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ve mode is hardly
> used these days.
Explain please?
I cannot see how the firewall could possible distinguish between using a
temporary variable or not in these two snippets:
# no temporary variable hangs, or fails
urllib2.urlopen("ftp://ftp2.census.gov/";).read()
# temporary variable succeeds
response = urllib2.urlopen("ftp://ftp2.census.gov/";)
response.read()
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 23 Jan 2013 10:01:24 +, Oscar Benjamin wrote:
> On 23 January 2013 03:58, Steven D'Aprano
> wrote:
>> On Wed, 23 Jan 2013 00:53:21 +, Oscar Benjamin wrote:
>>
>>> On 22 January 2013 23:46, Steven D'Aprano
>>> wrote: [SNIP]
>>
just use
> PyObject_GetItem; obviously, this is an optimization).
Thanks for the reply Rouslan.
Perhaps I should report this as a bug.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
this makes a copy of the set, it is O(n). The
straight-forward approach:
for element in S:
if x == element:
x = element
break
is also O(n), but with less overhead. On the other hand, the retrieve
function above does most of its work in C, while the straight-forward loop
is pure Python, so it's difficult to say which will be faster. I suggest
you time them and see.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
mount of sample data needed to demonstrate
the problem; three or four words is enough, no need to waste
everyone's time and bandwidth with sixteen thousand words;
- choose a MEANINGFUL subject line, there is no need to paste the entire
body of your code in the subject line.
Thank you.
> ...MyError: 'details are not ignored!'
> ---cut---
> see, ellipsis-prefix in MyError
Have you tried it to see? Add this comment to your docstring, following the
line which causes an exception:
>>> example() #doctest: +ELLIPSIS
Traceback (most recent call l
u iterate over an empty list, the body of the loop never executes,
and the result list remains empty.
What did you expect it to do?
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
other words, an empty list.
Er, no. It's a one-element list: index 5 is included, index 6 is excluded.
py> L = list("abcdefgh")
py> L[5:6]
['f']
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ascal record.
Lists are very roughly intended to be somewhat close to an array,
although as I said the array.py module is even closer.
>> A dictionary is a mapping type; it allows you to access items via a
>> meaningful name (usually a string.)
[...]
> Thank you, I understand it better it is kind of like a hash table.
Correct. Also known as "associative array".
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
lled, or at least not where you think
it is.
Am I close? If not, I recommend that you actually show us the errors you are
getting.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
[1]"
10 loops, best of 3: 71 msec per loop
steve@runes:~$ python -m timeit "L = []" "for i in xrange(25000): L = L + [1]"
10 loops, best of 3: 2.06 sec per loop
Notice that as the number of list additions goes up by a factor of 5,
the time taken goes up by a factor of 25.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ector()
return func(self, *args, **kwargs)
return inner
class A(object):
@decorate
def mymethod(self):
"""Do something useful."""
class B(A):
def _protect(self):
raise RuntimeError("I'm sorry Dave, I'm afraid I cannot do that.")
Try studying that to see how it works, and then try studying it to
realise how pointless it is, since it too relies on class B protecting
class A from B.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
>> def _protector_decorator(fcn):
>> def newfcn(self, *args, **kwargs):
>> return fcn(self, *args, **kwargs)
>> return newfcn
>
> Well, that surely isn't going to work, because it always decorates the
> same funct
Jason Swails wrote:
> On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano <
> steve+comp.lang.pyt...@pearwood.info> wrote:
>> Well, that surely isn't going to work, because it always decorates the
>> same function, the global "fcn".
>
> I don
dg.google.gro...@thesamovar.net wrote:
> If you could take one minute to make sure you
> are signed in to your Google+ account
Which Google+ account would that be? I have so few.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
spammy and trying again.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
a new news post;
2) Type the To address comp.lang.python;
3) Type a meaningful subject line such as "Geographic Masking in Python"
4) Type your message.
5) Hit send.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
- http://wiki.python.org/moin/
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
y sometimes
display floats slightly differently. Sometimes 3.3 will show more decimal
places:
[steve@ando ~]$ python2.7 -c "x = 1.0/33; print (x+x+x)"
0.0909090909091
[steve@ando ~]$ python3.3 -c "x = 1.0/33; print (x+x+x)"
0.09090909090909091
but you can be sure that they are the same value, it is just a difference in
the default display of floats:
[steve@ando ~]$ python2.7 -c "x = 1.0/33; print (x+x+x).hex()"
0x1.745d1745d1746p-4
[steve@ando ~]$ python3.3 -c "x = 1.0/33; print((x+x+x).hex())"
0x1.745d1745d1746p-4
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
m/2
1.5
This does not happen in Python 3.x -- you always get floating point
division, even if both the numerator and denominator are ints.
You can fix this, and get the proper calculator-style floating point
division, in Python 2 by putting this line at the very top of your script:
from __future__
math.log(s), one version might
be accurate to (say) 15 decimal places and the other to (say) 14 decimal
places, and that difference is magnified by subsequent calculations.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
er True/False over any other object
simply because it is more readable and clear as to your intention. But it
is no big deal if you prefer 1/0 instead.
If you branch over an arbitrary named object, like "while x", there is no
point in writing that as "while bool(x)". All that does is indicate that
you are uncomfortable with, or don't understand, Python's truth model,
and perform an extra, unnecessary, name lookup and function call.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
h are best coded as simple Python tests that are much faster,
such as using a regex where a simple str.startswith() would do.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
his news group is supposed to be for discussing the
Python programming language. At least it used to be about Python. It is
hard to understand why you think discussing English idioms is the right
thing to do here.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
n and long-time troll here. You shouldn't take him too
seriously.
(P.S. in future, please trim the quoted text of your replies, there's no
need to quote the entire email, only the parts you are replying to and
enough to give context.)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ely, you could try the nose or py.test frameworks, which I
understand already support running tests in parallel.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
it__(self, colour='green'):
print("Spam spam spam LOVELY SPAM!!!")
self.colour = colour
def spam(self, n):
return "spam!"*n
# Add the extra method that we want.
Spam.eggs = a.eggs
So now you have three ways of doing something that shouldn't be done :)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
siderable extent, considerably; fairly, moderately,
tolerably"
I think it is absolutely wonderful that the English language has evolved
in such a way that "pretty" means both warlike and dainty :)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
traight Python.
> PS: In my eyes, Python 3000 is already a dinosaur.
We look forward to seeing your re-write. I'm sure all right-thinking
programmers will flock to your Python fork as soon as you start writing
it.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
#x27;re all talk.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
powerful as older words like "organ", "part",
"stuff", "bits", all of which have subtle differences of meaning. In the
same way that a native English speaker would never make the mistake of
using "organ" to refer to an unnamed mechanical device, so she would
never use "gadget" to refer to an unnamed body part.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
your promise to fork the language so all the right-
thinking people can follow you to the Promised Land.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
I don't believe Python's regex engine supports scoped flags, I think all
flags are global to the entire regex.
MRAB's regex engine does support scoped flags.
http://pypi.python.org/pypi/regex
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
is:
import sys
sys.version
What does it show?
(2) Show us the exact command you give on the command line that
successfully runs the script.
There may be more questions later, but this will do to start.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 27 Jan 2012 09:06:57 -0800, Emile van Sebille wrote:
> On 1/25/2012 9:14 PM Steven D'Aprano said...
>> In the
>> same way that a native English speaker would never make the mistake of
>> using "organ" to refer to an unnamed mechanical device, so she wou
bin-whin-bim-lim-bus-stop-F'tang-
F'tang-Olé-Biscuitbarrel.
> * Pie-Pie?
Or that one.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
rony.
However, you can fetch another module's globals by using:
vars(module)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
small part of them.
>
> I believe a '\x1a' byte marks the end of a text file. Maybe you've run
> into one of these.
That's Windows only, and only when reading in text mode.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
hard-coded path, and actually I think the
>> majority here is not using windows.
>>
> But I also think that the majority of people on here could change his
> script to run if they are not on Windows
Could, but won't, particularly since the error is so easy to spot without
ceptions that are contained in that tuple.
Both lists and tuples *are* single things in themselves. Both lists and
tuples are containers:
A list is a single thing that contains other things.
A tuple is a single thing that contains other things.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
idered
by some people a feature, not a bug, and in fact even in Python 3.2 the
same applies. The difference in 3.2 is that you can't *accidentally* use
old left-over .pyc files, you have to move and rename them before they
can be used as sourceless modules.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
ink of boxes as containers". What exactly are they
if not containers?
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
e.
Almost, but not quite.
The finally block is not guaranteed to execute if the try block never
exits -- infinite loops are still infinite loops.
Also, unlike sys.exit, os._exit doesn't work through the exception
mechanism, can't be caught, and simply exits immediately.
>>> i
source of the bug and make it harder to solve in the
long run. So the proper way to fix the problem is:
(1) Identify which variable is not a string.
(2) Find out why it becomes set to None.
(3) Fix it.
The first part is easy: insert this line before line 86:
print("fn, ln, sdob:", fn, l
way!"
And if you *do* know exactly what you are doing, you will probably decide
not to play this way also!
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
you call sys.path.extend(['a', 'b']) you get a path that looks
like ['fe', 'fi', 'fo', 'fum', 'a', 'b']. Calling "import spam" locates
some left over junk file, fi/spam.py or fi/spam.pyc, which doesn't
import, and you get an ImportError.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
hildren who have never programmed before?
Mathematicians?
Babies?
Rocket scientists?
Hunter-gatherers from the Kalahari desert?
My intuition tells me you have never even considered that intuition
depends on who is doing the intuiting.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 01 Feb 2012 23:19:57 -0800, Rainer Grimm wrote:
> You can do it more concise.
>
>>>> def isListOrString(p):
> ...return any((isinstance(p,list),isinstance(p,str)))
Or even more concisely still:
isinstance(p, (list, str))
--
Steven
--
http://mail.python
ass"
100 loops, best of 3: 0.238 usec per loop
steve@runes:~$ python -m timeit -s "L=range(3)" "for x in iter(L): pass"
100 loops, best of 3: 0.393 usec per loop
But of course the difference is only relatively significant, in absolute
terms nobody is going to notice an extra 0.1 or 0.2 microseconds.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 02 Feb 2012 19:11:53 +1100, John O'Hagan wrote:
> You're right, in fact, for me the surprise is that "t[1] +=" is
> interpreted as an assignment at all, given that for lists (and other
> mutable objects which use "+=") it is a mutation. Although as
1201 - 1300 of 15549 matches
Mail list logo