Closed biologyguy closed 10 years ago
Okay, I've got it working now. Took a little more fiddling - I didn't realise that I had to actually open the file and read it for the Evopic class to work. I was trying to do this:
boy = Evopic(bob.evp)
When I actually ended up doing to make it work was this:
with open('bob.evp', 'r') as infile:
boy = Evopic(infile.read())
It would be nice if I didn't have use .read()
, but I don't think it really matters. First hurdle overcome! Things should theoretically get a bit more straightforward now.
Hey Jane,
When working with classes in general, here are two things to keep in mind. First, when you create a new object from that class, the init() function will be called automatically, and any arguments you pass into the object call will be handed off to init(). Second, there is a convention in Python that any methods beginning with an underscore, like _parse_evp(), are not meant to be used directly on an object. In a lot of other languages you have public and private variables/methods, but not in Python. Everything is public, so the leading underscore is a way of saying "I would have made this private if I could have, so use at your own risk".
To your Evopic usage questions specifically.
Yes ma'am. And I've just added a couple lines in the 'sandbox' at the bottom of breed.py that do just that.
File paths are going to be replaced by calls to the MySQL database very shortly, but for now, yes.
This is actually done automatically in Evopic.init(), so just by creating the new object, you will have access to all of the paths data. Try this:
Hopefully this will make it clear what's going on, but let me know if it isn't.
Classes are awesome, once you get the hang of them :)