Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
nested for loops glob
#1
I'm trying to use a for loop and a nested for loop
So what I have is:

for f in glob("/Users/Desktop/network5"):
         for x in glob(f/NET_00*):
              print x
         break
    break
This doesn't give me any output.

I realize if I use glob I probably can't use the "f" I defined earlier in the for loop. But how can I use the same path that is assigned to f to use in the nested for loop, x?

For the nested loop, x, I wanted it to loop through all the files in that directory.
Reply


Messages In This Thread
nested for loops glob - by devenuro - Sep-20-2018, 07:46 PM
RE: nested for loops glob - by ODIS - Sep-20-2018, 08:20 PM
RE: nested for loops glob - by devenuro - Sep-20-2018, 08:41 PM
RE: nested for loops glob - by ODIS - Sep-20-2018, 09:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  reduce nested for-loops Phaze90 11 1,919 Mar-16-2023, 06:28 PM
Last Post: ndc85430
  Nested for loops: Iterating over columns of a DataFrame to plot on subplots dm222 0 1,725 Aug-19-2022, 11:07 AM
Last Post: dm222
  Nested for loops - help with iterating a variable outside of the main loop dm222 4 1,603 Aug-17-2022, 10:17 PM
Last Post: deanhystad
  breaking out of nested loops Skaperen 3 1,231 Jul-18-2022, 12:59 AM
Last Post: Skaperen
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,496 Oct-21-2021, 03:29 AM
Last Post: buran
  Break out of nested loops muzikman 11 3,369 Sep-18-2021, 12:59 PM
Last Post: muzikman
  [SOLVED] Input parameter: Single file or glob? Winfried 0 1,588 Sep-10-2021, 11:54 AM
Last Post: Winfried
  q re glob.iglob iterator and close jimr 2 2,239 Aug-23-2021, 10:14 PM
Last Post: perfringo
  How to break out of nested loops pace 11 5,394 Mar-03-2021, 06:25 PM
Last Post: pace
  Nested for Loops sammay 1 8,736 Jan-09-2021, 06:48 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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