Remona Remona - 1 year ago 83
Python Question

What is the AttributeError in this code? Pathon 3.4

# Do the fun!
def fire(self):

print ("Hitting webserver in mode '{0}' with {1} workers running {2} connections each. Hit CTRL+C to cancel.").format(self.method, self.nr_workers, self.nr_sockets)

print ("Starting {0} concurrent workers").format(self.nr_workers)

AttributEerror: 'NoneType' object has no attribute 'format'

enter image description here

enter image description here

Answer Source

You are formatting after print statement is closed

print (x).format(something)
#       ^ Move this parentheses to end

What you need is this:

print ("Starting {0} concurrent workers".format(self.nr_workers))
#                                                               ^ here 

In Python 2 however, it wouldn't have mattered:

>>> print ("Starting {0} concurrent workers").format(5)
Starting 5 concurrent workers
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download