Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
boolean result of loop
#10
If you want it in one line it sounds like you would be using a list comprehension for it. Why not just use the conditional part of the list comprehension?
if [part for part in filename.split('/') if part == '..']:
    raise UnsafeFileError(filename)
It's kind of inefficient, but it works.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
boolean result of loop - by Skaperen - Mar-31-2017, 01:47 AM
RE: boolean result of loop - by wavic - Mar-31-2017, 02:27 AM
RE: boolean result of loop - by Skaperen - Mar-31-2017, 05:50 AM
RE: boolean result of loop - by Ofnuts - Mar-31-2017, 08:30 AM
RE: boolean result of loop - by Skaperen - Apr-01-2017, 04:10 AM
RE: boolean result of loop - by buran - Apr-01-2017, 04:48 AM
RE: boolean result of loop - by wavic - Apr-01-2017, 05:02 AM
RE: boolean result of loop - by buran - Apr-01-2017, 05:13 AM
RE: boolean result of loop - by wavic - Apr-01-2017, 06:09 AM
RE: boolean result of loop - by ichabod801 - Apr-01-2017, 10:45 AM
RE: boolean result of loop - by wavic - Apr-01-2017, 11:20 AM
RE: boolean result of loop - by buran - Apr-01-2017, 12:07 PM
RE: boolean result of loop - by ichabod801 - Apr-01-2017, 12:42 PM
RE: boolean result of loop - by Skaperen - Apr-02-2017, 01:03 AM
RE: boolean result of loop - by Skaperen - Apr-02-2017, 02:52 AM
RE: boolean result of loop - by Ofnuts - Apr-02-2017, 08:33 PM
RE: boolean result of loop - by wavic - Apr-02-2017, 11:34 PM
RE: boolean result of loop - by micseydel - Apr-02-2017, 11:50 PM
RE: boolean result of loop - by wavic - Apr-02-2017, 11:56 PM
RE: boolean result of loop - by ichabod801 - Apr-03-2017, 12:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Running A Loop Until You See A Particular Result knight2000 6 32,139 Sep-04-2021, 08:55 AM
Last Post: knight2000
  Noob Alert! Wrong result using loop and if statemnent GJG 7 3,091 Dec-19-2020, 05:18 PM
Last Post: buran

Forum Jump:

User Panel Messages

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