Re: Multi-line string extension

Tim Peters (
Mon, 18 Apr 94 23:49:00 -0400

> > [tim]
> > ...nobody writes "i = 1+2" by hand...

> [larry]
> Though you do see 24*60*60 pretty often.

No argument; "doesn't buy much" isn't "doesn't buy anything".

The saving grace in Python is that typical Python users tend to package
functions in modules more than typical Perl users tend to modularize
functions in packages <wink>, and so in Python you'll _usually_ see
something like

import time
_SECONDS_PER_DAY = 24*60*60 # a module-level binding

def full_days_in_epoch(): # a function supplied by the module
return int(time.time() / _SECONDS_PER_DAY)

The constant expressions aren't optimized away, but module-level code is
executed only once per job (when the module is first imported), so the
constant expressions here are evaluated only once per job.

It's true that a user might pay a significant price for writing

return int(time.time()/(24*60*60))

today; seems rare in Python, though.

once<wink>-ly y'rs - tim

Tim Peters
not speaking for Kendall Square Research Corp