Python - Class Empty Class

Introduction

The following statement makes a class with no attributes attached, an empty namespace object:

class rec: pass              # Empty namespace object 

After we make the class by running this statement, we can attach attributes to the class by assigning names to it completely outside of the original class statement: 
rec.name = 'Bob'             # Just objects with attributes 
rec.age  = 40 

And, we can fetch them with the usual syntax.

When used this way, a class is roughly similar to a "struct" in C.

It's an object with field names attached to it:

print(rec.name)              # Like a C struct or a record 

Related Topic