Python Forum
First time python 3.6 tells me nonsense
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First time python 3.6 tells me nonsense
#1
print("__main__.py")
def Tracer(aClass):
	class Wrapper:
		def __init__(self, *args, **kargs):
			self.fetcges=0
			self.wrapped=aClass(*args, **kargs) 
		def __getattr__(self, attrname):
			print('Trace: '+ attrname)
			self.fetches +- 1
			return getattr(self.wrapped, attrname)
	return wrapper
	
	
	if __name__=='__main__':
		
		@Tracer
		class Spam:
			def display(self):
				print('Spam!' * 8)
				
			
		@Tracer
		class person: 
			def __init__(self, name, hours, rate):
				self.name=name
				self.hours=hours
				self.rate=rate
			def pay(self):
				return self.hours * self.rate
				
				                              
		food=Spam()
		food.display()
		print([food.fetches])
		
		
		bob=Person('Bob', 40, 50)
		print(bob.name)
		print(bob.pay())
		print('')
		
		
		sue=Person('Sue', rate=100, hours=60)
		print(sue.name)
		print(sue.pay())           
		print(bob.name)
		print(bob(pay())
		#print([bob.fetches], [sue.fetches])
		#print([bob.fetches, sue.fetches])
		print('end of file!')
print('end!!!!')


		
Error:
C:\Users\Sylvain\fs>python __main__.py File "__main__.py", line 51 print('end of file!') ^ SyntaxError: invalid syntax
Reply
#2
Line 47 add print(bob(pay())).
Reply
#3
With "print(bob.pay()) the nonsense vanished. Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to change UTC time to local time in Python DataFrame? SamKnight 2 1,599 Jul-28-2022, 08:23 AM
Last Post: Pedroski55
  Getting error in finding time.time() value in python Lakshana 1 2,490 Jan-11-2018, 07:07 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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