Is this meant to be an expected behavior?

Yes, this is one of the best known quirks of the language:

It has nothing to do with classes, but with functions (including methods). It has always worked this way; there has been an incredible amount of discussion of it; and the Ideas category contains many proposals for changing how it works.

It also isn’t clear to me what you mean by “creating new instances of the class manually” (as opposed to what?); and the observed behaviour is a result of not passing an explicit list or dict to the Test constructor. It’s also important to understand (this is thoroughly addressed in the linked explanation, but it’s a key conceptual issue) that doing something like t1.listed.append('app') is fundamentally different from doing something like t1.num = 3. In the first case, the object that t1.listed refers to is modified; in the second, the object that t1.num refers to is replaced (there is no way from within Python to modify the integer object itself; it would be very bad if the concept of 3 itself could be forced to change).

2 Likes