On Sun, Jan 31, 2010 at 4:25 PM, Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote: > On Sun, 31 Jan 2010 15:40:36 -0800, Chris Rebert wrote: >> On Sun, Jan 31, 2010 at 2:36 PM, Steven D'Aprano >> <st...@remove-this-cybersource.com.au> wrote: >>> On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: >>>> In most functional languages you just name a function to access it and >>>> you do it ALL the time. >>>> >>>> for example, in if you have a function 'f' which takes two parameters >>>> to call the function and get the result you use: >>>> >>>> f 2 3 >>>> >>>> If you want the function itself you use: >>>> >>>> f >>> >>> How do you call a function of no arguments? >> >> It's not really a function in that case, it's just a named constant. >> (Recall that functions don't/can't have side-effects.) > > >>>> time.time(), random.random() > (1264983502.7505889, 0.29974255140479633) >>>> time.time(), random.random() > (1264983505.9283719, 0.74207867411026329) > > > They don't look terribly constant to me.
Those aren't functions in the pure functional programming sense; which is unsurprising since Python isn't a [pure] functional language. They both involve side-effects. time() does I/O to the clock chip to see what time it is, and random() uses and changes a global seed value variable (which, in a double-whammy, takes its initial value from time()). Pure functions must be referentially transparent [http://en.wikipedia.org/wiki/Referential_transparency_(computer_science)], and as you've demonstrated, neither of those Python functions qualify. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list