Re: [Tutor] 'in-place' methods

2006-02-19 Thread Alan Gauld
[1] Every couple of years, I decide to learn Java, and start going through a book -- usually the same book. It doesn't go long before I say to my self, Gosh, why would I ever want to program this language, anyway? I've taught myself Java three times(*), first from the O'Reilly Nutshell book

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Brian van den Broek
Michael Broe said unto the world upon 17/02/06 03:57 PM: snip Second question. Do I really have to write the sort_print() function like this: def sort_print(L): L.sort() print L i.e. first perform the operation in-place, then pass the variable? Is this the

Re: [Tutor] 'in-place' methods

2006-02-18 Thread w chun
Perhaps you've seen this already, but since you are wrapping the print in a function, I suspect you want the original list to be unmodified. Thus, compare: def sort_print1(a_list): a_list.sort() print a_list def sort_print2(a_list): t = list(a_list)

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Terry Carroll
On Fri, 17 Feb 2006, Kent Johnson wrote: Ruby has an interesting approach to this - the names of mutating methods end with !. So it would be list.sort!() which gives a strong cue to what is happening. What a great idea! Hmm.. maybe Python could do this, too; and use some other characters

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Alan Gauld
Ruby has an interesting approach to this - the names of mutating methods end with !. So it would be list.sort!() which gives a strong cue to what What a great idea! Hmm.. maybe Python could do this, too; and use some other characters like $, @ and % to indicate if a name is a reference to a

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Terry Carroll
On Sun, 19 Feb 2006, Alan Gauld wrote: But don't even joke about it. It is pretty cringe-worthy, isn't it? Decorators are bad enough, no more line noise in Python. I was actually kind of sad to see that added. It struck me as the first grafted-on feature of Python that *felt* grafted-on.