Python Forum
newbie questions about objects properties...
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
newbie questions about objects properties...
#1
Hi everyone,
Still confused between objects and properties..

When I run this:

from datetime import date
from datetime import time
from datetime import datetime

  
today = datetime.now()
f = today.time()
print f

print datetime.time(datetime.now())
 
Questions: When I'm running f = today.time() does this mean I'm calling the time method from the object "today" ? Or am I calling the time method from the datetime module and use today variable as "data input" ?

Why datetime.time(datetime.now()) is equivalent ? what is the "datetime.time()" ? a method straight from the datetime module ?

How should I code ? Do I need initialise objects by assigning a variable or can I call them straight like in the print datetime.time example ?


Also on the same lines..

import os 
print os.name;
Why above I can't do the below instead ? (this to understand properties...)

import os 
a = os.name
print a.name
Reply


Messages In This Thread
newbie questions about objects properties... - by slowbullet - Aug-12-2018, 09:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I need help writing this code for string properties and methods hannah71605 4 3,227 Mar-22-2021, 12:36 PM
Last Post: menator01
  Sort objects by protected properties. Sigriddenfeta 1 1,958 Mar-17-2020, 04:11 AM
Last Post: Larz60+
  Newbie to CS and Python, 2 questions johneven 2 2,320 Feb-01-2019, 03:00 AM
Last Post: johneven
  Creating a script with a class have specific properties dvldgs05 13 6,054 Oct-15-2018, 08:54 PM
Last Post: dvldgs05

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020