def Extinction(extval,name=None):
   """Generate extinction curve to be used with spectra.

    By default, :meth:`~CustomRedLaw.reddening` is used to
    generate the extinction curve. If a deprecated
    reddening law is given, then
    `~pysynphot.extinction.DeprecatedExtinction` is used
    instead.

   .. note::

       Reddening laws are cached in ``pysynphot.Cache.RedLaws``
       for better performance. Repeated calls to the same
       reddening law here returns the cached result.

   Parameters
   ----------
   extval : float
       Value of :math:`E(B-V)` in magnitudes.

   name : str or `None`
       Name of reddening law (see :func:`print_red_laws`).
       If `None` (default), the average Milky Way extinction
       (``'mwavg'``) will be used.

   Returns
   -------
   ext : `~pysynphot.spectrum.ArraySpectralElement` or `~pysynphot.extinction.DeprecatedExtinction`
       Extinction curve.

   Raises
   ------
   ValueError
       Invalid reddening law.

   Examples
   --------
   >>> ext = S.Extinction(0.3, 'mwavg')

   """
   try:
       ext=Cache.RedLaws[name].reddening(extval)
   except AttributeError:
       #The cache hasn't yet been filled.
       Cache.RedLaws[name]=RedLaw(Cache.RedLaws[name])
       ext=Cache.RedLaws[name].reddening(extval)
   except KeyError:
       #There's no reddening law by that name. See if we've been
       #given a filename from which we can read one.
       try:
           Cache.RedLaws[name]=RedLaw(name)
           ext=Cache.RedLaws[name].reddening(extval)
       except IOError:
           #If not, see if it's an old extinction law
           try:
               ext=extinction.DeprecatedExtinction(extval,name)
           except KeyError:
               raise ValueError('No extinction law has been defined for "%s", and no such file exists'%name)
   return ext
Generate extinction curve to be used with spectra.

    By default, :meth:`~CustomRedLaw.reddening` is used to
    generate the extinction curve. If a deprecated
    reddening law is given, then
    `~pysynphot.extinction.DeprecatedExtinction` is used
    instead.

   .. note::

       Reddening laws are cached in ``pysynphot.Cache.RedLaws``
       for better performance. Repeated calls to the same
       reddening law here returns the cached result.

   Parameters
   ----------
   extval : float
       Value of :math:`E(B-V)` in magnitudes.

   name : str or `None`
       Name of reddening law (see :func:`print_red_laws`).
       If `None` (default), the average Milky Way extinction
       (``'mwavg'``) will be used.

   Returns
   -------
   ext : `~pysynphot.spectrum.ArraySpectralElement` or `~pysynphot.extinction.DeprecatedExtinction`
       Extinction curve.

   Raises
   ------
   ValueError
       Invalid reddening law.

   Examples
   --------
   >>> ext = S.Extinction(0.3, 'mwavg')