Why is a call to a shadowing non-virtual member function in the derived class not calling the base class member function?

Yep, you are misunderstanding a little. The method of the same name on the derived class will hide the parent method in this case. You would imagine that if this weren’t the case, trying to create a method with the same name as a base class non-virtual method should throw an error. It is allowed … Read more

What is Shadowing?

Shadowing hides a method in a base class. Using the example in the question you linked: class A { public int Foo(){ return 5;} public virtual int Bar(){return 5;} } class B : A { public new int Foo() { return 1;} public override int Bar() {return 1;} } Class B overrides the virtual method … Read more

Importing a library from (or near) a script with the same name raises “AttributeError: module has no attribute” or an ImportError or NameError

This happens because your local module named requests.py shadows the installed requests module you are trying to use. The current directory is prepended to sys.path, so the local name takes precedence over the installed name. An extra debugging tip when this comes up is to look at the Traceback carefully, and realize that the name … Read more

Why does “example = list(…)” result in “TypeError: ‘list’ object is not callable”? [duplicate]

Seems like you’ve shadowed the builtin name list, which points at a class, by the same name pointing at an instance of it. Here is an example: >>> example = list(‘easyhoss’) # here `list` refers to the builtin class >>> list = list(‘abc’) # we create a variable `list` referencing an instance of `list` >>> … Read more

UnboundLocalError trying to use a variable (supposed to be global) that is (re)assigned (even after first use)

Python treats variables in functions differently depending on whether you assign values to them from inside or outside the function. If a variable is assigned within a function, it is treated by default as a local variable. Therefore, when you uncomment the line, you are trying to reference the local variable c before any value … Read more

Why are my dplyr group_by & summarize not working properly? (name-collision with plyr)

I believe you’ve loaded plyr after dplyr, which is why you are getting an overall summary instead of a grouped summary. This is what happens with plyr loaded last. library(dplyr) library(plyr) df %>% group_by(DRUG,FED) %>% summarize(mean=mean(AUC0t, na.rm=TRUE), low = CI90lo(AUC0t), high= CI90hi(AUC0t), min=min(AUC0t, na.rm=TRUE), max=max(AUC0t,na.rm=TRUE), sd= sd(AUC0t, na.rm=TRUE)) mean low high min max sd 1 … Read more

Importing installed package from script with the same name raises “AttributeError: module has no attribute” or an ImportError or NameError

This happens because your local module named requests.py shadows the installed requests module you are trying to use. The current directory is prepended to sys.path, so the local name takes precedence over the installed name. An extra debugging tip when this comes up is to look at the Traceback carefully, and realize that the name … Read more

Lambda capture and parameter with same name – who shadows the other? (clang vs gcc)

Update: as promised by the Core chair in the bottom quote, the code is now ill-formed: If an identifier in a simple-capture appears as the declarator-id of a parameter of the lambda-declarator‘s parameter-declaration-clause, the program is ill-formed. There were a few issues concerning name lookup in lambdas a while ago. They were resolved by N2927: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)