What does the slash mean when help() is listing method signatures?

It signifies the end of the positional only parameters, parameters you cannot use as keyword parameters. Before Python 3.8, such parameters could only be specified in the C API. It means the key argument to __contains__ can only be passed in by position (range(5).__contains__(3)), not as a keyword argument (range(5).__contains__(key=3)), something you can do with … Read more

How can I determine the type of a generic field in Java?

Have a look at Obtaining Field Types from the Java Tutorial Trail: The Reflection API. Basically, what you need to do is to get all java.lang.reflect.Field of your class and call Field#getType() on each of them (check edit below). To get all object fields including public, protected, package and private access fields, simply use Class.getDeclaredFields(). … Read more

property type or class using reflection

After searching through Apples Documentation about objc Runtime and according to this SO answer I finally got it working. I just want to share my results. unsigned int count; objc_property_t* props = class_copyPropertyList([MyObject class], &count); for (int i = 0; i < count; i++) { objc_property_t property = props[i]; const char * name = property_getName(property); … Read more

How do I access properties of a javascript object if I don’t know the names?

You can loop through keys like this: for (var key in data) { console.log(key); } This logs “Name” and “Value”. If you have a more complex object type (not just a plain hash-like object, as in the original question), you’ll want to only loop through keys that belong to the object itself, as opposed to … Read more

Get property name as a string

You can try this: unsigned int propertyCount = 0; objc_property_t * properties = class_copyPropertyList([self class], &propertyCount); NSMutableArray * propertyNames = [NSMutableArray array]; for (unsigned int i = 0; i < propertyCount; ++i) { objc_property_t property = properties[i]; const char * name = property_getName(property); [propertyNames addObject:[NSString stringWithUTF8String:name]]; } free(properties); NSLog(@”Names: %@”, propertyNames);