How can I create customized classes that have similar properties as 'str'?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Nov 24 17:17:56 EST 2007
On Sat, 24 Nov 2007 04:54:43 -0800, samwyse wrote:
> create a hash that maps your keys to themselves, then use the values of
> that hash as your keys.
>
>>>> store = {}
>>>> def atom(str):
> global store
> if str not in store:
> store[str] = str
> return store[str]
Oh lordy, that's really made my day! That's the funniest piece of code
I've seen for a long time! Worthy of being submitted to the DailyWTF.
Samwyse, while I applaud your willingness to help, I think you actually
need to get some programming skills before doing so. Here's a hint to get
you started: can you think of a way to optimize that function so it does
less work?
--
Steven.
More information about the Python-list
mailing list