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

seeking the "Hello World" of Packages

I'm trying to get an idea of how packages work and I've read about it in
the Py Tutorial and Nutshell, but I'm still craving a concrete example
that I can poke through. Does anyone have a really basic package that
does very little that I could look at?

What I've gathered thus far is that a package is simply a directory, say
C:\MyPackage, that would contain __init__.py which tells Python to be
aware of all the other modules in C:\MyPackage. Am I correct?

C:\MyPackage\
\__init__.py
\justPrintHelloWorld.py
\multiply5By10.py

Would I expect the following behavior?:
>>>import MyPackage
MyPackage.justPrintHelloWorld
"Hello World"
>>>MyPackage.multiply5by10
50

Aug 11 '06 #1
2 1441
yep, that's all a package is.
if you have trouble importing, check your PYTHONPATH environment
variable, or sys.path.

Bell, Kevin wrote:
I'm trying to get an idea of how packages work and I've read about it in
the Py Tutorial and Nutshell, but I'm still craving a concrete example
that I can poke through. Does anyone have a really basic package that
does very little that I could look at?

What I've gathered thus far is that a package is simply a directory, say
C:\MyPackage, that would contain __init__.py which tells Python to be
aware of all the other modules in C:\MyPackage. Am I correct?

C:\MyPackage\
\__init__.py
\justPrintHelloWorld.py
\multiply5By10.py

Would I expect the following behavior?:
>>import MyPackage
MyPackage.justPrintHelloWorld
"Hello World"
>>MyPackage.multiply5by10
50
Aug 11 '06 #2
Kevin,

I just posted a small package to the python package index. It has one
source file of interest and some unit tests. The remaining files are
either needed for or made by distutils. Should be pretty easy to
follow if you've read the distutils docs. Note that the package you
get does not have the MANIFEST.in file (the tool creates MANIFEST
automatically using info from MANIFEST.in).

http://cheeseshop.python.org/pypi/pycscope/0.2

share and enjoy,

!!Dean

Aug 13 '06 #3

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

Similar topics

2
by: ME | last post by:
I am trying to find a prewritten method for converting a string like this:"Hello World" to this "Hello\sWorld". I plan to use it to build a regular expression. Specifically I am looking for a...
9
by: PG | last post by:
Hi gurus, I have AIX visual age C++ compiler version 5.0.2.3. I have a simple hello world program that gives compilation errors. Any help will be appreciated. Thanks PG ***test.cpp**** ...
6
by: Matthew | last post by:
How would I go about creating a simple "hello world" program that will run in Unix. I am using MS Visual C++.
21
by: Alf P. Steinbach | last post by:
Just because there seems to be a lack of post-standard _correct_ tutorials: <url: http://home.no.net/dubjai/win32cpptut/>. Disclaimer: written this evening so perhaps there are "bugs" in the...
33
by: ankursinha | last post by:
Hi, Is it possible to write a C program that prints "Hello World" on screen without having a single semi-colon in the entire program? The extra constraint here is that u r not allowed to use...
42
by: Prashanth Badabagni | last post by:
Hi, Can any body tell me how to print "hello,world" with out using semicolon Thanks in advance .. Bye Prashanth Badabagni
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
4
by: arnuld | last post by:
i am learning C and doing the exercise 1-1 of K&R2, where K&R ask to remove some parts of programme and experiment with error, so here i go: #include <stdio.h> int main () { printf('hello...
0
by: Gerardo Herzig | last post by:
Hi all. Im having some "problems" with a small concurrent plpython function. Based on a small example about concurrent programming, there is some code which works fine under python: #!...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.