Created
November 30, 2014 04:36
-
-
Save androm3da/8a646fbe817d576b1f0d to your computer and use it in GitHub Desktop.
Optional parens for python tuples, what's the difference?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import dis | |
def assign_no_paren_const(a, b): | |
x = 1, 2 | |
def assign_w_paren_const(a, b): | |
x = (1, 2) | |
def assign_no_paren(a, b): | |
x = a, b | |
def assign_w_paren(a, b): | |
x = (a, b) | |
dis.dis(assign_no_paren_const) | |
dis.dis(assign_w_paren_const) | |
dis.dis(assign_no_paren) | |
dis.dis(assign_w_paren) | |
x = 12 * 4, 5 | |
print(x) | |
x = 12 * (4, 5) | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this gist was created as an appendix to this answer to a question on SO regarding tuples with and without parens.