1

I came across the following syntax in some Python3 code I found online:

Note: this is actually from Vyper, a subset of Python3 used for programming on Ethereum. The developers of Vyper claim that all Vyper code is valid Python3 syntax (although the converse is not true)

myvariable: somefunction(someglobalvariable)

I haven't been able to uncover the specific documentation from Python3 explaining the meaning of this syntax.

What does this do?

vaultah
  • 44,105
  • 12
  • 114
  • 143
Marco Merlini
  • 875
  • 7
  • 29
  • Somewhat unclear what are you asking about – Ivan Vinogradov May 24 '18 at 15:53
  • Assignment using the colon operator is not valid Python(2 or 3) syntax outside of a dictionary. – Adam Smith May 24 '18 at 15:53
  • @vaultah ah, no, I was just misunderstanding the notation. This isn't assignment it's type hinting – Adam Smith May 24 '18 at 15:56
  • (that said, I learned something new -- I've only used annotations in function signatures and did not know they were valid elsewhere) – Adam Smith May 24 '18 at 15:57
  • **@Makoe**, it doesn't look like a Python3's syntax. It's related to the state variables that **Vyper** understands well. The coders of **Vyper** have made their own syntax to force package users to follow their syntax to work with the package so that they could work with the package nicely. You check http://viper.readthedocs.io/en/latest/structure-of-a-contract.html#structure-state-variables and read more about defining state variables – hygull May 24 '18 at 16:14
  • "It doesn't look like Python3's syntax". [PEP-526](https://www.python.org/dev/peps/pep-0526/) begs to differ. – chepner May 24 '18 at 16:15

0 Answers0