On Thu, 19 Oct 2006 20:07:27 -0400, Brad [EMAIL PROTECTED] wrote:
It has been my experience that Python has discouraging forums with
someone always calling someone else an idiot or telling them they are
awful in some way. I love Python, but the community is way too negative,
uptight and
Steven D'Aprano wrote:
On Thu, 19 Oct 2006 20:07:27 -0400, Brad wrote:
Steven D'Aprano wrote:
Gah!!! That's *awful* in so many ways.
Thanks... I'm used to hearing encouragement like that. After a while you
begin to believe that everything you do will be awful, so why even
bother trying?
On Fri, 20 Oct 2006 16:17:09 +0200, Fredrik Lundh wrote:
Tim N. van der Leeuw wrote:
In practice, the short-term fix would be to add a __str__ method to the
'reversed' object
so what should
str(reversed(range(10)))
do ?
The same as str(range(9, -1, -1)) perhaps?
I notice that
On Sat, 21 Oct 2006 01:58:33 -0500, Ron Adam wrote:
[You said from an earlier post...]
(That's a complaint I have about the dis module -- it prints its results,
instead of returning them as a string. That makes it hard to capture the
output for further analysis.)
I have a rewritten
Steven D'Aprano wrote:
On Sat, 21 Oct 2006 01:58:33 -0500, Ron Adam wrote:
[You said from an earlier post...]
(That's a complaint I have about the dis module -- it prints its results,
instead of returning them as a string. That makes it hard to capture the
output for further analysis.)
I
Fredrik Lundh [EMAIL PROTECTED]wrote:
8---
'a man a plan a canal panama' is not a palindrome
?
not if spaces count -
able was I ere I saw elba - is one - but its a tougher test...
- Hendrik
--
http://mail.python.org/mailman/listinfo/python-list
Brad [EMAIL PROTECTED] wrote:
Steven D'Aprano wrote:
Gah!!! That's *awful* in so many ways.
Thanks... I'm used to hearing encouragement like that. After a while you
begin to believe that everything you do will be awful, so why even
bother trying?
rant
It has been my experience that
rick wrote:
...
see that the sequence is reversed. Backwards is pure, simple and easy.
This is not so in Python and it should be.
foo[::-1] isn't pure, simple and easy?
It derives cleanly from the slice notation, it does exactly what you
want, and it even works with lists and tuples and any
On Fri, 20 Oct 2006 09:04:07 +1000, Steven D'Aprano wrote:
I agree -- the reversed() function appears to be an obvious case of purity
overriding practicality :(
str(reversed(some string))
'reversed object at 0xb7edca4c'
repr(reversed(some string))
'reversed object at 0xb7edca4c'
This
Paul wrote:
.join(sum(map(list,zip(s,s[len(s)/2:])),[]))
perhaps?
Not quite as elegant as a string.shuffle would be, am I right?
-Jeff
This email is intended only for the individual or entity to which it is
addressed. This email may contain information that is privileged, confidential
or
The Ruby approach makes sense to me as a human being.
http://happyfuncog.blogspot.com/2006/09/confessions-of-pseudo-misanthrope.html
The Python approach is not easy for me (as a human being) to remember.
I always thought we Pythonistas are already idiots but whenever I meet
a Rubist it ( the
Brad [EMAIL PROTECTED] wrote:
Do you have children? How would your child feel if he brought you
something he had made and you then told him it was awful in *sooo* many
ways.
If you're arguing that everything a child does and says should be rewarded,
I seriously doubt that you have any.
(on
Hendrik van Rooyen wrote:
'a man a plan a canal panama' is not a palindrome
not if spaces count -
which they do if you rely on a single reverse operation (my point was
that it takes a bit more work than that to check for a palindrome).
/F
--
Fredrik Lundh wrote:
Brad [EMAIL PROTECTED] wrote:
Do you have children? How would your child feel if he brought you
something he had made and you then told him it was awful in *sooo* many
ways.
If you're arguing that everything a child does and says should be rewarded...
I'm not
Demel, Jeff [EMAIL PROTECTED] wrote:
I've been programming professionally for over 10 years, and have never
once needed to reverse a string. Maybe it's a lack of imagination on my
part, but I can't think of a single instance this might be necessary.
I did want to reverse some strings once,
I V wrote:
On Fri, 20 Oct 2006 09:04:07 +1000, Steven D'Aprano wrote:
I agree -- the reversed() function appears to be an obvious case of purity
overriding practicality :(
str(reversed(some string))
'reversed object at 0xb7edca4c'
repr(reversed(some string))
'reversed object at
Tim N. van der Leeuw wrote:
In practice, the short-term fix would be to add a __str__ method to the
'reversed' object
so what should
str(reversed(range(10)))
do ?
and perhaps to all iterators too (so that trying to build a string from an
iterator would do the obvious thing).
all
[EMAIL PROTECTED] wrote:
The extended slice notation comes from the
numeric community though where they are probably all former FORTRAN
programmers. I think the concept of start, stop, step (or stride?) is
pretty common there.
Yep. I do a bit of numerical work and the meaning of abc[::-1]
Demel, Jeff wrote:
I've been programming professionally for over 10 years, and have never
once needed to reverse a string. Maybe it's a lack of imagination on my
part, but I can't think of a single instance this might be necessary.
Say you're using a function from a third-party library that
Demel, Jeff wrote:
I've been programming professionally for over 10 years, and have
never
once needed to reverse a string. Maybe it's a lack of imagination on
my part, but I can't think of a single instance this might be
necessary.
Carl wrote:
Say you're using a function from a third-party
Fredrik Lundh wrote:
Tim N. van der Leeuw wrote:
In practice, the short-term fix would be to add a __str__ method to the
'reversed' object
so what should
str(reversed(range(10)))
do ?
My idea was that reversed.__str__() would do something like the
equivalent of
John Salerno wrote:
I'm not steeped enough in daily programming to argue that it isn't
necessary, but my question is why do you need to reverse strings? Is it
something that happens often enough to warrant a method for it?
String reversal comes in handy when you do palindromes.
--
Carl Banks wrote:
Say you're using a function from a third-party library that finds the
first character in a string that meets some requirement. You need to
find the last such character.
You seem to imply that invoking a function on a reversed input is
somehow a generic solution to the
egbert wrote:
String reversal comes in handy when you do palindromes.
Yes, that's where the big bucks are, the Palindrome Industry.
It is the shortsightedness of the Python core developers that keeps the
palindrome related functions and algorithms out of the standard library
i.
--
egbert String reversal comes in handy when you do palindromes.
Which would by implication make it handy to have in a CS algorithms class
and not much else. ;-)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
On 20 Oct 2006 09:34:55 -0700, Istvan Albert [EMAIL PROTECTED] wrote:
Yes, that's where the big bucks are, the Palindrome Industry.
It is the shortsightedness of the Python core developers that keeps the
palindrome related functions and algorithms out of the standard library
+1 QOTW
--
Istvan Albert wrote:
Carl Banks wrote:
Say you're using a function from a third-party library that finds the
first character in a string that meets some requirement. You need to
find the last such character.
You seem to imply that invoking a function on a reversed input is
somehow a
On Thu, 19 Oct 2006 20:07:27 -0400, Brad wrote:
Steven D'Aprano wrote:
Gah!!! That's *awful* in so many ways.
Thanks... I'm used to hearing encouragement like that. After a while you
begin to believe that everything you do will be awful, so why even
bother trying?
Well obviously I hit
On Thu, 19 Oct 2006 22:22:34 -0300, Gabriel Genellina wrote:
(1) The name is bad. invert is not the same as reverse. Here's an
invert: 1/2 = 0.5. Your function falsely claims numbers aren't
invertable.
Dictionary.com
invert = to reverse in position, order, direction, or relationship.
Why can't Python have a reverse() function/method like Ruby?
Python:
x = 'a_string'
# Reverse the string
print x[::-1]
Ruby:
x = 'a_string'
# Reverse the string
print x.reverse
The Ruby approach makes sense to me as a human being. The Python
approach is not easy for me (as a human being) to
rick wrote:
Why can't Python have a reverse() function/method like Ruby?
I'm not steeped enough in daily programming to argue that it isn't
necessary, but my question is why do you need to reverse strings? Is it
something that happens often enough to warrant a method for it?
--
rick [EMAIL PROTECTED] writes:
Why can't Python have a reverse() function/method like Ruby?
Python:
x = 'a_string'
# Reverse the string
print x[::-1]
The Ruby approach makes sense to me as a human being. The Python
approach is not easy for me (as a human being) to remember. Can that
be
rick wrote:
The Ruby approach makes sense to me as a human being.
do the humans on your planet spend a lot of time reversing strings?
it's definitely not a very common thing to do over here.
anyway, if you do this a lot, why not define a helper function?
def reverse(s):
return
John Salerno wrote:
'm not steeped enough in daily programming to argue that it
sn't necessary, but my question is why do you need to
reverse strings? Is it something that happens often enough
to warrant a method for it?
I've been programming professionally for over 10 years, and have never
John Salerno wrote:
'm not steeped enough in daily programming to argue that it sn't
necessary, but my question is why do you need to reverse strings? Is it
something that happens often enough to warrant a method for it?
I've been programming professionally for over 10 years, and have never
John Salerno wrote:
rick wrote:
Why can't Python have a reverse() function/method like Ruby?
I'm not steeped enough in daily programming to argue that it isn't
necessary, but my question is why do you need to reverse strings? Is it
something that happens often enough to warrant a method
On 2006-10-19, Brad [EMAIL PROTECTED] wrote:
I'm home for lunch so my email addy is different.
No, it doesn't happen very often, but when I need to reverse
something (usually a list or a string). I can never remember
right of the top of my head how to do so in Python. I always
have to Google
Fredrik Lundh wrote:
rick wrote:
The Ruby approach makes sense to me as a human being.
do the humans on your planet spend a lot of time reversing strings? it's
definitely not a very common thing to do over here.
On our planet, we're all dyslexic. We tend to do things 'backwards' so
Demel, Jeff [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
John Salerno wrote:
P.S. How about a string.shuffle() method that splits the string in half
into two new strings str1 and str2, and then recompiles the string by
alternating one character from each str1 and str2 as it goes?
P.S. How about a string.shuffle() method that splits the string in half
into two new strings str1 and str2, and then recompiles the string by
alternating one character from each str1 and str2 as it goes? Like
shuffling cards. ;)
Well, for a true shuffling of a string, there's a
Dennis Lee Bieber wrote:
ONE usage... The old intro-to-programming Palindrome detector
becomes a very simple assignment given an easy means of reversing a
string (vs the expected loop comparing from the ends in to the center)
you mean like
s = a man a plan a canal panama
if list(s)
[EMAIL PROTECTED] wrote:
ONE usage... The old intro-to-programming Palindrome detector
becomes a very simple assignment given an easy means of
reversing a string (vs the expected loop comparing from
the ends in to the center)
Ok, let me re-phrase:
...[snip]...
I've been programming
John Salerno wrote:
rick wrote:
Why can't Python have a reverse() function/method like Ruby?
I'm not steeped enough in daily programming to argue that it isn't
necessary, but my question is why do you need to reverse strings?
It would provide symmetry for reversing any sequence
Demel, Jeff wrote:
Ok, let me re-phrase:
...[snip]...
I've been programming professionally for over 10 years, and have never
once needed to reverse a string *or detect a palindrome*. Maybe it's a
lack of imagination on my part, but I can't think of a single instance
this might be
Is this why the applicants I see that are fresh out of college
with their shiny new computer science degrees can't seem to
code their way out of a wet paper bag?
Well, there you go! Apparently, your wet paper bag has no
detect a palendrome exit. While you're installing such an
egress to
Demel, Jeff wrote:
P.S. How about a string.shuffle() method that splits the string in half
into two new strings str1 and str2, and then recompiles the string by
alternating one character from each str1 and str2 as it goes? Like
shuffling cards. ;)
Jeff,
To my mind that would be the
Tim Chase wrote:
Well, there you go! Apparently, your wet paper bag has no detect a
palendrome exit. While you're installing such an egress to your soggy
dead-tree satchel, you could also provide similar write a binary
Glad you guys are enjoying this. We're getting off-topic and I think
James Stroud wrote:
It would provide symmetry for reversing any sequence (without requiring
an iterator).
(1,2,3).reversed()
123.reversed()
[1,2,3].reversed()
That might infuriate those who regard strings as mischievous
sequences (ie. things which cause errors because you think you have
Paul Boddie wrote:
James Stroud wrote:
(1,2,3).reversed()
123.reversed()
[1,2,3].reversed()
I guess Python 2.5 has the reversed method of which you speak.
Not that I could find (as methods of any built in sequence type). 2.5
just has the reversed function that returns and iterator and so
James Stroud wrote:
Of course, I think str.join can operate on iterators, as Paul Rubin
suggests:
print ''.join(reversed(x))
This latter approach still seems a little clunky, though.
James
Slices can be named so you could do...
reverser = slice(None, None, -1)
James Stroud wrote:
without requiring an iterator
can we perhaps invent some more arbitrary constraints while we're at it?
/F
--
http://mail.python.org/mailman/listinfo/python-list
rick wrote:
Well, there you go! Apparently, your wet paper bag has no detect a
palendrome exit. While you're installing such an egress to your soggy
dead-tree satchel, you could also provide similar write a binary
Glad you guys are enjoying this. We're getting off-topic and I think my
Fredrik Lundh wrote:
James Stroud wrote:
without requiring an iterator
can we perhaps invent some more arbitrary constraints while we're at it?
/F
Why does it seem to me that you are confusing convienience with
constraint, or are the two equivalent?
James
--
James Stroud
On 2006-10-19, Fredrik Lundh [EMAIL PROTECTED] wrote:
James Stroud wrote:
without requiring an iterator
can we perhaps invent some more arbitrary constraints while
we're at it?
No letter G. I don't like them. They wet their nests.
--
Neil Cerutti
You only get a once-in-a-lifetime
Fredrik Lundh wrote:
James Stroud wrote:
without requiring an iterator
can we perhaps invent some more arbitrary constraints while we're at it?
/F
I guess while I'm at it, this thread wouldn't have so much steam were
these idioms seemingly unpythonic:
.join(reverse(x))
Neil Cerutti wrote:
On 2006-10-19, Fredrik Lundh [EMAIL PROTECTED] wrote:
James Stroud wrote:
without requiring an iterator
can we perhaps invent some more arbitrary constraints while
we're at it?
No letter G. I don't like them. They wet their nests.
The requirement for an iterator
James I guess while I'm at it, this thread wouldn't have so much steam
James were these idioms seemingly unpythonic:
James.join(reverse(x))
Jamesalist[::-1]
James The latter, while more terse than alist.reversed(), is unnatural
James and ugly compared to
On Thu, 19 Oct 2006 12:38:55 -0400, Brad wrote:
John Salerno wrote:
rick wrote:
Why can't Python have a reverse() function/method like Ruby?
I'm not steeped enough in daily programming to argue that it isn't
necessary, but my question is why do you need to reverse strings? Is it
Steven D'Aprano [EMAIL PROTECTED] writes:
''.join(list(reversed(some string)))
'gnirts emos'
''.join(reversed('some string')) should work, without building the
intermediate list.
I generally don't remember the ::-1 syntax so the above would occur to
me sooner.
--
Steven D'Aprano wrote:
Gah!!! That's *awful* in so many ways.
Thanks... I'm used to hearing encouragement like that. After a while you
begin to believe that everything you do will be awful, so why even
bother trying?
rant
It has been my experience that Python has discouraging forums with
At Thursday 19/10/2006 21:07, Brad wrote:
Gah!!! That's *awful* in so many ways.
It has been my experience that Python has discouraging forums with
someone always calling someone else an idiot or telling them they are
awful in some way. I love Python, but the community is way too negative,
Brad wrote:
John Salerno wrote:
rick wrote:
Why can't Python have a reverse() function/method like Ruby?
I'm not steeped enough in daily programming to argue that it isn't
necessary, but my question is why do you need to reverse strings? Is it
something that happens often enough to
62 matches
Mail list logo