From 87f1523daa4745e91c2f199869c80424d30b4c02 Mon Sep 17 00:00:00 2001 From: Mark Tearle Date: Mon, 6 Apr 2015 17:02:08 +0800 Subject: [PATCH] Alter display code to pad with spaces and simplify --- VendServer/VendingMachine.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VendServer/VendingMachine.py b/VendServer/VendingMachine.py index 4f4b674..72cec3d 100644 --- a/VendServer/VendingMachine.py +++ b/VendServer/VendingMachine.py @@ -160,9 +160,9 @@ class VendingMachine: return (code == '501', code, string) def display(self, string): - if len(string) > 10: - string = string[0:10] - self.wfh.write('D'+string+'\n') + # display first ten characters of string, left aligned + self.wfh.write('D%-10.10s\n' % string) + (code, string) = self.get_response() return (code == '300', code, string) -- 2.20.1