Massimo''s has a small typo: two paren's after 'return((.....' and a closing paren... EIther of these "work" in that they both give me (for example):
getName(db) '_5' getName(f._db) '_5' SO they are consistent references to some string, presumably with a correlation to the SQLStorage object... with this as my example: ydb.define_table('my_table',SQLField('my_field')) f=ydb.my_table.my_field and using Jonathan's solution, I see this: In [23]: getName(f._db, findAllNames=True) Out[23]: ['_5', 'ydb', '_', '_22'] In [24]: getName(ydb, findAllNames=True) Out[24]: ['__', '_5', 'ydb', '_22'] As you can see, the variable name you use to reference a given object is somewhat arbitrary (it's just a reference), and "the name" (!) that you want is also arbitrary (that is, you could use ydb.my_table or _5.my_table equivalently; not "_" or "__" as they are transient). This begs the question: if you are writing code "live", you can use whatever string your heart desires (including picking the first one from Jonathan's output that doesn't start with '_'). Actually, maybe that's what you really want: a getName function that returns the first non-'_' name. So, Denes, how are you going to use these references to objects? I guess I'm not understanding something ... With interest, Yarko On Wed, Dec 17, 2008 at 9:58 AM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > Here it is a little shorter > > def getName(obj): return ([k for k,v in globals().items() if v==obj]+ > [None])[0] > > Massimo > > On Dec 17, 9:33 am, DenesL <denes1...@yahoo.ca> wrote: > > Thank you Jonathan, that's exactly it!. > > I knew it had to involve globals somehow. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---