python - Is it OK to create two objects with a single command? -
i'd create 2 empty list objects. tried use
vlist,slist = [],[]
and seems work. never saw in manual (but python still basic). non empty lists i'd doing harms readability ok identical, empty ones? considered bad practice or are there bad side effects?
does same hold (empty) strings?
there no bad side effects, unless use
vlist = slist = []
which references both variables same list.
i don't think pep8 says this, splitting assignments on 2 lines read much better.
however, @gorlum0 mentioned, if objects related , relatively simple, might improve utilize tuple unpacking. if they're unrelated, reader quite confused trying see why you've set them on 1 line.
python
No comments:
Post a Comment