BloodyInari's Profile User Rating: -----

Reputation: 6 Worker
Active Members
Active Posts:
106 (0.06 per day)
16-November 09
Profile Views:
Last Active:
User is offline Nov 26 2013 05:06 PM

Previous Fields

OS Preference:
Who Cares
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Dream Kudos:

Latest Visitors

Icon   BloodyInari Slave to the machine, prisoner to equations

Posts I've Made

  1. In Topic: Calling Class Error: The Sequel

    Posted 1 Feb 2013

    View Postandrewsw, on 31 January 2013 - 08:24 PM, said:

    What are you expecting to happen(?).

    In the first example you haven't set any positions and Python does its best to output the (empty) attribute pos_vector.

    BTW For this second example, your x and y are totally unrelated - I don't know if you were expecting them to be connected in some way.

    Gotcha. Fixed with a try/except catch.
        def set_posX(self, pos = 0):
            self.pos_x = pos
        def get_posX(self):
                return self.pos_x
            except AttributeError:
                return self.pos_X

    I suppose it might be bad coding practice but in most of the cases for my variables, if they haven't been defined, need to be designated along the origin of my coordinate system with null (aherm, "zero") values. Hence [0,0,0] as an output for my examples.
    That's why in the first example I was expecting some set of default numbers to at least be returned when load_Pos() was called.

    View Postandrewsw, on 31 January 2013 - 08:24 PM, said:

    I get the impression that main() should be a nested/inner class of vectors(), but it depends on what you are trying to achieve.

    Ehhh... it could work that way (actually that was how it originally was set up...) but my Equations class is already fairly large as it is and uses a lot of different functions that are not necessarily tied in to/with my Loader class; thus the reason they are separate files.
    Secondly, I'm trying to get more exposure and understanding on using multiple classes in relation to one another while trying to break my single-file-project habits. :sweatdrop:
  2. In Topic: Calling Class Error: The Sequel

    Posted 31 Jan 2013

    View Postandrewsw, on 31 January 2013 - 05:03 PM, said:

    Erm, dunno, as you haven't detailed where this comes from:


    Uh sorry, just ignore it; it's effectively the Operator module and class.
    Anyhow, tinkered around some more, it works about right but I have another question.

    As it now tries to get/set data from one class to another, but the problem is as such that it doesn't seem to perform the proper operations in one class to give any data to the one that's calling it.

    for example, if this is what is executed in the shell, it won't result in an error and appear as though everything has gone accordingly but when you try to access the variable/array list for which the data is stored:
    >>> x = vectors()
    >>> x.load_Pos()
    >>> x.pos_vector
    [<bound method main.pos_x of <Equations.main object at 0x02AB54F0>>, <bound method main.pos_y of <Equations.main object at 0x02AB54F0>>, <bound method main.pos_z of <Equations.main object at 0x02AB54F0>>]

    however, I stilled fiddled with it and got this output as well. Why is that?
    >>> x = vectors()
    >>> y = Equations.main()
    >>> y.set_posX(0)
    >>> y.set_posY(0)
    >>> y.set_posZ(0)
    >>> position = [y.get_posX(), y.get_posZ(), y.get_posZ()]
    >>> position
    [0, 0, 0]

    [Edit: ]If it appears in any way to be confusing, I've included the pertinent bits below.

  3. In Topic: Calling Class Error: The Sequel

    Posted 31 Jan 2013

    View Postandrewsw, on 30 January 2013 - 05:06 PM, said:

    You are importing Operator, which is a module. Operator is not a class or function so you can't call it uses brackets ().

    Thanks for the tip, I was pretty sure that was one of the problems involved.

    View Postandrewsw, on 30 January 2013 - 05:06 PM, said:

    some_fun = functions()

    and then you might call the methods set_posX and get_posX on this instance (of the class functions). There is no connection between set/get_posX and your other class, vectors.

    So, just off the top of my head, something like this will work then?
    class vectors(object):
        def __init__(self):
            self.function = Equations.library()
        def load_Pos(self, pos_x = 0):
            vector = [self.function.get_posX()]
            self.pos_vector = vector
  4. In Topic: Calling Class Error

    Posted 28 Jan 2013

    View PostNallo, on 28 January 2013 - 06:08 PM, said:

    Python complains correctly. The reason is: when Python runs into a class statement it first builds a dictionary of all the methods. It looks at the arguments and finds a default value self.G. But self refers to an instance to the class which does not yet exist. So Python complains.

    The old some_function(bar=None) trick:
    class func(object):
        def __init__(self):
            self.G = 123
        def set_attractor(self, val=None):
            if val is None:
                val = self.G
            self.G_const = val
    f = func()
    print f.G_const

    I see, makes sense...
    well problem fixed. Thanks for the help. :rockon:

My Information

Member Title:
D.I.C Head
Age Unknown
January 14
Ft Worth, TX
Mathematical Theory concerning Algebra/Calculus, Manga (Shirow Masamune & Yukito Kishiro), Science Fiction and/or Fantasy, Astrophyiscs concepts and colonization, Welding and Soldering, Snowboarding, Pyromania, blah, blah, blah... talk to me sometime
Full Name:
Years Programming:
Programming Languages:
Java, Python, C/C++, BASIC

Contact Information

Click here to e-mail me
Website URL:
Website URL  http://
Skype  kenkon.kitsune


BloodyInari hasn't added any friends yet.


BloodyInari has no profile comments yet. Why not say hello?