How to del item of a list in loop?

2005-01-15 Thread skull
== 2: lst.remove(i) the result is: 1 2 >>> as you would see, '3' is missing. this problem is caused by 'lst.remove(i)'. apparently, 'marked-and-sweep' is a solution to deal with this issue. but I think there SHOULD BE more 'wise' trick. I wa

Re: How to del item of a list in loop?

2005-01-15 Thread skull
skull <[EMAIL PROTECTED]> writes: Thank you for your replys. lst[:] is did a solution, it makes a copy of list specially for iteration and removes items from the original one. but I still have an other thing to worry about coming with this way: does performance sucks when the list

Re: How to del item of a list in loop?

2005-01-15 Thread skull
n lst[:]: E2: for i in reversed(lst): print sys.getrefcount(i) ### E1 outputs: 4 4 4 E2 outputs: 3 3 3 It looks that the reversed does not make a copy of list in contrast with lst[:]. so should we regard: reversed is faster than lst[:]? I do not have any idea about why it is. - skull -- http://mail.python.org/mailman/listinfo/python-list

Re: Is the standard output thread-safe?

2006-03-12 Thread Skull
Fernando Rodríguez <[EMAIL PROTECTED]> writes: > Hi, > > Is the standard output thread-safe? Can I use print from several > threads without having to use a mutex? > > Thanks > > Check this: http://me.in-berlin.de/doc/python/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe fr