473,385 Members | 1,427 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,385 software developers and data experts.

TypeCheck vs IsInstance in C API

I'm examining the C API, and I have a question.

http://docs.python.org/api/object.html

There are two functions that appear to do nearly same thing, and I just
want to be certain I'm not missing something. First is PyObject_IsInstance:

int PyObject_IsInstance(PyObject *inst, PyObject *cls);
Returns 1 if inst is an instance of the class cls or a subclass of cls,
or 0 if not...

Second is PyObject_TypeCheck:

int PyObject_TypeCheck(PyObject *o, PyTypeObject *type);
Return true if the object o is of type type or a subtype of type...

Now, I can see that IsInstance can take a tuple as the second argument
and check the type of the first argument against every item in the
tuple. I also see that TypeCheck was added in version 2.2. Why was it
added? Its functionality already seems covered by IsInstance. Is it a
new-style vs. old-style class thing?

-Kirk McDonald
May 30 '06 #1
0 1310

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

Similar topics

6
by: Michal Vitecek | last post by:
hello, please consider the following situation: under the current directory there's a subdirectory 'package' with two files: __init__.py and module.py ./package: __init__.py module.py
2
by: | last post by:
I need to find out dynamically if an object is instance of a Class but I don't know how to use this isinstance buit-in function. I have the object and the name of the class, what should I do? ...
5
by: Jordan Rastrick | last post by:
Hi everyone, Just a little issue that I've come across in Python where I'd be interested to read the thoughts and opinions of the great thinkers and programmers who frequent this newsgroup. ...
2
by: Gregory Petrosyan | last post by:
Hello all! Please enlighten me about optional typecheck: 1) Will it be available in Python 2.5? 2) Will it support things like def f(a: int | float) 3) Will it support interface checking...
19
by: Mr.Rech | last post by:
Hi all, I've read some thread about isinstance(), why it is considered harmful and how you can achieve the same results using a coding style that doesn't break polymorphism etc... Since I'm trying...
12
by: codefire | last post by:
Hi, I'm using the isinstance built-in function. I've found the docs for it, but there are no docs on the supported types. For example isinstance(a, int) works fine but isinstance(s, string)...
21
by: abcd | last post by:
In my code I am debating whether or not to validate the types of data being passed to my functions. For example def sayHello(self, name): if not name: rasie "name can't be null" if not...
7
by: Tlis | last post by:
I am using a software system with an embedded Python interpreter (version 2.3) for scripting. The KcsPoint2D.py module contains a Point2D class with the following method: def...
5
by: Boris Borcic | last post by:
Given the ABC innovation, maybe an infix syntax for isinstance() would be good. Possibilities : - stealing "is" away from object identity. As a motivation, true use cases for testing object...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.