1
class Empty:
    pass

a = Empty()
a.m = 1

the above code works well and there is no error.

a = object()
a.m = 1 # it throws AttributeError

but this code throws an exception.

AttributeError: 'object' object has no attribute 'm'

What is the difference?

I just want an empty object and add some variable to it.

How can I do that? Should I make an empty class?

quamrana
  • 37,849
  • 12
  • 53
  • 71
usan
  • 81
  • 1
  • 8

0 Answers0