Python Forum
splitting or parsing control characters
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
splitting or parsing control characters
#20
(May-26-2017, 06:59 PM)volcano63 Wrote:
list(itertools.chain(*([s] if re.match('[\x01-\x20]', s)
                      [''.join(g) for _, g in itertools.groupby(s)] 
                      for i, s in enumerate(splits))))
Its probably little nitpicking, but I think that this adjustment can use some adjusting - like adding forgotten else, switching "ternary" arguments or negating condition, adding if s and perhaps removing now obsolete enumerate.
Reply


Messages In This Thread
RE: splitting or parsing control characters - by zivoni - May-26-2017, 07:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Remove escape characters / Unicode characters from string DreamingInsanity 5 14,158 May-15-2020, 01:37 PM
Last Post: snippsat
  splitting on 2 or more possible characters Skaperen 6 3,669 Sep-03-2018, 04:10 AM
Last Post: perfringo
  splitting a string by 2 characters Skaperen 8 9,092 Dec-27-2016, 06:14 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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