[Tutor] instantiate and name a class from / with a string

ingo ingo at ingoogni.nl
Fri Aug 9 13:55:21 EDT 2019


With the available classes Root, Channel and SSE I build the following
(in CherryPy):

root = Root()
root.channel = Channel()

root.channel.weather = SSE('weather')
root.channel.energy = SSE('energy')
root.channel.mail = SSE('mail')
root.channel.rss = SSE('rss')
...

http://example.com/channel/weather/ will then become the emitter of the
weather event stream.

I'd like create the instances of SSE programmatically by pulling the
string 'weather', 'energy' etc. from a database.

Ingo


More information about the Tutor mailing list