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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:23:56+00:00 2026-06-06T06:23:56+00:00

class Pen(object): def __init__(self, mean_radius = None, length = None): self.usage = Is used

  • 0
class Pen(object):
    def __init__(self, mean_radius = None, length = None):
        self.usage = "Is used to apply ink trails to drawing surfaces"
        self.mean_radius = mean_radius
        self.length = length

class FountainPen(Pen):
    def __init__(self, manufacturer = "Waterman", *args, **kwargs):
        Pen.__init__(self, *args, **kwargs)
        self.manufacturer = manufacturer
        self.cartridge_state =  "non-empty"

>>> instance_FP = FountainPen(5, 1)
>>> instance_FP.mean_radius
>>> print instance_FP.mean_radius
1    
>>> print instance_FP.length
None

What happens with the integer 5 being passed as an argument in the instantiation of FountainPen?
Why does print instance_FP.mean_radius return 1 and not 5?

  • 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-06T06:23:57+00:00Added an answer on June 6, 2026 at 6:23 am

    You have to think it like that: *args and **kwargs “eat” all the positional/keyword arguments left by the “regular” arguments that precede them. If you put them in the end, they will only get whatever couldn’t fit the “regular arguments”.

    So, when you write FountainPen(5,1) what happens is that FountainPen.__init__ gets called like this:

    • self is set to the newly created instance;
    • manufacturer gets the first argument, which is 5;
    • *args “eats” all the remaining positional arguments, i.e. just 1; so args is now set to [1];
    • *kwargs would eat any keyword argument left, but there’s none, so it becomes {}.

    It’s then clear that Pen.__init__ is called with just 1 as argument (besides self), and length remains set to its default value (None).

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

Sidebar

Related Questions

class ShortInputException(Exception): '''A user-defined exception class.''' def __init__(self, length, atleast): Exception.__init__(self) self.length = length
class A(object): _all = set() def __new__(cls): obj = super(A,cls).__new__(cls) cls._all.add(obj) return obj class
m.pen = Pens.Red; //No error m.pen.EndCap = System.Drawing.Drawing2D.LineCap.Square; //error Where m is an object
In the code below I create a Pen object and initialize it's color to
I have a Shape class wich contains public Pen outlinePen; What I try to
I've been attempting to create a pen tool for my Java drawing program using
class A{ public A(){ System.out.println(in A); } } public class SampleClass{ public static void
Class A { string name; IList<A> minorList = new List<A>(); } IList<A> majorList =
class BaseA{}; , class DerivedB{}; class DerivedC{}; DerivedB can be derived from BaseA :
class A { String s4 = abc; static public void main(String[]args ) { String

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.