python (12.9k questions)
javascript (9.2k questions)
reactjs (4.7k questions)
java (4.2k questions)
java (4.2k questions)
c# (3.5k questions)
c# (3.5k questions)
html (3.3k questions)
Python - the meaning of "!"
While studying Python, I run the following example code regarding function.wrap.
def trace(func):
def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
print(f'{func.__name_...
Lee na-hyeon
Votes: 0
Answers: 0
Define multiple versions of the same function name
Is it possible to somehow to have 2 functions with the same name, but only one of the gets defined.
Something like:
version='revA'
def RevA():
if (version=='revA'):
return lambda x: x
...

enekow
Votes: 0
Answers: 2
Python decorator show signature and docstring from both decorator and decorated function
I'm trying to write a decorator whose wrapper function takes an additional input argument, based on which some processing is done within the wrapper. However, I'm having a hard time
a) figuring out ho...

emilaz
Votes: 0
Answers: 1
decorate a function to count the number of times it gets called while preserving the original functions args
I want to write a decorator function that adds a counter to a function, counting the number of times it was called. E.g.
foo <- function(x) {x}
foo <- counter_decorator(foo)
foo(1)
foo(1)
# =>...
Mark Heckmann
Votes: 0
Answers: 2