Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
joined ranges
#1
given 4 ints which define 2 ranges, i can do
foo = [x for x in range(a,b)]+[x for x in range(c,d)]
but it would be nice if there was a more compact form like
foo = range(a,b,1,c,d,1) # warning: invalid code
anyone know of a compact way to join multiple ranges preferably in a range-like object? otherwise, i'm thinking of making a generator to do this.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
joined ranges - by Skaperen - Feb-27-2018, 02:23 AM
RE: joined ranges - by Gribouillis - Feb-27-2018, 07:51 AM
RE: joined ranges - by Skaperen - Feb-28-2018, 01:06 AM
RE: joined ranges - by nilamo - Apr-03-2018, 06:30 PM
RE: joined ranges - by Gribouillis - Apr-03-2018, 07:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] [loop] Exclude ranges in… range? Winfried 2 1,665 May-14-2023, 04:29 PM
Last Post: Winfried
  Delete all Excel named ranges (local and global scope) pfdjhfuys 2 2,033 Mar-24-2023, 01:32 PM
Last Post: pfdjhfuys
  Dictionary with ranges that have a float step value Irv1n 2 2,197 Apr-21-2021, 09:04 PM
Last Post: Yoriz
  Two operations in two ranges salwa17 3 2,267 Jun-22-2020, 04:15 PM
Last Post: perfringo
  iterating a list of ranges Skaperen 1 2,091 May-22-2019, 07:44 AM
Last Post: Gribouillis
  Subnet Mask Ranges ab52 0 1,868 Mar-11-2019, 10:39 AM
Last Post: ab52
  a dictionary of ranges Skaperen 10 6,345 Dec-02-2017, 11:29 PM
Last Post: Windspar
  compacting multiple ranges Skaperen 2 3,168 Oct-11-2017, 08:33 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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