multithreading - Does a trailing comma after an n-tuple in Python change its value? -
this basic doubt came mind. when use threading module in python start new thread, have see 2 different ways in arguments passed call:
version 1:
thread = threading.thread(target=tar,args=(4,0.25,)) version 2:
thread = threading.thread(target=tar,args=(4,0.25)) the difference addition of , @ end of argument list @ end of version 1 call. both versions work fine want know if theres significant difference between 2 versions above , if ones better way write? if theres no difference reason lot of people , articles choose use version 1 , add redundant , @ end of argument list.
the 2 forms of writing 2-tuple equivalent. proof:
>>> (4,0.25,) == (4,0.25) true for elaboration on valid tuple syntax in python, see https://wiki.python.org/moin/tuplesyntax. specifically:
in python, multiple-element tuples like:
1,2,3
the essential elements commas between each element of tuple. multiple-element tuples may written trailing comma, e.g.
1,2,3,
but trailing comma optional.
Comments
Post a Comment