- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
Do you think declarations within Python class are equivalent to those within __init__ method?
Declarations anywhere in the class(other than in __init__) and declarations in the __init__method are not the same. The following code shows this to be true.
import sys class foo(): print 'within class' def __init__(self): print 'within init' def do_smthng(self): print 'do something' def main(): f=foo() f.do_smthng() return 0 if __name__ == '__main__': sys.exit( main() )
within class within init do something
- Related Articles
- CSS :focus-within pseudo class
- What do you think when you are alone?
- Do you think Python Dictionary is really Mutable?
- How to access Python objects within objects in Python?
- Python – Filter Strings within ASCII range
- How to call Python file from within PHP?
- How to define a Python dictionary within dictionary?
- Do you think a Python dictionary is thread safe?
- How does constructor method __init__ work in Python?
- How to handle a python exception within a loop?
- Capacity To Ship Packages Within D Days in Python
- Count unique sublists within list in Python
- Why do you think tuple is an immutable in Python?