class_docstr: Context for multiprecision arithmetic with a global precision.
class_docstr_tok: ["Context","for","multiprecision","arithmetic","with","a","global","precision","."]
docstr: Convert an ``mpf`` or ``mpc`` to a decimal string literal with *n*
  significant digits. The small default value for *n* is chosen to
  make this function useful for printing collections of numbers
  (lists, matrices, etc).
  
  If *x* is a list or tuple, :func:`~mpmath.nstr` is applied recursively
  to each element. For unrecognized classes, :func:`~mpmath.nstr`
  simply returns ``str(x)``.
  
  The companion function :func:`~mpmath.nprint` prints the result
  instead of returning it.
  
  The keyword arguments *strip_zeros*, *min_fixed*, *max_fixed*
  and *show_zero_exponent* are forwarded to :func:`~mpmath.libmp.to_str`.
  
  The number will be printed in fixed-point format if the position
  of the leading digit is strictly between min_fixed
  (default = min(-dps/3,-5)) and max_fixed (default = dps).
  
  To force fixed-point format always, set min_fixed = -inf,
  max_fixed = +inf. To force floating-point format, set
  min_fixed >= max_fixed.
  
      >>> from mpmath import *
      >>> nstr([+pi, ldexp(1,-500)])
      '[3.14159, 3.05494e-151]'
      >>> nprint([+pi, ldexp(1,-500)])
      [3.14159, 3.05494e-151]
      >>> nstr(mpf("5e-10"), 5)
      '5.0e-10'
      >>> nstr(mpf("5e-10"), 5, strip_zeros=False)
      '5.0000e-10'
      >>> nstr(mpf("5e-10"), 5, strip_zeros=False, min_fixed=-11)
      '0.00000000050000'
      >>> nstr(mpf(0), 5, show_zero_exponent=True)
      '0.0e+0'
docstr_tok: ["Convert","an","``","mpf","``","or","``","mpc","``","to","a","decimal","string","literal","with","*","n","*","significant","digits",".","The","small","default","value","for","*","n","*","is","chosen","to","make","this","function","useful","for","printing","collections","of","numbers","(","lists",",","matrices",",","etc",")",".","If","*","x","*","is","a","list","or","tuple",",",":","func",":","`","~mpmath.nstr","`","is","applied","recursively","to","each","element",".","For","unrecognized","classes",",",":","func",":","`","~mpmath.nstr","`","simply","returns","``","str","(","x",")","``",".","The","companion","function",":","func",":","`","~mpmath.nprint","`","prints","the","result","instead","of","returning","it",".","The","keyword","arguments","*","strip_zeros","*",",","*","min_fixed","*",",","*","max_fixed","*","and","*","show_zero_exponent","*","are","forwarded","to",":","func",":","`","~mpmath.libmp.to_str","`",".","The","number","will","be","printed","in","fixed-point","format","if","the","position","of","the","leading","digit","is","strictly","between","min_fixed","(","default","=","min","(","-dps\/3",",","-5",")",")","and","max_fixed","(","default","=","dps",")",".","To","force","fixed-point","format","always",",","set","min_fixed","=","-inf",",","max_fixed","=","+inf",".","To","force","floating-point","format",",","set","min_fixed",">","=","max_fixed",".",">",">",">","from","mpmath","import","*",">",">",">","nstr","(","[","+pi",",","ldexp","(","1",",","-500",")","]",")","'","[","3.14159",",","3.05494e-151","]","'",">",">",">","nprint","(","[","+pi",",","ldexp","(","1",",","-500",")","]",")","[","3.14159",",","3.05494e-151","]",">",">",">","nstr","(","mpf","(","``","5e-10","''",")",",","5",")","'","5.0e-10'",">",">",">","nstr","(","mpf","(","``","5e-10","''",")",",","5",",","strip_zeros=False",")","'","5.0000e-10'",">",">",">","nstr","(","mpf","(","``","5e-10","''",")",",","5",",","strip_zeros=False",",","min_fixed=-11",")","'","0.00000000050000'",">",">",">","nstr","(","mpf","(","0",")",",","5",",","show_zero_exponent=True",")","'","0.0e+0","'"]
code: def nstr(ctx, x, n=6, **kwargs):
      """
      Convert an ``mpf`` or ``mpc`` to a decimal string literal with *n*
      significant digits. The small default value for *n* is chosen to
      make this function useful for printing collections of numbers
      (lists, matrices, etc).
  
      If *x* is a list or tuple, :func:`~mpmath.nstr` is applied recursively
      to each element. For unrecognized classes, :func:`~mpmath.nstr`
      simply returns ``str(x)``.
  
      The companion function :func:`~mpmath.nprint` prints the result
      instead of returning it.
  
      The keyword arguments *strip_zeros*, *min_fixed*, *max_fixed*
      and *show_zero_exponent* are forwarded to :func:`~mpmath.libmp.to_str`.
  
      The number will be printed in fixed-point format if the position
      of the leading digit is strictly between min_fixed
      (default = min(-dps/3,-5)) and max_fixed (default = dps).
  
      To force fixed-point format always, set min_fixed = -inf,
      max_fixed = +inf. To force floating-point format, set
      min_fixed >= max_fixed.
  
          >>> from mpmath import *
          >>> nstr([+pi, ldexp(1,-500)])
          '[3.14159, 3.05494e-151]'
          >>> nprint([+pi, ldexp(1,-500)])
          [3.14159, 3.05494e-151]
          >>> nstr(mpf("5e-10"), 5)
          '5.0e-10'
          >>> nstr(mpf("5e-10"), 5, strip_zeros=False)
          '5.0000e-10'
          >>> nstr(mpf("5e-10"), 5, strip_zeros=False, min_fixed=-11)
          '0.00000000050000'
          >>> nstr(mpf(0), 5, show_zero_exponent=True)
          '0.0e+0'
  
      """
      if isinstance(x, list):
          return "[%s]" % (
              ", ".join(ctx.nstr(c, n, **kwargs) for c in x)
          )
      if isinstance(x, tuple):
          return "(%s)" % (
              ", ".join(ctx.nstr(c, n, **kwargs) for c in x)
          )
      if hasattr(x, "_mpf_"):
          return to_str(x._mpf_, n, **kwargs)
      if hasattr(x, "_mpc_"):
          return "(" + mpc_to_str(x._mpc_, n, **kwargs) + ")"
      if isinstance(x, basestring):
          return repr(x)
      if isinstance(x, ctx.matrix):
          return x.__nstr__(n, **kwargs)
      return str(x)
  
