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

how to absolute import?

>From Guido's PEP8:

- Relative imports for intra-package imports are highly
discouraged. Always use the absolute package path for all
imports.

Does it mean I should put my develop directory into PYTHONPATH (e.g.
/home/hongqn/devel/python) and use "import myproj1.package1.module1 as
module1" all the way? Or should I make a "./setup.py install" for
every package whenever I made a change?

I'm using python 2.3 so from .foo import bar doesn't work for me.

Jul 18 '05 #1
1 2229
Qiangning Hong wrote:
From Guido's PEP8:
- Relative imports for intra-package imports are highly
discouraged. Always use the absolute package path for all
imports.

Does it mean I should put my develop directory into PYTHONPATH (e.g.
/home/hongqn/devel/python) and use "import myproj1.package1.module1 as
module1" all the way? Or should I make a "./setup.py install" for
every package whenever I made a change?


Yes. =) Either one of those is a reasonable solution. I tend to put
local modules that I don't expect to distribute (but that I use
frequently) on my PYTHONPATH, but actually building them as a package is
certainly a reasonable solution too.
I'm using python 2.3 so from .foo import bar doesn't work for me.


This doesn't work in 2.4 either. ;)

STeVe
Jul 18 '05 #2

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

Similar topics

8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
2
by: Markus Doering | last post by:
Hello, I just switched from 2.2 to Python 2.3. I am developing an XML/CGI interface to databases as a python package called "unitWrapper" containing several modules which ran fine under v2.2. ...
1
by: Alexander Hoffmann | last post by:
Hello, I have a project with a number of python modules, which means there are several *.py files all in the same folder /usr/local/myproject/*.py . I ran the program to test it and of course as...
11
by: could ildg | last post by:
I want to import c:\xxx\yyy\zzz.py into my programme, What should I do? Thank you~
1
by: Kevin Liu | last post by:
Attribute Programming generates IDL file automatically. The IDL looks like import "C:\Program Files\Microsoft Visual Studio ..NET\Vc7\PlatformSDK\include\prsht.idl"; import "C:\Program...
0
by: Jason Lawrence | last post by:
I have an attributed ATL project (call it B) that I am building with Microsoft Visual C++ .NET (55537-640-3684941- 18356). In the project I include the COM generated file A.h (from another ATL...
4
by: Bill Nguyen | last post by:
How do I get the absolute value of an expression in VB.NET? The new ABS function looks scary to me! Thanks Bill
26
by: Clodoaldo Pinto | last post by:
I'm starting a programming tutorial for absolute beginners using Python and I would like your opinions. http://programming-crash-course.com Regards, Clodoaldo Pinto
0
by: jUrner | last post by:
Hello all I just played around a bit with python 2.5 and relative imports. Bit disappointed so far. Hoped to be able to use this new feature to develop standalone libraries that can be just...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.