I`m new to python and I have the stupid problem with passing an argument.
class MyClass():
@staticmethod
def add_group(name, parent_id):
print "add_group method, name: %s, parent_id: %s" % (name, parent_id)
Other class method
def task():
print "task method, name: %s, group_id: %s" % (name, parent_id)
MyClass.add_group(name, parent_id)
Output:
task method, name: blabla, group_id: 15
add_group method, name: blabla, parent_id: (15L,)
What’s happened with parent_id argument? Any help would be appreciated!
In one case you passed in
15, in the other case you passed in(15L,)(i.e. a tuple whose first value is 15L, that is long(15) or an arbitrary-precision number representing 15.)Numbers naturally transform into longs when they become very large values such as 10**20, but in this case it is very small; the only way I can think of you would have gotten a long you weren’t expecting was doing something like
10**20 - 10**20 + 15, or somehow some other value in your program is a long.edit: Specifically, the other value in your program may be being returned by a library you are using.