Python Forum
Function - Return multiple values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function - Return multiple values
#1
Greeting!
I have to scan directories and find/process subdirectories.
Number of SubDirs not static.
I thought I could use a function but found I cannot "return" all the SubDirs.
I can print all of them but not return them.
I'm sure it is simple but I could not find a clear answer but I cannot find one.
def func(dir1):
    for ed1 in os.listdir(dir1) :
        echd_p = os.path.join(dir1,ed1)
        if os.path.isdir(echd_p) :
            return (echd_p)

fdp =  func(dir1)
print(type(fdp))   
print(fdp)  
Thank you.
Reply


Messages In This Thread
Function - Return multiple values - by tester_V - May-31-2021, 11:14 PM
RE: Function - Return multiple values - by tester_V - Jun-01-2021, 01:11 AM
RE: Function - Return multiple values - by tester_V - Jun-01-2021, 01:38 AM
RE: Function - Return multiple values - by tester_V - Jun-01-2021, 06:39 AM
RE: Function - Return multiple values - by tester_V - Jun-01-2021, 05:14 PM
RE: Function - Return multiple values - by tester_V - Jun-02-2021, 05:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  __init__() got multiple values for argument 'schema' dawid294 4 3,097 Jan-03-2024, 09:42 AM
Last Post: buran
  Need to return 2 values from 1 DF that equals another DF cubangt 5 737 Oct-21-2023, 02:45 PM
Last Post: deanhystad
  nested function return MHGhonaim 2 736 Oct-02-2023, 09:21 AM
Last Post: deanhystad
  return next item each time a function is executed User3000 19 2,638 Aug-06-2023, 02:29 PM
Last Post: deanhystad
  function return boolean based on GPIO pin reading caslor 2 1,317 Feb-04-2023, 12:30 PM
Last Post: caslor
  Adding values with reduce() function from the list of tuples kinimod 10 2,922 Jan-24-2023, 08:22 AM
Last Post: perfringo
  [Solved]Return values from npyscreen Extra 2 1,261 Oct-09-2022, 07:19 PM
Last Post: Extra
  Parallelism with return values Plexian 7 1,634 Aug-14-2022, 09:33 AM
Last Post: Plexian
  How to combine multiple column values into 1? cubangt 15 3,212 Aug-11-2022, 08:25 PM
Last Post: cubangt
  function accepts infinite parameters and returns a graph with those values edencthompson 0 930 Jun-10-2022, 03:42 PM
Last Post: edencthompson

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020