Skip to main content

New answers tagged

4 votes

Initializing an object using a staticmethod

comment vs. annotation self.att1 = set() # set(tuple) self.att2 = {} # dict(str:str) Please don't write comments just for humans. Tell ...
J_H's user avatar
  • 30.5k
7 votes
Accepted

What is the best way to set a class value to a variable in Python if it exists in a dictionary?

tl;dr: It should be a @dataclass. code which sets values in a location class from values from JSON data. The vocabulary word you're looking for is "object attribute". The code sets ...
J_H's user avatar
  • 30.5k
6 votes

What is the best way to set a class value to a variable in Python if it exists in a dictionary?

Correctness remote_str is defined at wrong indentation level, it will fail with an UnboundLocalError for ...
STerliakov's user avatar

Top 50 recent answers are included