This piece of code works:
Big-Mac:Classes chare$ more tmp.py
import re
def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\
\-\#\$\*\@\!\%\^\]').search):
#string = string.rstrip()
return not bool(search(string))
print special_match(admin)
print special_match(!*)
print
On Tue, Jul 10, 2012 at 10:56 AM, Chris Hare ch...@labr.net wrote:
The input to the function in the larger program is the same as the first test
in the small script that works -- admin.
As a side note -- the rstrip call is also broken, although the string module
is imported. I just can't
On 07/10/2012 10:56 AM, Chris Hare wrote:
This piece of code works:
Big-Mac:Classes chare$ more tmp.py
import re
def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\
\-\#\$\*\@\!\%\^\]').search):
#string = string.rstrip()
return not bool(search(string))
You just
This piece of code works:
Big-Mac:Classes chare$ more tmp.py
import re
def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\ \-
\#\$\*\@\!\%\^\]').search):
#string = string.rstrip()
return not bool(search(string))
print special_match(admin)
print
On 10 Jul 2012 11:31, Chris Hare ch...@labr.net wrote:
This piece of code works:
Big-Mac:Classes chare$ more tmp.py
import re
snip
return not bool(search(string))
snip
However, when I use the EXACT same code in the context of the larger
code, I get the error
return not
Chris Hare wrote:
def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\
\-\#\$\*\@\!\%\^\]').search):
#string = string.rstrip()
return not bool(search(string))
The call to bool is redundant. Get rid of it. The not operator will
automatically convert its argument into a
Okay - I am officially embarrassed.
As you might now, I am splitting this 10,000 line file apart, and that is
posing certain challenges which I am fixing, and cleaning up stuff that was
broken and visible only when doing this split.
This is one of them.
What I failed to remember -- and
Chris Hare wrote:
Okay - I am officially embarrassed.
[...]
Meh, don't beat yourself up too badly. We've all been where you are now.
Sometimes I look back at my early Python code... I tell you, that's always a
good antidote for a big head.
--
Steven
On Wed, 11 Jul 2012, Steven D'Aprano wrote:
Chris Hare wrote:
Okay - I am officially embarrassed.
[...]
Meh, don't beat yourself up too badly. We've all been where you are now.
Sometimes I look back at my early Python code... I tell you, that's always a
good antidote for a big head.
I