Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@TheVariant Only when you assign it too. The nearest thing to do that is:
x = None
but there is no such thing as:
int x; -
@zchfvy Nice to see, that someone actually knows about this nice feature.
I use it frequently to keep track of types myself and help my texteditor with autocompletion.
However, even if the statements work in python, it apparently has no effect, since it doesn't declare the variable.
In general the ": <type>" is only an annotation in python and needs python 3.6+ for it to throw no errors (my rPi for example doesn't have the required version). -
@zchfvy I neither checked it before.
I also only knew that you can use them in your code, but actually do nothing to your code other than adding the annotation.
You can use them, but nobody is required to follow them if you e.g. have them as function-parameters. Python does no type-checks by itself. -
@LinusCDE oh you mean initializing a variable, sorry, was confused when you said declaring
-
@TheVariant Yeah. It's more academic but declaring and initializing are two completly different things in most programing languages.
Related Rants
woah, what are you trying to do there?
joke/meme
python