1

This snippet of python code has a lot of errors, but I wanted to know if someone can specifically explain to me what the "No global traceback found" error and "self is not first method argument?" The following occur on lines 16 and 28 respectively.

 1 #! /usr/bin/env python
 2
 3 'Example errors caught by PyChecker'
 4
 5 import string
 6
 7 metaslash = 1
 8
 9 def printNames():
10 neal = 'neal'
11 michelle = 'michele'
12 eric = 5
13 print "Local values: %(neal)S %(michele)s %(eric)" % locals()
14
15 class Nothing:
16 def printValue(value):
17 print value
18 def set(self, value):
19 self.value = value
20
21 def tryToDoSomething(self, value):
22 try:
23 import string
24 if not value:
25 raise RuntimeError, "Hey, there's no value"
26 printNames('a, b, c')
27 except:
28 traceback.print_exc()
29
30 def setGlobal(value=None):
31 print 'Old MetaSlash value is:', metaslash
32 metaslash = value
33 useless = Nothing(5)
34 print 'a useless value is:', useless.valeu
TimK
4,8952 gold badges29 silver badges27 bronze badges
asked Nov 16, 2012 at 4:58

1 Answer 1

3

line 16 should be:

def printValue(self, value):

on line 28, what is this traceback object you are calling from? Python is not finding it.

answered Nov 16, 2012 at 4:59
Sign up to request clarification or add additional context in comments.

7 Comments

Ok, figured it out and get what you're saying. What about line 16?
On line 16 you forgot the self, which every function within a class needs (see answer)
It doesn't have to be. You could always decorate it with @classmethod to get around that.
yes that's true, but beginner pythoneers probably shouldn't mess around with decorators
Can you further explain the use of @classmethod ?
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.