-
-
Save stephengruppetta/29c250d0a87984e6fefb87d69da85293 to your computer and use it in GitHub Desktop.
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
import functools | |
import random | |
def roll_dice(max_value, number_of_dice): | |
return [ | |
random.randint(1, max_value) | |
for _ in range(number_of_dice) | |
] | |
# Create a partial object that always rolls | |
# standard dice with 6 sides | |
roll_standard_dice = functools.partial(roll_dice, 6) | |
print(roll_standard_dice.func) | |
# <function roll_dice at 0x102ab0720> | |
print(roll_standard_dice.args) | |
# (6,) | |
print(roll_standard_dice.keywords) | |
# {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment