- Original Message -
From: Seymore4Head Seymore4Head@Hotmail.invalid
To: python-list@python.org
Sent: Friday, 28 November, 2014 4:31:50 AM
Subject: Re: Can you use self in __str__
On Thu, 27 Nov 2014 21:49:29 -0500, Dave Angel da...@davea.name
wrote:
class Hand:
def
On Thu, 4 Dec 2014 20:22:11 +0100 (CET), Jean-Michel Pichavant
jeanmic...@sequans.com wrote:
- Original Message -
From: Seymore4Head Seymore4Head@Hotmail.invalid
To: python-list@python.org
Sent: Friday, 28 November, 2014 4:31:50 AM
Subject: Re: Can you use self in __str__
On Thu
Seymore4Head wrote:
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This is part of a Hand class. I need a hand for the dealer and a hand
for the player.
dealer=Hand()
player=Hand()
This prints out 'Hand
On 11/27/2014 10:31 PM, Seymore4Head wrote:
On Thu, 27 Nov 2014 21:49:29 -0500, Dave Angel da...@davea.name
wrote:
class Hand:
def __init__(self):
self.hand = []
# create Hand object
def __str__(self):
s = 'Hand contains '
for x in self.hand:
On Fri, Nov 28, 2014 at 12:26 PM, Seymore4Head
Seymore4Head@hotmail.invalid wrote:
dealer=Hand()
player=Hand()
This prints out 'Hand contains foo bar
for both the dealer's hand and the player's hand.
Is there a way to include self in the __string__ so it reads
Dealer hand contains foo bar
On 11/27/2014 08:43 PM, Chris Angelico wrote:
On Fri, Nov 28, 2014 at 12:26 PM, Seymore4Head
Seymore4Head@hotmail.invalid wrote:
dealer=Hand()
player=Hand()
This prints out 'Hand contains foo bar
for both the dealer's hand and the player's hand.
Is there a way to include self in the
On Friday, November 28, 2014 6:57:23 AM UTC+5:30, Seymore4Head wrote:
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This is part of a Hand class. I need a hand for the dealer and a hand
for the player.
On Friday, November 28, 2014 7:51:40 PM UTC+5:30, Rustom Mody wrote:
On Friday, November 28, 2014 6:57:23 AM UTC+5:30, Seymore4Head wrote:
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This is part of a
2014-11-28 13:00 GMT+08:00 Chris Angelico ros...@gmail.com:
On Fri, Nov 28, 2014 at 2:04 PM, Shiyao Ma i...@introo.me wrote:
What if it's in the local namespace of a function or method? IDK, try
to get that thing first.
Sure enough. I will even avoid using id as it's dependent on CPython
On Sat, Nov 29, 2014 at 2:16 PM, Shiyao Ma i...@introo.me wrote:
2014-11-28 13:00 GMT+08:00 Chris Angelico ros...@gmail.com:
On Fri, Nov 28, 2014 at 2:04 PM, Shiyao Ma i...@introo.me wrote:
What if it's in the local namespace of a function or method? IDK, try
to get that thing first.
Sure
2014-11-29 11:36 GMT+08:00 Chris Angelico ros...@gmail.com:
You can use id() on any object. You are guaranteed to get back an
integer which is both stable and unique among all ids of objects that
exist at the same time as the one you called it on. For as long as the
object continues to exist,
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This is part of a Hand class. I need a hand for the dealer and a hand
for the player.
dealer=Hand()
player=Hand()
This prints out 'Hand contains foo bar
for both the
On 11/27/2014 08:26 PM, Seymore4Head wrote:
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This is part of a Hand class. I need a hand for the dealer and a hand
for the player.
dealer=Hand()
player=Hand()
2014-11-28 9:26 GMT+08:00 Seymore4Head Seymore4Head@hotmail.invalid:
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This is part of a Hand class. I need a hand for the dealer and a hand
for the player.
On Thu, 27 Nov 2014 21:49:29 -0500, Dave Angel da...@davea.name
wrote:
class Hand:
def __init__(self):
self.hand = []
# create Hand object
def __str__(self):
s = 'Hand contains '
for x in self.hand:
s = s + str(x) +
return s
I am
On Fri, 28 Nov 2014 11:04:26 +0800, Shiyao Ma i...@introo.me wrote:
2014-11-28 9:26 GMT+08:00 Seymore4Head Seymore4Head@hotmail.invalid:
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This is part of a Hand
On Fri, Nov 28, 2014 at 2:04 PM, Shiyao Ma i...@introo.me wrote:
What if it's in the local namespace of a function or method? IDK, try
to get that thing first.
What if it's in multiple namespaces? What if it's not in any at all?
Your solution is not going to work in the general case, AND it's a
Seymore4Head wrote:
On Fri, 28 Nov 2014 11:04:26 +0800, Shiyao Ma i...@introo.me wrote:
2014-11-28 9:26 GMT+08:00 Seymore4Head Seymore4Head@hotmail.invalid:
def __str__(self):
s = Hand contains
for x in self.hand:
s = s + str(x) +
return s
This
18 matches
Mail list logo