PythonDefine a class and create an object in Python

class MyClass:
    x = 5

p1 = MyClass()
print(p1.x)

Related Snippets

Cover Image for Dictionary Comprehension in Python

Dictionary Comprehension in Python

Loading...
Cover Image for Efficiently read a file with Python

Efficiently read a file with Python

Loading...
Cover Image for Error Handling in Python

Error Handling in Python

Loading...
Cover Image for Generate a list in a single line of code in Python

Generate a list in a single line of code in Python

Loading...
Cover Image for Lambda Function in Python

Lambda Function in Python

Loading...
Cover Image for Reading a File in Python

Reading a File in Python

Loading...