Python Forum
Please, how do I call the method inside this class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please, how do I call the method inside this class
#2
You have
print(''.join(str(next(self) for j in range(n))))
which is turning a generator into a string str(next(self) for j in range(n))
i think what you are looking for is
print(''.join(str(next(self)) for j in range(n)))
which is turning the next item into a string str(next(self))

The following
print(type(i for i in range(2)))
creates a generator
Output:
<class 'generator'>
whereas including square brackets
print(type([i for i in range(2)]))
creates a list
Output:
<class 'list'>
Reply


Messages In This Thread
RE: Please, how do I call the method inside this class - by Yoriz - Jun-26-2020, 01:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  class method on two object gabejohnsonny21 4 2,470 Apr-22-2020, 06:57 AM
Last Post: DeaD_EyE
  Class/Method Confusion ramadan125 1 2,618 Sep-10-2018, 12:19 AM
Last Post: ichabod801
  call an instance of a class in the interactive nzcan 3 2,985 Aug-23-2018, 10:47 AM
Last Post: nzcan
  Class and calling a method Zatoichi 3 3,122 Mar-13-2018, 08:44 PM
Last Post: Zatoichi
  List not passing between methods inside a class definition ijosefson 5 4,457 Oct-15-2017, 07:15 PM
Last Post: ijosefson

Forum Jump:

User Panel Messages

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