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 9259129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:34:51+00:00 2026-06-18T12:34:51+00:00

I often find myself overwriting methods of a parent class, and can never decide

  • 0

I often find myself overwriting methods of a parent class, and can never decide if I should explicitly list given parameters or just use a blanket *args, **kwargs construct. Is one version better than the other? Is there a best practice? What (dis-)advantages am I missing?

class Parent(object):

    def save(self, commit=True):
        # ...

class Explicit(Parent):

    def save(self, commit=True):
        super(Explicit, self).save(commit=commit)
        # more logic

class Blanket(Parent):

    def save(self, *args, **kwargs):
        super(Blanket, self).save(*args, **kwargs)
        # more logic

Perceived benefits of explicit variant

  • More explicit (Zen of Python)
  • easier to grasp
  • function parameters easily accessed

Perceived benefits of blanket variant

  • more DRY
  • parent class is easily interchangeable
  • change of default values in parent method is propagated without touching other code
  • 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-06-18T12:34:52+00:00Added an answer on June 18, 2026 at 12:34 pm

    Liskov Substitution Principle

    Generally you don’t want you method signature to vary in derived types. This can cause problems if you want to swap the use of derived types. This is often referred to as the Liskov Substitution Principle.

    Benefits of Explicit Signatures

    At the same time I don’t think it’s correct for all your methods to have a signature of *args, **kwargs. Explicit signatures:

    • help to document the method through good argument names
    • help to document the method by specifying which args are required and which have default values
    • provide implicit validation (missing required args throw obvious exceptions)

    Variable Length Arguments and Coupling

    Do not mistake variable length arguments for good coupling practice. There should be a certain amount of cohesion between a parent class and derived classes otherwise they wouldn’t be related to each other. It is normal for related code to result in coupling that reflects the level of cohesion.

    Places To Use Variable Length Arguments

    Use of variable length arguments shouldn’t be your first option. It should be used when you have a good reason like:

    • Defining a function wrapper (i.e. a decorator).
    • Defining a parametric polymorphic function.
    • When the arguments you can take really are completely variable (e.g. a generalized DB connection function). DB connection functions usually take a connection string in many different forms, both in single arg form, and in multi-arg form. There are also different sets of options for different databases.
    • …

    Are You Doing Something Wrong?

    If you find you are often creating methods which take many arguments or derived methods with different signatures you may have a bigger issue in how you’re organizing your code.

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

Sidebar

Related Questions

I often find myself with a list of disconnected Linq2Sql objects or keys that
While striving for const-correctness, I often find myself writing code such as this class
I often find myself remembering the name of a class that I want to
I often find myself needing to compose a list of items from attributes of
I often find myself wanting (and then usually writing) Scalaz type class instances for
I often find myself writing class constructors like this: class foo: def __init__(self, arg1,
I often find myself asserting that an object isKindOfClass of some class in Objective-C.
I often find myself into this: .class { border-top:1px dashed #0000000; border-bottom:1px dashed #0000000;
I often find myself implementing a class maintaining some kind of own status property
I often find myself confused with how the terms 'arguments' and 'parameters' are used.

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.