#14795: Mutable defaults in function/method definitions
------------------------+---------------------------------------------------
   Reporter:  mguaypaq  |             Owner:  mguaypaq           
       Type:  task      |            Status:  new                
   Priority:  minor     |         Milestone:  sage-5.12          
  Component:  misc      |          Keywords:                     
Work issues:            |   Report Upstream:  N/A                
  Reviewers:            |           Authors:  Mathieu Guay-Paquet
  Merged in:            |      Dependencies:                     
   Stopgaps:            |  
------------------------+---------------------------------------------------
 Several functions and methods in Sage have mutable default arguments,
 especially lists. This is generally frowned upon, at least on the Python
 side (see http://effbot.org/zone/default-values.htm), since it can cause
 so many subtle bugs, and there's usually no benefit to doing this instead
 of using a tuple or `None` (with creation of the mutable argument in the
 function body).

 Are there any objections to fixing this?

 Here is a somewhat filtered (and certainly non-exhaustive) output of a
 naive grep search through the codebase:

 {{{
 sage/combinat/partition.py:    def content(self, r, c, multicharge=[0]):
 sage/combinat/partition.py:    def dimension(self, smaller = [], k = 1):
 sage/combinat/root_system/pieri_factors.py:    def __classcall__(cls, W,
 min_length = 0, max_length = infinity, min_support = frozenset([]),
 max_support = None):
 sage/combinat/root_system/weight_lattice_realizations.py:        def
 plot(self, size=[[0],[0]], projection='usual', simple_roots=True,
 fundamental_weights=True, alcovewalks=[]):
 sage/combinat/tableau.py:    def content(self, k, multicharge=[0]):
 sage/combinat/designs/covering_design.py:    def __init__(self, v=0, k=0,
 t=0, size=0, points=[], blocks=[], low_bd=0, method='', creator
 ='',timestamp=''):
 sage/combinat/integer_vector.py:def _slider01(A, t, k, p1, p2,
 fixedcols=[]):
 sage/plot/graphics.py:    def _extract_kwds_for_show(cls, kwds,
 ignore=[]):
 sage/matrix/benchmark.py:def report(F, title, systems = ['sage', 'magma'],
 **kwds):
 sage/server/notebook/worksheet.py:    def
 do_sage_extensions_preparsing(self, s, files_seen_so_far=[],
 this_file=''):
 sage/sets/family.py:def Family(indices, function = None, hidden_keys = [],
 hidden_function = None, lazy = False, name=None):
 sage/modular/etaproducts.py:def eta_poly_relations(eta_elements, degree,
 labels=['x1','x2'], verbose=False):
 sage/modular/modform/find_generators.py:    def generators(self,
 maxweight=8, prec=10, start_gens=[], start_weight=2):
 sage/modular/modform/find_generators.py:    def gen_forms(self,
 maxweight=8, start_gens=[], start_weight=2):
 sage/quadratic_forms/random_quadraticform.py:def random_quadraticform(R,
 n, rand_arg_list=[]):
 sage/quadratic_forms/random_quadraticform.py:def
 random_quadraticform_with_conditions(R, n, condition_list=[],
 rand_arg_list=[]):
 sage/groups/perm_gps/cubegroup.py:def color_of_square(facet,
 colors=['lpurple', 'yellow', 'red', 'green', 'orange', 'blue']):
 sage/groups/perm_gps/cubegroup.py:    def plot_cube(self, mv, title=True,
 colors = [lpurple, yellow, red, green, orange, blue]):
 sage/groups/perm_gps/cubegroup.py:    def __init__(self, state=None,
 history=[], colors=[lpurple,yellow,red,green,orange,blue]):
 sage/rings/number_field/totallyreal_rel.py:def
 enumerate_totallyreal_fields_rel(F, m, B, a = [], verbose=0,
 return_seqs=False):
 sage/rings/number_field/number_field_ideal.py:    def
 invertible_residues_mod(self, subgp_gens=[], reduce=True):
 sage/rings/polynomial/groebner_fan.py:    def __init__(self,
 gfan_polyhedral_fan, parameter_indices = []):
 sage/rings/polynomial/groebner_fan.py:    def __init__(self,
 gfan_polyhedral_fan, polynomial_system, poly_ring, parameters = []):
 sage/rings/polynomial/groebner_fan.py:    def tropical_intersection(self,
 parameters = [], symmetry_generators = [], *args, **kwds):
 sage/geometry/polytope.py:    def convex_hull(self, points=[]):
 sage/doctest/forker.py:    def __init__(self, source, options,
 funclist=[]):
 sage/homology/cubical_complex.py:    def __init__(self, maximal_faces=[],
 **kwds):
 sage/interfaces/magma.py:    def function_call(self, function, args=[],
 params={}, nvals=1):
 sage/interfaces/qepcad.py:    def __init__(self, formula, vars, qvars=[]):
 sage/interfaces/frobby.py:    def __call__(self, action, input=None,
 options=[], verbose=False):
 sage/misc/preparser.py:def containing_block(code, ix,
 delimiters=['()','[]','{}'], require_delim=True):
 sage/misc/sage_unittest.py:    def run(self, category = None, skip = [],
 catch = True, raise_on_failure = False, **options):
 sage/misc/latex.py:    def __init__(self, bb=False, delimiters=["(",
 ")"]):
 sage/misc/profiler.py:    def __init__(self, systems=[], verbose=False):
 sage/schemes/elliptic_curves/ell_egros.py:def is_possible_j(j,S=[]):
 sage/schemes/elliptic_curves/ell_egros.py:def egros_from_j_1728(S=[]):
 sage/schemes/elliptic_curves/ell_egros.py:def egros_from_j_0(S=[]):
 sage/schemes/elliptic_curves/ell_egros.py:def egros_from_j(j,S=[]):
 sage/schemes/elliptic_curves/ell_egros.py:def
 egros_from_jlist(jlist,S=[]):
 sage/schemes/elliptic_curves/ell_egros.py:def egros_get_j(S=[],
 proof=None, verbose=False):
 sage/schemes/elliptic_curves/constructor.py:def
 EllipticCurves_with_good_reduction_outside_S(S=[], proof=None,
 verbose=False):
 sage/schemes/elliptic_curves/ell_number_field.py:    def
 regulator_of_points(self, points=[], precision=None):
 sage/schemes/elliptic_curves/ell_rational_field.py:    def
 has_good_reduction_outside_S(self,S=[]):
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14795>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to