Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 16-03-2009
Member
 
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.
Reply With Quote
  #2  
Old 16-03-2009
Member
 
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 .
Reply With Quote
  #3  
Old 16-03-2009
Member
 
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!
Reply With Quote
  #4  
Old 16-03-2009
Member
 
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?
Reply With Quote
  #5  
Old 16-03-2009
Member
 
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)
Reply With Quote
  #6  
Old 16-03-2009
Member
 
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 ()
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Question on classes in Python"
Thread Thread Starter Forum Replies Last Post
Question about SanDisk sansa Clip Zip playlists question VARIJ Portable Devices 8 27-01-2012 01:14 PM
C # using classes in C + + klite Software Development 3 01-10-2009 10:15 AM
Classes in VB.NET Samir_1 Software Development 2 10-04-2009 12:07 AM
Download Python 3.0 / Python 3000 Amaresh Software Development 6 24-02-2009 09:28 AM


All times are GMT +5.5. The time now is 12:33 AM.