Skip to content

Commit ed13a18

Browse files
author
Michael Howitz
committed
Document that __name__ is needed to define classes.
1 parent aaa3c8b commit ed13a18

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Changes
44
5.2 (unreleased)
55
----------------
66

7-
- Nothing changed yet.
7+
- Document that ``__name__`` is needed to define classes.
88

99

1010
5.1 (2020-10-07)

docs/usage/basic_usage.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ Necessary setup
101101
properly.
102102

103103
To use classes in Python 3
104-
``__metaclass__`` must be set. Set it to ``type`` to use no custom metaclass.
104+
* ``__metaclass__`` must be set. Set it to ``type`` to use no custom metaclass.
105+
* ``__name__`` must be set. As classes need a namespace to be defined in.
106+
It is the name of the module the class is defined in. You might set it to
107+
an arbitrary string.
105108

106109
To use ``for`` statements and comprehensions:
107-
* ``_getiter_`` must point to an ``iter`` implementation. As an unguarded variant you might use
110+
* ``_getiter_`` must point to an ``iter`` implementation. As an unguarded variant you might use
108111
:func:`RestrictedPython.Eval.default_guarded_getiter`.
109-
112+
110113
* ``_iter_unpack_sequence_`` must point to :func:`RestrictedPython.Guards.guarded_iter_unpack_sequence`.
111114

112115
To use ``getattr``

0 commit comments

Comments
 (0)