473,386 Members | 1,791 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,386 software developers and data experts.

Re: Advice on the style to use in imports

On Sat, Aug 30, 2008 at 4:53 PM, Eric Wertman <ew******@gmail.comwrote:
>I read the PEP8 and the "importing Python Modules" article. However,
I'm still a little confused on what should the general rules for
importing modules.

I'm showing what I used in my current project, and will accept your
advices on how I should change them.
>import module

and then use

module.MyClass

( in case of a flat module)

or

from package.subpackage import module

and then use

module.MyClass

(( for a package/subpackage structure ))

My opinion is that this is the preffered way, generally speaking. Not
only does it avoid namespace issues as effbot pointed out, but it also
makes code easier to read later. As examples, I tend to break those
rules frequently with these :

from pprint import pprint # Because pprint.pprint is just redundant
from lxml import etree # Actually I guess this doesn't break the rule.
from datetime import datetime # This might be a bad idea... I haven't
had problems yet though. datetime.datetime gets on my nerves though.

just my .02

Eric
--
http://mail.python.org/mailman/listinfo/python-list
Thanks Eric; your 02 cents are worthy for me ;)

Regards
Marco

--
Marco Bizzarri
http://iliveinpisa.blogspot.com/
http://notenotturne.blogspot.com/
Aug 30 '08 #1
0 714

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

Similar topics

10
by: Jeff Wagner | last post by:
I am in the process of learning Python (obsessively so). I've been through a few tutorials and read a Python book that was lent to me. I am now trying to put what I've learned to use by rewriting...
2
by: Tim Mackey | last post by:
hi folks, i'm puzzled over this one, anyone with some solid db experience might be able to enlighten me here. i'm modelling a file system in a database as follows, and i can't figure out to...
2
by: Sky Sigal | last post by:
Hello: I'm currently messing around, and need as much feedback/help as I can get, trying to find the most economical/graceful way to build usercontrols that rely on styling to look any good... ...
0
by: Willie Neal | last post by:
I'm new to vb.net and would like the advice of my peers. Here is my scenario: I have a user control which consists of three buttons, three listboxes and three labels. When the user selects a button...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
0
by: Marco Bizzarri | last post by:
Hi all. I read the PEP8 and the "importing Python Modules" article. However, I'm still a little confused on what should the general rules for importing modules. I'm showing what I used in my...
0
by: Fredrik Lundh | last post by:
Marco Bizzarri wrote: importing objects instead of the module (namespace) they live in can cause all sorts of aliasing and dependency issues. avoid unless you know exactly what you're doing....
13
by: terry.holland | last post by:
I have a three tiered CRM application (ASP.Net UI, VB.Net Business Layer & VB.Net Data Access Layer) that consists of number of classes. The application will be deployed to a number of clients. ...
0
by: James Mills | last post by:
David, Here's a "good" example (NB: subjective): http://hg.softcircuit.com.au/index.wsgi/circuits/file/251bce4b92fd/circuits/core.py On Fri, Oct 24, 2008 at 10:04 AM, David Di Biase...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.