Carter Temm wrote: > Hi all. > I've been looking at this for a bit, and can't seem to come to a possible > conclusion on what could be happening to get an error. Anyway, here is the > code, then I'll explain. > > http://pastebin.com/raw/YPiTfWbG > > the issue comes when using argv. But when I change > > TIME = argv > > to > > TIME = 2 > > It does exactly what I intended, no issues. What's wrong? Thanks for any > help. > > > > Also, The error I get when trying to run is: Traceback (most recent call > last): File "sound_recorder.py", line 21, in <module> for i in range(0, > int(RATE / CHUNK * TIME)): OverflowError: range() result has too many > items‬
RATE/CHUNK is an integer, but TIME when extracted from sys.argv is a str. The * operator tells python to repeat the string RATE/CHUNK times: >>> RATE = 44100 >>> CHUNK = 1024 >>> TIME = "2" >>> RATE/CHUNK * TIME '2222222222222222222222222222222222222222222' You need to convert TIME to an int before evaluating the expression to get the expected result: >>> RATE/CHUNK * int(TIME) 86 -- https://mail.python.org/mailman/listinfo/python-list