Questions tagged [introspection]

A capability of some object-oriented programming languages to determine the type of an object at runtime.

Some OOP languages providing Type Introspection ability : Ruby, Objective-C, C++, Java, PHP, Perl, Python, Object Pascal, Actionscript (as3)

The introspection is done differently, depending on the form of program, it is performed upon: inspecting a source code or compiled byte-code is called compile-time introspection, while inspecting properties of running code is a run-time introspection.

For example, Java supports both types of introspection: users of run-time introspection typically perform it via , while compile-time introspection can be implemented with tools or .

http://en.wikipedia.org/wiki/Type_introspection

1021 questions
0
votes
1 answer

Get context of an object

I'm writing a game in Python. The player character and enemy characters are instances of Person. Characters can have powers, of class Power. When a character uses a power in combat, the Power object needs to know who owns the power (in order to…
henrebotha
  • 1,244
  • 2
  • 14
  • 36
0
votes
1 answer

Weird PHP Introspection: Get original variable NAMES from function call?

I have a strange question that's probably not possible, but it's worth asking in case there are any PHP internals nerds who know a way to do it. Is there any way to get the variable name from a function call within PHP? It'd be easier to give an…
joshwoodward
  • 201
  • 2
  • 10
0
votes
2 answers

correct use of java Commons BeanUtils?

Hi still learn some concepts in java. so sorry if this is a silly question I Have a class in a jar. i am loading it to my class path dynamically using reflection. and then i am calling the classes constructor method like so : File jar =…
Mr Gallagher
  • 95
  • 10
0
votes
1 answer

Making a generic function and using TypeOf on it

I have a mother trait 'Contract' that is extended by a number of case classes, 'scale' being one of them. I am trying to make a generic function such that it takes an object of one of those case classes and does some action on the basis of what kind…
Core_Dumped
  • 4,577
  • 11
  • 47
  • 71
0
votes
1 answer

How to retrieve a function or method's argument / parameter list from outside the function in Actionscript 3

In another class elsewhere in the code, I want to access the parameters (and their types) of Foo.bar. The result would contain [ "a", Number ] and [ "b", String ] in one form or another. public class Foo { ... public function bar(a:Number,…
Fragsworth
  • 33,919
  • 27
  • 84
  • 97
0
votes
1 answer

Getting class containing method

I'm writing a method decorator and require access to the class defining the method that is currently decorated. The issue seems with this is, that with Python 3 methods in a class are just functions unless the class is instantiated. Is there any way…
dom0
  • 7,356
  • 3
  • 28
  • 50
0
votes
1 answer

How to include "user friendly" column names in SQLalchemy

I am trying to write a function in python, that makes some introspection on one ORM object to generate a simple html form. I get the column names, like order_name , supplier_code, etc, but I would like to assign some names like "Order Name",…
Javier Loureiro
  • 354
  • 2
  • 12
0
votes
2 answers

introspect current thread in python

How can one instrospect to receive the current thread object? Consider this somewhat artificial code snippet. The use case is different, but for the sake of simplicity, I've boiled it down the the essential bit t1 = threading.Thread(target=func) t2…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
0
votes
2 answers

How to find the variables defined in a function

Suppose I have a long javascript function such as function test() { var x; var a; ... ... ... ... ... } is there any way I can ask the function itself to tell me what variables were defined so far. function test() { …
lorenzo
  • 15
  • 1
  • 3
0
votes
4 answers

How do I know where is a function was executed in Python?

Let's imagine, I've got a module foo.py with declared a function foofunc: def foofunc(): # smart things return And two different modules — bar.py and spam.py, where exists code which directly executes the function from foo module. # `bar`…
I159
  • 29,741
  • 31
  • 97
  • 132
0
votes
2 answers

Is it possible to dynamically populate Python methods with code?

I have a number of methods that are of the following format: def p_methodone(a): pass def p_methodtwo(a): pass ... I would like to remove the pass and populate these methods with the code a[0] = a[1]. Is it possible to do this in Python…
sdasdadas
  • 23,917
  • 20
  • 63
  • 148
0
votes
1 answer

Can I enumerate the instance methods of a Java interface in JRuby?

I'm trying to enumerate the methods of an interface from the Ruby side, which as far as I know, JRuby maps to modules. What I thought should work: name = # omitting logic which is currently iterating entries of a jar file clazz =…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
0
votes
2 answers

List all function argument names (no docu)

I am a relative beginner in Python and I am trying to use it to run some not-well-documented code. My question is, how can I get a list of possible arguments of a function or a class constructor using interactive shell, for example. Ideally, I would…
coffee
  • 703
  • 2
  • 9
  • 14
0
votes
1 answer

Finding out which keys a dictionary inside a function object accesses python

Sorry for the slightly obscure question title. In essence, I need to do the following. I have a function in Python, for example: @Wrapper def auselessfunction(dictionary): dictionary["foo"] = 3 dictionary["bar"] = 5 I then have a decorator…
user2515310
  • 357
  • 3
  • 8
0
votes
3 answers

A pattern where a class has a number of similar methods (same type signature, similar semantics)

It's hard to describe this in the abstract, so let me just give a (simplified & snipped) example: class ClassificationResults(object): …
Coquelicot
  • 8,775
  • 6
  • 33
  • 37