Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ethan Furman
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~

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ben Finney
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ben Finney
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. > -->

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Paul Moore
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Lele Gaifax
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 --

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Chris Angelico
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ethan Furman
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Chris Angelico
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) >>> >>>

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Peter Otten
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Nathan Ernst
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ethan Furman
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Paul Moore
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ethan Furman
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?

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Chris Angelico
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? >> >>

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Lele Gaifax
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 >

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
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: -->

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ethan Furman
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Chris Angelico
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

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Peter Otten
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

Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ethan Furman
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' -->

Re: stackoverflow question

2012-03-10 Thread Ethan Furman
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:

Re: stackoverflow question

2012-03-10 Thread Terry Reedy
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

Re: stackoverflow question

2012-03-10 Thread Owen Jacobson
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

Re: stackoverflow question

2012-03-10 Thread Ethan Furman
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

Re: stackoverflow question

2012-03-10 Thread Owen Jacobson
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).

stackoverflow question

2012-03-09 Thread Ethan Furman
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,

Re: stackoverflow question

2012-03-09 Thread Terry Reedy
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