979
980 def _log_message(undef: Undefined) -> None:
981 logger.warning( # type: ignore
982 "Template variable warning: %s", undef._undefined_message 983 )
984
985 class LoggingUndefined(base): # type: ignore
383 )
384 offset = len(prefix)
385
386 for name in self._loader._files.keys(): # type: ignore387 # Find names under the templates directory that aren't directories.
388 if name.startswith(prefix) and name[-1] != os.path.sep:
389 results.append(name[offset:].replace(os.path.sep, "/"))
503
504 if isinstance(name, Undefined):
505 try:
506 name._fail_with_undefined_error() 507 except Exception as e:
508 msg = f"{msg} ({e}; did you forget to quote the callable name?)"
509
1032 .. versionadded:: 2.3
1033 """
1034 if isinstance(names, Undefined):
1035 names._fail_with_undefined_error()1036
1037 if not names:
1038 raise TemplatesNotFound(
Accessing a protected member (a member prefixed with _
) of a class from outside that class is not recommended, since the creator of that class did not intend this member to be exposed. If accesing this attribute outside of the class is absolutely needed, refactor it such that it becomes part of the public interface of the class.
class Rectangle(object):
def __init__(self, height, width):
self._height = height
self._width = width
r = Rectangle(4, 8)
area = r._height * r._width
class Rectangle(object):
def __init__(self, height, width):
self._height = height
self._width = width
def area():
return self._height * self._width
r = Rectangle(4, 8)
area = r.area()