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

  • Home
  • SEARCH
  • 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 8254221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:07:04+00:00 2026-06-08T01:07:04+00:00

To be honest, I was expecting some sort of error, like ‘ you can’t

  • 0

To be honest, I was expecting some sort of error, like ‘you can’t rename two nested functions with same name in a same body like that’ , Can we define any number of functions with same name in python ?

In [40]: def add(i,j):
   ....:     def add(i,j):
   ....:         print i+j
   ....:     def add(i,j):    
   ....:         print i-j
   ....:     return add(i,j)
   ....: 

In [41]: add(5,4)
1

Is this Overloading of function, or Overriding of function ??

  • 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-08T01:07:06+00:00Added an answer on June 8, 2026 at 1:07 am

    Of course. A def statement is functionally an assignment (of the function to the name), and you can have any number of assignments to the same name. (It`s important to realize that function definitions are executed in Python, they are not statically evaluated at compile time.)

    There are hacky ways to catch this in class definitions, such as this method I posted in May. If you’re using Python 3, there’s a better way.

    For functions, that won’t work, so I believe you’re stuck with this behavior.

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

Sidebar

Related Questions

To be honest, I do not really know how to name that problem. I'll
Ive read about it and to be honest it all seems like a bunch
I have an objective-C++ class which contain some honest C++ object pointers. When the
(This looks like a long question, but it's not really, honest!) I am trying
I like C++ a lot and to be honest the Objective-C super set of
We're trying to do some things on Facebook but to be honest we have
To be honest there are a couple of questions I'd like to ask, but
New to using databases, so not sure where my error lies to be honest.
I'll try to explain my problem although to be honest I can't even understand
I have a problem while executing a SSIS script component. To be honest I

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.