python 2.7 - replacing global variables with class -


hi beginner question here.

i have written script works uses global variables (set input network, , used in different function change state) allow me change , acces content of variables several functions. understand global variables questionable looking replacing them class.

  1. is idea?
  2. is example of how can done in "correct" way?:

    class values1(object):

        def __init__(self):         self.__height = 2.85      def set_height(self,height):         self.__height =height     def get_height(self):         return self.__height  val = values1() def print1():     print (val.get_height())     val.set_height(3.45) def print2():     print val.get_height()  print1() print2() 


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -