Home
Blogs
Questions

Home

About Us

Blogs

Questions

Monetize

Post Job

banner

Questions about default-parameters

Read more about default-parameters

python (12.9k questions)

javascript (9.2k questions)

reactjs (4.7k questions)

java (4.2k questions)

java (4.2k questions)

c# (3.5k questions)

c# (3.5k questions)

html (3.3k questions)

Questions - default-parameters

Are there caveats of using mutable types as default parameters in functions in Python?

I have recently read about mutable default parameters in Python. For some reason, I came up with an idea of using it like this: data = [3, 4, 1, 8, 5, 9, 2, 6, 7] def get_min(checked=[]): global...
test-img

Oleksandr Novik

python

function

mutable

default-parameters

Votes: 0

Answers: 1

Latest Answer

The main caveat is that someone reading your code later, unless they're familiar with this particular gotcha, might not understand that checked persists, or that the caller isn't actually intended to ...
test-img

Samwise

Posts

Questions

Blogs

Where knowledge meets opportunity!

About

  • Company
  • Monetize your knowledge
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved