Edward Elliott <[EMAIL PROTECTED]> wrote:
> I'm looking for the "best" way to strip a large set of chars from a filename
> string (my definition of best usually means succinct and readable). I
> only want to allow alphanumeric chars, dashes, and periods. This is what I
> would write in Perl (bl
On 4/05/2006 4:30 PM, Edward Elliott wrote:
> Bryan wrote:
>> >>> keepchars = set(string.letters + string.digits + '-.')
>
> Now that looks a lot better. Just don't forget the underscore. :)
>
*Looks* better than the monkey business. Perhaps I should point out to
those of the studio audience
Edward Elliott wrote:
> Bryan wrote:
>
>> >>> keepchars = set(string.letters + string.digits + '-.')
>
>
> Now that looks a lot better. Just don't forget the underscore. :)
>
You may also want to have a look at string.translate() and
string.maketrans()
--
bruno desthuilliers
python -c "print
Bryan wrote:
> >>> keepchars = set(string.letters + string.digits + '-.')
Now that looks a lot better. Just don't forget the underscore. :)
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
> [expletives deleted] and it was wrong anyway (according to your
> requirements);
> using \w would keep '_' which is *NOT* alphanumeric.
Actually the perl is correct, the explanation was the faulty part. When in
doubt, trust the code. Plus I explicitly allowed _ further down,
> >>> keepchars = set(alphabet + alphabet.upper() + '1234567890-.')
or
>>> keepchars = set(string.letters + string.digits + '-.')
bryan
--
http://mail.python.org/mailman/listinfo/python-list
On 4/05/2006 1:36 PM, Edward Elliott wrote:
> I'm looking for the "best" way to strip a large set of chars from a filename
> string (my definition of best usually means succinct and readable). I
> only want to allow alphanumeric chars, dashes, and periods. This is what I
> would write in (b
I'm looking for the "best" way to strip a large set of chars from a filename
string (my definition of best usually means succinct and readable). I
only want to allow alphanumeric chars, dashes, and periods. This is what I
would write in Perl (bless me father, for I have sinned...):
$filename =~