Re: Linq to Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hrishy

    Re: Linq to Python

    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@y ahoo.nowrote:
    Code:
    xmlSource.Descendants("Stooge")[QUOTE]
          Join to the array on the common element
    From: sturlamolden <sturlamolden@y ahoo.no> Subject: Re: Linq to Python To: python-list@python.org Date: Thursday, 25 September, 2008, 12:02 PM On 25 Sep, 12:06, hrishy <hris...@yahoo. co.ukwrote:
    Code:
     var stoogeGuys =
          Beginning with the XML source
          from xmlGuys in
    "stoogeName"[QUOTE]      join arrayGuys in familyFacts            on[/QUOTE] xmlGuys.Element("stoogeName").Value equals arrayGuys.stoogeName[QUOTE]      Join to the database on the common element[/QUOTE] "stoogeName"[QUOTE]      join dbGuys in stoogeContext.stoogeTables            on[/QUOTE] xmlGuys.Element("stoogeName").Value equals dbGuys.stoogeName[QUOTE]      select new      {         firstName    = dbGuys.stoogeName,         familyName   = arrayGuys.familyName,         birthDate    =[/QUOTE] xmlGuys.Element("birthDate").Value,[QUOTE]         deathDate    =[/QUOTE] xmlGuys.Element("deathDate").Value,[QUOTE]         hairCutStyle = dbGuys.stoogeHaircut,      }; [/QUOTE]
    It could e.g. look like this in Python:

    stoogeGuys = []
    for xmlGuys in xmlSource.Desce ndants["Stooge"]:
    arrayGuys = familyFacts[xmlGuys.stoogeN ame]
    dbGuys = stoogeContext.s toogeTables[xmlGuys.stoogeN ame]
    stoogeGuys += \
    [{'firstName': dbGuys.stoogeNa me,
    'familyName': arrayGuys.famil yName,
    'birthDate': xmlGuys.birthDa te,
    'deathDate': dbGuys.deathDat e,
    'hairCutStyle': dbGuys.stoogeHa ircut}]

    --
    http://mail.python.org/mailman/listinfo/python-list[/QUOTE]



  • sturlamolden

    #2
    Re: Linq to Python

    On 25 Sep, 13:08, hrishy <hris...@yahoo. co.ukwrote:
    Pardon my ignorance again but id ont see any join in python or did i miss something ?
    It's more Pythonic to use the syntax of dictionary lookups.

    Comment

    Working...