Re: refactoring a group of import statements

2010-06-29 Thread Aahz
In article , Thomas Jollans wrote: > >(3) Why not > >try: >import x >import y >import z >except ImportError as exc: >display_error_properly(exc) >raise exc Why not? Because that destroys the original traceback. Inside an except clause, you should almost always use a bare ra

Re: refactoring a group of import statements

2010-06-28 Thread Steven W. Orr
On 06/27/10 23:20, quoth GrayShark: > Thanks for the help > That was what I was looking for. All the rest, the arguments were > unhelpful. > > Question: If you can't answer the question, why are you talking? > > I'm American Indian. That's what I was taught. We don't talk that much. > But you

Re: refactoring a group of import statements

2010-06-28 Thread Stephen Hansen
On 6/28/10 12:54 PM, rantingrick wrote: On Jun 27, 10:20 pm, GrayShark wrote: Question: If you can't answer the question, why are you talking? Q: If you can't take advice without complaining, then why are you asking? I'm American Indian. That's what I was taught. We don't talk that much. Bu

Re: refactoring a group of import statements

2010-06-28 Thread rantingrick
On Jun 27, 10:20 pm, GrayShark wrote: > Question: If you can't answer the question, why are you talking? Q: If you can't take advice without complaining, then why are you asking? > I'm American Indian. That's what I was taught. We don't talk that much. > But you get an answer when we do talk. Ma

Re: refactoring a group of import statements

2010-06-27 Thread GrayShark
Thanks for the help Thomas Jollans. Just what I needed. I was wondering what the: __import__(name, globals={}, locals={}, fromlist=[], level=-1) globals was (that was from the docstring on __import__. Odd, the doc on www.python.org has globals as a list, not a dictionary). In any case, I

Re: refactoring a group of import statements

2010-06-27 Thread rantingrick
On Jun 27, 6:09 pm, Thomas Jollans wrote: > > import Tkinter as tk > > try: > >     import Image #from PIL > >     print 'Using high quality images :)' > > except ImportError: > >     print 'Using low quality images :(' > > As such, that still appears rather useless - the following code doesn't >

Re: refactoring a group of import statements

2010-06-27 Thread Thomas Jollans
On 06/28/2010 12:48 AM, rantingrick wrote: > On Jun 27, 5:18 pm, Thomas Jollans wrote: >> On 06/28/2010 12:06 AM, GrayShark wrote: >>> I have a large list of package files to import. I'm using a try/except >>> test to verify the import. Looks like: > > > >> (1) Don't. If you need the module, th

Re: refactoring a group of import statements

2010-06-27 Thread rantingrick
On Jun 27, 5:18 pm, Thomas Jollans wrote: > On 06/28/2010 12:06 AM, GrayShark wrote: > > I have a large list of package files to import. I'm using a try/except > > test to verify the import. Looks like: > (1) Don't. If you need the module, there's no reason to check for > exceptions. Just let t

Re: refactoring a group of import statements

2010-06-27 Thread Thomas Jollans
On 06/28/2010 12:06 AM, GrayShark wrote: > I have a large list of package files to import. I'm using a try/except > test to verify the import. Looks like: > > try: > import abc > except ImportError: > print( "Error importing abc" ) > > I've got many of those segments. I want to try a