Linked Questions

0 votes
2 answers
953 views

As Python can have multiple classes in one file/module, then how to read Number of Methods class by class?
Muhammad Ali's user avatar
0 votes
0 answers
36 views

I am trying to list available datasets loaders after importing datasets module from sklearn to see a list of available function but it gives me an error : from sklearn import datasets datasets.load_ ...
pk24's user avatar
  • 1
709 votes
22 answers
792k views

Given a Python object of any kind, is there an easy way to get the list of all methods that this object has? Or if this is not possible, is there at least an easy way to check if it has a particular ...
Thomas Lötzer's user avatar
391 votes
30 answers
532k views

I'm starting to code in various projects using Python (including Django web development and Panda3D game development). To help me understand what's going on, I would like to basically 'look' inside ...
littlejim84's user avatar
  • 9,341
199 votes
8 answers
258k views

I C# we do it through reflection. In Javascript it is simple as: for(var propertyName in objectName) var currentPropertyValue = objectName[propertyName]; How to do it in Python?
Jader Dias's user avatar
  • 91.1k
158 votes
14 answers
96k views

I have something roughly like the following. Basically I need to access the class of an instance method from a decorator used upon the instance method in its definition. def decorator(view): # do ...
Carl G's user avatar
  • 18.4k
252 votes
5 answers
353k views

dir(re.compile(pattern)) does not return pattern as one of the lists's elements. Namely it returns: ['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner', 'search', 'split', 'sub', '...
Bartosz Radaczyński's user avatar
102 votes
5 answers
64k views

Lets say my class has many methods, and I want to apply my decorator on each one of them, later when I add new methods, I want the same decorator to be applied, but I don't want to write @mydecorator ...
rapadura's user avatar
  • 5,340
29 votes
4 answers
44k views

I'm trying to use a Python library written in C that has no documentation of any kind. I want to use introspection to at least see what methods and classes are in the modules. Does somebody have a ...
Evan Kroske's user avatar
  • 4,584
20 votes
7 answers
45k views

I am trying to run all the functions in my class without typing them out individually. class Foo(object): def __init__(self,a,b): self.a = a self.b=b def bar(self): ...
collarblind's user avatar
  • 4,749
24 votes
5 answers
24k views

I'm using Python 2.x and I have an object I'm summoning from the aether; the documentation on it is not particularly clear. I would like to be able to get a list of properties for that object and the ...
user avatar
9 votes
3 answers
10k views

I am trying to dynamically create module level functions from the methods in a class. So for every method in a class, I want to create a function with the same name which creates an instance of the ...
saltycrane's user avatar
  • 6,719
10 votes
4 answers
4k views

I am a Python beginner and my main language is C++. You know in C++, it is very common to separate the definition and implementation of a class. (How) Does Python do that? If not, how to I get a clean ...
updogliu's user avatar
  • 6,355
4 votes
4 answers
6k views

What is the proper way to loop over a Python object's methods and call them? Given the object: class SomeTest(): def something1(self): print "something 1" def something2(self): print "...
BuddyJoe's user avatar
  • 71.4k
4 votes
1 answer
3k views

How do you dynamically find out which functions have been defined from an instance of a class? For example: class A(object): def methodA(self, intA=1): pass def methodB(self, strB): ...
Dan's user avatar
  • 35.8k

15 30 50 per page