"Ron_Adam" <[EMAIL PROTECTED]> wrote: > On 25 Mar 2005 10:09:50 GMT, Duncan Booth > <[EMAIL PROTECTED]> wrote: > > > >I've never found any need for an is_defined function. If in doubt I just > >make sure and initialise all variables to a suitable value before use. > >However, I'll assume you have a good use case. > > I admit that that is the better practice. George's example was the > conversion of data from one form to another where the data is mixed > with complete and incomplete items. And Kay is looking at tuple > unpacking. > > It's hard to beat try/except for these situations though. :)
I posted a recipe in python cookbook (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/392768) for the subproblem I was interested in initially (variable-length iterable unpacking), and I prefer it over explicit try/except (but of course I'm biased :-)). Kay is proposing something even more general and powerful, and it will be interesting to see if all this brainstorming can be brought forward more 'formally', e.g. at a PEP or pre-PEP level. Regards, George -- http://mail.python.org/mailman/listinfo/python-list