PEP 255: Simple Generators

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Jun 21 01:02:32 EDT 2001


David Bolen wrote:
> 
>     def f():
>         return UserList.UserList([1,2,3])

But f isn't *creating* an instance here, it's just passing
on the one created by calling UserList.UserList(). If you
were to look at the definition of the latter, you would
find that it was defined using a "class" statement, making
it rather clear what sort of thing it is.

Similarly, there's nothing wrong with

  def f():
    return g()

  generator g():
    ...

Even though f happens to return a generator-iterator
when you call it, that doesn't mean I think it needs 
a special syntax.

> Eventually this could devolve into
> the point elsewhere in the thread of wanting defint rather than def
> for functions returning an integer.

No, it couldn't -- at least, not to anyone who really
understands what I'm saying.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list