Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variables with underline

I'm getting an underline in some variables on Android Studio (in this case on the 'position' variable). I think it's not an error because the application runs perfectly and the compiler passes everything ok. I'm wondering what does that mean?

enter image description here

like image 218
Jackowski Avatar asked Dec 23 '15 21:12

Jackowski


People also ask

Can we start a variable with _?

Variable name may not start with a digit or underscore, and may not end with an underscore. Double underscores are not permitted in variable name. Variable names may not be longer than 32 characters and are required to be shorter for some question types: multiselect, GPS location and some other question types.

What does _ before a variable mean?

A single leading underscore in front of a variable, a function, or a method name means that these objects are used internally. This is more of a syntax hint to the programmer and is not enforced by the Python interpreter which means that these objects can still be accessed in one way on another from another script.

Can you use underscore in variables?

An underscore in front usually indicates an instance variable as opposed to a local variable. It's merely a coding style that can be omitted in favor of "speaking" variable names and small classes that don't do too many things.

Why do some variables start with underscore?

The underscore prefix is meant as a hint to another programmer that a variable or method starting with a single underscore is intended for internal use. This convention is defined in PEP 8. This isn't enforced by Python. Python does not have strong distinctions between “private” and “public” variables like Java does.


1 Answers

It could be a sign of "Reassigned parameter"

enter image description here

like image 130
teymourlouie Avatar answered Oct 09 '22 21:10

teymourlouie