On Dec 24, 2:15 am, Roy Smith <r...@panix.com> wrote:
> I know this is not quite the same thing, but it's interesting to look at
> what django (and mongoengine) do in their model definitions, prompted by
> your time.time() example.  You can do declare a model field something
> like:
>
> class Foo(models.Model):
>    timestamp = DateTimeField(default=datetime.utcnow)
>
> Now, when you create a Foo, if you don't supply a timestamp, it
> generates one by calling utcnow() for you.  Very handy.
>
> I'm not arguing that Python should do that, just pointing out an example
> of where late binding is nice.

There is absolutely nothing stopping you from writing functions now
with that behaviour. All Python functions are "early binding, late
calling" with their arguments, if you treat the arguments as callables
within the function body.



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to