From 383efbfe23a205e3fc11c29c196d2db0d421a06e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rg=20Lehmann?= Date: Thu, 25 Oct 2007 09:48:01 +0000 Subject: [PATCH] Do not use list as default argument. Although it doesn't matter in this particular case, it's bad style and can be confusing. git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@2943 069f4177-920e-0410-937b-c2a4a81bcd90 --- pyx/canvas.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pyx/canvas.py b/pyx/canvas.py index 875b784e..103c1685 100644 --- a/pyx/canvas.py +++ b/pyx/canvas.py @@ -1,4 +1,4 @@ -# -*- coding: ISO-8859-1 -*- +=# -*- coding: ISO-8859-1 -*- # # # Copyright (C) 2002-2006 Jörg Lehmann @@ -68,11 +68,11 @@ class _canvas(canvasitem.canvasitem): """a canvas holds a collection of canvasitems""" - def __init__(self, attrs=[], texrunner=None): + def __init__(self, attrs=None, texrunner=None): """construct a canvas - The canvas can be modfied by supplying args, which have + The canvas can be modfied by supplying a list of attrs, which have to be instances of one of the following classes: - trafo.trafo (leading to a global transformation of the canvas) - canvas.clip (clips the canvas) @@ -102,17 +102,16 @@ class _canvas(canvasitem.canvasitem): # from the right. # Note that while for the stroke and fill styles the order doesn't matter at all, # this is not true for the clip operation. - attrs = attrs[:] - attrs.reverse() - for aattr in attrs: - if isinstance(aattr, trafo.trafo_pt): - self.trafo = self.trafo * aattr - elif isinstance(aattr, clip): - if self.clipbbox is None: - self.clipbbox = aattr.clipbbox().transformed(self.trafo) - else: - self.clippbox *= aattr.clipbbox().transformed(self.trafo) - self.items.append(aattr) + if attrs is not None: + for aattr in attrs[::-1]: + if isinstance(aattr, trafo.trafo_pt): + self.trafo = self.trafo * aattr + elif isinstance(aattr, clip): + if self.clipbbox is None: + self.clipbbox = aattr.clipbbox().transformed(self.trafo) + else: + self.clippbox *= aattr.clipbbox().transformed(self.trafo) + self.items.append(aattr) def __len__(self): return len(self.items) -- 2.11.4.GIT