Toggle navigation
Home
Free Trial
Plugin Store
Purchase
New Customers
Indigo Store (US/Canada)
Worldwide Resellers
Existing Customers
Software Upgrades
Support
Software Downloads
Support Resources
Indigo Documentation
Frequently Asked Questions
How-To Wiki
User Forums
File Library
Other Resources
Compatible Devices
Recover Lost Registration Code
Contact Support
Blog
Contact Us
Path:
Board index
»
Indigo Help
»
Extending Indigo
»
Python Scripting
Advanced
Anonymous
Login
Register
In Python, how would I decide whether an object is iterable?
Post a reply
Page
1
of
1
First unread post
Posted on
Wed Jul 20, 2022 5:12 am
Lakshit
offline
In Python, how would I decide whether an object is iterable?
Is there a technique like iterable? The main arrangement I have found so far is to call
Code:
Select all
hasattr(myObj, '__iter__')
In any case, I don't know how secure this is.
Posted on
Wed Jul 20, 2022 6:09 am
FlyingDiver
offline
Posts:
7220
Joined:
Jun 07, 2014
Location:
Southwest Florida, USA
Re: In Python, how would I decide whether an object is itera
I don't see any reason that wouldn't be acceptable. How are you getting these objects in the first place?
joe (aka FlyingDiver)
my plugins:
http://forums.indigodomo.com/viewforum.php?f=177
Posted on
Wed Jul 20, 2022 10:47 am
jay (support)
offline
Site Admin
Posts:
18220
Joined:
Mar 19, 2008
Location:
Austin, Texas
Re: In Python, how would I decide whether an object is itera
That might not catch all possible iterables. The best idea is to just try to iterate and catch any exceptions (it'll be a TypeError if it's not iterable) and do whatever is appropriate.
[MODERATOR NOTE]
: moved to a more appropriate forum.
Jay
(Indigo Support)
Twitter
|
Facebook
|
LinkedIn
Post a reply
Page
1
of
1
Display posts from previous:
All posts
1 day
7 days
2 weeks
1 month
3 months
6 months
1 year
Sort by
Author
Post time
Subject
Ascending
Descending
Who is online
Users browsing this forum: No registered users and 3 guests