Whittle it on down
DFS
nospam at dfs.com
Thu May 5 17:36:11 EDT 2016
On 5/5/2016 1:54 PM, Steven D'Aprano wrote:
> On Thu, 5 May 2016 10:31 pm, DFS wrote:
>
>> You are out of your mind.
>
> That's twice you've tried to put me down, first by dismissing my comments
> about text processing with "Linguist much", and now an outright insult. The
> first time I laughed it off and made a joke about it. I won't do that
> again.
>
> You asked whether it was better to extract the matching strings into a new
> list, or remove them in place in the existing list. I not only showed you
> how to do both, but I tried to give you the mental tools to understand when
> you should pick one answer over the other. And your response is to insult
> me and question my sanity.
>
> Well, DFS, I might be crazy, but I'm not stupid. If that's really how you
> feel about my answers, I won't make the mistake of wasting my time
> answering your questions in the future.
>
> Over to you now.
heh! Relax, pal.
I was just trying to be funny - no insult intended either time, of
course. Look for similar responses from me in the future. Usenet
brings out the smart-aleck in me.
Actually, you should've accepted the 'Linguist much?' as a compliment,
because I seriously thought you were.
But you ARE out of your mind if you prefer that convoluted "function"
method over a simple 1-line regex method (as per S. Hansen).
def isupperalpha(string):
return string.isalpha() and string.isupper()
def check(string):
if isupperalpha(string):
return True
parts = string.split("&")
if len(parts) < 2:
return False
parts[0] = parts[0].rstrip(" ")
parts[-1] = parts[-1].lstrip(" ")
for i in range(1, len(parts)-1):
parts[i] = parts[i].strip(" ")
return all(isupperalpha(part) for part in parts)
I'm sure it does the job well, but that style brings back [bad] memories
of the VBA I used to write. I expected something very concise and
'pythonic' (which I'm learning is everyone's favorite mantra here in
python-land).
Anyway, I appreciate ALL replies to my queries. So thank you for taking
the time.
Whenever I'm able, I'll try to contribute to clp as well.
More information about the Python-list
mailing list