Python project layout?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Python project layout?

Alec Muffett-2
Hi folks,

I'm a old fart^H^H^H^H Perl hacker converting to Python, and am  
starting out on my first Python project.  I'm currently inhaling "Dive  
into Python" and the "Python Cookbook", and am lining up the Django  
book as my next read.  So far I've read heaps of syntax and code, and  
written a few test scripts.

Beyond some information on how "import" works, what I am not finding  
is anything about typical project layout - ie: the names of files and  
subdirectories laid out for class inheritance, loading etc; For  
instance, in http://bitbucket.org/jespern/django-piston/src/tip/examples/blogserver/ 
  there are actualy *files* called "__init__.py" and so forth.  I  
suspect that's a Django thing rather than python syntax, but am not  
sure.

So far I am putting all my classes and all their methods into a single  
file, which I am sure it not tenable.  I suspect I should really  
create a project directory "foo" and edit "foo/bar.py" and "foo/
baz.py" so that I can "import foo.bar" -- but is there any other magic  
I need to do? (cf: package templates in perl)

Is there anything on the web I can look at to find out about this stuff?

thanks in advance,

        - alec


_______________________________________________
python-uk mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-uk
Reply | Threaded
Open this post in threaded view
|

Re: Python project layout?

Tim Golden-4
Alec Muffett wrote:
> Hi folks,

Hi, welcome to Python. Be aware that this list (python-uk)
is very low volume, and tends to be used for announcements
of UK Python meetups, conferences, jobs and the like. Nothing
wrong with posting technical questions here, but you might
be better off on the main Python list:

  http://mail.python.org/mailman/listinfo/python-list

As to your actual question re project layout, I myself
don't have any strong feelings, and I haven't seen
anything very authoritative noised about, either.

The __init__.py file *is* in fact a part of the "syntax",
so to speak, of Python: it indicates that the directory
containing it is to be treated as a Python package:

  http://docs.python.org/tutorial/modules.html#packages

TJG
_______________________________________________
python-uk mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-uk
Reply | Threaded
Open this post in threaded view
|

Re: Python project layout?

Carles Pina i Estany-2

Hi,

On May/08/2009, Tim Golden wrote:
> Alec Muffett wrote:
>> Hi folks,
>
> Hi, welcome to Python. Be aware that this list (python-uk)
> is very low volume, and tends to be used for announcements
> of UK Python meetups, conferences, jobs and the like. Nothing

How often is there a Python meetup in London?

I checked in meetup.com (we are using it in the Barcelona Python group)
but London group is on hold.

In one month I'm moving to London so I was wondering where the Python
people meets :-)

Cheers,

--
Carles Pina i Estany
        http://pinux.info
_______________________________________________
python-uk mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-uk
Reply | Threaded
Open this post in threaded view
|

Re: Python project layout?

Ross Lawley-2
In reply to this post by Tim Golden-4
Hello Alec,

Welcome, sounds like you've got some good reading, as Alec says __init__.py are core for packages and therefore namespacing - so read up on that.

Other than that the best advice I can give is get coding - I often find doing a little project is a great way to focus my learning in a new language.

Also, don't forget to do: "import this" in a python shell for the zen of python!

Good luck and have fun!

Ross

On Fri, May 8, 2009 at 12:53 PM, Tim Golden <[hidden email]> wrote:
Alec Muffett wrote:
Hi folks,

Hi, welcome to Python. Be aware that this list (python-uk)
is very low volume, and tends to be used for announcements
of UK Python meetups, conferences, jobs and the like. Nothing
wrong with posting technical questions here, but you might
be better off on the main Python list:

 http://mail.python.org/mailman/listinfo/python-list

As to your actual question re project layout, I myself
don't have any strong feelings, and I haven't seen
anything very authoritative noised about, either.
The __init__.py file *is* in fact a part of the "syntax",
so to speak, of Python: it indicates that the directory
containing it is to be treated as a Python package:

 http://docs.python.org/tutorial/modules.html#packages

TJG

_______________________________________________
python-uk mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-uk


_______________________________________________
python-uk mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-uk
Reply | Threaded
Open this post in threaded view
|

Re: Python project layout?

Thomas Morton
In reply to this post by Tim Golden-4
Further to Tim's reply about project layout.

One of the tennats of Python is that it is a choice language. If you want to put modules in a single file then do so. If it fits better in a directory then that's fine too. Both work well and neither approach will make you a leper to other Python devs. :)

I usually mix it up. Large modules go in directories. Simple small ones in a single file :)

--
Tom
++
No problem should ever have to be solved twice ++


Google Talk: morton.thomas MSN: [hidden email]
TwitterFacebookLast.fmBloggerYoutubeDigg
Short reply? I use the five.sentenc.es policy in mail replies




2009/5/8 Tim Golden <[hidden email]>
Alec Muffett wrote:
Hi folks,

Hi, welcome to Python. Be aware that this list (python-uk)
is very low volume, and tends to be used for announcements
of UK Python meetups, conferences, jobs and the like. Nothing
wrong with posting technical questions here, but you might
be better off on the main Python list:

 http://mail.python.org/mailman/listinfo/python-list

As to your actual question re project layout, I myself
don't have any strong feelings, and I haven't seen
anything very authoritative noised about, either.
The __init__.py file *is* in fact a part of the "syntax",
so to speak, of Python: it indicates that the directory
containing it is to be treated as a Python package:

 http://docs.python.org/tutorial/modules.html#packages

TJG

_______________________________________________
python-uk mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-uk


_______________________________________________
python-uk mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-uk