Python Forum
Convert each element of a list to a string for processing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert each element of a list to a string for processing
#3
I'm trying to remove/clean a bunch of directories using 'glob.glob'
I do not want to do 10 'try/except' for each directory.
I thought I can make a list of directories
prod_tod_to_Rem = glob.glob("C:/0001/**/*.txt", recursive=True)   
dev_tod_to_Rem =glob.glob("C:/04/**/*.txt",recursive=True)        
rm_lst = [prod_tod_to_Rem,dev_tod_to_Rem]
and will pass them to the try/except one by one.

I tried
rm_lst = [*prod_tod_to_Rem, *dev_tod_to_Rem]  
it does the same thing like the
rm_lst = [prod_tod_to_Rem,dev_tod_to_Rem]
 
tor = [str(i) for i in rm_lst]
print(tor)
I might be confused and do not understand your suggestion...
thank you.
Reply


Messages In This Thread
RE: Convert each element of a list to a string for processing - by tester_V - Jun-14-2021, 08:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  element in list detection problem jacksfrustration 5 444 Apr-11-2024, 05:44 PM
Last Post: deanhystad
  list in dicitonary element problem jacksfrustration 3 755 Oct-14-2023, 03:37 PM
Last Post: deanhystad
  convert string to float in list jacklee26 6 1,962 Feb-13-2023, 01:14 AM
Last Post: jacklee26
  convert a list to links Pir8Radio 3 1,139 Nov-28-2022, 01:52 PM
Last Post: Pir8Radio
  Help with Logical error processing List of strings dmc8300 3 1,114 Nov-27-2022, 04:10 PM
Last Post: Larz60+
  Find (each) element from a list in a file tester_V 3 1,259 Nov-15-2022, 08:40 PM
Last Post: tester_V
  Сheck if an element from a list is in another list that contains a namedtuple elnk 8 1,886 Oct-26-2022, 04:03 PM
Last Post: deanhystad
  convert this List Comprehensions to loop jacklee26 8 1,547 Oct-21-2022, 04:25 PM
Last Post: deanhystad
  how to convert tuple value into string mg24 2 2,399 Oct-06-2022, 08:13 AM
Last Post: DeaD_EyE
  Membership test for an element in a list that is a dict value for a particular key? Mark17 2 1,239 Jul-01-2022, 10:52 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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