notorious pass by reference vs pass by value biting me in the backside
here. Proceeding in order.
I need to scan a list of strings. If one of the elements matches the
beginning of a search keyword, that element needs to snap to the front
of the list.
I achieved that this way:
for i in
Fillmore wrote:
>
> notorious pass by reference vs pass by value biting me in the backside
> here. Proceeding in order.
>
> I need to scan a list of strings. If one of the elements matches the
> beginning of a search keyword, that element needs to snap to the front
> of the list.
> I achieved t
On 2016-04-01 21:27, Fillmore wrote:
notorious pass by reference vs pass by value biting me in the backside
here. Proceeding in order.
I need to scan a list of strings. If one of the elements matches the
beginning of a search keyword, that element needs to snap to the front
of the list.
I achie
Give this a shot
def snap(keyword, words):
matches = [i for i, s in enumerate(words) if s.startswith(keyword)]
for i in matches:
lst.insert(0, lst.pop(i))
Your current implementation is reassigning the local variable ``mylist`` to
a new list inside the function.
O
On Fri, Apr 1, 2016 at 2:39 PM, Rob Gaddi
wrote:
> Fillmore wrote:
>> Nope, wrong! contrary to what I thought I had understood about how
>> parameters are passed in Python, the function is acting on a copy(!) and
>> my original list is unchanged.
>>
>
> Nope, that's not your problem. Your problem
On Fri, Apr 1, 2016 at 1:52 PM, Ian Kelly wrote:
> On Fri, Apr 1, 2016 at 2:39 PM, Rob Gaddi
> wrote:
> > Fillmore wrote:
> >> Nope, wrong! contrary to what I thought I had understood about how
> >> parameters are passed in Python, the function is acting on a copy(!) and
> >> my original list is
On 04/01/2016 01:27 PM, Fillmore wrote:
notorious pass by reference vs pass by value biting me in the backside
here. Proceeding in order.
It's only notorious for folks that don't understand that Python uses
neither. It also doesn't help when folks don't understand how
name-binding works.
On Fri, Apr 1, 2016 at 3:10 PM, Chris Kaynor wrote:
> The overall algorithm is O(n^2), as its doing a O(n) operation in a O(n)
> loop:
Depends on whether the OP expects to find only one match or
potentially multiple matches in the list. E did say "if one of the
elements matches".
If there are on
On 01/04/2016 21:27, Fillmore wrote:
notorious pass by reference vs pass by value biting me in the backside
here. Proceeding in order.
It is pass by object.
By definition your following analysis is wrong.
To my knowledge this has been discussed at least twice a year for the
past 15 years.
On Sat, 2 Apr 2016 07:27 am, Fillmore wrote:
>
> notorious pass by reference vs pass by value biting me in the backside
> here. Proceeding in order.
Python is NEITHER pass by reference nor pass by value.
Please read this:
http://import-that.dreamwidth.org/1130.html
before asking any additiona
On 04/01/2016 04:27 PM, Fillmore wrote:
notorious pass by reference vs pass by value biting me in the backside here.
Proceeding in order.
Many thanks to all of those who replied!
--
https://mail.python.org/mailman/listinfo/python-list
Fillmore wrote:
> I need to scan a list of strings. If one of the elements matches the
> beginning of a search keyword, that element needs to snap to the front
> of the list.
I know this post regards the function passing, but, on you specific problem,
can't you just ... sort the list with a cust
On Sat, Apr 2, 2016, 1:46 AM Vito De Tullio wrote:
> Fillmore wrote:
>
> > I need to scan a list of strings. If one of the elements matches the
> > beginning of a search keyword, that element needs to snap to the front
> > of the list.
>
> I know this post regards the function passing, but, on yo
Michael Selik wrote:
>> > I need to scan a list of strings. If one of the elements matches the
>> > beginning of a search keyword, that element needs to snap to the front
>> > of the list.
>>
>> I know this post regards the function passing, but, on you specific
>> problem,
>> can't you just ... s
Vito De Tullio wrote:
> Michael Selik wrote:
>
>>> > I need to scan a list of strings. If one of the elements matches the
>>> > beginning of a search keyword, that element needs to snap to the front
>>> > of the list.
>>>
>>> I know this post regards the function passing, but, on you specific
>>>
On 02/04/2016 06:51, Michael Selik wrote:
On Sat, Apr 2, 2016, 1:46 AM Vito De Tullio wrote:
Fillmore wrote:
I need to scan a list of strings. If one of the elements matches the
beginning of a search keyword, that element needs to snap to the front
of the list.
I know this post regards the
On Sat, Apr 2, 2016 at 6:32 AM Peter Otten <__pete...@web.de> wrote:
> Vito De Tullio wrote:
>
> > Michael Selik wrote:
> >
> >>> > I need to scan a list of strings. If one of the elements matches the
> >>> > beginning of a search keyword, that element needs to snap to the
> front
> >>> > of the l
On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:
> notorious pass by reference vs pass by value biting me in the backside
> here. Proceeding in order.
As others have pointed out, this is false dichotomy. There are other
possibilities than pass by reference and pass by value. Python
On Sat, Apr 2, 2016, at 15:28, Ned Batchelder wrote:
> On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:
> > notorious pass by reference vs pass by value biting me in the backside
> > here. Proceeding in order.
>
> As others have pointed out, this is false dichotomy. There are other
On 04/02/2016 12:54 PM, Random832 wrote:
On Sat, Apr 2, 2016, at 15:28, Ned Batchelder wrote:
On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:
notorious pass by reference vs pass by value biting me in the backside
here. Proceeding in order.
As others have pointed out, this is fal
On Sat, Apr 2, 2016, at 19:15, Ethan Furman wrote:
> Also, if "pass-by-value" is being used, even mutation of the passed
> object will not show up in the caller.
I disagree. I don't think the definition of pass-by-value implies this.
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, 3 Apr 2016 05:54 am, Random832 wrote:
> On Sat, Apr 2, 2016, at 15:28, Ned Batchelder wrote:
>> On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:
>> > notorious pass by reference vs pass by value biting me in the backside
>> > here. Proceeding in order.
>>
>> As others have po
22 matches
Mail list logo