Re: How to determine an object is "scriptable"

2006-03-30 Thread Peter Hansen
abcd wrote: > Daniel Evers wrote: > >>Right. You can check this e.g. with >> >>hasattr(x, "__getitem__") >> >>because the __getitem__ method is used for indexing. > > Thanks...that is what I was looking for! Maybe, but it's not a particularly Pythonic way of doing it. Better is probabl

Re: How to determine an object is "scriptable"

2006-03-30 Thread bruno at modulix
abcd wrote: > I recently came across a problem where I saw this error: > "TypeError: unsubscriptable object" > > How can I determine if an object is "scriptable" or "unscriptable"? By trying to apply the subscript operator ('[]'). If it raises a TypeError, then it's not subscriptable. But, as La

Re: How to determine an object is "scriptable"

2006-03-30 Thread bruno at modulix
abcd wrote: > Richard Brodie wrote: > >>subscriptable: supports an indexing operator, like a list does. > > doesn't seem to be a builtin function or module... It's not. Look no further. > or is that just your > definition of subscriptable? It's a correct definition of 'subscriptable' in the c

Re: How to determine an object is "scriptable"

2006-03-30 Thread Richard Brodie
"abcd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > doesn't seem to be a builtin function or module...or is that just your > definition of subscriptable? Yes, I figured you were just confused. You were using the wrong words, after all. -- http://mail.python.org/mailman/list

Re: How to determine an object is "scriptable"

2006-03-30 Thread bruno at modulix
Larry Bates wrote: > abcd wrote: > >>I recently came across a problem where I saw this error: >>"TypeError: unsubscriptable object" >> >>How can I determine if an object is "scriptable" or "unscriptable"? >> > > Simplest answer is to use isinstance to see if it is a string, list, > or tuple: > >

Re: How to determine an object is "scriptable"

2006-03-30 Thread abcd
Daniel Evers wrote: > Right. You can check this e.g. with > > hasattr(x, "__getitem__") > > because the __getitem__ method is used for indexing. Thanks...that is what I was looking for! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to determine an object is "scriptable"

2006-03-30 Thread Daniel Evers
Richard Brodie wrote: > subscriptable: supports an indexing operator, like a list does. Right. You can check this e.g. with hasattr(x, "__getitem__") because the __getitem__ method is used for indexing. Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: How to determine an object is "scriptable"

2006-03-30 Thread Larry Bates
abcd wrote: > I recently came across a problem where I saw this error: > "TypeError: unsubscriptable object" > > How can I determine if an object is "scriptable" or "unscriptable"? > Simplest answer is to use isinstance to see if it is a string, list, or tuple: if isinstance(variable, (str, list

Re: How to determine an object is "scriptable"

2006-03-30 Thread abcd
Richard Brodie wrote: > subscriptable: supports an indexing operator, like a list does. doesn't seem to be a builtin function or module...or is that just your definition of subscriptable? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to determine an object is "scriptable"

2006-03-30 Thread Richard Brodie
"abcd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I recently came across a problem where I saw this error: > "TypeError: unsubscriptable object" > > How can I determine if an object is "scriptable" or "unscriptable"? subscriptable: supports an indexing operator, like a list do

How to determine an object is "scriptable"

2006-03-30 Thread abcd
I recently came across a problem where I saw this error: "TypeError: unsubscriptable object" How can I determine if an object is "scriptable" or "unscriptable"? -- http://mail.python.org/mailman/listinfo/python-list