RE: [Python] File Sorter 06-19-2014, 03:03 PM
#11
Good Job Bro! keep up the good work
mile:
mile:
| [Python] File Sorter filter_list | |
(06-19-2014, 02:59 PM)L0aD1nG Wrote: First of all i havent tried that argparse module but i think that same can happen with optparse..but i am not sure as i havent check the argparse module yet.
On the other hand now i didnt recommend him naming functions like that i just wanted to show him the way that optparse works so i just putted a random and little funny name to the function.Also using the main funtion is highly recommended by pro pythonistaz cause its a way to nicely organize all the code at last and run it like that after check if not debuging flag is on.
def main():
parser = optparse.OptionParser("Usage : " + sys.argv[0] + " -p <path you would like sort>" )
parser.add_option('-p', dest = 'sort_path', type = 'string', help = 'This is the path location you want to sort')
(options, args) = parser.parse_args()
sort_path = options.sort_path
if not sort_path:
print parser.usage
exit(1)
else:
my_sweet_sort(sort_path)
exit(0)if __name__ == '__main__':
main()(06-21-2014, 02:43 AM)Cosh Wrote: looks really good man. how long did that take you type up?