> [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
b
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.
>> 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
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
> 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
Michael Broe said unto the world upon 17/02/06 03:57 PM:
> 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 id
Michael Broe wrote:
> I think I understand this sorting-a-list 'in place' stuff, and things
> of that kind (reversing for example); but I am finding it very
> difficult to get used to, since sorting a list doesn't return the
> sorted list as a value, but simply does the work as a side effect.
> is, I think you've hit on the answer: the default, if you will, is to
> perform operations in-place, to avoid the necessity of reassigning a
> list to it's sorted version, to give one example.
But that isn't necessary, you could just return a reference to the
sorted list, that is:
x = L.s
>I think I understand this sorting-a-list 'in place' stuff, and things
> of that kind (reversing for example); but I am finding it very
> difficult to get used to, since sorting a list doesn't return the
> sorted list as a value, but simply does the work as a side effect.
If its any consola
hi mike,
welcome to python. :-) your query is quite common amongst beginners,
and i have actually spend some time on this topic in my courses.
On 2/17/06, Michael Broe <[EMAIL PROTECTED]> wrote:
> I think I understand this sorting-a-list 'in place' stuff, and things
> of that kind (reversing fo
Michael Broe wrote:
>I think I understand this sorting-a-list 'in place' stuff, and things
>of that kind (reversing for example); but I am finding it very
>difficult to get used to, since sorting a list doesn't return the
>sorted list as a value, but simply does the work as a side effect.
>
I think I understand this sorting-a-list 'in place' stuff, and things
of that kind (reversing for example); but I am finding it very
difficult to get used to, since sorting a list doesn't return the
sorted list as a value, but simply does the work as a side effect.
The place where it really
12 matches
Mail list logo