Re: [Python-ideas] Should __builtins__ have some kind of pass-through print function, for debugging?
Perhaps there could be a special magic method that classes could implement
for such a function? I.e. something like this:
class Pizza(object):
diameter = 1
toppings = []
def __init__(self, diameter=1, toppings=[]):
self.diameter = diameter
self.toppings = toppings
def __str__(self):
return '{}-inch pizza, toppings: {}'.format(self.diameter, ',
'.join(self.toppings))
def __repr__(self):
return '<{}-inch Pizza>'.format(self.diameter)
def __dprint__(self):
return '
On Sat, Apr 28, 2018 at 04:33:32PM +0800, Ken Hilton wrote:
Perhaps there could be a special magic method that classes could implement for such a function? I.e. something like this:
That doesn't help for the scenario in the original motivating example, where there are no classes involved. -- Steve
participants (2)
-
Ken Hilton
-
Steven D'Aprano