Few questions about new features in Python 2.2

sebastien s.keim at laposte.net
Tue Oct 23 10:06:13 CEST 2001

I've tryed Python2.2b1 this week-end. 
I would thanks Python contributors, theses guys have done an
impressive job.

I know Python since 1.52 release. With 1.6, 2.0 and 2.1 except for
pydoc and nested scopes
my felling was something like "yes that's great but I have been able
to live without before".

But I'm asking myself how I have been able to live without:
- iterators and generators
- class and type unification
- properties
- new division (even if some desagree with me ;-) ) 
I think that all of this is not only new features but really an
improvement (maybe in the direction of orthogonality) in the
fundations of the Python language.

But there are little things that seems strange for me:

Why iterators can't be copied?
Something like:
MyIter = iter([1,2,3,4])
MyIter2 = iter(MyIter) 
doesn't provide a copy but a reference to the iterator
And that:
import copy
MyIter2 = copy.copy(MyIter)
Just doesn't work
But you can have the need to save an iterator position when you want
to try something and
retry other thing if the first attempt fail.
For sample I think Tim recipe for removing duplicate would need copy
to work with iterator.

How to overload builtins constructor?
I have tried something like:
class xxx (int):
	def __init__(self, x, y):
		int.__init__ (self, x*y)
That doesn't seem to work.

What is the goal for __floordiv__ ?
I doesn't understand why to have appended this special method.
For me with or without from __future__ import division, the new //
operator could
call the old __div__ method.
Or there is a pitfall that I haven't seen?


More information about the Python-list mailing list