Skip to main content
added 18 characters in body
Source Link
Alexander
  • 5.2k
  • 1
  • 24
  • 28

In Python when you want a local variable, you just assign to it x = 10.

In most modern languages you declare local vars (regardless of type):

  • JavaScript: letlet/constconst/varvar
  • Swift: letlet/varvar
  • Kotlin: valval/varvar
  • Rust: letlet
  • Go: varvar
  • ...

...

Is there any documentation as to why this approach was taken in Python? I couldn't find anything that explains this decision.

In Python 3 they broke a lot of the syntax, so I take it they still thought/think it's a good idea.

To clarify: I'm not asking for pros and cons here. Just wondering why Python designers made this specific choice.

In Python when you want a local variable, you just assign to it x = 10.

In most modern languages you declare local vars (regardless of type):

  • JavaScript: let/const/var
  • Swift: let/var
  • Kotlin: val/var
  • Rust: let
  • Go: var

...

Is there any documentation as to why this approach was taken in Python? I couldn't find anything that explains this decision.

In Python 3 they broke a lot of the syntax, so I take it they still thought/think it's a good idea.

To clarify: I'm not asking for pros and cons here. Just wondering why Python designers made this specific choice.

In Python when you want a local variable, you just assign to it x = 10.

In most modern languages you declare local vars (regardless of type):

  • JavaScript: let/const/var
  • Swift: let/var
  • Kotlin: val/var
  • Rust: let
  • Go: var
  • ...

Is there any documentation as to why this approach was taken in Python? I couldn't find anything that explains this decision.

In Python 3 they broke a lot of the syntax, so I take it they still thought/think it's a good idea.

To clarify: I'm not asking for pros and cons here. Just wondering why Python designers made this specific choice.

Post Closed as "Opinion-based" by gnat, Greg Burghardt, Thomas Owens
Source Link
noamtm
  • 235
  • 2
  • 5

Why did Python designers decide not to declare vars?

In Python when you want a local variable, you just assign to it x = 10.

In most modern languages you declare local vars (regardless of type):

  • JavaScript: let/const/var
  • Swift: let/var
  • Kotlin: val/var
  • Rust: let
  • Go: var

...

Is there any documentation as to why this approach was taken in Python? I couldn't find anything that explains this decision.

In Python 3 they broke a lot of the syntax, so I take it they still thought/think it's a good idea.

To clarify: I'm not asking for pros and cons here. Just wondering why Python designers made this specific choice.