Skip to content

Instantly share code, notes, and snippets.

@w495
Created March 5, 2020 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w495/a643fbd88509b223afbf60700e0b158b to your computer and use it in GitHub Desktop.
Save w495/a643fbd88509b223afbf60700e0b158b to your computer and use it in GitHub Desktop.
Пример использования приватных методов модуля в классе
# coding: utf-8
import logging
__logger = logging.getLogger(__name__)
def global_function():
__logger.error('global_function')
class Base(object):
def base_function(self):
"""
:raises NameError: name '_Base__logger' is not defined
"""
__logger.error('base_function')
if __name__ == '__main__':
__logger.error('main call')
global_function()
b = Base()
b.base_function()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment