Last active
January 3, 2020 15:17
-
-
Save brezniczky/f2b9efb6d1f76786ee8a048b8225c5b1 to your computer and use it in GitHub Desktop.
Demonstrates that Python's partial() allows for 'overriding' the already frozen parameters
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
""" Partial's frozen arguments are not 'as frozen' as I would have thought | |
at first. | |
""" | |
from functools import partial | |
f = partial(int, base=2) | |
# results in 9 - great! | |
print(f("1001")) | |
# 1. executes, no warning, no exception :( | |
# 2. results in 28 :S | |
print(f("1001", base=3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment