personal library

Dave Angel davea at davea.name
Tue Oct 29 22:00:40 EDT 2013


On 29/10/2013 17:29, patrick vrijlandt wrote:

> Hello list,
>
> Python has been a hobby for me since version 1.5.2. Over the years I
> accumulated quite a lot of reusable code. It is nicely organised in
> modules, directories and subdirectories. With every project, the library
> grows and is developed further. I would like to ask your advice for two
> problems:
>
> For most projects I use python's most recent, stable release. Obviously,
> some 3rd party libraries still do not support Python3 (like wx) and I will
> use 2.7. Does this mean I should maintain seperate libraries for 2 and 3,
> or can this be done easier? I do like new language features!

Two approaches are feasible here.  Best would be to change your
library code (usually in minor ways) so that it just works on both
version 2.7 and 3.x  That would mainly involve including from __future__
imports inside a conditional clause - based on version check.  Many of
the most painful differences have been back ported to 2.7

If that's just not doable, then write the code such that either 2to3 or
3to2 will convert your master copy to the other state.  If you can avoid
separately editing the two versions, bug will be lots easier to contain.
    (see  https://wiki.python.org/moin/3to2   but I haven't ever used
it)

>
> How do I arrange that I can access the most recent version of my library on
> every computer in my home network? Development is usually on my desktop,
> sometimes on my laptop, and of course I use python for maintenance tasks on
> other computers in the house (e.g. The children's). I now have the library
> on a network share and local copies on each computer, but of course I
> forget to synchronise often enough.

First, I haven't seen any mention of a source control system.  Get one,
learn it, and use it.  That should always hold your master copy.  And
the actual repository should be on a system you can access from any of
the others.

Then, once you can get to such a repository, you use it to sync your
various local copies on your individual machines.  You could have the
synch happen automatically once a day, or whatever.  You could also
build an auto-synch utility which pushed the synch from the server
whenever the server was updated.

If you're always going to be using these machines with real-time access
to the central server, you could use Windows shares to avoid needing any
updates.  Just create a share on the server, and mount it on each of the
clients.  Add it to your system.path and you're done.

I don't like that last answer because I'm frequently *don't* have access
even to the internet, never mind to a particular server.

-- 
DaveA





More information about the Python-list mailing list