Alan Gauld wrote:
> "Terry Carroll" <[EMAIL PROTECTED]> wrote
>
>> if Y in X:
>
> FWIW I believe that 'in' did only work for single characters up until
> version 2.X so your ideas may have been based on experiences with
> an earlier Python version.
Yes, it changed in Python 2.3.
Kent
"Terry Carroll" <[EMAIL PROTECTED]> wrote
> if Y in X:
>
> Which is much more elegant/pythonic; but I didn't know you could do
> that
> with one string over another. For some reason, I had thought Y
> would have
> to exactly match one iterable element in X (e.g., one element of a
> list,
>
On Tue, 24 Jul 2007, wesley chun wrote:
> i don't have any time myself either (getting ready for OSCON talk),
> but i'm not sure what terry's OP was about... looking for a
> well-written piece of code, a faster-performing snippet, or both? i
> think he was just unsatissfied with his 1st attempt.
> any() and all() also short-circuit, and they move the iteration out of
> Python into the C runtime. My guess is the solutions with any() and
> all() and equivalent hoisting of string.printable will be faster than
> yours, but I don't want to take the time to check ATM...I would also try
> using s
wesley chun wrote:
> from string import printable as prglobal
> def printable(s):
> prlocal = prglobal
> for x in s:
> if x not in prlocal:
> return False
> return True
>
> the solutions using LCs above are great when it comes to an expressive
> piece of code in a
> > > > all(char in string.printable for char in testString)
>
> That was my favorite, too. I didn't notice the new all method in 2.5. It
> certainly seems the most Pythonic approach.
all() has a sister built-in function, also introduced in 2.5, so i
think that any(char not in string.printable
On Sun, 22 Jul 2007, Jerry Hill wrote:
> On 7/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
> > > all(char in string.printable for char in testString)
> >
> > What is all?
> > Is that a 2.5 thing (I'm still on 2.4 here)
>
> Yes, it's a 2.5 thing.
That was my favorite, too. I didn't notice the ne
On 7/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
> > all(char in string.printable for char in testString)
>
> What is all?
> Is that a 2.5 thing (I'm still on 2.4 here)
Yes, it's a 2.5 thing. All returns true if all of the elements of an
iterable are true. According to the docs, it is the equiv
"Jerry Hill" <[EMAIL PROTECTED]> wrote
> I like this one:
> all(char in string.printable for char in testString)
What is all?
Is that a 2.5 thing (I'm still on 2.4 here)
testString = "qwerty\buiop"
all(char in string.printable for char in testString)
> False
>
> --
> Jerry
> __