Python and Ruby

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon Feb 1 01:25:44 CET 2010


On Sun, 31 Jan 2010 15:40:36 -0800, Chris Rebert wrote:

> On Sun, Jan 31, 2010 at 2:36 PM, Steven D'Aprano
> <steve at 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.


There is a difference between a function that does "give me whatever 
value is specified by a fixed description" and a function that does "give 
me a fixed value".



-- 
Steven



More information about the Python-list mailing list