Cameron Simpson wrote:
> On 29Aug2020 16:50, Chris Green wrote:
> >However the problem appears to be that internally in Python 3 mailbox
> >class there is an assumption that it's being given 'ascii'. Here's
> >the error (and I'm doing no processing of the message at all):-
> >
> >Traceback (
Karsten Hilbert wrote:
> > However the problem appears to be that internally in Python 3 mailbox
> > class there is an assumption that it's being given 'ascii'.
>
> Do you really _need_ the mailbox class ? From what you've
> written so far my understanding was that you receive data
> (bytes) and
On 29Aug2020 16:50, Chris Green wrote:
>However the problem appears to be that internally in Python 3 mailbox
>class there is an assumption that it's being given 'ascii'. Here's
>the error (and I'm doing no processing of the message at all):-
>
>Traceback (most recent call last):
> File
> Just appending a message as a raw file to a mailbox, doesn't properly
> add it as a new message. You need to add a From: line to the front, and
> then go through the message and alter any line that begins as "From:"
> (and possibly any line that begins with something like ">From:" or
> ">>From:"
On 8/29/20 3:31 PM, Karsten Hilbert wrote:
>> However the problem appears to be that internally in Python 3 mailbox
>> class there is an assumption that it's being given 'ascii'.
> Do you really _need_ the mailbox class ? From what you've
> written so far my understanding was that you receive data
> However the problem appears to be that internally in Python 3 mailbox
> class there is an assumption that it's being given 'ascii'.
Do you really _need_ the mailbox class ? From what you've
written so far my understanding was that you receive data
(bytes) and want to append that to a file (which
On 8/29/20 11:50 AM, Chris Green wrote:
> Chris Green wrote:
>> Dennis Lee Bieber wrote:
>>> On Fri, 28 Aug 2020 12:26:07 +0100, Chris Green declaimed
>>> the
>>> following:
>>>
>>>
>>>
Maybe I shouldn't but Python 2 has been managing to do so for several
years without any issues. I
Chris Green wrote:
> Dennis Lee Bieber wrote:
> > On Fri, 28 Aug 2020 12:26:07 +0100, Chris Green declaimed
> > the
> > following:
> >
> >
> >
> > >Maybe I shouldn't but Python 2 has been managing to do so for several
> > >years without any issues. I know I *could* put the exceptions in a
>
Dennis Lee Bieber wrote:
> On Fri, 28 Aug 2020 12:26:07 +0100, Chris Green declaimed the
> following:
>
>
>
> >Maybe I shouldn't but Python 2 has been managing to do so for several
> >years without any issues. I know I *could* put the exceptions in a
> >bucket somewhere and deal with them sep
On 2020-08-28, Chris Green wrote:
> Maybe I shouldn't but Python 2 has been managing to do so for several
> years without any issues. I know I *could* put the exceptions in a
> bucket somewhere and deal with them separately but I'd really rather
> not.
Then just leave it as bytes and do whateve
On 2020-08-27, Chris Green wrote:
> bbb = [b'aaa', b'bbb', b'ccc']
> sss = []
> for i in range(0, 2):
> sss.append(str(bbb[i])
>
> but that does seem a bit clumsy. Is there a better way?
sss = [str(s) for s in bbb]
--
Grant
--
https://mail.python.org/mailman/listinfo/pyth
On 2020-08-27, Marco Sulla wrote:
> Are you sure you want `str()`?
>
str(b'aaa')
> "b'aaa'"
>
> Probably you want:
>
> map(lambda x: x.decode(), bbb)
If you're an old Scheme or Lisp programmer. :)
This is probably the more usual way to spell it:
sss = [x.decode() for x in bbb]
--
ht
On 28Aug2020 12:26, Chris Green wrote:
>Cameron Simpson wrote:
>> POP3 is presumably handing you bytes containing a message. If the
>> Python
>> email.BytesParser doesn't handle it, stash the raw bytes _elsewhere_ in
>> a distinct file in some directory.
>>
>> with open('evil_msg_bytes', 'wb
On 8/28/20 8:44 AM, Chris Green wrote:
> Stefan Ram wrote:
>> Chris Green writes:
>>> Therein lies the problem, the incoming byte stream *isn't* ASCII, it's
>>> an E-Mail message which may, for example, have UTF-8 or other encoded
>>> characters in it. Hopefully it will have an encoding given in
On Fri, Aug 28, 2020 at 11:24 PM Chris Green wrote:
>
> Chris Angelico wrote:
> >
> > Also, if you're parsing an email message, you can and should be doing
> > so with respect to the encoding(s) stipulated in the headers, after
> > which you will have valid Unicode text.
> >
> But not all E-Mail
On 2020-08-28 08:30, Richard Damon wrote:
> This might be one of the cases where Python 2's lack handling of string
> vs bytes was an advantage.
For English speaking Americans.
> Python2 handled that sort of case quite easily. Python 3 on the other
> hand, will have issue converting the byte mess
Chris Angelico wrote:
>
> Also, if you're parsing an email message, you can and should be doing
> so with respect to the encoding(s) stipulated in the headers, after
> which you will have valid Unicode text.
>
But not all E-Mail messages are 'well behaved', the above works fine
if the headers sp
> I want to transport the message into my mbox and Python 3 won't do it
> without knowing how it's encoded whereas Python 2 just stuffed it in
> there 'as is'.
>
> I want Python 3's mailbox class to juyst put what I tell it (even if
> mis-formatted or mis-encoded) into the mbox.
I guess using the
On 8/28/20 8:39 AM, Chris Green wrote:
> Richard Damon wrote:
>> On 8/28/20 7:50 AM, Karsten Hilbert wrote:
> No interpreation requires, since parsing failed. Then you can start
> dealing with these exceptions. _Do not_ write unparsable messages into
> an mbox!
>
Maybe I shoul
On Fri, Aug 28, 2020 at 10:51 PM Chris Green wrote:
>
> > One possible solution in Python3 is to decode the byte string using an
> > encoding that allows all 256 byte values, so it won't raise any encoding
> > errors, just give your possibly non-sense characters for non-ASCII text.
> >
> But this
Stefan Ram wrote:
> Chris Green writes:
> >Therein lies the problem, the incoming byte stream *isn't* ASCII, it's
> >an E-Mail message which may, for example, have UTF-8 or other encoded
> >characters in it. Hopefully it will have an encoding given in the
> >header but that's only if the sender
Richard Damon wrote:
> On 8/28/20 7:50 AM, Karsten Hilbert wrote:
> >>> No interpreation requires, since parsing failed. Then you can start
> >>> dealing with these exceptions. _Do not_ write unparsable messages into
> >>> an mbox!
> >>>
> >> Maybe I shouldn't but Python 2 has been managing to do
On Fri, Aug 28, 2020 at 10:32 PM Richard Damon wrote:
>
> This might be one of the cases where Python 2's lack handling of string
> vs bytes was an advantage.
>
> If he was just scanning the message for specific ASCII strings, then not
> getting the full message decoded write is unlikely to have b
On 8/28/20 7:50 AM, Karsten Hilbert wrote:
>>> No interpreation requires, since parsing failed. Then you can start
>>> dealing with these exceptions. _Do not_ write unparsable messages into
>>> an mbox!
>>>
>> Maybe I shouldn't but Python 2 has been managing to do so for several
>> years without an
On 8/28/20 7:50 AM, Karsten Hilbert wrote:
>>> No interpreation requires, since parsing failed. Then you can start
>>> dealing with these exceptions. _Do not_ write unparsable messages into
>>> an mbox!
>>>
>> Maybe I shouldn't but Python 2 has been managing to do so for several
>> years without an
> > No interpreation requires, since parsing failed. Then you can start
> > dealing with these exceptions. _Do not_ write unparsable messages into
> > an mbox!
> >
> Maybe I shouldn't but Python 2 has been managing to do so for several
> years without any issues.
I am inclined to congratulate you
Cameron Simpson wrote:
> On 28Aug2020 08:56, Chris Green wrote:
> >Stefan Ram wrote:
> >> Chris Angelico writes:
> >> >But this is a really good job for a list comprehension:
> >> >sss = [str(word) for word in bbb]
> >>
> >> Are you all sure that "str" is really what you all want?
> >>
> >Not
On 28Aug2020 08:56, Chris Green wrote:
>Stefan Ram wrote:
>> Chris Angelico writes:
>> >But this is a really good job for a list comprehension:
>> >sss = [str(word) for word in bbb]
>>
>> Are you all sure that "str" is really what you all want?
>>
>Not absolutely, you no doubt have been follow
Cameron Simpson wrote:
> On 27Aug2020 23:54, Marco Sulla wrote:
> >Are you sure you want `str()`?
> >
> str(b'aaa')
> >"b'aaa'"
> >
> >Probably you want:
> >
> >map(lambda x: x.decode(), bbb)
>
> _And_ you need to know the encoding of the text in the bytes. The above
> _assumes_ UTF-8 beca
Chris Angelico wrote:
> On Fri, Aug 28, 2020 at 6:36 AM Chris Green wrote:
> >
> > This sounds quite an easy thing to do but I can't find how to do it
> > elegantly.
> >
> > I have a list of bytes class objects (i.e. a list containing sequences
> > of bytes, which are basically text) and I want t
Stefan Ram wrote:
> Chris Angelico writes:
> >But this is a really good job for a list comprehension:
> >sss = [str(word) for word in bbb]
>
> Are you all sure that "str" is really what you all want?
>
Not absolutely, you no doubt have been following other threads related
to this one. :-)
> >Are you sure you want `str()`?
> >
> str(b'aaa')
> >"b'aaa'"
> >
> >Probably you want:
> >
> >map(lambda x: x.decode(), bbb)
>
> _And_ you need to know the encoding of the text in the bytes. The above
> _assumes_ UTF-8 because that is the default for bytes.decode, and if
> that is _not_ wha
On 27Aug2020 23:54, Marco Sulla wrote:
>Are you sure you want `str()`?
>
str(b'aaa')
>"b'aaa'"
>
>Probably you want:
>
>map(lambda x: x.decode(), bbb)
_And_ you need to know the encoding of the text in the bytes. The above
_assumes_ UTF-8 because that is the default for bytes.decode, and if
Are you sure you want `str()`?
>>> str(b'aaa')
"b'aaa'"
Probably you want:
map(lambda x: x.decode(), bbb)
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, Aug 28, 2020 at 6:36 AM Chris Green wrote:
>
> This sounds quite an easy thing to do but I can't find how to do it
> elegantly.
>
> I have a list of bytes class objects (i.e. a list containing sequences
> of bytes, which are basically text) and I want to convert it to a list
> of string ob
This sounds quite an easy thing to do but I can't find how to do it
elegantly.
I have a list of bytes class objects (i.e. a list containing sequences
of bytes, which are basically text) and I want to convert it to a list
of string objects.
One of the difficulties of finding out how to do this is
That might also work:
new_list = [i for i in the_list if i not in targets]
# given you have no special requirements for the selection
# out of 'targets'
-Sivan
On Wed, Dec 9, 2015 at 12:58 AM, Thomas 'PointedEars' Lahn <
pointede...@web.de> wrote:
> Mark Lawrence wrote:
>
> > On 03/12/2015 01:1
On Wednesday 09 December 2015 09:58, Thomas 'PointedEars' Lahn wrote:
> Mark Lawrence wrote:
>
>> On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
>>> I would like to know how this could be done more elegant/pythonic.
>>>
>>> I have a big list (over 10.000 items) with strings (each 100 to 300
>>> ch
Mark Lawrence wrote:
> On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
>> I would like to know how this could be done more elegant/pythonic.
>>
>> I have a big list (over 10.000 items) with strings (each 100 to 300
>> chars long) and want to filter them.
>>
>> list = .
>> […]
>
> targets = ['Ba
On Thu, 3 Dec 2015 10:27:19 +0100, wrote:
[snip]
> I often saw constructions like this
> x for x in y if ...
> But I don't understand that combination of the Python keywords (for,
> in, if) I allready know. It is to complex to imagine what there really
> happen.
Don't give up! List comprehensi
On 12/3/2015 7:28 AM, Mark Lawrence wrote:
On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in list[:]
Denis McMahon writes:
> On Thu, 03 Dec 2015 08:32:49 +0200, Jussi Piitulainen wrote:
>
>> def isbad(item):
>> return ( 'Banana' in item or
>> 'Car' in item )
>>
>> def isgood(item)
>> return not isbad(item)
>
> badthings = [ 'Banana', 'Car', ]
>
> def isgood(item)
>
On Thu, 03 Dec 2015 08:32:49 +0200, Jussi Piitulainen wrote:
> def isbad(item):
> return ( 'Banana' in item or
> 'Car' in item )
>
> def isgood(item)
> return not isbad(item)
badthings = [ 'Banana', 'Car', ]
def isgood(item)
for thing in badthings:
if thi
On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in list[:]:
if 'Banana' in item:
list.remove(
On 03/12/15 02:15, c.bu...@posteo.jp wrote:
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in list[:]:
if 'Banana' in item:
list.remove(it
writes:
> Thank you for your suggestion. This will help a lot.
>
> On 2015-12-03 08:32 Jussi Piitulainen wrote:
>> list = [ item for item in list
>> if ( 'Banana' not in item and
>> 'Car' not in item ) ]
>
> I often saw constructions like this
> x for x in y if ...
> But
Laura Creighton wrote:
> In a message of Thu, 03 Dec 2015 10:27:19 +0100, c.bu...@posteo.jp writes:
>>Thank you for your suggestion. This will help a lot.
>>
>>On 2015-12-03 08:32 Jussi Piitulainen wrote:
>>> list = [ item for item in list
>>> if ( 'Banana' not in item and
>>>
On 12/03/2015 10:27 AM, c.bu...@posteo.jp wrote:
I often saw constructions like this
x for x in y if ...
But I don't understand that combination of the Python keywords (for,
in, if) I allready know. It is to complex to imagine what there really
happen.
I understand this
for x in y:
if
In a message of Thu, 03 Dec 2015 10:27:19 +0100, c.bu...@posteo.jp writes:
>Thank you for your suggestion. This will help a lot.
>
>On 2015-12-03 08:32 Jussi Piitulainen wrote:
>> list = [ item for item in list
>> if ( 'Banana' not in item and
>> 'Car' not in item ) ]
>
>I o
On 03.12.2015 10:27, c.bu...@posteo.jp wrote:
>
> I often saw constructions like this
>x for x in y if ...
> But I don't understand that combination of the Python keywords (for,
> in, if) I allready know. It is to complex to imagine what there really
> happen.
>
> I understand this
>for x
On Thu, Dec 3, 2015 at 8:27 PM, wrote:
> Thank you for your suggestion. This will help a lot.
>
> On 2015-12-03 08:32 Jussi Piitulainen wrote:
>> list = [ item for item in list
>> if ( 'Banana' not in item and
>> 'Car' not in item ) ]
>
> I often saw constructions like thi
Thank you for your suggestion. This will help a lot.
On 2015-12-03 08:32 Jussi Piitulainen wrote:
> list = [ item for item in list
> if ( 'Banana' not in item and
> 'Car' not in item ) ]
I often saw constructions like this
x for x in y if ...
But I don't understand that
writes:
> I would like to know how this could be done more elegant/pythonic.
>
> I have a big list (over 10.000 items) with strings (each 100 to 300
> chars long) and want to filter them.
>
> list = .
>
> for item in list[:]:
> if 'Banana' in item:
> list.remove(item)
> if 'Car' in i
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in list[:]:
if 'Banana' in item:
list.remove(item)
if 'Car' in item:
list.remove(item)
On Sun, 13 Oct 2013 22:34:43 -0700, Starriol wrote:
> I'm trying to search for several strings, which I have in a .txt file
> line by line, on another file.
> So the idea is, take input.txt and search for each line in that file in
> another file, let's call it rules.txt.
>
> So far, I've been abl
On 14/10/2013 01:34, Starriol wrote:
> Hi guys,
>
> I'm trying to search for several strings, which I have in a .txt file line by
> line, on another file.
> So the idea is, take input.txt and search for each line in that file in
> another file, let's call it rules.txt.
>
> So far, I've been able
Starriol wrote:
> Hi guys,
>
> I'm trying to search for several strings, which I have in a .txt file line
> by line, on another file. So the idea is, take input.txt and search for
> each line in that file in another file, let's call it rules.txt.
>
> So far, I've been able to do this, to search
Hi guys,
I'm trying to search for several strings, which I have in a .txt file line by
line, on another file.
So the idea is, take input.txt and search for each line in that file in another
file, let's call it rules.txt.
So far, I've been able to do this, to search for individual strings:
[cod
On Jul 23, 7:27 pm, Grant Edwards wrote:
> That said, "map" seems to be frowned upon by the Python community for
> reasons I've never really understood,...
Maybe the analogy:
comprehension : map:: relational calculus : relational algebra
In particular map, filter correspond to project and
On 2012-07-22, Jan Riechers wrote:
> I am not sure why everyone is using the for-iterator option over a
> "map", but I would do it like that:
>
> MODUS_LIST= map(int, options.modus_list)
>
> "map" works on a list and does commandX (here "int" conversion, use
> "str" for string.. et cetera) on s
On 07/22/2012 11:29 AM, Tony the Tiger wrote:
> Hi,
> Is there such a thing in the language, or do I have to invent it myself?
>
> I came up with the following:
>
> # options.modus_list contains, e.g., "[2,3,4]"
> # (a string from the command line)
>
>
&
On 22.07.2012 20:01, Steven D'Aprano wrote:
[SNIP]
map is faster than an ordinary for-loop if the function you are applying
is a builtin like int, str, etc. But if you have to write your own pure-
Python function, the overhead of calling a function negates the advantage
of map, which is no faster
On Sun, Jul 22, 2012 at 10:20 AM, Jan Riechers wrote:
> Hi,
>
> I am not sure why everyone is using the for-iterator option over a "map",
> but I would do it like that:
>
> MODUS_LIST= map(int, options.modus_list)
>
> "map" works on a list and does commandX (here "int" conversion, use "str"
> for
On 22.07.2012 20:03, David Robinow wrote:
On Sun, Jul 22, 2012 at 12:20 PM, Jan Riechers wrote:
On 22.07.2012 18:39, Alister wrote:
looks like a classic list comprehension to me and can be achieved in a
single line
MODUS_LIST=[int(x) for x in options.modus_list]
Hi,
I am not sure why everyon
On Sun, 22 Jul 2012 19:20:18 +0300, Jan Riechers wrote:
> "map" works on a list and does commandX (here "int" conversion, use
> "str" for string.. et cetera) on sequenceY, returning a sequence. More
> in the help file.
>
> And if I'm not completely mistaken, it's also the quicker way to do
> perf
Tony the Tiger writes:
> # options.modus_list contains, e.g., "[2,3,4]"
Try this:
import ast
MODUS_LIST = ast.literal_eval(options.modus_list)
literal_eval is like eval except it can only evaluate literals rather
than calling functions and the like. The idea is you can use it on
untrus
On Sun, Jul 22, 2012 at 12:20 PM, Jan Riechers wrote:
> On 22.07.2012 18:39, Alister wrote:
>> looks like a classic list comprehension to me and can be achieved in a
>> single line
>> MODUS_LIST=[int(x) for x in options.modus_list]
> Hi,
>
> I am not sure why everyone is using the for-iterator opt
Tony the Tiger wrote:
> On Sun, 22 Jul 2012 11:39:30 -0400, Roy Smith wrote:
>
>> To answer the question you asked, to convert a list of strings to a list
>> of ints, you want to do something like:
>>
>> MODUS_LIST = [int(i) for i in options.modus_list]
>
>
On 22.07.2012 18:39, Alister wrote:
On Sun, 22 Jul 2012 10:29:44 -0500, Tony the Tiger wrote:
I came up with the following:
# options.modus_list contains, e.g., "[2,3,4]"
# (a string from the command line)
# MODUS_LIST contains, e.g., [2,4,8,16]
# (i.e., a list of integers)
if
On Sun, 22 Jul 2012 10:29:44 -0500, Tony the Tiger wrote:
> Hi,
> Is there such a thing in the language, or do I have to invent it myself?
>
> I came up with the following:
>
> # options.modus_list contains, e.g., "[2,3,4]"
> # (a string from the command line)
> # MODUS_LIST contains, e.g.,
m))
> MODUS_LIST = intTmp
To answer the question you asked, to convert a list of strings to a list
of ints, you want to do something like:
MODUS_LIST = [int(i) for i in options.modus_list]
But, to answer the question you didn't ask, if you're trying to parse
command-l
Thanks to all for your responses! Good lessons. I implemented
something like what Jerry Hill suggested (dictionary), which works
well for my purposes. The list of strings that is being passed into
this code is also provided by something I wrote so I do trust what is
being sent. Might use what
In article
<2ab25f69-6017-42a6-a7ef-c71bc2ee8...@l2g2000vbn.googlegroups.com>,
noydb wrote:
> How would you convert a list of strings into a list of variables using
> the same name of the strings?
>
> So, ["red", "one", "maple"] into [red, one
noydb wrote:
> How would you convert a list of strings into a list of variables using
> the same name of the strings?
>
> So, ["red", "one", "maple"] into [red, one, maple]
>
> Thanks for any help!
red="a string"
one="another stri
Chris Angelico wrote:
> On Thu, Aug 18, 2011 at 5:09 PM, John Gordon wrote:
>> for x in list_of_strings:
>> list_of_variables.append(eval(x))
>>
>
> If this really is what you need, you can simplify it by using the
> globals() dictionary - it's a regular dictionary whose contents are
> all the g
Hi,
If the «variables» are named attributes you can use getattr.
#
class colors:
red=1
green=2
blue=3
c=colors()
a=['red','green','blue']
for v in a:
print v,getattr(c,v)
#---
AB
--
http://mail.python.org/mailman/listinfo/pytho
On Thu, 18 Aug 2011 16:09:43 +, John Gordon wrote:
>> How would you convert a list of strings into a list of variables using
>> the same name of the strings?
>
>> So, ["red", "one", "maple"] into [red, one, maple]
>
> If the strings
On Thu, Aug 18, 2011 at 5:09 PM, John Gordon wrote:
> for x in list_of_strings:
> list_of_variables.append(eval(x))
>
If this really is what you need, you can simplify it by using the
globals() dictionary - it's a regular dictionary whose contents are
all the global variables in your current m
In <2ab25f69-6017-42a6-a7ef-c71bc2ee8...@l2g2000vbn.googlegroups.com> noydb
writes:
> How would you convert a list of strings into a list of variables using
> the same name of the strings?
> So, ["red", "one", "maple"] into [red, one, maple]
&
On Aug 18, 11:29 am, Jerry Hill wrote:
> On Thu, Aug 18, 2011 at 11:19 AM, noydb wrote:
> > I am being passed the list of strings. I have variables set up
> > already pointing to files. I need to loop through each variable in
> > the list and do things to the files. The
On Thu, Aug 18, 2011 at 11:19 AM, noydb wrote:
> I am being passed the list of strings. I have variables set up
> already pointing to files. I need to loop through each variable in
> the list and do things to the files. The list of strings will change
> each time, include up to 22
On Aug 18, 11:12 am, David Robinow wrote:
> On Thu, Aug 18, 2011 at 10:57 AM, noydb wrote:
> > How would you convert a list of strings into a list of variables using
> > the same name of the strings?
>
> > So, ["red", "one", "maple"] int
On Thu, Aug 18, 2011 at 10:57 AM, noydb wrote:
> How would you convert a list of strings into a list of variables using
> the same name of the strings?
>
> So, ["red", "one", "maple"] into [red, one, maple]
Why would you want to?
--
http://mail.python.org/mailman/listinfo/python-list
How would you convert a list of strings into a list of variables using
the same name of the strings?
So, ["red", "one", "maple"] into [red, one, maple]
Thanks for any help!
--
http://mail.python.org/mailman/listinfo/python-list
OW Ghim Siong writes:
> I have a big file 1.5GB in size, with about 6 million lines of
> tab-delimited data. I have to perform some filtration on the data and
> keep the good data. After filtration, I have about 5.5 million data
> left remaining. As you might already guessed, I have to read them
On Tue, 30 Nov 2010 18:29:35 +0800
OW Ghim Siong wrote:
>
> Does anyone know why is there such a big difference memory usage when
> storing the matrix as a list of list, and when storing it as a list of
> string?
That's because any object has a fixed overhead (related to metadata and
allocatio
On 11/30/2010 04:29 AM, OW Ghim Siong wrote:
a=open("bigfile")
matrix=[]
while True:
lines = a.readlines(1)
for line in lines:
data=line.split("\t")
if several_conditions_are_satisfied:
matrix.append(data)
print "Number of lines read:", len(li
OW Ghim Siong wrote:
> Hi all,
>
> I have a big file 1.5GB in size, with about 6 million lines of
> tab-delimited data. I have to perform some filtration on the data and
> keep the good data. After filtration, I have about 5.5 million data left
> remaining. As you might already guessed, I have to
OW Ghim Siong wrote:
> I have a big file 1.5GB in size, with about 6 million lines of
> tab-delimited data.
How many fields are there an each line?
> I have to perform some filtration on the data and
> keep the good data. After filtration, I have about 5.5 million data left
> remaining. As you m
Hi all,
I have a big file 1.5GB in size, with about 6 million lines of
tab-delimited data. I have to perform some filtration on the data and
keep the good data. After filtration, I have about 5.5 million data left
remaining. As you might already guessed, I have to read them in batches
and I d
Dun Peal, 28.10.2010 09:10:
I find myself surprised at the relatively little use that Cython is seeing.
I don't think it's being used that little. It just doesn't show that
easily. We get a lot of feedback on the mailing list that suggests that
it's actually used by all sorts of people in all
On Wed, Oct 20, 2010 at 6:52 AM, Stefan Behnel wrote:
> Well, the estimate is about one man-month, so it would be doable in about
> three months time if we had the money to work on it. So far, no one has made
> a serious offer to support that project, though.
I find myself surprised at the relati
Dun Peal, 20.10.2010 02:07:
On Mon, Oct 18, 2010 at 1:41 AM, Stefan Behnel wrote:
Or, a bit shorter, using Cython 0.13:
def only_allowed_characters(list strings):
cdef unicode s
return any((c< 31 or c> 127)
for s in strings for c in s)
Very cool, this
On Mon, Oct 18, 2010 at 1:41 AM, Stefan Behnel wrote:
> Or, a bit shorter, using Cython 0.13:
>
> def only_allowed_characters(list strings):
> cdef unicode s
> return any((c < 31 or c > 127)
> for s in strings for c in s)
Very cool, this caused me to look up the
Printable in the screen, all of them are, except for blank spaces ehhehehe
2010/10/18, Tim Chase :
> On 10/18/10 09:28, Grant Edwards wrote:
>> There's no easy way to even define what "printable" means. Ask three
>> different people, and you'll get at least four different answers
>> answers.
>
>
On 10/18/10 09:28, Grant Edwards wrote:
There's no easy way to even define what "printable" means. Ask three
different people, and you'll get at least four different answers
answers.
I don't have a printer...that makes *all* characters unprintable,
right? Now I can convert the algorithm to O
On 2010-10-18, Steven D'Aprano wrote:
> Neither is accurate. all_ascii would be:
>
> all(ord(c) <= 127 for c in string for string in L)
Definitely.
> all_printable would be considerably harder. As far as I can tell, there's
> no simple way to tell if a character is printable.
There's no easy
Dun Peal, 17.10.2010 21:59:
`all_ascii(L)` is a function that accepts a list of strings L, and
returns True if all of those strings contain only ASCII chars, False
otherwise.
What's the fastest way to implement `all_ascii(L)`?
My ideas so far are:
1. Match against a regexp with a char
On Sun, 2010-10-17 at 14:59 -0500, Dun Peal wrote:
> `all_ascii(L)` is a function that accepts a list of strings L, and
> returns True if all of those strings contain only ASCII chars, False
> otherwise.
>
> What's the fastest way to implement `all_ascii(L)`?
>
> M
On Mon, 18 Oct 2010 01:04:09 +0100, Rhodri James wrote:
> On Sun, 17 Oct 2010 20:59:22 +0100, Dun Peal
> wrote:
>
>> `all_ascii(L)` is a function that accepts a list of strings L, and
>> returns True if all of those strings contain only ASCII chars, False
>> otherwis
1 - 100 of 210 matches
Mail list logo