[TriPython] Massaging list
Rex Dwyer
rexadwyer at gmail.com
Thu Aug 12 07:23:57 EDT 2021
#1. It’s rare to need to explicitly copy a list. Are you transforming each
element of the list? Consider using map(f,lis).
On Wed, Aug 11, 2021 at 12:00 PM <trizpug-request at python.org> wrote:
> Send TriZPUG mailing list submissions to
> trizpug at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mail.python.org/mailman/listinfo/trizpug
> or, via email, send a message with subject or body 'help' to
> trizpug-request at python.org
>
> You can reach the person managing the list at
> trizpug-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of TriZPUG digest..."
> Today's Topics:
>
> 1. Editing a list in a function (Mauricio Tavares)
>
>
>
> ---------- Forwarded message ----------
> From: Mauricio Tavares <raubvogel at gmail.com>
> To: "Triangle (North Carolina) Python Users Group (formerly TriZPUG)" <
> TriZPUG at python.org>
> Cc:
> Bcc:
> Date: Wed, 11 Aug 2021 10:38:11 -0400
> Subject: [TriPython] Editing a list in a function
> Thought process question: I have a list I want to massage a list
>
> def massage_list(thelist):
> # Do things
>
> inputlist = [...]
>
> If I want to preserve the original list, would it be more logical if
>
> 1. massage_list() returns new list. If you want the output to be
> applied to inputlist, you have to do something like
>
> inputlist = massage_list(inputlist)
>
> 2. You create a new list which is a deepcopy() of inputlist, and then
> feed it to massage_list()
>
> I am leaning towards #1 (function creates things which are returned)
> but if #2 makes more sense, do let me know before I go too far.
>
> _______________________________________________
> TriZPUG mailing list
> TriZPUG at python.org
> https://mail.python.org/mailman/listinfo/trizpug
> http://tripython.org is the Triangle Python Users Group
>
--
Rex A. Dwyer
-------------- next part --------------
#1.** It***s rare to need to explicitly copy a list. Are you transforming
each element of the list? Consider using map(f,lis).
On Wed, Aug 11, 2021 at 12:00 PM <[1]trizpug-request at python.org> wrote:
Send TriZPUG mailing list submissions to
** ** ** ** [2]trizpug at python.org
To subscribe or unsubscribe via the World Wide Web, visit
** ** ** ** [3]https://mail.python.org/mailman/listinfo/trizpug
or, via email, send a message with subject or body 'help' to
** ** ** ** [4]trizpug-request at python.org
You can reach the person managing the list at
** ** ** ** [5]trizpug-owner at python.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of TriZPUG digest..."
Today's Topics:
** **1. Editing a list in a function (Mauricio Tavares)
---------- Forwarded message ----------
From:**Mauricio Tavares <[6]raubvogel at gmail.com>
To:**"Triangle (North Carolina) Python Users Group (formerly TriZPUG)"
<[7]TriZPUG at python.org>
Cc:**
Bcc:**
Date:**Wed, 11 Aug 2021 10:38:11 -0400
Subject:**[TriPython] Editing a list in a function
Thought process question: I have a list I want to massage a list
def massage_list(thelist):
** ** # Do things
inputlist = [...]
If I want to preserve the original list, would it be more logical if
1. massage_list() returns new list. If you want the output to be
applied to inputlist, you have to do something like
inputlist = massage_list(inputlist)
2. You create a new list which is a deepcopy() of inputlist, and then
feed it to massage_list()
I am leaning towards #1 (function creates things which are returned)
but if #2 makes more sense, do let me know before I go too far.
_______________________________________________
TriZPUG mailing list
[8]TriZPUG at python.org
[9]https://mail.python.org/mailman/listinfo/trizpug
[10]http://tripython.org is the Triangle Python Users Group
--
Rex A. Dwyer
References
Visible links
1. mailto:trizpug-request at python.org
2. mailto:trizpug at python.org
3. https://mail.python.org/mailman/listinfo/trizpug
4. mailto:trizpug-request at python.org
5. mailto:trizpug-owner at python.org
6. mailto:raubvogel at gmail.com
7. mailto:TriZPUG at python.org
8. mailto:TriZPUG at python.org
9. https://mail.python.org/mailman/listinfo/trizpug
10. http://tripython.org/
More information about the TriZPUG
mailing list