Re: PHP vs. Python
On Thursday, 23 December 2004 03:33:36 UTC+5:30, (unknown) wrote: Anyone know which is faster? I'm a PHP programmer but considering getting into Python ... did searches on Google but didn't turn much up on this. Thanks! Stephen Here some helpful gudance. http://hentenaar.com/serendipity/index.php?/archives/27-Benchmark-PHP-vs.-Python-vs.-Perl-vs.-Ruby.html -- http://mail.python.org/mailman/listinfo/python-list
unpacking with default values
Hi all, probably a dumb question, but I didn't find something elegant for my problem so far. In perl you can unpack the element of a list to variables similar as in python (a, b, c = [0, 1, 2]), but the number of variables need not to fit the number of list elements. That means, if you have less list elements variables are filled with 'undef' (None in python), if you have more list elements as necessary the rest is ignored. How can I achieve this behaviour with python in an elegant and fast way? Best regards Andreas Mock -- http://mail.python.org/mailman/listinfo/python-list
Re: unpacking with default values
On 17 Jul., 18:33, Gary Herron [EMAIL PROTECTED] wrote: In Python 2.x, you can't do that directly, but you should be able to create a function that lengthens or shortens an input tuple of arguments to the correct length so you can do: a,c,b = fix(1,2) d,e,f = fix(1,2,3,4) However, the function won't know the length of the left hand side sequence, so it will have to be passed in as an extra parameter or hard coded. Hi Gary, thank you for the answer. Do you know the protocol used by python while unpacking? Is it a direct assingnment? Or iterating? Best regards Andreas Mock -- http://mail.python.org/mailman/listinfo/python-list
Re: Logging to different addressees
Hi Vinay, thank you for being so patient. On 16 Jul., 01:21, Vinay Sajip [EMAIL PROTECTED] wrote: On Jul 15, 5:17 pm, McA [EMAIL PROTECTED] wrote: If you added the admin sink handler to the root logger, you're done. Isn't that the first thing above? What do you mean? I gave you a choice - to add the handler to the admin_logger OR the root logger. So I am saying here that if you added to the root logger (and not common_logger, assuming they're different), then there's nothing more to do... Reading the rest of your mail let me understand what you meant. # simple.py import logging admin_logger = logging.getLogger() # The root logger addressee_logger = logging.getLogger(addressee) admin_sink = logging.FileHandler(admin.log, w) addressee_sink = logging.FileHandler(addressee.log, w) admin_logger.addHandler(admin_sink) addressee_logger.addHandler(addressee_sink) admin_logger.setLevel(logging.DEBUG) admin_logger.debug(This message appears in admin sink only.) addressee_logger.debug(This message appears in both admin sink and addressee sink. Thank you for that snippet. That means, that the root-logger does inherit EVERY message (if it fits to the level and isn't filtered) and the inheritage chain is build by the chosen logger names, e.g. messages to logging.getLogger('tree.leave') would also show up in logging.getLogger('tree') automatically? If this is true, how can I avoid this bubbling up if I would like to? (You see, that's a new question, but I want to take the chance to get the answers from you personally ;-) Hope not to bother. Best regards Andreas Mock -- http://mail.python.org/mailman/listinfo/python-list
Re: Logging to different addressees
On 16 Jul., 15:38, Vinay Sajip [EMAIL PROTECTED] wrote: On Jul 16, 8:55 am, McA [EMAIL PROTECTED] wrote: messages tologging.getLogger('tree.leave') would also show up inlogging.getLogger('tree') automatically? Yes. Ok. Hope not to bother. Use the propagate flag, which is mentioned in the documentation. That's the right hint. In fact, please make sure you've reviewed all the documentation before posting, as the documentation is intended to answer the more straightforward and common questions which come up. I did it and I'll do it again. :-) You know, sometimes a piece of text/documentation starts to become information for the reader when he exactly hits the problem. Anyway, thank you for your help and for that module. Best regards, Vinay Sajip Best regards Andreas Mock -- http://mail.python.org/mailman/listinfo/python-list
Logging to different addressees
Hi all, I need a recommendation. I would to like to use the logging module to create log messages the following way: a) Every log message does go to a admin sink. b) The logging of special messages should go to the admin sink AND to a sink specifically for a certain addressee. c) I don't want to write the log message to two different loggers for that purpose. I would like to do it this way: common_logger.log('bla') - message to admin sink certain_logger.log('something' - message to admin sink and addressee- sink d) Filtering and debug level should work as expected. I could I achieve this in a elegant way? Best regards Andreas Mock -- http://mail.python.org/mailman/listinfo/python-list
Re: Logging to different addressees
Hi Vinary, thank you for answering. I start be proud that the author of the logging package himself is answering. :-) On 15 Jul., 15:51, Vinay Sajip [EMAIL PROTECTED] wrote: On Jul 15, 1:27 pm, McA [EMAIL PROTECTED] wrote: Add a handler to the root logger (or common_logger) to send to the admin sink. That's clear. Add a handler to certain_logger to send to the addressee sink. That's also clear. If you added the admin sink handler to the root logger, you're done. Isn't that the first thing above? What do you mean? Otherwise, you need to ensure that certain_logger is a child of common_logger. What I want to code is something like that. a) I know thet this is a message for the admin only: admin_logger.log('blabla') (admin_logger = root_logger = logging.get_logger()) b) certain_logger.log('something' = log to the root/admin/-sink as well as to the certain-sink. Do I have to create a logger subclass where I do the multiplexing of the logging messages? I'm pretty sure I miss something. ;-) Regards, Vinay Sajip Regards Andreas Mock -- http://mail.python.org/mailman/listinfo/python-list