Python Forum
Object reference in Dict - not resolved at runtime
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Object reference in Dict - not resolved at runtime
#1
Here is my code:

total_runtime = None
mail_pfx = "dVDS FULL5 CN"

mail_subj = {
	'completed' : f"{mail_pfx} : [INFO] Refresh completed successfully in: {total_runtime}.",
	'warnissues' : f"{mail_pfx} : [ALERT] Refresh completed with issues in: {total_runtime}"
	}

class Stopwatch():

	def __init__(self):
		self.tick = 0
		self.tock = 0
		self.time = 0

	def start(self):
		self.tick = time.perf_counter()

	def stop(self):
		self.tock = time.perf_counter()
		self.time = timedelta(seconds=math.ceil(self.tock-self.tick))

	def __str__(self):
		return str(self.time)

total_runtime = Stopwatch()
total_runtime.start()
total_runtime.stop()

print(mail_subj['warnissues'])
This is printing "dVDS FULL5 CN : [ALERT] Refresh completed with issues in: None"

I want it to resolve the object at runtime instead of compile time, is there any way to do this?
Reply


Messages In This Thread
Object reference in Dict - not resolved at runtime - by benthomson - Apr-01-2020, 10:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  class and runtime akbarza 4 559 Mar-16-2024, 01:32 PM
Last Post: deanhystad
  how to return a reference to an object? Skaperen 8 1,475 Jun-07-2023, 05:30 PM
Last Post: Skaperen
  painfully slow runtime when handling data dadazhu 3 1,129 Jan-20-2023, 07:11 PM
Last Post: snippsat
  Big O runtime nested for loop and append yarinsh 4 1,567 Dec-31-2022, 11:50 PM
Last Post: stevendaprano
  Reducing runtime memory usage in Cpython interpreter david_the_graower 2 2,373 Oct-18-2021, 09:56 PM
Last Post: david_the_graower
Exclamation win32com: How to pass a reference object into a COM server class Alfalfa 3 5,141 Jul-26-2021, 06:25 PM
Last Post: Alfalfa
  Repeating Words in MadLib [resolved] actual_satan 1 1,884 May-07-2021, 08:45 AM
Last Post: ibreeden
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,686 Sep-07-2020, 08:02 AM
Last Post: perfringo
  Sort a dict in dict cherry_cherry 4 101,234 Apr-08-2020, 12:25 PM
Last Post: perfringo
  PyCharm asking for VC++ runtime 14.0 whereas I have already installed VC++ 19.0 SarmadiRizvi 1 1,953 Apr-02-2020, 06:17 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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