Re: [Python-ideas] Allow function to return multiple values

2017-07-05 Thread Chris Barker
On Sun, Jun 25, 2017 at 6:20 PM, Mikhail V wrote: > And it reminded me times starting with Python and wondering > why I can't simply write something like: > > def move(x,y): > x = x + 10 > y = y + 20 > move(x,y) > > Instead of this: > > def move(x,y): > x1 = x + 10 > y1 = y + 20

Re: [Python-ideas] Allow function to return multiple values

2017-06-25 Thread Mikhail V
On 26 June 2017 at 01:14, [email protected] wrote: > IIRC I'm pretty sure the OP just didn't know about the existence of tuple > unpacking and the ability to use that to return multiple values. > Can be so, though it was not quite clear. The original OP's example function included same variables a

Re: [Python-ideas] Allow function to return multiple values

2017-06-25 Thread [email protected]
IIRC I'm pretty sure the OP just didn't know about the existence of tuple unpacking and the ability to use that to return multiple values. -- Ryan (ライアン) Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone elsehttp://refi64.com On Jun 25, 2017 at 6:09 PM, > wrote: joannah nanjek

Re: [Python-ideas] Allow function to return multiple values

2017-06-25 Thread Mikhail V
joannah nanjekye wrote: > [...] > >Today I was writing an example snippet for the book and needed to write a >function that returns two values something like this: > >def return_multiplevalues(num1, num2): > return num1, num2 > > I noticed that this actually returns a tuple of the values whic

Re: [Python-ideas] Allow function to return multiple values

2017-06-09 Thread Abe Dillon
No. You're right. I don't know why I thought strings were treated differently. On Jun 9, 2017 7:47 AM, "Mark E. Haase" wrote: > On Thu, Jun 8, 2017 at 4:27 PM, Abe Dillon wrote: > >> >>> a, *b = 1, 2, 3, 4, 5 # NOTE: Most itterables unpack starred >> variables as a list >> >>> type(b) >> >>

Re: [Python-ideas] Allow function to return multiple values

2017-06-09 Thread Mark E. Haase
On Thu, Jun 8, 2017 at 4:27 PM, Abe Dillon wrote: > >>> a, *b = 1, 2, 3, 4, 5 # NOTE: Most itterables unpack starred > variables as a list > >>> type(b) > > > >>> a, *b = "except strings" > >>> type(b) > > I was just playing around with this, and on Python 3.5.3, I see strings unpacked as li

Re: [Python-ideas] Allow function to return multiple values

2017-06-09 Thread joannah nanjekye
Thanks Abe for the insight. On Thu, Jun 8, 2017 at 11:27 PM, Abe Dillon wrote: > Welcome to the group, Joannah! > > Now that you've been introduced to packing and unpacking in Python, I > would suggest learning the complete syntax, because it's a very useful > feature. > > >>> a, b = "hi" # you

Re: [Python-ideas] Allow function to return multiple values

2017-06-08 Thread Abe Dillon
Welcome to the group, Joannah! Now that you've been introduced to packing and unpacking in Python, I would suggest learning the complete syntax, because it's a very useful feature. >>> a, b = "hi" # you can unpack any iterable >>> a 'h' >>> b 'i' >>> a, b = 1, 2 # this is the same as: a, b = (

Re: [Python-ideas] Allow function to return multiple values

2017-06-08 Thread joannah nanjekye
Thanks for response on automatic tuple unpack. My bad I dint know about this all along. Infact this works same way Go does. I have been analyzing why we would really need such a function (allow function to return multiple types) in python given we have this feature( automatic tuple unpack) and hav

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Mark Lawrence via Python-ideas
On 02/06/2017 01:11, Steven D'Aprano wrote: Hi Joannah, and welcome! On Thu, Jun 01, 2017 at 05:17:49PM +0300, joannah nanjekye wrote: [...] My proposal is we provide a way of functions returning multiple values. This has been implemented in languages like Go and I have found many cases where

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Steven D'Aprano
Hi Joannah, and welcome! On Thu, Jun 01, 2017 at 05:17:49PM +0300, joannah nanjekye wrote: [...] > My proposal is we provide a way of functions returning multiple values. > This has been implemented in languages like Go and I have found many cases > where I needed and used such a functionality. I

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Terry Reedy
On 6/1/2017 10:17 AM, joannah nanjekye wrote: Today I was writing an example snippet for the book and needed to write a function that returns two values something like this: def return_multiplevalues(num1, num2): return num1, num2 I noticed that this actually returns a tuple of the va

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Ethan Furman
On 06/01/2017 07:17 AM, joannah nanjekye wrote: Today I was writing an example snippet for the book and needed to write a function that returns two values something like this: def return_multiplevalues(num1, num2): return num1, num2 I noticed that this actually returns a tuple of the

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Thomas Nyberg
On 06/01/2017 07:17 AM, joannah nanjekye wrote: > a function that returns two values something like this: > > def return_multiplevalues(num1, num2): > return num1, num2 > > I noticed that this actually returns a tuple of the values which I did > not want in the first place.I wanted python t

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread אלעזר
What is the difference between returning a tuple and returning two values? I think at least theoretically it's different wording for precisely the same thing. Elazar בתאריך יום ה׳, 1 ביונ' 2017, 17:21, מאת Markus Meskanen ‏< [email protected]>: > Why isn't a tuple enough? You can do autom

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Markus Meskanen
Why isn't a tuple enough? You can do automatic tuple unpack: v1, v2 = return_multiplevalues(1, 2) On Jun 1, 2017 17:18, "joannah nanjekye" wrote: Hello Team, I am Joannah. I am currently working on a book on python compatibility and publishing it with apress. I have worked with python for

[Python-ideas] Allow function to return multiple values

2017-06-01 Thread joannah nanjekye
Hello Team, I am Joannah. I am currently working on a book on python compatibility and publishing it with apress. I have worked with python for a while we are talking about four years. Today I was writing an example snippet for the book and needed to write a function that returns two values somet