[Python] Keep Returning a list from a python function iteratively back to the function

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    I have a simple pipe delimited file with 2 columns with plain text columns - job & dependent jobs. Data looks like this-

    jobA|job1,job2,job3
    jobB|job4,job5
    job1|jobX,jobY
    job2|Null
    job3|Null
    job4|jobP,jobQ
    job5|Null
    jobP|jobR
    jobQ|Null
    jobR|Null
    jobX|Null
    jobY|jobZ
    jobZ|Null


    This data talks about a particular job and all of its dependent jobs. Null means that job doesn't have any dependency (which is acceptable). All jobs are accounted for here in this table. The way to read this data is that JobA has 3 predecessor jobs- job1, job2 and job3. Job1 in turn has 2 predecessors- jobX and jobY and so on.

    The requirement is to have a simple python function which takes a list of job names as input argument and drills down on all its dependent jobs (and their dependent jobs individually up to lowest level.

    So if i pass ['jobA'] to this function, I should get below list in return-

    ['job1','job2','job3','jobX','jobY','jobZ']



    If i pass ['jobB'], i should get below in return-

    ['job4','job5','jobP','jobQ','jobR']


    If i pass the list to this function - ['jobA','jobB'] , we should get combined list.

    ['job1','job2','job3','jobX','jobY','jobZ','job4','job5','jobP','jobQ','jobR']

    Continue reading...

Compartilhe esta Página