Re: [Tutor] Puzzling case of assertRaises not running properly

2016-12-30 Thread Steven D'Aprano
On Fri, Dec 30, 2016 at 09:51:46PM +, angela ebirim wrote: > class Bill(object): > >def tax(self, total): > tax = float(total * 0.05) > return round(tax, 2) > >def check_input(self, seat1, app1): > try: > seat1 = float(seat1) > app1 = float(app1) >

Re: [Tutor] Puzzling case of assertRaises not running properly

2016-12-30 Thread Martin A. Brown
Hello, Overall, I must say good work and your question was clear. >Learning about how to write tests in Python and have a query. Excellent! I will snip everything except where I think you should look... def check_input(self, seat1, app1): try: seat1 = float(seat1)

[Tutor] Puzzling case of assertRaises not running properly

2016-12-30 Thread angela ebirim
Hi, Learning about how to write tests in Python and have a query. *#bill.py* class Bill(object): def tax(self, total): tax = float(total * 0.05) return round(tax, 2) def check_input(self, seat1, app1): try: seat1 = float(seat1) app1 = float(app1) except

Re: [Tutor] ReadableInt

2016-12-30 Thread Steven D'Aprano
On Fri, Dec 30, 2016 at 04:46:26PM +, Albert-Jan Roskam wrote: > Hi, > > > Why does the call to str() below return '1' and not 'one'? Because the literals 1, 2, 3 etc are hard-coded in the interpreter to return objects of type `int`. Shadowing the name in the builtins module doesn't chang

Re: [Tutor] ReadableInt

2016-12-30 Thread eryk sun
On Fri, Dec 30, 2016 at 4:46 PM, Albert-Jan Roskam wrote: > > Remember I only intend to use it while debugging the given script. Have you tried hooking sys.displayhook? > Why does the call to str() below return '1' and not 'one'? Should I implement > __new__ > because int is immutable? You can

[Tutor] ReadableInt

2016-12-30 Thread Albert-Jan Roskam
Hi, Why does the call to str() below return '1' and not 'one'? Should I implement __new__ because int is immutable? I have a datafile that contains values and an associated metadata file with the associated labels. I need to recode the values. Because just using the values is a bit error prone