Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Needs[], BeginPackage[], filename

  • To: mathgroup at
  • Subject: [mg101060] Re: [mg101038] Needs[], BeginPackage[], filename
  • From: "David Annetts" <davidannetts at>
  • Date: Tue, 23 Jun 2009 07:03:54 -0400 (EDT)
  • References: <>

Hi Scott,

> Needs[] allows the context and filename to be specified.
> BeginPackage[] allows a context and not a file name.
> Then, my packages require two steps, as in the following example:
> ** start **
> Needs["sizedistribution`", "size functions.m"]
> BeginPackage["tandemdma`", {"sizedistribution`"}]
> ** stop **
> Are two steps really necessary or am I missing something very simple?

Two steps are not necessary.
> My goal would be to just forego Needs[] and handle everything 
> in one step with BeginPackage, but I cannot figure out a way 
> to feed the filename to BeginPackage[].
> I had a search on the MathArchives, but I did not succed in 
> locating any material addressing this question.

This question has been answered before.  

The answer is in the online help.  Search for BeginPackage and you will find

BeginPackage["YourContext", {"Packages`You`Need`"}]

will call Needs["Packages`You`Need`"]

Another way to see this is to look in the supplied packages.  They are only
text files and there's a wealth of information there.


  • Prev by Date: Re: Ansatz?
  • Next by Date: Re: Needs[], BeginPackage[], filename
  • Previous by thread: Needs[], BeginPackage[], filename
  • Next by thread: Re: Needs[], BeginPackage[], filename