On 12/07/2017 10:28 AM, Ethan Furman wrote:
The simple answer is No, and all the answers agree on that point.
It does beg the question of what an identity function is, though.
Thankfully, Paul answered that question with a good explanation*.
Thanks, everyone, for the discussion.
--
~Ethan~
Nathan Ernst writes:
> There is a built-in identity function in Python. The function is called
> 'id'.
It should be clear from the rest of the thread. But, to be explicit:
That's not what is meant by “identity function”, and the Python ‘id’
function is not an identity
Ethan Furman writes:
> My contention is that an identity function is a do-nothing function
> that simply returns what it was given:
>
> --> identity(1)
> 1
>
> --> identity('spam')
> 'spam'
These seem good to me. One argument given, the same result returned.
> -->
On 7 December 2017 at 20:35, Chris Angelico wrote:
> Because it's impossible to return multiple values. IMO the "identity
> function" is defined only in terms of one single argument, so all of
> this is meaningless.
Indeed, this is the key point. The Python language only allows
Chris Angelico writes:
> On Fri, Dec 8, 2017 at 6:29 AM, Lele Gaifax wrote:
>> Chris Angelico writes:
>>
>>> On Fri, Dec 8, 2017 at 5:53 AM, Peter Otten <__pete...@web.de> wrote:
Hm, what does -- and what should --
On Fri, Dec 8, 2017 at 8:30 AM, Lele Gaifax wrote:
> Chris Angelico writes:
>
>> On Fri, Dec 8, 2017 at 6:29 AM, Lele Gaifax wrote:
>>> Chris Angelico writes:
>>>
On Fri, Dec 8, 2017 at 5:53 AM, Peter Otten
On 12/07/2017 12:24 PM, Peter Otten wrote:
identity((a, b, c))
calls identity() with one argument whereas
identity(a, b, c)
calls identity() with three arguments. That's certainly an effect; you just
undo it with your test for len(args) == 1. That means that your identity()
function throws
On Fri, Dec 8, 2017 at 7:25 AM, Ned Batchelder wrote:
> On 12/7/17 2:41 PM, Ethan Furman wrote:
>>
>> On 12/07/2017 11:23 AM, Ned Batchelder wrote:
>>>
>>> On 12/7/17 1:28 PM, Ethan Furman wrote:
>>
>>
--> identity('spam', 'eggs', 7)
('spam', 'eggs', 7)
>>>
>>>
On 12/7/17 2:41 PM, Ethan Furman wrote:
On 12/07/2017 11:23 AM, Ned Batchelder wrote:
On 12/7/17 1:28 PM, Ethan Furman wrote:
--> identity('spam', 'eggs', 7)
('spam', 'eggs', 7)
I don't see why this last case should hold. Why does the function
take more than one argument? And if it
Ethan Furman wrote:
> On 12/07/2017 10:53 AM, Peter Otten wrote:
>> Ethan Furman wrote:
>>
>>> The simple answer is No, and all the answers agree on that point.
>>>
>>> It does beg the question of what an identity function is, though.
>>>
>>> My contention is that an identity function is a
There is a built-in identity function in Python. The function is called
'id'. See https://docs.python.org/3/library/functions.html#id Note that
this will not behave the same across different Python runtimes. e.g.
CPython, IronPython or Jython all implement this differently.
An example:
Python
On 12/07/2017 11:46 AM, Paul Moore wrote:
On 7 December 2017 at 18:28, Ethan Furman wrote:
The simple answer is No, and all the answers agree on that point.
It does beg the question of what an identity function is, though.
My contention is that an identity function is a
On 7 December 2017 at 18:28, Ethan Furman wrote:
> The simple answer is No, and all the answers agree on that point.
>
> It does beg the question of what an identity function is, though.
>
> My contention is that an identity function is a do-nothing function that
> simply
On 12/07/2017 11:23 AM, Ned Batchelder wrote:
On 12/7/17 1:28 PM, Ethan Furman wrote:
--> identity('spam', 'eggs', 7)
('spam', 'eggs', 7)
I don't see why this last case should hold. Why does the function take more
than one argument? And if it does, then
why doesn't it work like this?
On Fri, Dec 8, 2017 at 6:29 AM, Lele Gaifax wrote:
> Chris Angelico writes:
>
>> On Fri, Dec 8, 2017 at 5:53 AM, Peter Otten <__pete...@web.de> wrote:
>>>
>>> Hm, what does -- and what should --
>>>
>>> identity(('spam', 'eggs', 7))
>>>
>>> produce?
>>
>>
Chris Angelico writes:
> On Fri, Dec 8, 2017 at 5:53 AM, Peter Otten <__pete...@web.de> wrote:
>>
>> Hm, what does -- and what should --
>>
>> identity(('spam', 'eggs', 7))
>>
>> produce?
>
> The same thing. And so should identity((('spam', 'eggs', 7))) and
>
On 12/7/17 1:28 PM, Ethan Furman wrote:
The simple answer is No, and all the answers agree on that point.
It does beg the question of what an identity function is, though.
My contention is that an identity function is a do-nothing function
that simply returns what it was given:
-->
On 12/07/2017 10:53 AM, Peter Otten wrote:
Ethan Furman wrote:
The simple answer is No, and all the answers agree on that point.
It does beg the question of what an identity function is, though.
My contention is that an identity function is a do-nothing function that
simply returns what it
On Fri, Dec 8, 2017 at 5:53 AM, Peter Otten <__pete...@web.de> wrote:
> Ethan Furman wrote:
>
>> The simple answer is No, and all the answers agree on that point.
>>
>> It does beg the question of what an identity function is, though.
>>
>> My contention is that an identity function is a
Ethan Furman wrote:
> The simple answer is No, and all the answers agree on that point.
>
> It does beg the question of what an identity function is, though.
>
> My contention is that an identity function is a do-nothing function that
> simply returns what it was given:
>
> --> identity(1)
> 1
The simple answer is No, and all the answers agree on that point.
It does beg the question of what an identity function is, though.
My contention is that an identity function is a do-nothing function that simply
returns what it was given:
--> identity(1)
1
--> identity('spam')
'spam'
-->
Terry Reedy wrote:
Thanks for the review, Terry!
On 3/9/2012 5:10 PM, Ethan Furman wrote:
http://stackoverflow.com/q/9638921/208880
If anyone here is willing to take a look at it and let me know if I did
not write it well, I would appreciate the feedback
Here's the question text:
On 3/10/2012 11:56 AM, Ethan Furman wrote:
I'm writing a metaclass to do some cool stuff, and part of its
processing is to check that certain attributes exist when the class is
created. Some of these are mutable, and would normally be set in
`__init__`, but since `__init__` isn't run until the
On 2012-03-09 22:10:18 +, Ethan Furman said:
Hey all!
I posted a question/answer on SO earlier, but there seems to be some
confusion around either the question or the answer (judging from the
comments).
http://stackoverflow.com/q/9638921/208880
If anyone here is willing to take a look
Owen Jacobson wrote:
On 2012-03-09 22:10:18 +, Ethan Furman said:
Hey all!
I posted a question/answer on SO earlier, but there seems to be some
confusion around either the question or the answer (judging from the
comments).
http://stackoverflow.com/q/9638921/208880
If anyone here is
On 2012-03-10 22:21:55 +, Ethan Furman said:
Owen Jacobson wrote:
On 2012-03-09 22:10:18 +, Ethan Furman said:
Hey all!
I posted a question/answer on SO earlier, but there seems to be some
confusion around either the question or the answer (judging from the
comments).
Hey all!
I posted a question/answer on SO earlier, but there seems to be some
confusion around either the question or the answer (judging from the
comments).
http://stackoverflow.com/q/9638921/208880
If anyone here is willing to take a look at it and let me know if I did
not write it well,
On 3/9/2012 5:10 PM, Ethan Furman wrote:
Hey all!
I posted a question/answer on SO earlier, but there seems to be some
confusion around either the question or the answer (judging from the
comments).
http://stackoverflow.com/q/9638921/208880
If anyone here is willing to take a look at it and
28 matches
Mail list logo