code: def real(self, newreal):
          
          try:
              iter(newreal)
          except TypeError:
              # `newreal` is not iterable, assume it can be assigned to
              # all indexed parts
              for part in self.parts:
                  part.real = newreal
              return
  
          if self.space.is_power_space:
              try:
                  # Set same value in all parts
                  for part in self.parts:
                      part.real = newreal
              except (ValueError, TypeError):
                  # Iterate over all parts and set them separately
                  for part, new_re in zip(self.parts, newreal):
                      part.real = new_re
                  pass
          elif len(newreal) == len(self):
              for part, new_re in zip(self.parts, newreal):
                  part.real = new_re
          else:
              raise ValueError(
                  'dimensions of the new real part does not match the space, '
                  'got element {} to set real part of {}'.format(newreal, self))
docs: Setter for the real part.
  
          This method is invoked by ``x.real = other``.
  
          Parameters
          ----------
          newreal : array-like or scalar
              Values to be assigned to the real part of this element.