may be a bug in string.rstrip

Scott SA pydev at rscorp.ab.ca
Fri Nov 23 14:33:39 EST 2007


On 11/23/07, Bruno Desthuilliers (bruno.42.desthuilliers at wtf.websiteburo.oops.com) wrote:

>> The better option, IMO, is probably to use regex. 
>
>You forgot at least the simplest solution:
>
>import os.path
>os.path.splitext('132.ext')[0]

Yes, I did miss that one... and while I was typing there was a nagging feeling I was missing something. I knew I shouldn't have replied at 12:30 am.

I got on the tangent of regext because of the "rstrip" use in the initial post rather than the simple task of splitting the path... that's my story 'n I'm sticking to it 8^)



To be constructive, rather than simply spamming the list with my prev. comments, I submit this:

    As a matter of preference, in simple scripts, prefer to
    use the following when splitting paths and files:
    
        file_name, file_ext = os.path.split('some_name.ext')
    
    
    While the shorthand is cleaner, I'm not always the guy
    maintaining the code.

Thanks

Scott

PS. Not all was a loss, I did learn something from one of the other replies... not that it helps "the rest of the world".



More information about the Python-list mailing list