Any equivalent to this one-line code in Python?
// C# just shows how class looks like
class MyClass {
public int A {get; set;}
public int B {get; set;}
}
// This is that one-line code in C#. Any pythonic way to do something like this?
// var x = MyClass() { A=1, B=2 } - "var" syntax sugar, at compile time it's == MyClass
MyClass x = MyClass() { A=1, B=2 }
Edit: Maybe my question wasn't so precise. My main goal is to not pass arguments to constructor.
How to initialize many class members (any combination of them) without passing them to constructor and without constructor with all default values.
Edit: Thx for answers and sorry for confusing question. I just wanted to know answer for question in topic - What is the best way (pythonic way) to initialize class's subset of attributes without explicity writing them in constructor.