Working with graphs - Kevin Bacon game

MRAB python at mrabarnett.plus.com
Wed Jan 9 08:14:37 EST 2019


On 2019-01-09 12:46, Josip Skako wrote:
> Thank You for Your answer,
> 
> I am not sure what to try anymore, I guess I have to return "ime" from __slots__ at cvor() class to show proper strings and I am not able to do it.
> 
With:

class cvor:
     __slots__ = ('ime','susjed')

     def __repr__(self):
         return self.ime

if you say:

print(kreiranjeCvora('Kevin Bacon'))

you get:

Kevin Bacon


However, that might not be desirable because it means that:

print([kreiranjeCvora('Kevin Bacon')])

gives you:

[Kevin Bacon]

so it might be better with:

class cvor:
     __slots__ = ('ime','susjed')

     def __repr__(self):
         return ascii(self.ime)

so that you get:

['Kevin Bacon']

> Now I am not sure that I am going at right direction to do Kevin Bacon game and will I be able to load this data into graph and find shortest way?
> 



More information about the Python-list mailing list