0

In javascript, we have this object declaration:

var object = {property1:1,property2:1 }

In python, the traditional way we do that:

class my_cls:
  def __init__(self):
    self.property1=1
    self.property2=1
object = my_cls()

is there a shortcut in python to declare an object?

2
  • Are you looking for a dictionary which has a very similar syntax to the Javascript object?
    – Klaus D.
    Commented Jun 24, 2020 at 0:17
  • try this, this and this at least one of them should answer your question.
    – era-net
    Commented Jun 24, 2020 at 0:31

0