imports: import functools
  import re
  from .ctx_base import StandardBaseContext
  from .libmp.backend import basestring, BACKEND
  from .None import libmp
  from .libmp import MPZ, MPZ_ZERO, MPZ_ONE, int_types, repr_dps, round_floor, round_ceiling, dps_to_prec, round_nearest, prec_to_dps, ComplexResult, to_pickable, from_pickable, normalize, from_int, from_float, from_str, to_int, to_float, to_str, from_rational, from_man_exp, fone, fzero, finf, fninf, fnan, mpf_abs, mpf_pos, mpf_neg, mpf_add, mpf_sub, mpf_mul, mpf_mul_int, mpf_div, mpf_rdiv_int, mpf_pow_int, mpf_mod, mpf_eq, mpf_cmp, mpf_lt, mpf_gt, mpf_le, mpf_ge, mpf_hash, mpf_rand, mpf_sum, bitcount, to_fixed, mpc_to_str, mpc_to_complex, mpc_hash, mpc_pos, mpc_is_nonzero, mpc_neg, mpc_conjugate, mpc_abs, mpc_add, mpc_add_mpf, mpc_sub, mpc_sub_mpf, mpc_mul, mpc_mul_mpf, mpc_mul_int, mpc_div, mpc_div_mpf, mpc_pow, mpc_pow_mpf, mpc_pow_int, mpc_mpf_div, mpf_pow, mpf_pi, mpf_degree, mpf_e, mpf_phi, mpf_ln2, mpf_ln10, mpf_euler, mpf_catalan, mpf_apery, mpf_khinchin, mpf_glaisher, mpf_twinprime, mpf_mertens, int_types
  from .None import function_docs
  from .None import rational
  from .ctx_mp_python import _mpf, _mpc, mpnumeric
label_desc: Use image node_id 30 for calling the MPContext obj's underlying member method code with example usage: obj.nstr(ctx, x, n) and returns: str, unknown, unknown, to_str, unknown, repr, x