Python Forum
Calling list() on permutation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling list() on permutation
#2
permutations returns a generator, which is an object that just sits there and generates values until it's done. Once it's done, that's it, it's dead. You can't get anything else out of it. A file object works the same way. You can only read through a file object once, and then it doesn't return anything when you try to read from it.

Note that once you have done list() on the value returned from permutations, you have all the data in the list. You use that instead.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Calling list() on permutation - by trevorkavanaugh - Mar-01-2019, 05:36 AM
RE: Calling list() on permutation - by ichabod801 - Mar-01-2019, 05:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to print each possible permutation in a dictionary that has arrays as values? noahverner1995 2 1,783 Dec-27-2021, 03:43 AM
Last Post: noahverner1995
  Even/Odd permutation braankoo 9 11,709 Jan-10-2021, 01:19 AM
Last Post: Larz60+
  Help with calling list from user input farispython 5 2,870 Nov-03-2019, 03:13 PM
Last Post: Gribouillis
  memory error using permutation list of 11 elements kikidog 1 3,927 Sep-10-2019, 08:22 PM
Last Post: ichabod801
  how to get all the possible permutation and combination of a sentence in python sodmzs 1 4,201 Jun-13-2019, 07:02 AM
Last Post: perfringo
  Permutation help. jarrod0987 1 2,211 Jun-28-2018, 04:44 PM
Last Post: ichabod801
  Calling list from previous function zykbee 1 2,976 Nov-13-2017, 12:10 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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