astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v0.3 »
- Astropy Core Package Utilities (`astropy.utils`) »
- deprecated_attribute

# deprecated_attribute

`astropy.utils.misc.``deprecated_attribute`(name, since, message=None, alternative=None, pending=False)

  Used to mark a public attribute as deprecated. This creates a property that will warn when the given attribute name is accessed. To prevent the warning (i.e. for internal code), use the private name for the attribute by prepending an underscore (i.e. `self._name`).

  Parameters:

  name : str

  > The name of the deprecated attribute.

  since : str

  > The release at which this API became deprecated. This is required.

  message : str, optional

  > Override the default deprecation message. The format specifier `%(name)s` may be used for the name of the attribute, and `%(alternative)s` may be used in the deprecation message to insert the name of an alternative to the deprecated function.

  alternative : str, optional

  > An alternative attribute that the user may use in place of the deprecated attribute. The deprecation warning will tell the user about this alternative if provided.

  pending : bool, optional

  > If True, uses a AstropyPendingDeprecationWarning instead of a AstropyDeprecationWarning.

  Examples

      class MyClass:
          # Mark the old_name as deprecated
          old_name = misc.deprecated_attribute('old_name', '0.1')

          def method(self):
              self._old_name = 42