Results 1 to 6 of 6

Thread: Question on classes in Python

  1. #1
    Join Date
    Feb 2008
    Posts
    1,260

    Question on classes in Python

    I am currently working on python and I just met a case which I find hard to understand:

    Instance1 = class1 ()
    Instance2 = Instance1.class2 ()

    I adapted the trick (in fact it comes from panda 3D)

    My question:
    The 2nd row can really exist, if yes what is it (I do not understand the "Instance1.class2 ()")

    I specify my problem a little, giving you the original in Panda 3D

    Code:
    # Load the panda actor, and loop its animation 
    pandaActor = Actor.Actor("models/panda-model",{"walk":"models/panda-walk4"})
    pandaActor.setScale (0.005,0.005,0.005) 
    pandaActor.reparentTo (render) 
    pandaActor.loop ("walk") 
    #Create the four lerp intervals needed to walk back and forth
    pandaPosInterval1= pandaActor.posInterval(13,Point3(0,-10,0), startPos=Point3(0,10,0))
    pandaPosInterval2= pandaActor.posInterval(13,Point3(0,10,0), startPos=Point3(0,-10,0))
    pandaHprInterval1= pandaActor.hprInterval(3,Point3(180,0,0), startHpr=Point3(0,0,0))
    pandaHprInterval2= pandaActor.hprInterval(3,Point3(0,0,0), startHpr=Point3(180,0,0))
    Actor is a class, so pandaActor is an instance of this class (line 2)
    What I can not understand is:
    pandaPosInterval1 = pandaActor.posInterval (........)
    posInterval is also a class, I do not therefore: pandaActor.posInterval (........)
    Practically, this I have no problem, I understand the trick, but at the theoretical level (pure Python), I do not know what this is.

  2. #2
    Join Date
    May 2008
    Posts
    685

    Re: Question on classes in Python

    look at the panda code ...

    But there is much chance that Actor.posInterval is a method that simply return an instance of a class named Interval .

  3. #3
    Join Date
    Feb 2008
    Posts
    1,260

    Re: Question on classes in Python

    Thank you for your reply, but the doc panda3d (reference), posInterval is listed in the classes and not methods! Hence my interrogation!

  4. #4
    Join Date
    May 2008
    Posts
    685

    Re: Question on classes in Python

    PosInterval != posInterval
    The case is important.

    I had a quick look on the doc panda3d and I did not find a method posInterval.
    Is the code that you gave run the latest version of panda?

  5. #5
    Join Date
    Feb 2008
    Posts
    1,260

    Re: Question on classes in Python

    Sorry for the box, it is PosInterval, and it is well documented in the classes (nothing in the functions and nothing in the methods) when my interrogation this is what: instance2 = Instance1.class2 (... )?
    Also, this is the last version panda3D (software and doc)

  6. #6
    Join Date
    Feb 2008
    Posts
    194

    Re: Question on classes in Python

    There is no "instance2 = instance1.class2 ()", it does absolutely nothing to say. There is just instance2 = instance1.method ()

Similar Threads

  1. Replies: 8
    Last Post: 27-01-2012, 01:14 PM
  2. C # using classes in C + +
    By klite in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 10:15 AM
  3. Classes in VB.NET
    By Samir_1 in forum Software Development
    Replies: 2
    Last Post: 10-04-2009, 12:07 AM
  4. Download Python 3.0 / Python 3000
    By Amaresh in forum Software Development
    Replies: 6
    Last Post: 24-02-2009, 09:28 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,628,558.34919 seconds with 16 queries