Steven D'Aprano wrote:
...
..
.
> You know, one or two examples was probably plenty. The other six or seven
> didn't add anything to your post except length.
>
> Also, type testing by equality is generally not a good idea. For example:
>
> class HexInt(int):
> """Like built-in ints, but prin
On Sat, 08 Sep 2007 12:08:16 -0300, Ricardo Aráoz wrote:
>> if type(x) == type(True):
>> ...print "bool"
>> ...
>> bool
>>
>>
> Or just :
>
a = True
type(a) == int
> False
[snip]
You know, one or two examples was probably plenty. The other six or seven
didn't add anything to
Zentrader wrote:
> On Sep 7, 11:30 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Fri, 07 Sep 2007 18:49:12 +0200, Jorgen Bodde wrote:
>>> As for why caring if they are bools or not, I write True and False to
>>> the properties, the internal mechanism works like this so I need to
>>>
On Fri, 07 Sep 2007 17:40:44 +0200, Jorgen Bodde wrote:
> is the bool derived from 'int' in some way?
Yes.
>>> issubclass(bool, int)
True
> What is the best way to
> check if the config I want to write is an int or a bool ?
if isinstance(value, bool):
print "it's a bool, or a subclass of
On Fri, 07 Sep 2007 12:26:46 -0700, Zentrader wrote:
> Looks like a "feature" of isinstance() is to consider both True and 1 as
> booleans, but type() distinguishes between the two.
That's not a "feature", it is just OOP. `bool` is a subclass of `int`
therefore every `bool` instance is also an i
On Sep 7, 11:30 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 07 Sep 2007 18:49:12 +0200, Jorgen Bodde wrote:
> > As for why caring if they are bools or not, I write True and False to
> > the properties, the internal mechanism works like this so I need to
> > make that distincti
On Fri, 07 Sep 2007 18:49:12 +0200, Jorgen Bodde wrote:
> As for why caring if they are bools or not, I write True and False to
> the properties, the internal mechanism works like this so I need to
> make that distinction.
Really? Can't you just apply the `int()` function?
In [52]: map(int, [1,
Awesome! Thanks you!
As for why caring if they are bools or not, I write True and False to
the properties, the internal mechanism works like this so I need to
make that distinction.
Thanks again guys,
- Jorgen
ps. Sorry TheFlyingDutch for mailing you personally, I keep forgetting
this mailinglis
On Sep 7, 8:40 am, "Jorgen Bodde" <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a dictionary with settings. The settinfgs can be strings, ints
> or bools. I would like to write this list dynamically to disk in a big
> for loop, unfortunately the bools need to be written as 0 or 1 to the
> config
Jorgen Bodde a écrit :
> Hi All,
>
> I have a dictionary with settings. The settinfgs can be strings, ints
> or bools. I would like to write this list dynamically to disk in a big
> for loop, unfortunately the bools need to be written as 0 or 1 to the
> config with WriteInt, the integers also with
Hi All,
I have a dictionary with settings. The settinfgs can be strings, ints
or bools. I would like to write this list dynamically to disk in a big
for loop, unfortunately the bools need to be written as 0 or 1 to the
config with WriteInt, the integers also with WriteInt and the strings
with a si
11 matches
Mail list logo