Re: Can't seem to start on this

Discussion in 'Python' started by D'Arcy J.M. Cain, Jan 3, 2013.

  1. On Thu, 03 Jan 2013 09:06:55 -0500
    Kene Meniru <> wrote:
    > > OK, "global variables" is the clue that you need to rethink this.
    > > Try to stay away from global variables as much as possible except
    > > for maybe some simple setup variables within the same file.
    > > Consider something like this instead.
    > >

    >
    > The global variable is not part of the LinearMark object. It will be
    > used by ALL objects created. I understand the uneasiness with this so
    > maybe I will make it a function so it will be set with something like:


    Applying to all objects in your file A is not an issue. See below.

    > SnapSize(num)


    That doesn't make it any less global.

    > As I mentioned, the file "A" can be considered a scene file. I do not


    I don't know what a "scene" file is.

    > want the user to have to create classes there. I apologize for the


    But you expect them to write Python code? Classes are a very powerful
    part of Python and if super classes are written well they can be very
    simple to write. Perhaps you found my examples too complicated. That
    was so I could illustrate a number of methods. I wouldn't expect you
    to use all of them in your code. Here is a simpler example that may
    meet your requirements.

    File B:

    class TopClass(object):
    def __init__(self, snap_size):
    self.snap_size = snap_size

    def put(self, ...

    In file A:

    class MyClass(TopClass):
    def __init__(self):
    TopClass.__init__(self, 10)

    x = MyClass()
    x.put(...

    Now you have a new class where every instance uses a snap size of 10.
    Notice that this class in what you call the user's code is only three
    lines. That's pretty simple for your "user."

    If you think that that is too complicated still then maybe the user
    shouldn't be writing any Python code and instead look at the various
    ways of parsing configuration files which they can write.

    --
    D'Arcy J.M. Cain <> | Democracy is three wolves
    http://www.druid.net/darcy/ | and a sheep voting on
    +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
    IM:
     
    D'Arcy J.M. Cain, Jan 3, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kene Meniru

    Can't seem to start on this

    Kene Meniru, Jan 3, 2013, in forum: Python
    Replies:
    0
    Views:
    180
    Kene Meniru
    Jan 3, 2013
  2. Mitya Sirenef

    Re: Can't seem to start on this

    Mitya Sirenef, Jan 3, 2013, in forum: Python
    Replies:
    0
    Views:
    182
    Mitya Sirenef
    Jan 3, 2013
  3. Kene Meniru

    Re: Can't seem to start on this

    Kene Meniru, Jan 3, 2013, in forum: Python
    Replies:
    0
    Views:
    137
    Kene Meniru
    Jan 3, 2013
  4. Mitya Sirenef

    Re: Can't seem to start on this

    Mitya Sirenef, Jan 3, 2013, in forum: Python
    Replies:
    0
    Views:
    145
    Mitya Sirenef
    Jan 3, 2013
  5. Kene Meniru

    Re: Can't seem to start on this

    Kene Meniru, Jan 3, 2013, in forum: Python
    Replies:
    0
    Views:
    166
    Kene Meniru
    Jan 3, 2013
Loading...

Share This Page