(root)/
Python-3.12.0/
Lib/
test/
pydocfodder.py
       1  """Something just to look at via pydoc."""
       2  
       3  import types
       4  
       5  class ESC[4;38;5;81mA_new:
       6      "A new-style class."
       7  
       8      def A_method(self):
       9          "Method defined in A."
      10      def AB_method(self):
      11          "Method defined in A and B."
      12      def AC_method(self):
      13          "Method defined in A and C."
      14      def AD_method(self):
      15          "Method defined in A and D."
      16      def ABC_method(self):
      17          "Method defined in A, B and C."
      18      def ABD_method(self):
      19          "Method defined in A, B and D."
      20      def ACD_method(self):
      21          "Method defined in A, C and D."
      22      def ABCD_method(self):
      23          "Method defined in A, B, C and D."
      24  
      25      def A_classmethod(cls, x):
      26          "A class method defined in A."
      27      A_classmethod = classmethod(A_classmethod)
      28  
      29      def A_staticmethod():
      30          "A static method defined in A."
      31      A_staticmethod = staticmethod(A_staticmethod)
      32  
      33      def _getx(self):
      34          "A property getter function."
      35      def _setx(self, value):
      36          "A property setter function."
      37      def _delx(self):
      38          "A property deleter function."
      39      A_property = property(fdel=_delx, fget=_getx, fset=_setx,
      40                            doc="A sample property defined in A.")
      41  
      42      A_int_alias = int
      43  
      44  class ESC[4;38;5;81mB_new(ESC[4;38;5;149mA_new):
      45      "A new-style class, derived from A_new."
      46  
      47      def AB_method(self):
      48          "Method defined in A and B."
      49      def ABC_method(self):
      50          "Method defined in A, B and C."
      51      def ABD_method(self):
      52          "Method defined in A, B and D."
      53      def ABCD_method(self):
      54          "Method defined in A, B, C and D."
      55      def B_method(self):
      56          "Method defined in B."
      57      def BC_method(self):
      58          "Method defined in B and C."
      59      def BD_method(self):
      60          "Method defined in B and D."
      61      def BCD_method(self):
      62          "Method defined in B, C and D."
      63  
      64  class ESC[4;38;5;81mC_new(ESC[4;38;5;149mA_new):
      65      "A new-style class, derived from A_new."
      66  
      67      def AC_method(self):
      68          "Method defined in A and C."
      69      def ABC_method(self):
      70          "Method defined in A, B and C."
      71      def ACD_method(self):
      72          "Method defined in A, C and D."
      73      def ABCD_method(self):
      74          "Method defined in A, B, C and D."
      75      def BC_method(self):
      76          "Method defined in B and C."
      77      def BCD_method(self):
      78          "Method defined in B, C and D."
      79      def C_method(self):
      80          "Method defined in C."
      81      def CD_method(self):
      82          "Method defined in C and D."
      83  
      84  class ESC[4;38;5;81mD_new(ESC[4;38;5;149mB_new, ESC[4;38;5;149mC_new):
      85      """A new-style class, derived from B_new and C_new.
      86      """
      87  
      88      def AD_method(self):
      89          "Method defined in A and D."
      90      def ABD_method(self):
      91          "Method defined in A, B and D."
      92      def ACD_method(self):
      93          "Method defined in A, C and D."
      94      def ABCD_method(self):
      95          "Method defined in A, B, C and D."
      96      def BD_method(self):
      97          "Method defined in B and D."
      98      def BCD_method(self):
      99          "Method defined in B, C and D."
     100      def CD_method(self):
     101          "Method defined in C and D."
     102      def D_method(self):
     103          "Method defined in D."
     104  
     105  class ESC[4;38;5;81mFunkyProperties(ESC[4;38;5;149mobject):
     106      """From SF bug 472347, by Roeland Rengelink.
     107  
     108      Property getters etc may not be vanilla functions or methods,
     109      and this used to make GUI pydoc blow up.
     110      """
     111  
     112      def __init__(self):
     113          self.desc = {'x':0}
     114  
     115      class ESC[4;38;5;81mget_desc:
     116          def __init__(self, attr):
     117              self.attr = attr
     118          def __call__(self, inst):
     119              print('Get called', self, inst)
     120              return inst.desc[self.attr]
     121      class ESC[4;38;5;81mset_desc:
     122          def __init__(self, attr):
     123              self.attr = attr
     124          def __call__(self, inst, val):
     125              print('Set called', self, inst, val)
     126              inst.desc[self.attr] = val
     127      class ESC[4;38;5;81mdel_desc:
     128          def __init__(self, attr):
     129              self.attr = attr
     130          def __call__(self, inst):
     131              print('Del called', self, inst)
     132              del inst.desc[self.attr]
     133  
     134      x = property(get_desc('x'), set_desc('x'), del_desc('x'), 'prop x')
     135  
     136  
     137  submodule = types.ModuleType(__name__ + '.submodule',
     138      """A submodule, which should appear in its parent's summary""")