Skip to content
Advertisement

Tag: python-decorators

Python square brackets between function name and arguments: func[…](…)

I was learning how to accelerate python computations on GPU from this notebook, where one line confuses me: Here, mandel_kernel is a decorated (by cuda.jit) function, griddim and blockdim are tuples of length 2: griddim=(32,16), blockdim=(32,8). Is this square brackets in between function name and argument list part of python syntax, or something specific to the cuda.jit decoration? Answer This

Decorating a class to monitor attribute changes

I want to have classes that automatically send notifications to subscribers whenever one of their attributes change. So if I would write this code: The output would be: My question is how to implement the ChangeMonitor decorator class. In the above example I assume it will print a line indicating the changes of an attribute, but for useful purposes it

Advertisement