开发者

Python programming .....Basics [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its 开发者_运维知识库current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Thank you, I have some doubt in python programming like

  1. Difference in between module,library,package.
  2. What is difference in between built in and keyword. Eg: None,True is Builtins not keywords.
  3. What is the use of writing the code(to call main method) if __name__=__main__:main rather than simple call main()
  4. 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()


  1. 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.

  2. 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 2 True and False are indeed builtins, but not keywords. In Python 3 they are both builtins and keywords.

  3. It allows you to use the module as a library, without calling main() when you import it.

  4. Yes you can.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