473,324 Members | 2,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Proper Way of checking for a collections class

Howdy,

I've been trying to find a good idiom for testing if the input to a
function is one of the collections classes... the best I could do is this:

if hasattr(thing_to_test, '__iter__'):
...

Is this right? Or, is there a better way besides a cascade of type()
tests?

Thanks!

Peace,
Gary

Jul 18 '05 #1
0 930

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Howard Swope | last post by:
Could someone help explain thread safety issues in the System.Collections classes? The documentation states:...
5
by: Atley | last post by:
I am trying to set up a nested collection so I can run statements like this: me.lblquestions.text = mysteps.item(1).questions(1).Asked Any ideas on how to do this? I have created a...
3
by: Paul | last post by:
Hello, I'm upgrading a small single user app to VB.NET and have a few questions about loading classes & collections classes with the data from a one to many dataset structure. I'm serializing...
2
by: a | last post by:
The problem: I want to allow an administrator (user) to create a list of teachers, each teacher in turn has a list of classes, each class has a list of students. There's an article at...
5
by: Simon | last post by:
Hi all, I am writing a windows application using vb.net on the 1.1 framework. We have in the application, some strongly typed collections that have been written as classes that do not inherit...
4
by: Adam Clauss | last post by:
I ran into a problem a while back when attempting to convert existing .NET 1.1 based code to .NET 2.0 using Generic collections rather than Hashtable, ArrayList, etc. I ran into an issue because...
4
by: Sid Price | last post by:
Hello, I have a class of objects (Device) that are managed by another object (Devices) with a collection class (DeviceCollection) inherited from Collections.Hashtable. Each of the Device objects...
1
by: ledneh | last post by:
I've been working on concurrency checking for an application I'm building, and a minor part of it has me slightly stumped. I've got a DetailsView that populates from an ObjectDataSource, using...
1
by: mattmao | last post by:
I am brand new to C#.NET so here is my trial on this lab exercise: using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace lab02exec { ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.