should error class be defined in the class it logically belongs?

2014-01-05 Thread Zhang Weiwu
Let's say we have in livestocks.py # livestocks.py stores all livestock classes class cat() ... class Dog() ... class CanineDistemper(Exception) ''' <<< Buddy = Dog(name = "Buddy") <<< raise CanineDistemper(Buddy) # horrible test code! ''' def __init__(self, dog)

Re: any use case of logging.config.listen()?

2013-12-04 Thread Zhang Weiwu
Thank you a lot for your case description. On Wed, 4 Dec 2013, Dan Sommers wrote: It begets the question, that if it is easier to write a socket-listening loging handler and forget all about logging.config.listen() stuff. I never did it before, hence the question. But why develop all of that

any use case of logging.config.listen()?

2013-12-03 Thread Zhang Weiwu
Why would anyone use it? I can't think of use cases when one need to change logging configuration dynamically through socket, but not needing the same flexibility on overall configuration for his application (configparser). It feels strange to design a socket interface only to expose logging co

looking for a pattern to change function behaviour by context

2013-10-31 Thread Zhang Weiwu
Problem: library method request() requests data from external server. Sometimes, if a request is failed, it should be ignored, like price inquiry - if we don't get the price, then no decision could be made based on the price, then we simply do nothing about it; Sometimes, if a request is fail