Introspection
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Wed Jan 6 11:38:35 EST 2010
On Wed, 06 Jan 2010 06:53:40 -0800, msj at infoserv.dk wrote:
> I'm looking for a way to make a list of string literals in a class.
>
> Example:
>
> class A:
> def method(self):
> print 'A','BC'
>
>>>> ExtractLiterals(A)
> ['A','BC']
>
> Is this possible? Can anyone point me in the right direction?
class A:
def extract_literals(self):
return "A BC".split()
def method(self):
print self.extract_literals()
a = A()
a.extract_literals()
--
Steven
More information about the Python-list
mailing list