Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
import time conflict
#1
module time has a function named time.  some code does import time and calls that function like time.time().  other code does from time import time and calls that function like time().

this can lead to conflicts.

i have a module that needs to call time.sleep().  if i do an import in the module it could change what that code (the code importing my module) has for the (global) variable named time.  is there a nice resolution to this or do i need to do the import of time or time.sleep in the functions that need it?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
This should only be a problem if you import your module using from foo import *, which is why you try to avoid that.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Well, I don't use from module import *. I could from module import method but only for my own scripts. If I want someone else to use my script/module I will import the module and that's all. Sleep function could be rewritten but time.sleep not. Technically can but no one will do this. I think :D
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  arg and keyword arg conflict: what to raise Skaperen 5 2,698 Jun-22-2020, 12:43 AM
Last Post: Skaperen
  annoying conflict: stat Skaperen 2 2,158 Dec-26-2019, 06:04 AM
Last Post: Skaperen
  venv conflict at shell prompt Skaperen 3 2,785 Feb-21-2019, 02:18 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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