Skip to main content
Code Review

Return to Revisions

2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/
  • Pythonic approach

    For sound playback in Python, see this discussion.

  • Avoid os.system

    If you are forced to use it, supply a fully qualified path to the executable. You never know what weird program called play may be in the search path prior to an intended one.

  • Modularize

    As written, the code is not reusable. An attempt to import it would result in an immediate alarm sound. Put the call to alarm in an

     if __name__ == '__main__':
    

    clause.

  • Avoid magic numbers

    All the parameters (beep duration, volume, etc) better be passed via a command line (see sys.argv and optparse module).

  • Dummy variable

    is customarily denoted as _:

     for _ in range(20):
    
vnp
  • 58.7k
  • 4
  • 55
  • 144
default

AltStyle によって変換されたページ (->オリジナル) /