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
from pymongo import MongoClient |
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
rc = "Rubik's Code" | |
f"{rc=}" |
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
rc = "Rubik's Code" | |
f"{rc} is awesome!" |
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
from typing import final | |
@final | |
class Song: | |
artist: str | |
title: str | |
album: str | |
year: int | |
class Derived(Song): # ERROR: Can't inherit from final class "Song" |
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
from typing import Literal | |
def nBackAtYa(n: Literal[11, 33, 66]): | |
if n < 111: | |
return n | |
else: | |
raise ValueError('n must less than 111') |
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
def nBackAtYa(n: int): | |
if n < 111: | |
return n | |
else: | |
raise ValueError('n must less than 111') |
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
from typing import TypedDict | |
class Song(TypedDict): | |
artist: str | |
title: str | |
album: str | |
year: int | |
song: Song = {'artist': 'Nikola Nezit', 'title': 'Three Suns Halo', 'album': 'Triad', 'year': 2013} |
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
from typing import TypedDict | |
class Song(TypedDict): | |
artist: str | |
title: str | |
album: str | |
year: int | |
song: Song = {'artist': 'Nikola Nezit', 'title': 'Three Suns Halo', 'album': 'Triad', 'year': 2013} |
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
def function(a, b /): | |
print(a + b) | |
# Invalid | |
function(a = 5, b = 6) | |
# Valid | |
function(5, 6) |
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
def function(a, b /, c, *, d): | |
print(a + b + c + d) |