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

Scripts

Name: Anonymous 2012-01-04 12:16

Hey /prog/, what scripts have you been working on? I just made this simple on that I really needed to change all spaces in folders to underscores:


#/usr/bin/env python

import os

def main ():
    current_dir = os.getcwd ()
    current_dir_list = os.listdir (current_dir)

    for current_file in current_dir_list:
        os.rename (current_file, current_file.replace (" ", ""))

if __name__ == "__main__":
    main ()


Show us your latest scripts and feel free to rewrite mine and others in other languages!

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-04 14:34

>>10

If he had called the function without enclosing it in the if test then the function would be called every time he imported the module

Holy shit you're stupid. Have you ever written a non trivial Python script for any firm? I have. And in fact, the scripts I wrote run over several servers you moron. Anyways, what the OP did is correct. And what I described in correct. Now run along and go scrub another toilet.

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