Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7167381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:34:07+00:00 2026-05-28T14:34:07+00:00

I am using the Python IDE PyCharm and something that is have by default

  • 0

I am using the Python IDE PyCharm and something that is have by default is it will showing warning when I have a mutbale type as a default value. For example, when I have this:

def status(self, options=[]):

PyCharm wants it to looks like:

def status(self, options=None):
    if not options: options = []

My question is whether or not this is a standard way of doing things in the Python community or is this just the way PyCharm thinks it should be done? Are there any disadvantages of having mutable data type as defaults method arguments?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:34:09+00:00Added an answer on May 28, 2026 at 2:34 pm

    This is the right way to do it because the same mutable object is used every time you call the same method. If the mutable object is changed afterwards, then the default value won’t probably be what it was intended to be.

    For example, the following code:

    def status(options=[]):
        options.append('new_option')
        return options
    
    print status()
    print status()
    print status()
    

    will print:

    ['new_option']
    ['new_option', 'new_option']
    ['new_option', 'new_option', 'new_option']
    

    which, as I said above, probably isn’t what you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using eclipse pydev IDE for coding python. I found that by default
im using the fantastic eric4 ide to code python, it's got a tool built
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
I am using Netbeans 6.8 as my Python IDE. I can use PIL (1.1.7)
I have a Python project that has the following structure: package1 class.py class2.py ...
Did my python ide break or something? import sys i = 0 sample =
besides from using a completely integrated IDE with debugger for python (like with Eclipse),
I want to start using Python for small projects but the fact that a
Python for Windows by default comes with IDLE, which is the barest-bones IDE I've
I have an Arduino microcontroller listening on COM3. Using the arduino IDE and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.