Re: Python inner function parameter shadowed

2016-09-14 Thread Christopher Reimer
> On Sep 13, 2016, at 8:58 PM, Lawrence D’Oliveiro > wrote: > >> On Wednesday, September 14, 2016 at 4:34:34 AM UTC+12, Daiyue Weng wrote: >> PyCharm warns about "Shadows name 'func' from outer scope" > > Typical piece of software trying to be too helpful and just

Re: Python inner function parameter shadowed

2016-09-14 Thread Steven D'Aprano
On Wednesday 14 September 2016 13:58, Lawrence D’Oliveiro wrote: > On Wednesday, September 14, 2016 at 4:34:34 AM UTC+12, Daiyue Weng wrote: >> PyCharm warns about "Shadows name 'func' from outer scope" > > Typical piece of software trying to be too helpful and just getting in the > way. > >

Re: Python inner function parameter shadowed

2016-09-13 Thread Lawrence D’Oliveiro
On Wednesday, September 14, 2016 at 4:34:34 AM UTC+12, Daiyue Weng wrote: > PyCharm warns about "Shadows name 'func' from outer scope" Typical piece of software trying to be too helpful and just getting in the way. Can you turn off such warnings? --

Re: Python inner function parameter shadowed

2016-09-13 Thread Brendan Abel
Yeah, you could change the name, but it shouldn't matter, the "func" in the inner function will always be the one passed into it, it won't be the "func" from the outer function, which in this specific case, would always be None (at least as far as the second inner function is concerned.) On Tue,

Re: Python inner function parameter shadowed

2016-09-13 Thread Chris Angelico
On Wed, Sep 14, 2016 at 4:28 AM, Brendan Abel <007bren...@gmail.com> wrote: > This looks like a decorator function that optionally accepts arguments to > change the behavior. Oh, I get it. So, yeah, it is one function doing two jobs - legitimately. In that case, I'd just rename one of the 'func'

Re: Python inner function parameter shadowed

2016-09-13 Thread Brendan Abel
This looks like a decorator function that optionally accepts arguments to change the behavior. You can safely ignore the warning form PyCharm. the variable won't be shadowed it's included in the function signature of the inner function. A lot of times, the outside decorator will just use the

Re: Python inner function parameter shadowed

2016-09-13 Thread Chris Angelico
On Wed, Sep 14, 2016 at 2:34 AM, Daiyue Weng wrote: > Hi, I am using inner function like this, > > def timeit(func=None, loops=1, verbose=False): > if func is not None: > def inner(*args, **kwargs): > > # some code > > return inner > else:

Python inner function parameter shadowed

2016-09-13 Thread Daiyue Weng
Hi, I am using inner function like this, def timeit(func=None, loops=1, verbose=False): if func is not None: def inner(*args, **kwargs): # some code return inner else: def partial_inner(func): return timeit(func, loops, verbose)