"pyth0n3r" wrote:
> I came across a problem that when i deal with int data with ',' as
> thousand separator, such as 12,916, i can not change it into int() or
> float(). How can i remove the comma in int data?
> Any reply will be appreciated!!
>
Parse it using the locale module, just be sure to
Hi D'A,
Thanks alot for your reply, it works for me perfectly.
Best,
Chen
On Mon, 15 Apr 2013 02:57:35 +0800
"pyth0n3r" wrote:
> float(). How can i remove the comma in int data? Any reply will be
int(n.replace(',', ''))
--
D'Arcy J.M. Cain | Democracy is three wolves
http://www.drui
On 15/04/2013 08:03, Steven D'Aprano wrote:
On Mon, 15 Apr 2013 03:19:43 +0100, Rotwang wrote:
[...]
(Sorry for linking to Google Groups. Does anyone know of a better c.l.p.
web archive?)
The canonical (although possibly not the best) archive for c.l.p. is the
python-list mailing list archive
On Mon, Apr 15, 2013 at 5:03 PM, Steven D'Aprano
wrote:
> On Mon, 15 Apr 2013 03:19:43 +0100, Rotwang wrote:
>
>> On 15/04/2013 02:14, Steven D'Aprano wrote:
>>> Strings are immutable. Consider building up a single string from four
>>> substrings:
>>
>> Actually, I believe that CPython is optimise
On Sun, 14 Apr 2013 22:35:42 -0400, Roy Smith wrote:
> In article ,
> Walter Hurry wrote:
>
>> On Mon, 15 Apr 2013 11:29:17 +1000, Chris Angelico wrote:
>>
>> > There are actually a lot of optimizations done, so it might turn out
>> > to be O(n) in practice. But strictly in the Python code, ye
On Mon, 15 Apr 2013 03:19:43 +0100, Rotwang wrote:
> On 15/04/2013 02:14, Steven D'Aprano wrote:
>> On Sun, 14 Apr 2013 17:44:28 -0700, Mark Janssen wrote:
>>
>>> On Sun, Apr 14, 2013 at 5:29 PM, Steven D'Aprano
>>> wrote:
On Sun, 14 Apr 2013 12:06:12 -0700, Mark Janssen wrote:
> cl
In article , Rotwang
wrote:
> (Sorry for linking to Google Groups. Does anyone know of a better c.l.p.
> web archive?)
http://dir.gmane.org/gmane.comp.python.general
--
Ned Deily,
n...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
In article ,
Walter Hurry wrote:
> On Mon, 15 Apr 2013 11:29:17 +1000, Chris Angelico wrote:
>
> > There are actually a lot of optimizations done, so it might turn out to
> > be O(n) in practice. But strictly in the Python code, yes, this is
> > definitely O(n*n).
>
> In any event, Janssen sho
On Mon, 15 Apr 2013 11:29:17 +1000, Chris Angelico wrote:
> There are actually a lot of optimizations done, so it might turn out to
> be O(n) in practice. But strictly in the Python code, yes, this is
> definitely O(n*n).
In any event, Janssen should cease and desist offering advice here if he
c
On 15/04/2013 02:14, Steven D'Aprano wrote:
On Sun, 14 Apr 2013 17:44:28 -0700, Mark Janssen wrote:
On Sun, Apr 14, 2013 at 5:29 PM, Steven D'Aprano
wrote:
On Sun, 14 Apr 2013 12:06:12 -0700, Mark Janssen wrote:
cleaned=''
for c in myStringNumber:
if c != ',':
cleaned+=c
int(clean
On Mon, Apr 15, 2013 at 11:14 AM, Steven D'Aprano
wrote:
> On Sun, 14 Apr 2013 17:44:28 -0700, Mark Janssen wrote:
>> What on earth makes you think that is an O(n**2) algorithm and not O(n)?
>
> Python *might* optimize the first concatenation, '' + 'fe', to just reuse
> 'fe', (but it might not). L
On Sun, 14 Apr 2013 17:44:28 -0700, Mark Janssen wrote:
> On Sun, Apr 14, 2013 at 5:29 PM, Steven D'Aprano
> wrote:
>> On Sun, 14 Apr 2013 12:06:12 -0700, Mark Janssen wrote:
>>
>>> cleaned=''
>>> for c in myStringNumber:
>>>if c != ',':
>>> cleaned+=c
>>> int(cleaned)
>>
>> due to b
On Sun, Apr 14, 2013 at 5:29 PM, Steven D'Aprano
wrote:
> On Sun, 14 Apr 2013 12:06:12 -0700, Mark Janssen wrote:
>
>> cleaned=''
>> for c in myStringNumber:
>>if c != ',':
>> cleaned+=c
>> int(cleaned)
>
> due to being an O(N**2) algorithm.
What on earth makes you think that is an
On Sun, 14 Apr 2013 12:06:12 -0700, Mark Janssen wrote:
> cleaned=''
> for c in myStringNumber:
>if c != ',':
> cleaned+=c
> int(cleaned)
Please don't write code like that. Firstly, it's long and bloated, and
runs at the speed of Python, not C. Second, it runs at the speed of
S
On 14/04/2013 19:57, pyth0n3r wrote:
Hi,
I came across a problem that when i deal with int data with ',' as
thousand separator, such as 12,916, i can not change it into int() or
float().
How can i remove the comma in int data?
Any reply will be appreciated!!
Best,
Chen
Use the string replace
> I would do int(num.replace(',', ''))
That's much more pythonic than my C-ish version
Mark
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 15 Apr 2013 02:57:35 +0800
"pyth0n3r" wrote:
> float(). How can i remove the comma in int data? Any reply will be
int(n.replace(',', ''))
--
D'Arcy J.M. Cain | Democracy is three wolves
http://www.druid.net/darcy/| and a sheep voting on
+1 416 788 2246 (Do
On 04/14/2013 02:57 PM, pyth0n3r wrote:
Hi,
> I came across a problem that when i deal with int data with ',' as
thousand separator, such as 12,916, i can not change it into int() or
float().
> How can i remove the comma in int data?
> Any reply will be appreciated!!
>
> Best,
> Chen
>
>
>
I
On Sun, Apr 14, 2013 at 11:57 AM, pyth0n3r wrote:
> I came across a problem that when i deal with int data with ',' as thousand
> separator, such as 12,916, i can not change it into int() or float().
> How can i remove the comma in int data?
> Any reply will be appreciated!!
cleaned=''
for c in m
19 matches
Mail list logo