Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stacking generators
#3
(Sep-18-2016, 08:21 PM)ichabod801 Wrote: Why not just return the appropriate generator:

def generator(self):
    if self.uc:
        return self.ucGenerator()
    else:
        return self.lcGenerator()
Then you're not generating over a generator, you're just providing the correct generator to the original iteration.

** Slaps forehead ** Doh... In my "factory" method I was returning self.ucGenerator and not self.ucGenerator(). These parens make a huge difference...

ichabod801.virtual_beers+=1
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
Stacking generators - by Ofnuts - Sep-18-2016, 06:56 PM
RE: Stacking generators - by ichabod801 - Sep-18-2016, 08:21 PM
RE: Stacking generators - by Ofnuts - Sep-18-2016, 08:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Stacking Problem in a game. HelloTobi22 2 1,012 Aug-05-2022, 09:48 AM
Last Post: HelloTobi22
  Image Stacking Help Rhys_SSD 2 2,671 Feb-25-2019, 10:49 AM
Last Post: Rhys_SSD
  2 iterators or generators Skaperen 1 33,555 Jan-04-2018, 07:41 AM
Last Post: Gribouillis
  Using Generators and their expressions BeerLover 3 4,561 Mar-18-2017, 11:06 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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