- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does built-in class attribute __name__ do in Python?
This built-in attributes prints the name of the class, type, function, method, descriptor, or generator instance.
For example, if the python interpreter is running that module (the source file) as the main program, it sets the special __name__ variable to have a value "__main__". If this file is being imported from another module, __name__ will be set to the module's name.
The following code illustrates the use of __name__.
class Bar(object): def foo(): """ This is an example of how a doc_string looks like. This string gives useful information about the function being defined. """ pass print foo.__name__ print Bar.__name__
This gives the output
- What does built-in class attribute __dict__ do in Python?
- What does built-in class attribute __doc__ do in Python?
- What does built-in class attribute __module__ do in Python?
- What does built-in class attribute __bases__ do in Python?
- What does a semicolon do after a C++ class name?
- What does the pandas.series.array attribute do?
- What does the pandas.series.index attribute do?
- What does the pandas.series.values attribute do?
- What are built-in class attributes in Python?
- What does the pandas DataFrame.index attribute do?
- What does the pandas DataFrame.columns attribute do?
- Built-In Class Attributes in Python
- What does % do to strings in Python?
- What does reload() function do in Python?