Re: How to structure packages

2011-09-10 Thread Littlefield, Tyler
On 9/10/2011 4:11 AM, Nobody wrote: On Fri, 09 Sep 2011 11:37:44 +1000, Chris Angelico wrote: The Java compiler also acts as a "make" program. If it doesn't find a .class file for a needed class, it will search for the corresponding .java file and compile that. So to compile a complex program,

Re: How to structure packages

2011-09-10 Thread Chris Angelico
On Sat, Sep 10, 2011 at 8:11 PM, Nobody wrote: > I suspect that the one-to-one correspondence between classes and .class > files is mostly technical (e.g. Java's security model). The one-to-one > correspondence between class files and source files could probably be > relaxed, but at the expense of

Re: How to structure packages

2011-09-10 Thread Nobody
On Fri, 09 Sep 2011 11:37:44 +1000, Chris Angelico wrote: >> The Java compiler also acts as a "make" program. If it doesn't find >> a .class file for a needed class, it will search for the corresponding >> .java file and compile that. So to compile a complex program, you only >> need to compile th

Re: How to structure packages

2011-09-09 Thread Alec Taylor
Kayode: Are the number of pages in that tutorial planned? :P > On Sat, Sep 10, 2011 at 1:57 AM, Kayode Odeyemi wrote: >> You might want to have a look at this: >> http://www.ccs.neu.edu/home/matthias/htdc.html >> >> On Fri, Sep 9, 2011 at 2:37 AM, Chris Angelico wrote: >>> >>> On Fri, Sep 9, 20

Re: How to structure packages

2011-09-09 Thread Kayode Odeyemi
You might want to have a look at this: http://www.ccs.neu.edu/home/matthias/htdc.html On Fri, Sep 9, 2011 at 2:37 AM, Chris Angelico wrote: > On Fri, Sep 9, 2011 at 10:45 AM, Nobody wrote: > > The Java compiler also acts as a "make" program. If it doesn't find > > a .class file for a needed cla

Re: How to structure packages

2011-09-08 Thread Chris Angelico
On Fri, Sep 9, 2011 at 10:45 AM, Nobody wrote: > The Java compiler also acts as a "make" program. If it doesn't find > a .class file for a needed class, it will search for the corresponding > .java file and compile that. So to compile a complex program, you only > need to compile the top-level fil

Re: How to structure packages

2011-09-08 Thread Nobody
On Thu, 08 Sep 2011 10:29:26 +1000, Steven D'Aprano wrote: > I suppose "one class per file" might be useful for those using an editor > with no search functionality. Other than that, is there any justification > for this rule? Any Java fans want to defend this? Not a Java fan, but: The Java comp

Re: How to structure packages

2011-09-08 Thread Jonathan Hartley
On Thursday, September 8, 2011 1:29:26 AM UTC+1, Steven D'Aprano wrote: > Steven D'Aprano wrote: > > Other than that, is there any justification > for this rule? Any Java fans want to defend this? > > If "one class per file", why not "one method per class" too? Why is the > second rule any more si

Re: How to structure packages

2011-09-08 Thread Dan Sommers
On Thu, 08 Sep 2011 10:29:26 +1000, Steven D'Aprano wrote: > I suppose "one class per file" might be useful for those using an editor > with no search functionality. Other than that, is there any > justification for this rule? Any Java fans want to defend this? Back in the dark ages known as the

Re: How to structure packages

2011-09-07 Thread Chris Angelico
On Thu, Sep 8, 2011 at 10:29 AM, Steven D'Aprano wrote: > Peter Otten wrote: > >> Classes and functions are grouped into >> submodules by their functionality rather than employing Java's mechanical >> one-class-per-file pattern. > > Surely it's an anti-pattern? I don't think that's true; Java mer

Re: How to structure packages

2011-09-07 Thread Steven D'Aprano
Peter Otten wrote: > Classes and functions are grouped into > submodules by their functionality rather than employing Java's mechanical > one-class-per-file pattern. Surely it's an anti-pattern? I suppose "one class per file" might be useful for those using an editor with no search functionality

Re: How to structure packages

2011-09-07 Thread Westley Martínez
First of all MyClass.py should be renamed to myclass.py. Module names should be lowercase. Secondly, put this in __init__.py: from .myclass import MyClass and there you go. On Wed, Sep 07, 2011 at 08:56:32AM -0700, bclark76 wrote: > I'm learning python, and was playing with structuring pac

Re: How to structure packages

2011-09-07 Thread Littlefield, Tyler
On 9/7/2011 9:56 AM, bclark76 wrote: I'm learning python, and was playing with structuring packages. Basically I want to have a package called mypackage that defines a number of classes and functions. so I create: mypackage __init__.py myfunc.py MyClass.py my __init__.py is b

Re: How to structure packages

2011-09-07 Thread rantingrick
On Sep 7, 10:56 am, bclark76 wrote: > I'm learning python, and was playing with structuring packages. > > Basically I want to have a package called mypackage that defines a > number of classes and functions. > > so I create: > > mypackage >     __init__.py >     myfunc.py >     MyClass.py Don't t

Re: How to structure packages

2011-09-07 Thread Peter Otten
bclark76 wrote: > I'm learning python, and was playing with structuring packages. If you are coming from Jave you have to unlearn a thing or two. > Basically I want to have a package called mypackage that defines a > number of classes and functions. > I'm trying to follow the rule that every f

Re: How to structure packages

2011-09-07 Thread Rafael Durán Castañeda
Check python pep8: http://www.python.org/dev/peps/pep-0008/ And you will see than you shouldn't named modules as you did, so you should do something like: mypackage __init__.py mymodule ... mypackage.mymodule.MyClass On 07/09/11 18:11, John Gordon wrote: In<2a4f542c-a8c1-46c7-98

Re: How to structure packages

2011-09-07 Thread John Gordon
In <2a4f542c-a8c1-46c7-9899-a3fad0940...@x11g2000yqc.googlegroups.com> bclark76 writes: > mypackage > __init__.py > myfunc.py > MyClass.py > from mypackage import MyClass Try this instead: from mypackage.MyClass import MyClass -- John Gordon A is for Amy, who

How to structure packages

2011-09-07 Thread bclark76
I'm learning python, and was playing with structuring packages. Basically I want to have a package called mypackage that defines a number of classes and functions. so I create: mypackage __init__.py myfunc.py MyClass.py my __init__.py is blank. my MyClass.py looks like: import b