Josh Holland wrote:
> How people would write a kernel in Python?
Like this:
http://code.google.com/p/cleese/wiki/CleeseArchitecturehttp://code.google.com/p/cleese/
?
--
JanC
--
http://mail.python.org/mailman/listinfo/python-list
Sorry, I meant to write "How *many* people ..."
--
Josh Holland
http://joshh.co.uk
madmartian on irc.freenode.net
--
http://mail.python.org/mailman/listinfo/python-list
On 2009-03-21, Josh Holland wrote:
> If you're referring to my reply (about his pseudocode looking
> like C), I hope you realise that it was tongue-in-cheek. For
> the record, I intend to learn C in the near future and know it
> is a very powerful language.
> How people would write a kernel in P
On Tue, Mar 17, 2009 at 08:00:51PM -0500, Jim Garrison wrote:
> There's always some "trollish" behavior in any comp.lang.*
> group. Too many people treat languages as religions instead
> of tools. They all have strengths and weaknesses :-)
If you're referring to my reply (about his pseudocode loo
bieff...@gmail.com wrote:
On Mar 18, 6:06 pm, Jim Garrison wrote:
S Arrowsmith wrote:
Jim Garrison wrote:
It's a shame the iter(o,sentinel) builtin does the
comparison itself, instead of being defined as iter(callable,callable)
where the second argument implements the termination test and r
On Mar 18, 6:06 pm, Jim Garrison wrote:
> S Arrowsmith wrote:
> > Jim Garrison wrote:
> >> It's a shame the iter(o,sentinel) builtin does the
> >> comparison itself, instead of being defined as iter(callable,callable)
> >> where the second argument implements the termination test and returns a
>
> What I was wondering
> was whether a similar construct was considered for a while loop or even an
> if clause, because then the above could be written like this:
>
> if open(filename, 'rb') as f:
> while f.read(1000) as buf:
> # do something with 'buf'
>
see here, and the associat
On Mar 18, 3:05 pm, Grant Edwards wrote:
> {snip] ... If it
> only going to be used once, then just do the usual thing:
>
> f = open(...)
> while True:
> buf = f.read()
> if not buf: break
> # whatever.
> f.close()
+1
That's the canonical way (maybe using "with ... as" nowadays). Surel
Quoting Jim Garrison :
> Jim Garrison wrote:
> > Luis Zarrabeitia wrote:
> >> On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote:
> >> with open(filename, "rb") as f:
> >> for buf in iter(lambda: f.read(1000),''):
> >> do_something(buf)
> >
> > This is the most pythonic solution
sorry, ignore that. hit send before thinking properly.
> have you looked in operators? that might avoid the need for a class.
--
http://mail.python.org/mailman/listinfo/python-list
have you looked in operators? that might avoid the need for a class.
Jim Garrison wrote:
> S Arrowsmith wrote:
>> Jim Garrison wrote:
>>> It's a shame the iter(o,sentinel) builtin does the
>>> comparison itself, instead of being defined as iter(callable,callable)
>>> where the second argument
S Arrowsmith wrote:
Jim Garrison wrote:
It's a shame the iter(o,sentinel) builtin does the
comparison itself, instead of being defined as iter(callable,callable)
where the second argument implements the termination test and returns a
boolean. This would seem to add much more generality... is
Jim Garrison wrote:
>It's a shame the iter(o,sentinel) builtin does the
>comparison itself, instead of being defined as iter(callable,callable)
>where the second argument implements the termination test and returns a
>boolean. This would seem to add much more generality... is
>it worthy of a PEP
Andrii V. Mishkovskyi wrote:
Just before you start writing a PEP, take a look at `takewhile'
function in `itertools' module. ;)
OK, after reading the itertools docs I'm not sure how to use it
in this context. takewhile() requires a sequence, and turning
f.read(bufsize) into an iterable require
On Wed, Mar 18, 2009 at 5:51 PM, Jim Garrison wrote:
> Jim Garrison wrote:
>>
>> Luis Zarrabeitia wrote:
>>>
>>> On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote:
>>> with open(filename, "rb") as f:
>>> for buf in iter(lambda: f.read(1000),''):
>>> do_something(buf)
>>
>> This is
Jim Garrison wrote:
Luis Zarrabeitia wrote:
On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote:
with open(filename, "rb") as f:
for buf in iter(lambda: f.read(1000),''):
do_something(buf)
This is the most pythonic solution yet.
Thanks to all the responders who took time to po
Jim Garrison wrote:
> andrew cooke wrote:
>> Jim Garrison wrote:
>>> I'm an experienced C/Java/Perl developer learning Python.
>>> What's the canonical Python way of implementing this pseudocode?
[ ... ]
>> but not doing much binary i/o
>> myself, i suggest:
>>
>> with open(...) as f:
>> while (
Luis Zarrabeitia wrote:
On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote:
with open(filename, "rb") as f:
for buf in iter(lambda: f.read(1000),''):
do_something(buff)
This is the most pythonic solution yet.
Thanks to all the responders who took time to ponder this seemingly
Grant Edwards wrote:
> with open(filename,"rb") as f:
> while True:
> buf = f.read(1)
> if not buf: break
> # do something
The pattern
with foo() as bar:
# do something with bar
is equivalent to
bar = foo()
if bar:
# do something with bar
except
def chunk_file(fp, chunksize=1):
s = fp.read(chunksize)
while s:
yield s
s = fp.read(chunksize)
Ah. That's the Pythonesque way I was looking for.
That's not pythonic unless you really do need to use
chumk_file() in a lot of places (IMO, more than 3 or 4). If it
only
Luis Zarrabeitia writes:
> One could use this:
>
> with open(filename, "rb") as f:
> for buf in iter(lambda: f.read(1000),''):
> do_something(buff)
This is by far the most pythonic solution, it uses the standard 'for'
loop, and clearly marks the sentinel value. lambda may look stra
On Mar 18, 2:00 am, Jim Garrison wrote:
> I don't want "for line in f:" because binary
> files don't necessarily have lines and I'm bulk processing
> files potentially 100MB and larger. Reading them one line
> at a time would be highly inefficient.
>
> Thanks- Hide quoted text -
>
> - Show quot
On 2009-03-18, Grant Edwards wrote:
> On 2009-03-17, Jim Garrison wrote:
>> I'm an experienced C/Java/Perl developer learning Python.
>>
>> What's the canonical Python way of implementing this pseudocode?
>>
>> String buf
>> File f
>> while ((buf=f.read(1)).length() > 0)
>>
On 2009-03-18, Jim Garrison wrote:
> Tim Chase wrote:
>>> Am I missing something basic, or is this the canonical way:
>>>
>>> with open(filename,"rb") as f:
>>> buf = f.read(1)
>>> while len(buf) > 0
>>> # do something
>>> buf = f.read(1
On 2009-03-17, Jim Garrison wrote:
> I'm an experienced C/Java/Perl developer learning Python.
>
> What's the canonical Python way of implementing this pseudocode?
>
> String buf
> File f
> while ((buf=f.read(1)).length() > 0)
> {
> do something
> }
>
>
Jim Garrison wrote:
Ah. That's the Pythonesque way I was looking for. I knew
it would be a generator/iterator but haven't got the Python
mindset down yet and haven't played with writing my own
generator. I'm still trying to think in purely object-
oriented terms where I would override __next_
Jim Garrison wrote:
[snip]
Ah. That's the Pythonesque way I was looking for.
>
FYI, the correct word is "Pythonic". "Pythonesque" refers to Monty
Python.
--
http://mail.python.org/mailman/listinfo/python-list
andrew cooke wrote:
> Jim Garrison wrote:
>> I'm an experienced C/Java/Perl developer learning Python.
>>
>> What's the canonical Python way of implementing this pseudocode?
[snip]
>
> embarrassed by the other reply i have read,
There's always some "trollish" behavior in any comp.lang.*
group.
Tim Chase wrote:
>> Am I missing something basic, or is this the canonical way:
>>
>> with open(filename,"rb") as f:
>> buf = f.read(1)
>> while len(buf) > 0
>> # do something
>> buf = f.read(1)
>
> That will certainly do. Since read()
On Tuesday 17 March 2009 19:10:20 Josh Holland wrote:
> On Tue, Mar 17, 2009 at 05:04:36PM -0500, Jim Garrison wrote:
> > What's the canonical Python way of implementing this pseudocode?
> >
> > String buf
> > File f
> > while ((buf=f.read(1)).length() > 0)
> > {
> > d
On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote:
>
> Am I missing something basic, or is this the canonical way:
>
> with open(filename,"rb") as f:
> buf = f.read(1)
> while len(buf) > 0
> # do something
> buf = f.read(1)
well, a
Jim Garrison writes:
> buf = f.read(1)
> while len(buf) > 0
> # do something
> buf = f.read(1)
I think it's more usual to use a 'break' rather than duplicate the read.
That is, something more like
while True:
buf = f.read(1)
Am I missing something basic, or is this the canonical way:
with open(filename,"rb") as f:
buf = f.read(1)
while len(buf) > 0
# do something
buf = f.read(1)
That will certainly do. Since read() should simply return a
0-length string
Jim Garrison wrote:
> I'm an experienced C/Java/Perl developer learning Python.
>
> What's the canonical Python way of implementing this pseudocode?
>
> String buf
> File f
> while ((buf=f.read(1)).length() > 0)
> {
> do something
> }
>
> In other words,
On Tue, Mar 17, 2009 at 05:04:36PM -0500, Jim Garrison wrote:
> What's the canonical Python way of implementing this pseudocode?
>
> String buf
> File f
> while ((buf=f.read(1)).length() > 0)
> {
> do something
> }
That looks more like C than pseudocode to me.
I'm an experienced C/Java/Perl developer learning Python.
What's the canonical Python way of implementing this pseudocode?
String buf
File f
while ((buf=f.read(1)).length() > 0)
{
do something
}
In other words, I want to read a potentially large file in 100
On May 25, 6:51 am, Jia Lu <[EMAIL PROTECTED]> wrote:
> Hi all
>
> I'm trying to parsing html with re module.
>
> html = """
>
>
>
> DATA1DATA2DATA3 HT>DATA4
>
>
> DATA5DATA6DATA7DATA8
>
>
> """
>
> I want to get DATA1-8 from that string.(DATA maybe not english words.)
> Can anyone tell me h
Thorsten Kampe ha scritto:
>> I'm trying to parsing html with re module.
> Just don't. Use an HTML parser like BeautifulSoup
Or HTMLParser/htmllib. of course you can mix those and re, it'll be
easier than re only.
--
|\/|55: Mattia Gentilini e 55 = log2(che_palle_sta_storia) (by mezzo)
|/_| ETI
Thorsten Kampe ha scritto:
>> I'm trying to parsing html with re module.
> Just don't. Use an HTML parser like BeautifulSoup
Or HTMLParser/htmllib
--
|\/|55: Mattia Gentilini e 55 = log2(che_palle_sta_storia) (by mezzo)
|/_| ETICS project at CNAF, INFN, Bologna, Italy
|\/| www.getfirefox.com ww
* Jia Lu (25 May 2007 04:51:35 -0700)
> I'm trying to parsing html with re module.
> [...]
> Can anyone tell me how to do it with regular expression in python?
Just don't. Use an HTML parser like BeautifulSoup
--
http://mail.python.org/mailman/listinfo/python-list
Hi all
I'm trying to parsing html with re module.
html = """
DATA1DATA2DATA3DATA4
DATA5DATA6DATA7DATA8
"""
I want to get DATA1-8 from that string.(DATA maybe not english words.)
Can anyone tell me how to do it with regular expression in python?
Thank you very much.
--
http://mail.py
> On 17 Oct 2006 02:56:45 -0700, Lad <[EMAIL PROTECTED]> wrote:
> >
> > Dennis,
> > Thank you for your reply
> > You say:
> > >Pretend you are the computer/application/etc. How would YOU
> > > perform such a ranking?
> > That is what I do not know , how to perform such ranking.
> > Do you have any
On 17 Oct 2006 02:56:45 -0700, Lad <[EMAIL PROTECTED]> wrote:
>
> Dennis,
> Thank you for your reply
> You say:
> >Pretend you are the computer/application/etc. How would YOU
> > perform such a ranking?
> That is what I do not know , how to perform such ranking.
> Do you have any idea?
The detail
Lad wrote:
> Dennis,
> Thank you for your reply
> You say:
> >Pretend you are the computer/application/etc. How would YOU
> > perform such a ranking?
> That is what I do not know , how to perform such ranking.
> Do you have any idea?
>
> Regards,
> Lad.
take a piece of paper to *play* the use-cas
Dennis,
Thank you for your reply
You say:
>Pretend you are the computer/application/etc. How would YOU
> perform such a ranking?
That is what I do not know , how to perform such ranking.
Do you have any idea?
Regards,
Lad.
--
http://mail.python.org/mailman/listinfo/python-list
In a web application users can post some information. I would like to
link each posting with a "weight of importance" for a user, depending
on a keywords in the posting.
For example, I know that a user A is interested in Nokia mobiles while
user B in Siemens mobiles.
So, if a user A is signed, he w
46 matches
Mail list logo