Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  • Pythonic approach

    For sound playback in Python, see this discussion 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):
    
  • 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):
    
  • 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):
    
Source Link
vnp
  • 58.6k
  • 4
  • 55
  • 144
  • 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):
    
lang-py

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