Jason Motley

    Jason Motley

    5 months ago
    What's the best approach to using a for loop that would normally be within the
    main
    section of a standard python script?
    Kevin Kho

    Kevin Kho

    5 months ago
    Mapping would be the analog if the tasks are independent. If it’s a sequential loop, we have Task Looping
    Jason Motley

    Jason Motley

    5 months ago
    This seems a little on the side of what I was thinking of. Right now I have a couple functions, which are then used in a for loop at the bottom. E.g.
    for x in my dict:
            id= dict[x]
            response1= function1(id)
            file= function2(id, response1)
            result= functino3(id, file)
    Kevin Kho

    Kevin Kho

    5 months ago
    Yes that should be able to be done by mapping
    Jason Motley

    Jason Motley

    5 months ago
    does my dictionary go in the .map(1, 2, 3) in the example?
    Kevin Kho

    Kevin Kho

    5 months ago
    Use a task to either pull out the keys or values since you need to map over a List
    Jason Motley

    Jason Motley

    5 months ago
    if you were rewriting my example above then, there would be a task before the first row in the for loop, which gets at the keys, and then
    I guess I'm trying to visualize this outside of the numerical example on the help page
    Kevin Kho

    Kevin Kho

    5 months ago
    with Flow() as flow:
        ids = get_keys(dict)
        response1 = function1.map(ids)
        files = function2.map(ids, response1)
        result = function3.map(ids, files)
    response1
    ,
    files
    ,
    result
    being Lists
    Jason Motley

    Jason Motley

    5 months ago
    Mapping cannot be done over dictionaries?
    Kevin Kho

    Kevin Kho

    5 months ago
    Maybe it can, but I wouldn’t advise because it’s not explicit whether you’re mapping over keys or values