Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the value of a <property object at 0x...> in Python

Tags:

python

astropy

I am new to Python and using Python 2.7 on Windows I am using Astropy library, but when I want to view an attribute on the following class:

>>> astropy.cosmology.FlatLambdaCDM.Ok0

it returns:

<property object at 0x7fa2c7e206d8>

Same for other attributes on that object. How do I access the numerical values?

like image 582
Sibte Raza Avatar asked Aug 05 '14 02:08

Sibte Raza


1 Answers

I don't know anything about astropy myself, but from your description it soulds like Ok0 is a property of the FlatLambdaCDM class. You're usually not supposed to try to access properties on a class directly, but rather through an instance of the class.

Try something like:

# create an instance
instance = FlatLambdaCDM()  # the constructor may require some arguments

# access the property on the instance
instance.Ok0

I don't know what arguments (if any) the FlatLambdaCDM class constructor requires, so you may need to add some more stuff to get a workable object.

like image 167
Blckknght Avatar answered Sep 28 '22 05:09

Blckknght