0

Is assign and declare same in python?

enter image description here

  • *Python doesn't have variable declarations*. That screenshot is using terminology incorrectly. Although, this is a frequent mistake, and a rather pedantic point. – juanpa.arrivillaga Aug 17 '21 at 04:34
  • @juanpa.arrivillaga Except with type hints, e.g. `a: int` – blhsing Aug 17 '21 at 04:35
  • 2
    @blhsing eh, sort of. I don't think of type annotations the same as variable declarations, they don't really work the same way as in languages that do have them. – juanpa.arrivillaga Aug 17 '21 at 04:36
  • @juanpa.arrivillaga Well but "declaring" a variable through a type annotation does statically binds the variable to the current scope, and to me that does behave like what a declaration in any language that has it does. Demo: https://replit.com/@blhsing/PurpleProfitableScience – blhsing Aug 17 '21 at 04:43
  • @blhsing ah, never knew about that behavior, I thought that they should have no runtime effect. I guess this would qualify as a declaration then – juanpa.arrivillaga Aug 17 '21 at 04:46

0 Answers0