If you are asking how to get a variable to call a function each time it's 
accessed... Well that's kind of a weird request. I know you can create 
properties in a class that act like variables but you can do whatever you want 
behind the scenes, like calling the now() function on each access. A much more 
clear way to do this would be to create a function that calls the now function 
and just call your function whenever you want the value. Is there a specific 
reason why you would prefer to solve this without having to type 2 extra 
characters () and in turn make your code more readable and logical? The problem 
with the approach you hint at is that then the function call is implicit. What 
if someone else wanted to use your variable in a tight loop? They don't 
probably expect or want your variable to automatically update itself.

Also are you aware of the timeit module for dete

Perhaps I misunderstood your intent.

Sent from my iPhone

On Jul 17, 2010 at 1:32 AM, "Richard D. Moores" <rdmoo...@gmail.com> wrote:

> Please see <http://tutoree7.pastebin.com/azLrNL0n>
> 
> Foolishly, without thinking it through, I expected the 2 prints to
> show different times. I understood right away why they were identical,
> but then I began to wonder how to create an "alias" for
> "ctime()[11:20]" so I wouldn't have to keep typing or pasting it.
> "now" would be fine. But how to get it to execute ctime()?
> 
> Thanks,
> 
> Dick Moores
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to