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 toalarm
in anif __name__ == '__main__':
clause.
Avoid magic numbers
All the parameters (beep duration, volume, etc) better be passed via a command line (see
sys.argv
andoptparse
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 toalarm
in anif __name__ == '__main__':
clause.
Avoid magic numbers
All the parameters (beep duration, volume, etc) better be passed via a command line (see
sys.argv
andoptparse
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 toalarm
in anif __name__ == '__main__':
clause.
Avoid magic numbers
All the parameters (beep duration, volume, etc) better be passed via a command line (see
sys.argv
andoptparse
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 toalarm
in anif __name__ == '__main__':
clause.
Avoid magic numbers
All the parameters (beep duration, volume, etc) better be passed via a command line (see
sys.argv
andoptparse
module).Dummy variable
is customarily denoted as
_
:for _ in range(20):