• Advertisement
Sign in to follow this  
  • entries
    570
  • comments
    2427
  • views
    216204

Untitled

Sign in to follow this  

190 views

omfg.

Hippo convinced me to sit down and read through the Python docs. I have to say, the Python Tutorial is fucking awesome. I loved it.

but... omfg. Python is scary. Its the embodiment of the phrase "NOTHING IS SACRED". Honestly. Like, if you want to make a class -
>>> class MyClass :
def foo(self):
print "lol hi"

def __init__(self):
self.rah = 3;
self.foo = 2;

That creates an object. A mutable object. Which you can treat like a ragdoll and do shit with. Like...
>>> rah = MyClass() #create an instance of our class
>>> del MyClass #...then delete the class definition

Now this one threw me for a loop. I assumed that our class would now be bork bork, but guess what -
>>> rah.__class__ #returns a valid reference to the class definition
>>> rawr = rah.__class__() #creates another instance of it

It took me a while to figure out that, dur dur, objects are reference counted, and that there was still an outstanding reference to the definition so it was still in memory. Hur hur.

Anyway, there were some other things I screwed up, like declaring class members is wonky (you have to do it in the __init__ function, rather than in the class definition) but it makes sense why that is. Had to ask for help on that one, because it was really really confusing. lolz.

But yeah, I think I've got some grip over the basics. Extending/Embedding Python sounds fun as shit, can't wait until I've got my engine bound and running. Hur hur!

NOTHING IS SACRED
Sign in to follow this  


4 Comments


Recommended Comments

Quote:
Original post by Mushu
Extending/Embedding Python sounds fun as shit


Right. I guess sticking the fork in the wall socket sounds fun, too. :-/

Share this comment


Link to comment
Nothing is sacred, huh? Just you wait until you really get knee-deep in python meta-programming.

...freely mixing class members..runtime inheritance..dynamically building classes from schratch..so much forbidden fruit to taste [wink]

And if you're extending/embedding using C++, I can't recommend boost::python enough, it makes an otherwise painful endeavour quite simple.

Share this comment


Link to comment
Yeah, I decided against looking at the metaprogramming stuff for exactly that reason. I think it would cause my brain to a splode.

I took a look at boost.python, and honestly, its overkill for my purposes. It isn't going to be that hard to implement the stuff I need though, I've already got the prototype for the cross-calls coded and working. Just got to dress it up in a pretty interface and such, then I can work on the shared data representation stuff, and voila done.

<3

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement