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 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
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 rewrit
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 n
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
>>
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
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 obviousl
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
> s
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
--
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
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.
--
http://m
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 pro
> > 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
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 ''.jo
>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 thir
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 tha
[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[::-
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 i
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"))
> > ''
> repr(reversed("some string"))
> > ''
>
> This doesn't seem par
"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 o
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
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).
--
http://mail.python.org/mailman/listinfo/pyth
"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.
> 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
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
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"))
> ''
repr(reversed("some string"))
> ''
This doesn't seem particularly "pure" to me, either
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
"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?
>
>
>
> It has been my exper
"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 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 ofte
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,
up
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?
It has been my experience that Python has discouraging forums with
someo
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.
--
http://mail.python.o
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 i
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))
James>alist[::-1]
James> The latter, while more terse than alist.reversed(), is unnatural
James> and ugly compa
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 requi
Fredrik Lundh wrote:
> James Stroud wrote:
>
> > without requiring an iterator
>
> can we perhaps invent some more arbitrary constraints while we're at it?
>
>
>
I guess while I'm at it, this thread wouldn't have so much steam were
these idioms seemingly unpythonic:
"".join(reverse(
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-lifeti
Fredrik Lundh wrote:
> James Stroud wrote:
>
> > without requiring an iterator
>
> can we perhaps invent some more arbitrary constraints while we're at it?
>
>
>
Why does it seem to me that you are confusing convienience with
constraint, or are the two equivalent?
James
--
James Stroud
U
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
James Stroud wrote:
> without requiring an iterator
can we perhaps invent some more arbitrary constraints while we're at it?
--
http://mail.python.org/mailman/listinfo/python-list
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)
>>>
>
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 i
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 thi
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 t
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 th
> 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 t
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 ne
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
[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 profe
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"
>>
> 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
random.
"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
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
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
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 me
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
o
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
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
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. Ca
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?
--
http://mail.py
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 rem
62 matches
Mail list logo