On Tue, Jun 3, 2008 at 3:16 PM, tmallen <[EMAIL PROTECTED]> wrote: > On Jun 3, 3:03 pm, Chris <[EMAIL PROTECTED]> wrote: >> On Jun 3, 8:40 pm, tmallen <[EMAIL PROTECTED]> wrote: >> >> > What's the proper way to instantiate a new variable? x = ""? >> >> You don't need to pre-declare your variables. Just assign them as you >> need them and they will take the correct type. > > unless I'm using the += or a similar operator, right? That doesn't > seem to instantiate a variable.
Right... because you don't have anything to increment or append to. I guess this also comes up in the case of something like lists or dictionaries you want to uniformly create in a loop. I guess you could call it instantiating, but really it's more like going ahead and assigning to them as Chris mentioned and you're just starting them with a default value. Assuming you're working with strings, x="" should work just fine in that case. Lists, x=[], dictionaries, x={}, integers, probably x=1 or x=0... -- http://mail.python.org/mailman/listinfo/python-list