warnings.warn vs logging.warning

2009-08-22 Thread Gunter Henriksen
When I want to issue a warning, I am uncertain about the distinction between warnings.warn() and logging.warning(). My naive thought is to presume "warning" means the same thing in both cases, and so if I call logging.warning(), it should take care of making sure something equivalent to my calling

Re: preferring [] or () in list of error codes?

2009-06-11 Thread Gunter Henriksen
> > >event_timestamp = (2009, 06, 04, 05, 02, 03) > > >(year, month, day, hour, minute, second) = event_timestamp > > > > [...] > > The point of each position having a different semantic meaning is that > tuple unpacking works as above. You need to know the meaning of each > position in ord

Re: preferring [] or () in list of error codes?

2009-06-11 Thread Gunter Henriksen
> Try, then, this tuple: > >event_timestamp = (2009, 06, 04, 05, 02, 03) >(year, month, day, hour, minute, second) = event_timestamp > > A list would be wrong for this value, because each position in the > sequence has a specific meaning beyond its mere sequential position. Yet > it also ma

Re: preferring [] or () in list of error codes?

2009-06-11 Thread Gunter Henriksen
> [In this tuple] >dodge_city = (1781, 1870, 1823) >(population, feet_above_sea_level, establishment_year) = dodge_city > each index in the sequence implies something very > different about each value. The semantic meaning > of each index is *more* than just the position in > the sequence;

Re: What text editor is everyone using for Python

2009-05-27 Thread Gunter Henriksen
> This, ladies and gentlemen of the jury, points > up the essential difference between a modal and > a non-modal way of doing things. That is one reason I love emacs... I not only get a selection of several "major modes", I can also have multiple "minor modes" active at the same time! And I can e

Re: Performance java vs. python

2009-05-19 Thread Gunter Henriksen
My experience has been that if the execution stays inside the VM, then for a "server side" application, the JVM is faster, and proportionally even faster when there are more threads ready to do something. When the VM has to do a lot of interaction with the OS, then I think it is difficult to make

Re: Context manager, atexit processing, and PEP 3143 DaemonContext.close

2009-05-19 Thread Gunter Henriksen
> > If there is a function which triggers a one-shot switch, I like > > to have a way to find out if it has already been triggered, I > > prefer to have the function tell me if it triggered the switch > > or not, but I would not want that to be by raising an exception. > > In this case, though, we'

Re: Context manager, atexit processing, and PEP 3143 DaemonContext.close

2009-05-18 Thread Gunter Henriksen
> Anyone else? If there is a function which triggers a one-shot switch, I like to have a way to find out if it has already been triggered, I prefer to have the function tell me if it triggered the switch or not, but I would not want that to be by raising an exception. -- http://mail.python.org/ma

Block-Local Variables using "with"

2009-05-14 Thread Gunter Henriksen
Presuming there is a reason to want block-local variables, does this seem like a good way to do something like it? @contextlib.contextmanager def blocklocal(**kwargs): bl = type('', (object,), {})() for (k, v) in kwargs.items(): bl.__setattr__(k, v) yield bl for k in bl.__d

x.abc vs x['abc']

2009-05-13 Thread Gunter Henriksen
Presuming it is very common to have objects created on the fly using some sort of external data definitions, is there an obvious common standard way to take a dict object and create an object whose attribute names are the keys from the dict? I realize I can do something like: >>> d = {"hello": "w

Re: How to walk up parent directories?

2009-05-05 Thread Gunter Henriksen
Be careful not to presume "/a/b/" is the same directory as "/a/b/c/../" I would consider the latter the parent of /a/b/c/, not the former. -- http://mail.python.org/mailman/listinfo/python-list

Re: Light (general) Inter-Process Mutex/Wait/Notify Synchronization?

2009-04-28 Thread Gunter Henriksen
> Linux doesn't do interprocess communication very well. > The options are [...] and shared memory (unsafe). I think the bar has to be set pretty high to say shared memory is too unsafe an approach for active entities to communicate. > If you're using CPython, don't worry about socket overhead.

Re: Light (general) Inter-Process Mutex/Wait/Notify Synchronization?

2009-04-27 Thread Gunter Henriksen
> > > Try this: http://nikitathespider.com/python/shm/ > > > > I am hoping not to plug something underneath the Python > > VM; I would rather use a socket, or use signals. > > I'm not sure what you mean. It's just an extension module > that you'd import like any of the stdlib modules. I cannot im

Re: Light (general) Inter-Process Mutex/Wait/Notify Synchronization?

2009-04-27 Thread Gunter Henriksen
> If you don't want to use a 3rd party module you could > use the multiprocessing module That is definitely good for when I have a tree of processes which are all Python applications. I use it for that. But I am looking for something where the Python application can interact conveniently with an

Re: Light (general) Inter-Process Mutex/Wait/Notify Synchronization?

2009-04-27 Thread Gunter Henriksen
> Try this: http://nikitathespider.com/python/shm/ I took a look at that (especially the posix_ipc at http://semanchuk.com/philip/posix_ipc/). I am hoping not to plug something underneath the Python VM; I would rather use a socket, or use signals. If I were to use a C library, I imagine I would

Light (general) Inter-Process Mutex/Wait/Notify Synchronization?

2009-04-27 Thread Gunter Henriksen
I am interested in the lightest mechanism to use in a Python application for mutex/wait/notify between processes, one of which may be a program which does not have a shared ancestral benefactor, or may not be a Python program at all. I would ideally like to have something which does not need to ma