[Tutor] Python OO
Juan C.
juan0christian at gmail.com
Sun Mar 29 03:16:05 CEST 2015
Ok, so, let me try to express what I think is 'right' here according to
what you said.
My code structure needs to be something like that:
pycinema
- package: pycinema
- - __init__.py
- - api.py
- - actor.py
- - movie.py
- - serie.py
- __main__.py
And why I use it this way?
1. You said that I need to separate the API methods and calls from my code,
so that if I need to move to another API or something like that, all the
API code and logic will be in one place
2. I've read in many places that a basic structure, package with all the
logic and a single __main__.py on the folder root, is good and simple.
Let's start with something more simple, the actor.py module. Currently I
already have this working code (http://pastebin.com/wcCnCwMc) for this
module.
How would be a good way to "convert" this API call to my api.py?
Should I create an API class and have a bunch of methods like "get_actor",
"get_movie", "get_serie", "get_season" and "get_episode"?
In this code I'm only getting the name of the actor, but I can get other
things from the API like birthday, deathday (when applicable),
place_of_birth, and so on.
Should my api.py get only the RAW data, in this case the JSON, and give it
to my classes (Actor, Movie, Serie) and they (the classes) read this JSON
and do what they need?
I'll be finishing this message here so as to not make it so long. But I
still have some "code design" doubts. But let's resolve it in parts.
More information about the Tutor
mailing list