introspection

How can I determine a function's argument count at runtime in Flex 3?

I want to pass an optional data parameter to some callbacks, but only to callbacks that support a single parameter; right now, I have a moderately-sized code base of callbacks that cannot accept a parameter at all. How can I check what parameters a Function object supports? ...

How to introspect django model fields?

Hello, I am trying to obtain class information on a field inside a model, when I only know name of the field and name of the model (both plain strings). How is it possible? I can load the model dynamically: from django.db import models model = models.get_model('myapp','mymodel') Now I have field - 'myfield' - how can I get the class ...

Run code before class instanciation in ActionScript 3

I need to run code in a class declaration before its instanciation. This would be especially useful to automatically register classes in a factory. See: // Main.as public class Main extends Sprite { public function Main() : void { var o : Object = Factory.make(42); } } // Factory.as public class Factory { priva...

get an array variable in python

hi, can I do this in a loop, by producing the file name from the name of the array to store ? ab = array.array('B', map( operator.xor, a, b ) ) f1 = open('ab', 'wb') ab.tofile(f1) f1.close ac = array.array('B', map( operator.xor, a, c ) ) f1 = open('ac', 'wb') ac.tofile(f1) f1.close ad = array.array('B', map( operator.xor, a, d ) ) f1 ...

What is the new way of checking "callable" methods in python 3.x?

Hi, I was studying introspection in Python, and as I was getting through basic examples, I found out that the callable built-in function is no longer available in Python 3.1. How can I check if a method is callable now? Thank you ...

Fastest/One-liner way to list attr_accessors in Ruby?

What's the shortest, one-liner way to list all methods defined with attr_accessor? I would like to make it so, if I have a class MyBaseClass, anything that extends that, I can get the attr_accessor's defined in the subclasses. Something like this: class MyBaseClass < Hash def attributes # ?? end end class SubClass < MyBaseCla...

How do I introspect things in Ruby?

For instance, in Python, I can do things like this if I want to get all attributes on an object: >>> import sys >>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_getframe', 'api_version', 'argv', 'builtin_module_name...

Detect LaTeX class name

I'm working on a LaTeX package which might need to do some things differently depending on the class that's being used. I'm wondering if there's a way to auto-detect or test the document class. One could certainly look up the class files and test for the existence of a specific macro defined by that class, but is there a smarter way? ...

Python Introspection: How to get varnames of class methods?

I want to get the names of the keyword arguments of the methods of a class. I think I understood how to get the names of the methods and how to get the variable names of a specific method, but I don't get how to combine these: class A(object): def A1(self, test1=None): self.test1 = test1 def A2(self, test2=None): ...

Python: Getting the attribute name that the created object will be given

Before I ask this, do note: I want this for debugging purposes. I know that this is going to be some bad black magic, but I want to use it just during debugging so I could identify my objects more easily. It's like this. I have some object from class A that creates a few B instances as attributes: class A(object): def __init__(self...

Listing defined functions in bash

I'm trying to write some code in bash which uses introspection to select the appropriate function to call. Determining the candidates requires knowing which functions are defined. It's easy to list defined variables in bash using only parameter expansion: $ prefix_foo="one" $ prefix_bar="two" $ echo "${!prefix_*}" prefix_bar prefix_foo...

C# how to get the name of the current method from code

I know you can do this.GetType().FullName Edit courtesy of @Pasi Savolainen To get My.Current.Class But what can I call to get My.Current.Class.CurrentMethod ...

Python: How to get the caller's method name in the called method?

Python: How to get the caller's method name in the called method? Assume I have 2 methods: def method1(self): ... a = A.method2() def method2(self): ... If I don't want to do any change for method1, how to get the name of the caller (in this example, the name is method1) in method2? ...

cocoa, mac, is there any tools can inspect the class constructs hierarchy of the window or view on Mac?

as topic, I want see the inner constructs of a special view on Mac, like the class name,and hierarchy , etc. as we know, on Windows, we can use Spy app for this purpose, if any the same feature app can be use on Mac ? thanks for you reply. Regards ...

Method parameter values via introspection ?

Hello, How/am I able, using introspection or reflection get the parameters a method 1 level up in the call stack and it's values ? ...

Can I find the path of the executable running a python script from within the python script?

Is there a way to retreive the path of the executable that is running the current python script (from within the python script)? ...

Any way to determine which object called a method? [Ruby]

I'm hoping that Ruby's message-passing infrastructure means there's some clever trick for this... How do I determine the calling object -- which object called the method I'm currently in? ...

add methods in subclasses within the super class constructor

I want to add methods (more specifically: method aliases) automatically to Python subclasses. If the subclass defines a method named 'get' I want to add a method alias 'GET' to the dictionary of the subclass. To not repeat myself I'd like to define this modifation routine in the base class. But if I check in the base class __init__ met...

Call private methods and private properties from outside a class in PHP

I want to access private methods and variables from outside the classes in very rare specific cases. I've seen that this is not be possible although introspection is used. The specific case is the next one: I would like to have something like this: class Console { final public static function run() { while (TRUE != FAL...

iPad. UIBarButtonItem has an undocumented view of type UIToolbarTextButton. Huh?

I have an iPad app where I have a view controller that is the UIGestureRecognizerDelegate for a number of UIGestureRecognizers. I have implemented the following method of UIGestureRecognizerDelegate: - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { // Double tapping anywhere on ...