Python Forum
Feedback on simple 'Mock Up' scripts
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feedback on simple 'Mock Up' scripts
#2
To answer your bottom questions:

Setters and getters are not generally used in Python (read: extremely discouraged).
Unless a setter or getter would do actual work you would never write one, and if you were in a situation where you needed to write one, you would use @property decorators and such.

Privacy: again same here. Python is not Java. Python has a much more "we are all adults here" attitude towards data access. We do not use private/public/protected data. You write a class and make it clear how the API operates but if someone wants to touch the mechanics underneath you don't generally try to stop them. Single underscore variables have their place but they are not common; don't get in the habit of trying to mark all your class members "private". It just doesn't work that way.

And absolutely don't mark variables with leading double underscores. This causes name mangling, again doesn't actually enforce privacy, and most importantly annoys the hell out of other Python programmers.
Reply


Messages In This Thread
Feedback on simple 'Mock Up' scripts - by fxJoan - Aug-20-2018, 04:30 PM
RE: Feedback on simple 'Mock Up' scripts - by Mekire - Aug-20-2018, 05:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Text Shop Simulator Feedback Dash 5 3,462 Apr-19-2019, 01:08 PM
Last Post: Dash

Forum Jump:

User Panel Messages

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