As you probably noticed if you follow the forum regularly, there's been a
recent discussion about providing classes in the python wrapper to expose the functions in a more OOP-like manner. This would mean a change from this code style:
import libtcodpy as libtcod
rand = libtcod.random_new()
x = libtcod.random_get_int(rand, 10, 20)
con = libtcod.console_new(80, 60)
libtcod.console_blit(con, ...)
To this:
import libtcodpy as libtcod
rand = libtcod.Random()
x = rand.get_int(10, 20)
con = libtcod.Console(80, 60)
con.blit(...)
At first, the code would be
duplicated, both in C-style and OOP-style, so your code wouldn't stop working just like that, and you can take time to make the transition. However, we couldn't maintain both versions forever, and probably in the next major libtcod version (which should take a while!) we would finally remove the old code (with plenty of
**compatibility break** warnings; an automatic tool to find deprecated code could also be arranged

).
Only functions that deal with an instance of some kind will be changed (ie, console, random, image...). Stuff like system functions will remain as they are. This is not a "NASA architecture" thing with multiple inheritance and all that; we'll just replace "class_method(instance, ...)" with "instance.method(...)".
This poll is to gauge interest in the python/libtcod users community. It may be a pain to change, but in the end your calls to libtcod should end up: (a) much shorter, (b) easier to look at (without tons of underscores

) and (c) more
pythonic (whatever that means!). However, in the end this is for you guys, so your opinion matters a lot. Direct any questions to this thread!
There's also the matter of
default instances. This only applies to the Console and Random classes. The root console and default random stream are currently referred to with the special code "0", but we can't have stuff like "0.blit(...)" -- we need default instances to refer to. They will be created automatically and be available at all times. I'm sure they'll be used a lot, so they need to have short names. To give you an idea, long names could be:
- libtcod.root_console
- libtcod.default_random or libtcod.random_stream
Relying on the convention that class names are LikeThis and instance names are like_this, a shorter version would be:
- libtcod.console
- libtcod.random
However, I understand this could be confused with the Console and Random classes (right?). Please vote and, if you agree with the change, but not this naming convention, suggest alternatives in this thread.
Ok, that's it. Important stuff! Sorry for the long post
