473,287 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Automatically organize module imports

Hi!

Is there any possibility/tool to automatically organize the imports at
the beginning of a module?

I don't mean automatic imports like autoimp does as I like seeing where
my objects/functions really come from.
For the same reason I don't like "from foo import *".

The downside is that you have a rather verbose import section at the
beginning of your code.
That's very bad if you reorganize your code and some imports are not
needed anymore or new imports are needed.
In Eclipse/Java there is a nice feature that automatically organizes
your imports, meaning that it removes unneded imports and even adds
missing imports automatically.

Unfortunately, this PyDev doesn't have an equally powerful feature.
As of the current version it only sorts the imports alphabetically, what
isn't very useful.

So, is there anything I can do about my imports?
Is there a tool that can organize my import section?
Shall I fall back to ambiguous imports like *?
Shall I write out the module name for every class/function that I use
(quite unhandy)?

Thank you!
--
Thomas Wittek
Web: http://gedankenkonstrukt.de/
Jabber: st*********@jabber.i-pobox.net
GPG: 0xF534E231
Oct 15 '07 #1
1 1872
On 10/15/07, Jean-Paul Calderone <ex*****@divmod.comwrote:
>
Pyflakes will tell you which imports aren't being used (among other
things). I don't know if an existing tool which will automatically
rewrite your source, though.
I'll second that recommendation of Pyflakes -- as the interpreter only
lets you know about undefined names when the code is executed, I find
Pyflakes really useful at finding missing imports (or other undefined
names) as soon as possible.

As I'm doing a lot of work with Django at the moment, which requires
some configuration of the environment to run, the fact that Pyflakes
reads the source without trying to execute any of it helps a great
deal.

Andrew.
Oct 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul Rubin | last post by:
That's what the Python style guides advise. They don't seem to like def frob(x): import re if re.search('sdfxyz', x): ... instead preferring that you pollute your module's global namespace...
8
by: Grant D. Watson | last post by:
If this has been answered before, or if my terminology is off, please bear with me; my Python experience is limited to use in one class and to personal projects. I'd like to do something rather...
2
by: Tian | last post by:
I am writing a python program which needs to support some plug-ins. I have an XML file storing some dynamic structures. XML file records some class names whose instance needs to be created in the...
10
by: Ron | last post by:
Hello, The following code works in a Form class module but not a standard module: Dim d1 As DateTime Format(d1, "MMMM") In a standard module I get a squigly line saying that an argument has...
2
by: Matthias Kramm | last post by:
Hi All, I'm having a little bit of trouble using the "imp" module to dynamically import modules. It seems that somehow cyclic references of modules don't work. I'm unable to get the following...
2
by: jimmyfishbean | last post by:
Hi, I have created a VB.Net windows service. Everything was working fine until I attempted to add a setup project. Now, for some strange, when I try and run the application (using INSTALLUTIL...
4
by: Daniel N | last post by:
I am new to .net and want to organize my code better. I am writing in vb.net and the code for my main form is nearing 50-60 pages and would like to create another file like a class, module or code...
6
by: Ritesh Raj Sarraf | last post by:
Hi, I've been very confused about why this doesn't work. I mean I don't see any reason why this has been made not to work. class Log: def __init__(self, verbose, lock = None): if verbose...
3
by: Jugdish | last post by:
Why doesn't the following work? $HOME/pkg/__init__.py $HOME/pkg/subpkg/__init__.py $HOME/pkg/subpkg/a.py $HOME/pkg/subpkg/b.py # empty import a
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.