-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from int3l/main
Code examples for episode 551
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# [tuple syntax doesn't have parens (beginner - intermediate)](https://youtu.be/EDGJ2TMuppM) | ||
|
||
Today we talk about tuples in python -- and surprisingly they don't actually use parens for syntax most of the time! I show off a little pitfall caused by this as well | ||
|
||
## Interactive examples | ||
|
||
### Python | ||
|
||
```python | ||
x = (1, 2, 3) | ||
x | ||
|
||
x = 1, 2, 3 | ||
x | ||
|
||
import ast | ||
ast.parse('x = (1, 2, 3)').body[0].value | ||
ast.parse('x = (1, 2, 3)').body[0].value.col_offset | ||
|
||
x = ( | ||
1, | ||
2, | ||
3, | ||
) | ||
|
||
print((1, 2, 3),) | ||
print((1, 2, 3)) | ||
print((1, 2, 3), 4) | ||
|
||
x = () | ||
x | ||
|
||
x = min(5, 4), | ||
x | ||
|
||
print( | ||
min(5, 4), | ||
) | ||
``` | ||
|
||
### Bash | ||
|
||
```bash | ||
python | ||
``` |