[EMAIL PROTECTED] wrote:
do things right is my fundamental beef with Python.
Dispite claims, I don't believe Python's designers have
a monopoly on the definition of right.
This hammer is stupid. It's very uncomfortable, and
it's not hard and heavy enough to get the nails into
the wall.
It
Alex Martelli wrote:
I think you mean volatile or mutable rather than transient? transient
is not a keyword in C++, while both volatile and mutable are, with
different semantics. Anyway, C++'s 'const' is a mess both theoretical
AND practical. I'm told Ruby's object-freezing works better
Magnus Lycka [EMAIL PROTECTED] wrote:
...
I think you mean volatile or mutable rather than transient? transient
...
Right, volatile it is. It's really great that I can program so much
Python now that I forget my C++! :) Thanks Alex (both for reminding me
of forgotten C++ syntax and for
Magnus Lycka [EMAIL PROTECTED] writes:
As I understand it, Ruby's ! isn't quite like procedure in Pascal,
or not const in C/C++, but rather a marker for surprising behaviour,
In my experience, ! is used in Ruby much the same way as it is in
Scheme, signifying that a method/function is called
Alex Martelli wrote:
I don't think these headaches and difficulties justify dumping the whole
field of reasoning about programs, nor the subfield of PbC. The concept
of immutable is really just a tiny corner of these fields, and it's a
long way from being the hardest or most problematic one
Magnus Lycka [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
I don't think these headaches and difficulties justify dumping the whole
field of reasoning about programs, nor the subfield of PbC. The concept
of immutable is really just a tiny corner of these fields, and it's a
long way from
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
OKB (not okblacke) wrote:
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
[ ... ]
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in
Sion Arrowsmith wrote:
1. sort() in place makes sense in terms of space, and is not
completely unintuitive.
2. reverse() should do what sort() does.
3. The inexperienced user is most likely to expect the above
code to print 3 2 1 3 2 1, and is more likely to have
difficulty
[EMAIL PROTECTED] wrote:
a reminder that the change is inplace. How arrogant! While
I'm sure the designers had kindly intentions. my memory, though
bad, is not that bad, and I object to being forced to write code
that is more clunky than need be, because the designers thought
they needed to
[EMAIL PROTECTED] wrote:
Alex Martelli wrote:
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
...
intuitive seems to be a very subjective matter, depends on once
background etc :-)
That's a strong point of Ruby, actually -- allowing an exclamation mark
at the end of a method name, which
Magnus Lycka [EMAIL PROTECTED] wrote:
...
indicate that the method is a mutator. So, you can have a.reverse [NOT
mutating a since no !] _and_ a.reverse! [mutating a]. Probably too much
of a change even for Python 3000, alas... but, it DOES make it obvious
when an object's getting mutated,
Magnus Lycka:
Except when it isn't obvious. What constitutes mutation of an object?
C++ handles this with 'const', and lets the programmer cheat by using
transient member variables, since there are cases when you actually
want to mutate objects a little, but claim that you don't...
Ruby
Magnus Lycka wrote:
[EMAIL PROTECTED] wrote:
a reminder that the change is inplace. How arrogant! While
I'm sure the designers had kindly intentions. my memory, though
bad, is not that bad, and I object to being forced to write code
that is more clunky than need be, because the
Neil Hodgson [EMAIL PROTECTED] wrote:
Magnus Lycka:
Except when it isn't obvious. What constitutes mutation of an object?
C++ handles this with 'const', and lets the programmer cheat by using
transient member variables, since there are cases when you actually
want to mutate objects a
[EMAIL PROTECTED] wrote:
do things right is my fundamental beef with Python.
Dispite claims, I don't believe Python's designers have
a monopoly on the definition of right.
I think raymond's post more correctly described it. Rather than do
things right, it is more the world view of python, just
[EMAIL PROTECTED] (Alex Martelli) writes:
Neil Hodgson [EMAIL PROTECTED] wrote:
Ruby uses '!' not for mutation but to indicate surprising or
destructive mutation. If it was placed on all mutators, code would be
full of '!'s. '!' is less common on methods that modify the receiver
than on
Magnus Lycka wrote:
Actually, I guess it's possible that sorted() is done so
that it works like below, but I don't think pre-sorted()
versions of Python support keyword arguments to list.sort()
anyway...
def sorted(l, *p, **kw): s=l[:];s.sort(*p, **kw);return s
One part you missed, sorted
Magnus Lycka wrote:
sorted_l = l.sort()
and while sorted_l would contain what one might expect, it
would in fact just be another name referencing exactly the
same sorted list as l, and it would probably be surprising
that l was also sorted, and that subsequent changes would
show up in both
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it to first print a in reverse
Fredrik Lundh wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it to first print a in reverse then a as it was.
a=[1,2,3]
I expect it to
[EMAIL PROTECTED] wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it to first print a in reverse then a as it was.
a=[1,2,3]
I
[EMAIL PROTECTED] wrote:
Since python's '=' is just name binding and that most objects(other
than those like int/float/string?) are mutable, I don't quite
understand why this is a gotcha that is so worrying.
a = [1,2,3]
a.sorted()
b = a
even an entry level python programmer can't expect
[EMAIL PROTECTED] wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it to first print a in reverse then a as it was.
a=[1,2,3]
I expect it to print
3
2
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it to first print a in reverse then a as it was.
a=[1,2,3]
Still don't see why even you ask it again.
fyi, I'm not [EMAIL PROTECTED] , and I've
never, as far I know, posted from readfreenews.net
/F
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
Still don't see why even you ask it again.
fyi, I'm not [EMAIL PROTECTED] , and I've
never, as far I know, posted from readfreenews.net
I have no idea what you are talking about. I read this list through
Google's group and I saw two of the same post. Google
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it to first print a in reverse then a as it was.
a=[1,2,3]
On Tue, 22 Nov 2005 08:53:07 -0800, rurpy wrote:
I am not a complete newb at python, but I am still pretty new.
I too thought immediately that the output should be 3,2,1, 1,2,3.
What you are saying is that a.reverse() should *both* change a in place
*and* return a reference to the same list.
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it to first print a in reverse then a as
Steven D'Aprano wrote:
There are four possibilities for a construction like list.sort():
(1) sort the list in place and return a reference to the same list;
(2) sort the list in place and return a copy of the same list;
(3) sort the list in place and return None;
(4) don't sort in place and
OKB (not okblacke) wrote:
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
so what would an entry-level Python programmer expect from this
piece of code?
for item in a.reverse():
print item
for item in a.reverse():
print item
I would expect it
Steven D'Aprano [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Tue, 22 Nov 2005 08:53:07 -0800, rurpy wrote:
I am not a complete newb at python, but I am still pretty new.
I too thought immediately that the output should be 3,2,1, 1,2,3.
What you are saying is that
[EMAIL PROTECTED] writes:
I think this is just another (admittedly minor) case of Python's
designers using Python to enforce some idea of programming
style purity.
You say that as if it were a bad thing.
mike
--
Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/
Mike Meyer wrote:
[EMAIL PROTECTED] writes:
I think this is just another (admittedly minor) case of Python's
designers using Python to enforce some idea of programming
style purity.
You say that as if it were a bad thing.
I would say interesting thing. As it seems that quite some people
Mike Meyer wrote:
[EMAIL PROTECTED] writes:
I think this is just another (admittedly minor) case of Python's
designers using Python to enforce some idea of programming
style purity.
You say that as if it were a bad thing.
Well, there are many languages that promote a specific
style of
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
...
intuitive seems to be a very subjective matter, depends on once
background etc :-)
That's a strong point of Ruby, actually -- allowing an exclamation mark
at the end of a method name, which conventionally is always used to
indicate that the
[EMAIL PROTECTED] wrote:
...
language, yea, I guess I think it's bad. A general
purpose language should strive to support as wide a
varity of styles as possible.
Definitely NOT Python's core design principle, indeed the reverse of it.
But this is getting rather off-topic.
Yep. If you
Alex Martelli wrote:
[EMAIL PROTECTED] wrote:
...
language, yea, I guess I think it's bad. A general
purpose language should strive to support as wide a
varity of styles as possible.
Definitely NOT Python's core design principle, indeed the reverse of it.
Priciples are fine if not
Alex Martelli wrote:
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
...
intuitive seems to be a very subjective matter, depends on once
background etc :-)
That's a strong point of Ruby, actually -- allowing an exclamation mark
at the end of a method name, which conventionally is always
Alex Martelli wrote:
[EMAIL PROTECTED] wrote:
...
language, yea, I guess I think it's bad. A general
purpose language should strive to support as wide a
varity of styles as possible.
Definitely NOT Python's core design principle, indeed the reverse of it.
Priciples are fine if not
[EMAIL PROTECTED] wrote:
Steven D'Aprano wrote:
There are four possibilities for a construction like list.sort():
(1) sort the list in place and return a reference to the same list;
(2) sort the list in place and return a copy of the same list;
(3) sort the list in place and return None;
(4)
[EMAIL PROTECTED] wrote:
most built-in function/method don't return the object but None. This
I believe is the language creator's preference for everything being
explicit.
The list methods .sort() and .reverse() don't create copies,
but rather change the existing object. The reson for this is
Shi Mu wrote:
Got confused by the following code:
a
[6, 3, 1]
b
[4, 3, 1]
c
{1: [[6, 3, 1], [4, 3, 1]], 2: [[6, 3, 1]]}
c[2].append(b.sort())
c
{1: [[6, 3, 1], [1, 3, 4]], 2: [[6, 3, 1], None]}
#why c can not append the sorted b??
In python 2.4, you can use the sorted() builtin
Shi Mu wrote:
Got confused by the following code:
a
[6, 3, 1]
b
[4, 3, 1]
c
{1: [[6, 3, 1], [4, 3, 1]], 2: [[6, 3, 1]]}
c[2].append(b.sort())
c
{1: [[6, 3, 1], [1, 3, 4]], 2: [[6, 3, 1], None]}
#why c can not append the sorted b??
In python 2.4, you can use the sorted() builtin
Got confused by the following code:
a
[6, 3, 1]
b
[4, 3, 1]
c
{1: [[6, 3, 1], [4, 3, 1]], 2: [[6, 3, 1]]}
c[2].append(b.sort())
c
{1: [[6, 3, 1], [1, 3, 4]], 2: [[6, 3, 1], None]}
#why c can not append the sorted b??
b.sort()
b
[1, 3, 4]
--
Shi Mu wrote:
Got confused by the following code:
a
[6, 3, 1]
b
[4, 3, 1]
c
{1: [[6, 3, 1], [4, 3, 1]], 2: [[6, 3, 1]]}
c[2].append(b.sort())
c
{1: [[6, 3, 1], [1, 3, 4]], 2: [[6, 3, 1], None]}
#why c can not append the sorted b??
b.sort()
b
[1, 3, 4]
most built-in
Shi Mu [EMAIL PROTECTED] writes:
#why c can not append the sorted b??
Because sort() doesn't return anything?
According to the library reference:
7) The sort() and reverse() methods modify the list in place for
economy of space when sorting or reversing a large list. To remind you
that they
47 matches
Mail list logo