Linq to Python

hrishy hrishys at yahoo.co.uk
Thu Sep 25 13:08:34 CEST 2008


Hi

Pardon my ignorance again but id ont see any join in python or did i miss something ?

regards
Hrishy


--- On Thu, 25/9/08, sturlamolden <sturlamolden at yahoo.no> wrote:

> From: sturlamolden <sturlamolden at yahoo.no>
> Subject: Re: Linq to Python
> To: python-list at python.org
> Date: Thursday, 25 September, 2008, 12:02 PM
> On 25 Sep, 12:06, hrishy <hris... at yahoo.co.uk> wrote:
> 
> > [code]
> > var stoogeGuys =
> >      Beginning with the XML source
> >      from xmlGuys in
> xmlSource.Descendants("Stooge")
> >      Join to the array on the common element
> "stoogeName"
> >      join arrayGuys in familyFacts
> >            on
> xmlGuys.Element("stoogeName").Value equals
> arrayGuys.stoogeName
> >      Join to the database on the common element
> "stoogeName"
> >      join dbGuys in stoogeContext.stoogeTables
> >            on
> xmlGuys.Element("stoogeName").Value equals
> dbGuys.stoogeName
> >      select new
> >      {
> >         firstName    = dbGuys.stoogeName,
> >         familyName   = arrayGuys.familyName,
> >         birthDate    =
> xmlGuys.Element("birthDate").Value,
> >         deathDate    =
> xmlGuys.Element("deathDate").Value,
> >         hairCutStyle = dbGuys.stoogeHaircut,
> >      };
> > [/code]
> 
> It could e.g. look like this in Python:
> 
> stoogeGuys = []
> for xmlGuys in xmlSource.Descendants["Stooge"]:
>     arrayGuys = familyFacts[xmlGuys.stoogeName]
>     dbGuys = stoogeContext.stoogeTables[xmlGuys.stoogeName]
>     stoogeGuys += \
>        [{'firstName':    dbGuys.stoogeName,
>          'familyName':   arrayGuys.familyName,
>          'birthDate':    xmlGuys.birthDate,
>          'deathDate':    dbGuys.deathDate,
>          'hairCutStyle': dbGuys.stoogeHaircut}]
> 
> --
> http://mail.python.org/mailman/listinfo/python-list


      



More information about the Python-list mailing list