Is THIS A New Way To Create CONSTANTS In Python?

preview_player
Показать описание
Is this a new way to create constants in Python? #Python #Code #Shorts
Рекомендации по теме
Комментарии
Автор

Python doesnc't have constant type. It's programmer rule that doesn't written. When you declare something with upper case, it just helps the other people who reads your code.
Also when you write ":" after a variable name, you don't set a type for the variable. It just helps your IDE to highlight them.

yusufkiris
Автор

Its called type hinting and doesnt prevent code from actually running. Its more of a readability and assurance thing

fallensach
Автор

in python there is this rule if you want a constant don't touch the variable

moussadadi
Автор

You can make this practically explicit by having mypy in your CICD pipeline, as any modification to the final type would cause mypy to raise an error.

richcaputo
Автор

This has nothing to do with being dynamically typed; in fact, Python doesn’t have constants at all. It’s just naming convention, nothing enforces it.

travelan
Автор

use a def that returns a value, use the def everywhere.

jyvben
Автор

I like this syntax since in C++ for example, you declare a constant variable as 'const int var = 10' or 'const auto var = 10' as a "generic type". So 'const int' is kind of the type of the variable('const auto' implies 'const int' because 10 is int). The same is here, 'Final' as a "generic type", similar to 'object' being a "generic type, " or 'Final[int]' as the concrete type. The same is in Java, for example, just being 'final int a = 10' or 'final var a = 10'(var is a keyword in Java so no variables named var; also not really sure about the last one, worked with Java a long time ago)

JordHaj
Автор

Hey! I just wanted to say that, for clarity, it's better to use the last seconds of the video to *actually explain* some use cases and so on. Hint from a fan ❤
The video model by itself is great already, just add this.

somexne
Автор

So you're saying that the typing module makes Python more like Java?

INGIE
Автор

Ey constant with ey value is ey very nice thing

bryce-bryce
Автор

Can the Final infer the type of it’s parameter? Is there any type inference in Python?

sobanya_
Автор

use enum class instead. typing hinting doesn't work

usswisconsin
Автор

In PerlCNF a constant can't change in thousand files loaded further.

vilijanac
Автор

Js has had constants despite being dynamic

nsambataufeeq
Автор

the uppercase convention _already_ signals "hey, don't change this, it's intended to be a constant!"
yet another fluff to say the same thing is silly... :/

danielalvesldiniz
Автор

I keep getting these python shorts even though i never used python haha.

Spine-ChillingGengar
Автор

If it can change its not a constant. I use all uppercase to tell me that the variable comes from an imported function.

lordfrz
Автор

At this point instead of learning more an more packages just write code in C++

eliassaf
Автор

Or, you can use a strongly typed language instead

rushas
Автор

Please make a video in Panda and data since

kamranview