Steve Holden wrote:
> how about print [sys.stdin.readline() for i in range(5)]
>
> At least that won't consume the whole file.
+1 on this approach. Clear and obvious and not reliant on any library
modules other than sys.
itertools, what WAS I thinking? :)
--
http://mail.python.org/mailman/listi
On 11/10/10 03:50, Lawrence D'Oliveiro wrote:
In message, Jon
Dufresne wrote:
Lawrence D'Oliveiro wrote:
I see that you published my unobfuscated e-mail address on USENET for all to
see. I obfuscated it for a reason, to keep the spammers away. I'm assuming
this was a momentary lapse of judge
On 11/10/10 16:46, Matty Sarro wrote:
Short story - I have a few thousand files in a directory I
need to parse through. Is there a simple way to loop through
files? I'd like to avoid writing a python script that can
parse 1 file, and have to call it a few thousand times from a
bash script. Any in
On 11/11/2010 00:29, James Mills wrote:
On Thu, Nov 11, 2010 at 8:56 AM, Emile van Sebille wrote:
Easiest would be print [ v for v in sys.stdin.readlines()[:5] ] but that
still reads the entire sys.stdin (whatever it may be...)
Here's a way of doing the same thing without consuming the entire
On Wed, Nov 10, 2010 at 5:38 PM, MRAB wrote:
> On 11/11/2010 00:29, James Mills wrote:
>> On Thu, Nov 11, 2010 at 8:56 AM, Emile van Sebille wrote:
>>> Easiest would be print [ v for v in sys.stdin.readlines()[:5] ] but that
>>> still reads the entire sys.stdin (whatever it may be...)
>>
>> Here'
On 2010-11-10 17:14 , Christian Heimes wrote:
Am 10.11.2010 18:56, schrieb Simon Mullis:
Yes, eval is evil, may lead to security issues and it's unnecessary
slow, too.
# In the meantime - and as a proof of concept - I'm using a dict instead.
xpathlib = {
"houses": r'[ y.t
On 2010-11-10 15:52 , Hrvoje Niksic wrote:
Simon Mullis writes:
If "eval" is not the way forward, are there any suggestions for
another way to do this?
ast.literal_eval might be the thing for you.
No, that doesn't work since he needs to call methods.
--
Robert Kern
"I have come to believ
In message , Seebs wrote:
> On 2010-11-10, Terry Reedy wrote:
>
>> I was referring to Schildt using gets() all the time and thereby
>> teaching new C generations to do he same.
>
> Ahh, yes.
>
> I am told that the current plan is to kill it in C1X. I would shed no
> tears.
Another function th
In message , Robert Kern
wrote:
> Well, the key reason he is using strings is so that he can easily slap on
> a Django admin UI to allow certain users to add new expressions. lambdas
> don't help with that.
Provded you can trust the users who are allowed to add such expressions,
it’s probably a
On 11/10/2010 7:29 PM, James Mills wrote:
> On Thu, Nov 11, 2010 at 8:56 AM, Emile van Sebille wrote:
>> Easiest would be print [ v for v in sys.stdin.readlines()[:5] ] but that
>> still reads the entire sys.stdin (whatever it may be...)
>
> Here's a way of doing the same thing without consuming
In message , Christian
Heimes wrote:
> Don't repeat the mistakes of others and use XML as a configuration
> language. XML isn't meant to be edited by humans.
My principle is: anything automatically generated by machine is not fit for
viewing or editing by humans. There’s nothing special about X
In message , Christian
Heimes wrote:
> I'm sorry but every time I read XML and configuration in one sentence, I
> see the horror of TomCat or Shibboleth XML configs popping up.
Tomcat I know is written in Java; let me guess—Shibboleth is too?
--
http://mail.python.org/mailman/listinfo/python-li
In message , Ian Kelly
wrote:
> On 11/9/2010 11:14 PM, r0g wrote:
>>
>> config = {}
>> for line in (open("config.txt", 'r')):
>> if len(line) > 0 and line[0] <> "#":
>> param, value = line.rstrip().split("=",1)
>> config[param] = value
>
> That's five whole lines of code. Wh
On 11/10/2010 4:36 AM Felipe Vinturini said...
> 2.* *I would like to know another way, a more pythonic way, to write the
> following:
> ===
> import sys
>
> def Z(iNumber):
> sum=0
> while (iNumber>=5):
>
On Thu, Nov 11, 2010 at 11:38 AM, MRAB wrote:
> 'list' will exhaust the input, then the slicing will return at most 5
> lines.
Hmm you're right :)
--
-- James Mills
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Nov 11, 2010 at 1:02 PM, Steve Holden wrote:
> This suggests that you are mistaken about not exhausting the source.
Yeah I was mistaken. Oh well :) I was thinking of a generator-based
solution and got lost in the implementation!
--
-- James Mills
--
-- "Problems are solved by method"
--
On Thu, Nov 11, 2010 at 11:01 AM, alex23 wrote:
> +1 on this approach. Clear and obvious and not reliant on any library
> modules other than sys.
>
> itertools, what WAS I thinking? :)
maybe:
import sys
from itertools import islice
print [v for v in islice((line for line in sys.stdin), 0, 5)]
On Wed, Nov 10, 2010 at 1:50 AM, Lawrence D'Oliveiro
wrote:
> In message , Jon
> Dufresne wrote:
>
>> On Mon, Nov 8, 2010 at 11:35 PM, Lawrence D'Oliveiro ...
>
> I see that you published my unobfuscated e-mail address on USENET for all to
> see. I obfuscated it for a reason, to keep the spammers
Il 09/11/2010 03:18, Lawrence D'Oliveiro ha scritto:
How exactly does
a.f(b, c)
save time over
f(a, b, c)
unfortunately in real world you have:
objId = objId.method(args)
vs.
objId = moduleName.method(objId, args)
I know you can use "from moduleName import *", but IMHO that pro
On 10/11/10 09:52, Peter Otten wrote:
r0g wrote:
I have a subclass of BaseHHTPRequestHandler which uses a dictonary
"paths" and a function "api_call" which are defined in the main
namespace of the module. I'd rather I was able to pass these object to
the constructor and store them as data attri
On Wed, Nov 10, 2010 at 8:14 PM, not1xor1 (Alessandro) <"
"@libero.it> wrote:
> Il 09/11/2010 03:18, Lawrence D'Oliveiro ha scritto:
>
>> How exactly does
>>
>> a.f(b, c)
>>
>> save time over
>>
>> f(a, b, c)
>
> unfortunately in real world you have:
>
> objId = objId.method(args)
>
> vs.
>
On 2010-11-10 22:18 , Jon Dufresne wrote:
On Wed, Nov 10, 2010 at 1:50 AM, Lawrence D'Oliveiro
wrote:
In message, Jon
Dufresne wrote:
On Mon, Nov 8, 2010 at 11:35 PM, Lawrence D'Oliveiro ...
I see that you published my unobfuscated e-mail address on USENET for all to
see. I obfuscated it f
On 11/10/2010 10:07 PM, Lawrence D'Oliveiro wrote:
> In message , Ian Kelly
> wrote:
>
>> > On 11/9/2010 11:14 PM, r0g wrote:
>>> >>
>>> >> config = {}
>>> >> for line in (open("config.txt", 'r')):
>>> >> if len(line) > 0 and line[0] <> "#":
>>> >> param, value = line.rstrip().split("
On 10/11/10 12:45, Mark Wooding wrote:
r0g writes:
You use your main address on USENET rather than a junk one!? Obfuscated or
not that's either brave or foolhardy!
I use my real email address. I also have an aggressive spam filter.
But I don't think that much of my comes from Usenet harvest
On Nov 10, 4:56 pm, Emile van Sebille wrote:
> On 11/10/2010 4:36 AM Felipe Vinturini said...
>
> > Hi Folks,
>
> > I am quite new to python and I don't have a lot of experience with it yet.
>
> > I have two simple questions:
>
> > 1. Is there a way to limit the number of times a list comprehensio
On Thu, Nov 11, 2010 at 3:05 PM, rantingrick wrote:
> Hey all you guys could be mistaken. It looks like the OP is trying to
> implement some sort of ghetto database. And he may NOT necessarily
> want the FIRST five lines of the file. He said (and i quote) "the
> values /between/ # and #". Where #
On 10/11/10 14:42, alexander wrote:
Hi, all
Here is the test. Plz help.
/
***/
If you use the new image search of Google, you will
Mag Gam wrote:
>
>I am measuring the round trip time using tcpdump. The C version is
>giving me around 80 microseconds (average) and the python is giving me
>close to 300 microseconds (average).
If you need the performance of a compiled language, then it's probably not
appropriate to use an inter
On 10/11/10 20:38, Ian wrote:
On Nov 10, 1:05 am, r0g wrote:
That's five whole lines of code. Why go to all that trouble when you can
just do this:
import config
Heh, mainly because I figure the config module will have a lot more
options than I have use for right now and therefore the docs
On 10/11/10 22:56, Emile van Sebille wrote:
On 11/10/2010 4:36 AM Felipe Vinturini said...
Hi Folks,
I am quite new to python and I don't have a lot of experience with it
yet.
I have two simple questions:
1. Is there a way to limit the number of times a list comprehension will
execute? E.g. I
On 10/11/10 23:18, Christian Heimes wrote:
Am 10.11.2010 04:36, schrieb Asun Friere:
Yes but configuration files are not necessarily meant to be edited by
humans either!
Yeah, you are right. I'm sorry but every time I read XML and
configuration in one sentence, I see the horror of TomCat or Sh
On 11/11/10 00:17, Steve Holden wrote:
On 11/10/2010 5:46 PM, Matty Sarro wrote:
Short story - I have a few thousand files in a directory I need to parse
through. Is there a simple way to loop through files? I'd like to avoid
writing a python script that can parse 1 file, and have to call it a f
On Wed, Nov 10, 2010 at 10:11 PM, r0g wrote:
> On 11/11/10 00:17, Steve Holden wrote:
>> On 11/10/2010 5:46 PM, Matty Sarro wrote:
>>>
>>> Short story - I have a few thousand files in a directory I need to parse
>>> through. Is there a simple way to loop through files? I'd like to avoid
>>> writin
On 11/11/10 06:23, Chris Rebert wrote:
On Wed, Nov 10, 2010 at 10:11 PM, r0g wrote:
On 11/11/10 00:17, Steve Holden wrote:
On 11/10/2010 5:46 PM, Matty Sarro wrote:
Short story - I have a few thousand files in a directory I need to parse
through. Is there a simple way to loop through files?
Robert Kern writes:
> On 2010-11-10 15:52 , Hrvoje Niksic wrote:
>> Simon Mullis writes:
>>
>>> If "eval" is not the way forward, are there any suggestions for
>>> another way to do this?
>>
>> ast.literal_eval might be the thing for you.
>
> No, that doesn't work since he needs to call methods.
101 - 135 of 135 matches
Mail list logo