Python Forum
More of my learning
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More of my learning
#2
There's a lot to be said about your code, but I'll just mention a few points here:
  • Using globals for state is bad, this is exactly what classes are for
  • You should use __str__ for the string representation of a class, instead of storing it as an attribute with a weird workaround
  • The way you're using for loops suggests you should take a look at nedbat's Loop Like A Native
  • A lot of your code could be simplified significantly, by slightly changing your approach, and learning a few additional things about python and/or its standard library. For example:
        deal=random.randint(0,12)
        car=deck[deal].card
        num=deck[deal].value
        image=deck[deal].draw
        player.append(Cards(car, num, image))
    could be simplified to:
        player.append(random.choice(deck))
Also,the code is a bit hard to follow,and I'm sure there are other things which could be improved.
Although, if I were you, I would address these things first and then post again for further advice.
Reply


Messages In This Thread
More of my learning - by LordHill - Dec-01-2016, 05:37 AM
RE: More of my learning - by stranac - Dec-01-2016, 09:10 AM
RE: More of my learning - by nilamo - Dec-01-2016, 08:50 PM

Forum Jump:

User Panel Messages

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