Python Forum
Decypher complex (to me) statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Decypher complex (to me) statement
#2
It is called list comprehension.
And it is equivalent to:
event_arr = []
for x in _485_trace.split(" "):
    if x:
        event_arr.append(x) # the first x in the expression
[x for x in _485_trace.split(" ") if x] appends x to event_arr if there is non-empty x.
str.split method splits the strin by a blank characters so the argument " " is not necessary.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
RE: Decypher complex (to me) statement - by wavic - Jul-31-2018, 12:24 PM
RE: Decypher complex (to me) statement - by buran - Jul-31-2018, 01:01 PM
RE: Decypher complex (to me) statement - by wavic - Jul-31-2018, 03:00 PM

Forum Jump:

User Panel Messages

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