Change in pysim[master]: pySim/filesystem: fix mutable default list/dict arguments

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sat Mar 27 18:28:33 UTC 2021


laforge has uploaded a new patch set (#3) to the change originally created by fixeria. ( https://gerrit.osmocom.org/c/pysim/+/23513 )

Change subject: pySim/filesystem: fix mutable default list/dict arguments
......................................................................

pySim/filesystem: fix mutable default list/dict arguments

Having lists and dictionaries as default argument values is a bad
idea, because the same instance of list/dict will be used by all
objects instantiated using such constructor:

  def appendItem(itemName, itemList=[]):
      itemList.append(itemName)
      return itemList

  print(appendItem('notebook'))
  print(appendItem('pencil'))
  print(appendItem('eraser'))

Output:

  ['notebook']
  ['notebook', 'pencil']
  ['notebook', 'pencil', 'eraser']

Change-Id: I83d718ff9c3ff6aef47930f38d7f50424f9b880f
---
M pySim/filesystem.py
1 file changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/13/23513/3
-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23513
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I83d718ff9c3ff6aef47930f38d7f50424f9b880f
Gerrit-Change-Number: 23513
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210327/c2117b7c/attachment.htm>


More information about the gerrit-log mailing list