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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:04:29+00:00 2026-06-14T22:04:29+00:00

A piece of code works that I don’t see why. It shouldn’t work from

  • 0

A piece of code works that I don’t see why. It shouldn’t work from my understanding. The problem is illustrated easily below:

“Main.py”

from x import * #class x is defined
from y import * #class y is defined


xTypeObj = x()
yTypeObj = y()
yTypeObj.func(xTypeObj)

“x.py”

class x(object):

    def __init__...
        ...
    def functionThatReturnsAString(self):
        return "blah"

“y.py”

#NO IMPORT STATEMENT NEEDED?? WHY

class y(object):
    def __init__...
        ...
    def func(self, objOfTypeX):
        print(objOfTypeX.functionThatReturnsAString())

My question is why do I NOT need to have an import statement in “y.py” of the type

from x import functionThatReturnAString()

How does it figure out how to call this method?

  • 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-14T22:04:30+00:00Added an answer on June 14, 2026 at 10:04 pm

    Python is a dynamically typed language. Unlike statically typed languages like C++ and Java calls to methods aren’t bound until they are actually executed, thus why importing the module were that method is defined is not necessary. This has several implications:

    1. Methods (and data members) can be added to and removed from an instance at runtime, so two instances of class Foo can actually have different methods even though they are of the same type.
    2. Methods (and data members) can be added to and removed from a class at runtime, which will impact all current instances as well as new instances.
    3. Bases classes can be added and removed to a class at runtime.

    Note that this is not an exhaustive list of all of the difference between dynamically typed langauges and statically types languages.

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

Sidebar

Related Questions

I'm struggling to get the below piece of code working. The problem is that
I have this piece of code that works fine in subsonic 2.2, I migrated
I have a small piece of code that works as a plugin for a
I've got a piece of code that works fine. It basically loops through each
I'm doing a pattern match in a piece of code that works fine in
I just realized that this piece of code works well in Firefox but not
I have a piece of code ( I'm student ) that should work in
I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
I have a piece of code here that does not work despite me using
I have a piece of code which works in a way that is unexpected

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.