Python built-in variables

Source: Internet
Author: User

Python Hidden variables
__doc__  # Indicates comments in this document
__FILE__ # Indicates the path to this file
__PACKAGE__ # The folder path where the imported py file is located
__CACHED__ # Cache of import files
__name__ #如果是主文件 __name__ = "__main__" otherwise equals function name
#!/usr/bin/env python#-*-coding:utf-8-*-"""{' __builtins__ ': <module ' builtins ' (built-in);, ' __package__ ': None, ' __cached__ ': none, ' __file_     _ ': ' c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py ', ' __doc__ ': None, ' __name__ ': ' __main__ ', ' __loader__ ': <_frozen_importlib_external. Sourcefileloader object at 0x0000026ec5a58978>, ' __spec__ ': None}"""if __name__=='__main__':    Print(__file__)    Print(__doc__)    Print(VARs ())
Operation Result:
c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py # __file__{# __doc__'__builtins__': <module'Builtins'(built-inch) >,     '__package__': None,'__cached__': None,'__file__':'c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py',     '__doc__': None,'__name__':'__main__',     '__loader__': <_frozen_importlib_external. Sourcefileloader Object at 0x0000026ec5a58978>,    '__spec__': None}
# VARs () {'__cached__': None,'__package__': None,'__doc__':"\n{\n ' __builtins__ ': <module ' builtins ' (built-in), \ n ' __package__ ': none,\n ' __cached__ ': none,\n ' __file__ ': ' c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py ', \ n ' __doc__ ': None, \ n ' __name__ ': ' __main__ ', \ n ' __loader__ ': <_frozen_importlib_external. Sourcefileloader object at 0x0000026ec5a58978>,\n ' __spec__ ': none}\n",'__builtins__': <module'Builtins'(built-inch);'__file__':'c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py','__loader__': <_frozen_importlib_external. Sourcefileloader object at 0x000002354bfb8978>'__spec__': None,'__name__':'__main__'}

Python built-in variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.