473,466 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Checking whether bool is a type

In my application I need to know whether bool is
available as a type (in Python2.3) or not. I just
realized I can use the following:

jand> python
Python 2.3c1 (#1, Jul 21 2003, 12:40:39)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
type(bool) is type True

jand> python2.2
Python 2.2.2 (#1, Oct 16 2002, 19:59:11)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information. type(bool) is type

0

Great isn't it ?! Not sure whether I should consider
this to be completely obvious or very deep ...

Regards, Jan

--
Jan Decaluwe - Resources bvba
Losbergenlaan 16, B-3010 Leuven, Belgium
mailto:ja*@jandecaluwe.com
http://jandecaluwe.com
Jul 18 '05 #1
2 2499
Jan Decaluwe <ja*@jandecaluwe.com> writes:
jand> python2.2
Python 2.2.2 (#1, Oct 16 2002, 19:59:11)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
type(bool) is type 0

Great isn't it ?! Not sure whether I should consider
this to be completely obvious or very deep ...


Very obvious.

Python 2.2.1 (#1, Sep 10 2002, 17:49:17)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
bool

<built-in function bool>

bool is a function in Python 2.2.1+, not a type. It became a type only
in Python 2.3, see PEP 285.

Regards,
Martin
Jul 18 '05 #2
On Sun, 27 Jul 2003 23:22:58 +0200, rumours say that Jan Decaluwe
<ja*@jandecaluwe.com> might have written:
In my application I need to know whether bool is
available as a type (in Python2.3) or not. I just
realized I can use the following:

type(bool) is type


You might like to do this as an alternative:

def bool_is_type():
try:
return isinstance(bool, type)
except NameError:
return 0

to catch older python versions as well.
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
Jul 18 '05 #3

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

Similar topics

3
by: George Sakkis | last post by:
Explicit type checking is not typically seen in Python code, and usually that's not a big problem; most typing errors are likely to raise a TypeError or AttributeError sooner than later. There are...
9
by: Bart Nessux | last post by:
Are these equivelent? Is one approach prefered over the other #check to see if var contains something... if so proceed. if var is not None: continue #check to see if var is empty... if so...
5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
0
by: Jeff | last post by:
I am trying to write some C# code that will allow me to determine if the current user running my application has "write" permissions to a particular folder. However, I can't seem to get it to...
7
by: Michael Kennedy [UB] | last post by:
Hi, I am back with more bug reports from Visual Studio.NET 2003's C++ compiler (unmanaged). Consider the following method: --------------------------------------------- __forceinline bool...
9
by: booksnore | last post by:
I am writing some code to search for strings that contain every letter of the alphabet. At the moment I am using the method below to check to see if a string contains every letter of the alphabet....
9
by: D. Shane Fowlkes | last post by:
(ASP.NET 2 / VB) Question - How can I write a If statement to see if a control (textbox) actually exists on a page? Upon page_load, a certain control may or may not be visible on the page so I...
4
by: Weeble | last post by:
I have an interface that looks something like this: public interface IFoo<Twhere T : IFoo<T{ ... } Inside a class that looks something like this... public class Bar<V{ ... } ....I would like to...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.