Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

File Name Split on Dashes

Name: Anonymous 2012-01-21 21:32

Hay guys. I'm developing an MP3 player of sorts in Python, and I've devised a way to split a file name by dashes, and return the artist and track separately, but I'm struggling with returning something if no dash is found. In that case, I'd like to return the original file name, and an empty string. As it is now, if no dash is found in a file name, it will just return "None".

Here is my function:

def parseName(song):
    flags = chr(6), chr(45), chr(173), chr(8211)
    for flag in flags:
        for letter in song:
            if flag == letter:
                        return song.split(flag)

Could anyone help? I'd appreciate it.

Name: Anonymous 2012-01-22 20:10

>>4

I honestly wasn't aware such a thing was possible. I'm a fair programmer, but this is the first time I've ever attempted to make a whole entire app, especially one that involves file handling, so my first instinct was to approach it in an elemental, manual way. Knowing of that really helps, though. I've looked it up and it already looks like it'll make everything x1000 easier. Thanks for the advice!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List