Reputation: 374
Is it possible to add some sort of decorator or alias to get hints on the possible inputs a variable can get in a function?
In the following example function input_var can take any values, but can I hint to use the values 'year','month' or 'day'?
def some_function(input_var):
""" This function does something cool, use input_var as bla, blah or blahh """
if input_var=='year':
print("Selected 1")
if input_var=='month':
print("Selected 2")
if input_var=='day':
print("Selected 3")
so far I add the "hint" to the docstring, but I'm want something like this:
where it could show input_var='year/month/day' or something like that.
Using Jupyter notebooks, with python 3
Thanks
Upvotes: 2
Views: 2476
Reputation: 3519
def foo(x: 'year/month/day'):
return "abc"
x
and press tab for suggestions it will show x : 'year/month/day'
.Upvotes: 3