How to get a list of all non callable attributes of the random class in Python

1 Answer

0 votes
import random

cls = "random"

non_callable_attributes = [s for s in dir(eval(cls)) if not s.startswith("__") and not
                                                         callable(eval(cls + "." + s))]
print(non_callable_attributes)


'''
run:
 
['BPF', 'LOG4', 'NV_MAGICCONST', 'RECIP_BPF', 'SG_MAGICCONST', 'TWOPI', '_e', '_inst',
'_pi', '_random']

'''

 



answered Feb 14, 2018 by avibootz

Related questions

1 answer 219 views
2 answers 239 views
2 answers 208 views
1 answer 138 views
...