On Thursday, October 30, 2014 4:10:23 AM UTC-7, Steven D'Aprano wrote:
> I don't particularly like either version. I prefer this:
>
> def load_int(obj):
> if isinstance(obj, int):
> # Case 1), an int, e.g. 7
> return obj
> elif isinstance(obj, str):
> # Case 2) and
On Fri, 31 Oct 2014 09:48:10 +1100, Steven D'Aprano wrote:
> MRAB wrote:
>> How about:
>>
>> int(str(obj).strip('"'))
>
> Absolutely not.
>
> obj = '""1\n\n\n\n' # not valid JSON load_int(obj)
> => raises ValueError int(str(obj).strip('"'))
> => wrongly returns 1
How about
#!/us
Roy Smith wrote:
> In article <54521c8f$0$12982$c3e8da3$54964...@news.astraweb.com>,
> Steven D'Aprano wrote:
>
>> Anton wrote:
>>
>> > Let's say I have an incoming list of values *l*. Every element of *l*
>> > can be one of the following options:
>> > 1) an integer value
>> > 2) a string in f
In article <54521c8f$0$12982$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> Anton wrote:
>
> > Let's say I have an incoming list of values *l*. Every element of *l* can
> > be one of the following options:
> > 1) an integer value
> > 2) a string in form of '', e.g. '7'
> > 3) a
MRAB wrote:
> On 2014-10-30 11:10, Steven D'Aprano wrote:
>> Anton wrote:
>>
>>> Let's say I have an incoming list of values *l*. Every element of *l*
>>> can be one of the following options:
>>> 1) an integer value
>>> 2) a string in form of '', e.g. '7'
>>> 3) a string with a json serialization
On 2014-10-30 11:10, Steven D'Aprano wrote:
Anton wrote:
Let's say I have an incoming list of values *l*. Every element of *l* can
be one of the following options:
1) an integer value
2) a string in form of '', e.g. '7'
3) a string with a json serialization of an integer value, e.g. '"7"'
4) so
Anton wrote:
> Let's say I have an incoming list of values *l*. Every element of *l* can
> be one of the following options:
> 1) an integer value
> 2) a string in form of '', e.g. '7'
> 3) a string with a json serialization of an integer value, e.g. '"7"'
> 4) something else that should be ignor
On Wednesday, October 29, 2014 4:59:25 AM UTC-7, Rafael Romero Carmona wrote:
> 2014-10-29 12:25 GMT+01:00 Martin Kemp :
> Actually it doesn't work because there is no add function and it
> doesn't catch the TypeError function to ignore other exceptions than
> ValueError. Doesn't it? I tested in Py
On Wednesday, October 29, 2014 4:43:33 AM UTC-7, Rafael Romero Carmona wrote:
> Hi, first in Python 2.7.6 and Python 3.4.0 list haven't got any add
> function but they have append.
You are right, in my original code I use set instead of array, so it should be
either values = set() or values.append
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 29/10/2014 12:01, Rafael Romero Carmona wrote:
> 2014-10-29 12:25 GMT+01:00 Martin Kemp : On
> 29/10/2014 10:45, Anton wrote:
Let's say I have an incoming list of values *l*. Every
element of *l* can be one of the following options: 1) an
2014-10-29 12:25 GMT+01:00 Martin Kemp :
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 29/10/2014 10:45, Anton wrote:
>> Let's say I have an incoming list of values *l*. Every element of
>> *l* can be one of the following options: 1) an integer value 2) a
>> string in form of '', e.g. '7
Hi, first in Python 2.7.6 and Python 3.4.0 list haven't got any add
function but they have append.
I think you could do better with something like
==
import json
l = [1, -1, 0, '1', '-1', '0', json.dumps(-1), json.dumps(1),
json.dumps(0), 'x', 'sqjklsqjk__', (1, 2)]
values = []
for c in
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 29/10/2014 10:45, Anton wrote:
> Let's say I have an incoming list of values *l*. Every element of
> *l* can be one of the following options: 1) an integer value 2) a
> string in form of '', e.g. '7' 3) a string with a json
> serialization of an int
Let's say I have an incoming list of values *l*. Every element of *l* can be
one of the following options:
1) an integer value
2) a string in form of '', e.g. '7'
3) a string with a json serialization of an integer value, e.g. '"7"'
4) something else that should be ignored
I need to transform th
Steve Holden wrote:
K-Dawg wrote:
I am trying to become more pythonic as I learn python and get my mind
around it instead of other languages I have used.
I have an app that has a series of classes for objects it uses. From a
style perspective, which should be done:
Different py file for each
K-Dawg wrote:
> I am trying to become more pythonic as I learn python and get my mind
> around it instead of other languages I have used.
>
> I have an app that has a series of classes for objects it uses. From a
> style perspective, which should be done:
>
> Different py file for each class
>
I am trying to become more pythonic as I learn python and get my mind around
it instead of other languages I have used.
I have an app that has a series of classes for objects it uses. From a
style perspective, which should be done:
Different py file for each class
or
One py file with all the c
17 matches
Mail list logo