In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > I did something like this. > index is passed from the command line. > > def __getBuffer( index): > if index == 1: > buf1 = [None] * 512 > print "Buffer: %s" % (buf1) > return buf1 > elif index == 2: > buf2 = [None] * 512 > print "Buffer: %s" % (buf2) > return buf2 > > Is this the best way to do this?
Best way to do what? That could be written as: def get_buffer(): buffer = [None] * 512 print "Buffer: %s" % buffer return buffer In your code, no matter if index equals 1 or 2, a list with 512 `None`s is created, printed and then returned. It would be really better if you describe *what* you want to achieve, not *how*. And in words please, not in code snippets. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list