Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strage default value behaviour #48208

Closed
dominikholler mannequin opened this issue Sep 24, 2008 · 3 comments
Closed

strage default value behaviour #48208

dominikholler mannequin opened this issue Sep 24, 2008 · 3 comments

Comments

@dominikholler
Copy link
Mannequin

dominikholler mannequin commented Sep 24, 2008

BPO 3958
Nosy @amauryfa
Files
  • test.py
  • index.html
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2008-09-24.15:58:27.208>
    created_at = <Date 2008-09-24.15:17:22.678>
    labels = ['invalid']
    title = 'strage default value behaviour'
    updated_at = <Date 2008-09-24.18:33:04.323>
    user = 'https://bugs.python.org/dominikholler'

    bugs.python.org fields:

    activity = <Date 2008-09-24.18:33:04.323>
    actor = 'dominik.holler'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-09-24.15:58:27.208>
    closer = 'amaury.forgeotdarc'
    components = ['None']
    creation = <Date 2008-09-24.15:17:22.678>
    creator = 'dominik.holler'
    dependencies = []
    files = ['11593', '11594']
    hgrepos = []
    issue_num = 3958
    keywords = []
    message_count = 3.0
    messages = ['73718', '73723', '73745']
    nosy_count = 2.0
    nosy_names = ['amaury.forgeotdarc', 'dominik.holler']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue3958'
    versions = ['Python 2.5', 'Python 2.4']

    @dominikholler
    Copy link
    Mannequin Author

    dominikholler mannequin commented Sep 24, 2008

    The behaviour is changing, if I toogle comment lines 10 + 11.

    Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
    (Intel)] on
    win32

    @amauryfa
    Copy link
    Member

    Your script is subject to the "shared default value" syndrome, explained
    here:
    http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects

    As indicated in the FAQ, your function could be rewritten like this:

    def getElementsByAttrib(self, value, AName="ID-REF", list=None):
      if list is None:
          list = []
      ...

    to have a less surprising behavior.

    @dominikholler
    Copy link
    Mannequin Author

    dominikholler mannequin commented Sep 24, 2008

    thx
    sorry reporting this bug

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant