Python Forum
Class variable / instance variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class variable / instance variable
#8
It is not a common practice to hid import statements inside a function. They should all appear at the top of the file unless you are trying to get around a circular reference problem.

As I said before, you cannot judge design in a vacuum. If this design works well for solving your problem, it is a good design. I can say that is is not a generic solution. This would never be a module that others can use to solve their problem. Components should be generic. An inventory control system would never have a "refill_all_components" method. It might have method(s) to check inventory numbers and aid in ordering, but "get everything right now" is unrealistic. In an inventory system the components would be more than just a string, they would be objects. The inventory system would know how to communicate with objects to let you know if a component was available or when a component was available.

Is this a good design? Maybe yes. Maybe no.
Reply


Messages In This Thread
Class variable / instance variable - by ifigazsi - Jul-26-2020, 02:32 PM
RE: Class variable / instance variable - by buran - Jul-26-2020, 03:20 PM
RE: Class variable / instance variable - by Yoriz - Jul-26-2020, 04:03 PM
RE: Class variable / instance variable - by deanhystad - Jul-27-2020, 02:57 PM
RE: Class variable / instance variable - by buran - Jul-28-2020, 11:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to get variable Azdaghost 3 529 Apr-23-2025, 07:43 PM
Last Post: deanhystad
  I trying to automate the Variable Logon button using the python code but I couldn't surendrasamudrala 0 357 Mar-07-2025, 05:02 AM
Last Post: surendrasamudrala
  not able to call the variable inside the if/elif function mareeswaran 3 692 Feb-09-2025, 04:27 PM
Last Post: mareeswaran
  creating arbitrary local variable names Skaperen 9 2,058 Sep-07-2024, 12:12 AM
Last Post: Skaperen
  Variable Substitution call keys Bobbee 15 3,105 Aug-28-2024, 01:52 PM
Last Post: Bobbee
  how solve: local variable referenced before assignment ? trix 5 1,917 Jun-15-2024, 07:15 PM
Last Post: trix
  Variable being erased inside of if statement deusablutum 8 2,326 Jun-15-2024, 07:00 PM
Last Post: ndc85430
  Cant contain variable in regex robertkwild 3 1,233 Jun-12-2024, 11:50 AM
Last Post: deanhystad
  is this a valid variable name? Skaperen 6 1,936 Jun-05-2024, 10:13 PM
Last Post: Skaperen
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 1,584 Apr-18-2024, 09:55 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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