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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:58:25+00:00 2026-05-27T04:58:25+00:00

I am trying to create a schedule class in python that takes the start

  • 0

I am trying to create a schedule class in python that takes the start time, end time, and location of a meeting. So far I have:

class Schedule(Time):
def __init__(self, start_time, end_time, location):
    self.start_time = start_time
    self.end_time = end_time
    self.location = location
    print (self.start_time)
    print (self.end_time)
    print (self.location)

I have a Time class completed which looks like this:

class Time():
    def __init__(self, init_hr = 12, init_min = 0, init_ampm = "AM"):
        self.hr = init_hr
        self.min = init_min
        self.ampm = init_ampm

Now I want to be able to make the parameters start_time and end_time (from the initialization of schedule) to be Time instances, however I’m confused on how I would go about doing that. Any suggestions?

  • 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-27T04:58:26+00:00Added an answer on May 27, 2026 at 4:58 am

    Some dynamically-typed languages would want you to do this everywhere (statically-typed languages will generally enforce it themselves), but in Python the generally recommended practice is duck typing, which suggests that you just expect it to be a Time, but if it’s something else, don’t worry (if it implements the same interface as Time, well and good, if it doesn’t, let it fail when you try accessing attributes that don’t exist on the object). The general idea there is that you are expected to be intelligent enough to know what you’re doing.

    If a I were writing this code, I would leave it as you have it, with a few notes:

    • As others have mentioned, change class Schedule(Time) to class Schedule(object).
    • In Time.__init__, don’t call your parameters init_hr, etc., just call them hr, etc. Python ain’t Java, where you’ve got to use different names or always refer to the class version as this.*. In Python, you always use self.*. Python also has keyword arguments – so you could have Time(hr=4, ...); Time(init_hr=4, ...) would be ugly.
    • If you’re in Python 2, change print (...) to print .... If you’re in Python 3, change it to print(...).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project in CruiseControl.net that I am trying to create a schedule
I am trying to create a service that check the location of the user
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create my first iPhone app that would play back audio. When I
Trying to create a small monitor application that displays current internet usage as percentage
I have a question about PHP Class. I am trying to get the result
I'm trying to create a batch file that will convert an Excel file to
I am trying to evaluate tools to create a resource schedule viewer. The rows
I'm trying to create a remote job for scheduling in Quartz.net. When I have
I am trying to create a simple script that gives me the next recycling

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.