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

Packages

I have a question on packages.

Suppose I have a package P with modules A.py, B.py, and C.py.
Suppose that C.py defines a class X.
Assume that the package __init__.py file contains the statement
"from C import X".

If I write an external Python program H.py, then I can refer to
the class X by doing:

import P
myX = P.X()

My question is that I would like to use the same method for
consistentcy sake for the modules A and B in the package.
That is, if A needs to use the class X from C, I would like
to do the following in the file A.py:

import P
aX = P.X()

I tried this and it works. But, is there a problem with
recursion here since C might refer to A, or B might refer to
A and C refer to B?

Is this even a good idea? Is there another way to achieve
the consistency whether referring to class X from an
external Python program or referring to class X from a
sibling Python program in the package?

Of course, the normal way to refer to class X in program A.py
is to do the following:

from C import X
aX = X()

Bill Hale
Aug 11 '06 #1
0 1052

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

Similar topics

3
by: Chris Barker | last post by:
Hi all, We've been having a discussion over on the wxPython-users mailing list about how to deal with multiple versions of wxPython. During the discussion it came up that this isn't a problem...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
2
by: Peter Saffrey | last post by:
(apologies for starting a new thread - Google can't retrieve the other message for some reason) Yes, /usr/lib/python/site-packages is in sys.path. This series of commands should explain what I...
0
by: Rich Burridge | last post by:
Hi, I work in the Accessibility Program Office at Sun Microsystems. I'm part of a team that is using Python to create a screen reader called Orca, that'll help blind people (and people with low...
0
by: giovanni gherdovich | last post by:
Hello, first of all: Is this the right place to ask plastek-related questions? I'm trying to make plastex work on my Ubuntu Dapper Drake. For LaTeX, I have the all-in-one package tetex.
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
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
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
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
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.