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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:12:42+00:00 2026-05-21T04:12:42+00:00

I have problem with casting in python. I have a method in file module_A.py:

  • 0

I have problem with casting in python.

I have a method in file module_A.py:

import Common.Models.Pax as Pax

def verify_passangers_data(self,paxes):
    for i in range(len(paxes)):
         pax=paxes[i]

Here is my Pax.py

class Pax:
    """"""

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
    #----------------------------------------------------------------------



class Adult(Pax):

    def __init__(self,last_day_of_travel,first_name,last_name,nationality,address=None):
        self.birth_day=datetime.today() - timedelta(days = random.randrange(6563, 20793-(date.today()-last_day_of_travel).days))
        self.first_name=first_name
        self.last_name=last_name
        self.nationality=nationality
        self.address=address

This is how I create collection in another module(module_C.py):

paxes=[]
        paxes.append(Pax.Adult(last_day_of_travel,'FirstName','LastName',Nationality.Poland,DataRepository.addresses['Default']))

but, look at my output from debug probe (in wing ide)

>>> type(pax)
<class 'Common.Models.Pax.Adult'>
>>> pax is Common.Models.Pax.Adult
Traceback (most recent call last):
  File "<string>", line 1, in <fragment>
builtins.NameError: name 'Common' is not defined

How can I check is pax is instance of Adult?

  • 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-21T04:12:43+00:00Added an answer on May 21, 2026 at 4:12 am

    How can I check is pax is instance of Adult?

    Use the isinstance function:

    isinstance(pax, Common.Models.Pax.Adult)
    

    Make you have imported the class, though (e.g., import Common.Models.Pax).

    (Although purists would argue that there’s rarely a need to check the type of a Python object. Python is dynamically typed, so you should generally check to see if an object responds to a particular method call, rather than checking its type. But you may have a good reason for needing to check the type, too.)

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

Sidebar

Related Questions

I have a problem with casting from float to double when fread; fread(doublePointer,sizeofFloat,500,f); if
I have the following casting problem when my data structure sSpecificData contains a field
I have a problem with what appears to be some sort of implicit casting
I have got a problem on casting an object to one of it's base
I have a casting problem. I am writing a code to open all the
I'm having a bit of problem with casting and datagrids. I have a LINQ
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE

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.