You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Description: Examples on how to use partial function in Python
# Environment: PyCharm and Anaconda environment
#
# MIT License
# Copyright (c) 2018 Valentyn N Sichkar
# github.com/sichkar-valentyn
#
# Reference to:
# [1] Valentyn N Sichkar. Examples on how to use partial function in Python // GitHub platform [Electronic resource]. URL: https://github.com/sichkar-valentyn/Partial_Function_in_Python (date of access: XX.XX.XXXX)
# Explaining partial function and how to use it
# Importing partial from functools
from functools import partial
# Assigning to x integer number in binary notation
x = int('1101', base=2)
print(x) # Showing result in decimal notation
# Creating function int_2 with partial
int_2 = partial(int, base=2)
x = int_2('1101')
print(x)
# Another examples how to sort lists easier with partial