Python programming .....Basics [closed]
Thank you, I have some doubt in python programming like
- Difference in between module,library,package.
- What is difference in between built in and keyword. Eg: None,True is Builtins not keywords.
- What is the use of writing the code(to call main method)
if __name__=__main__:main
rather than simple callmain()
- Can I access the attributes of class,using class name like below code
Code:
class A:
atri=9
def method(self):
print 'This is method'
def my():
print 'attribute access using Class name ',A.atri
print 'method calling using Class name ',A.method()
my()
A module is a Python file. A package is a directory that has an
__init__.py
file. It behaves almost like it's a module, although it's a directory. A library is a reusable module or package.A keyword is a reserved word which you can't assign to. A builtin is a variable that is available "by default" so to speak. They are listed in the
__builtins__
variable. In Python 2True
andFalse
are indeed builtins, but not keywords. In Python 3 they are both builtins and keywords.It allows you to use the module as a library, without calling main() when you import it.
Yes you can.
精彩评论