On 12 August 2010 20:34, Ben Fritz <[email protected]> wrote: > > > On Aug 12, 4:23 am, winterTTr <[email protected]> wrote: >> >> OK, thanks so much for your answers. I do not notice the get() method. >> There is indeed an alternate way to do so. That's great. >> >> However, I must use this code everywhere if i want the feature as i >> mentioned. >> Even the other person who want to use my code should do the same thing. >> This is not a elegant way, right? >> >> I just want to figure out whether we can hack the dictionary object >> to give it the __index__ feature at the "script" level? > > How about adding a function to the dictionary called myGet() or > something like that. Although you CAN access the elements like > mydict.index or mydict['index'], instead you would use (and encourage > other users of your script to use) mydict.myGet('index'). Under normal > circumstances myGet would just return self[a:index].
Yes, right now, I just use this way. Half a loaf is better than no bread :-) > > -- > You received this message from the "vim_dev" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
