Re: Is Eval *always* Evil?

2010-11-10 Thread Hrvoje Niksic
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.

Re: Looping through files in a directory

2010-11-10 Thread r0g
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?

Re: Looping through files in a directory

2010-11-10 Thread Chris Rebert
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

Re: Looping through files in a directory

2010-11-10 Thread r0g
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

Re: DTD Parsing

2010-11-10 Thread r0g
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

Re: Questions: While And List Comprehension

2010-11-10 Thread r0g
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

Re: DTD Parsing

2010-11-10 Thread r0g
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

Re: udp sockets with python

2010-11-10 Thread Tim Roberts
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

Re: Curses Programming

2010-11-10 Thread r0g
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

Re: Questions: While And List Comprehension

2010-11-10 Thread James Mills
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 #

Re: Questions: While And List Comprehension

2010-11-10 Thread rantingrick
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

Re: How to test if a module exists?

2010-11-10 Thread r0g
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

Re: DTD Parsing

2010-11-10 Thread Steve Holden
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("

Re: How to test if a module exists?

2010-11-10 Thread Robert Kern
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

Re: subclassing str

2010-11-10 Thread Chris Rebert
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. >

Re: Class extension confusion :(

2010-11-10 Thread r0g
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

Re: subclassing str

2010-11-10 Thread not1xor1 (Alessandro)
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

Re: How to test if a module exists?

2010-11-10 Thread Jon Dufresne
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

Re: Questions: While And List Comprehension

2010-11-10 Thread James Mills
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)]

Re: Questions: While And List Comprehension

2010-11-10 Thread James Mills
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" --

Re: Questions: While And List Comprehension

2010-11-10 Thread James Mills
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

Re: Questions: While And List Comprehension

2010-11-10 Thread Ian
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): >    

Re: DTD Parsing

2010-11-10 Thread Lawrence D'Oliveiro
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

Re: DTD Parsing

2010-11-10 Thread Lawrence D'Oliveiro
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

Re: DTD Parsing

2010-11-10 Thread Lawrence D'Oliveiro
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

Re: Questions: While And List Comprehension

2010-11-10 Thread Steve Holden
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

Re: Is Eval *always* Evil?

2010-11-10 Thread Lawrence D'Oliveiro
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

Re: Silly newbie question - Caret character (^)

2010-11-10 Thread Lawrence D'Oliveiro
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

Re: Is Eval *always* Evil?

2010-11-10 Thread Robert Kern
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

Re: Is Eval *always* Evil?

2010-11-10 Thread Robert Kern
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

Re: Questions: While And List Comprehension

2010-11-10 Thread Chris Rebert
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'

Re: Questions: While And List Comprehension

2010-11-10 Thread MRAB
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

Re: Looping through files in a directory

2010-11-10 Thread Tim Chase
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

Re: How to test if a module exists?

2010-11-10 Thread Tim Chase
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

Re: Questions: While And List Comprehension

2010-11-10 Thread alex23
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

Re: Commercial or Famous Applicattions.?

2010-11-10 Thread alex23
Martin Gregorie wrote: > Now, if ESR had fixed fetchmail [...] Did you try submitting patches? -- http://mail.python.org/mailman/listinfo/python-list

Re: Questions: While And List Comprehension

2010-11-10 Thread Steve Holden
On 11/10/2010 6:01 PM, James Mills wrote: > On Wed, Nov 10, 2010 at 10:36 PM, Felipe Vinturini > wrote: >> 1. Is there a way to limit the number of times a list comprehension will >> execute? E.g. I want to read from input only 5 values, so I would like >> something like (the values between # # ar

Re: Looping through files in a directory

2010-11-10 Thread Emile van Sebille
On 11/10/2010 2:46 PM Matty Sarro said... 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. An

Re: Looping through files in a directory

2010-11-10 Thread Chris Rebert
On Wed, Nov 10, 2010 at 2: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 few > thousand times from

Re: Questions: While And List Comprehension

2010-11-10 Thread James Mills
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 stream (sys.stdin): #!/usr/bin/env pyt

Re: Am I The Only One Who Keeps Reading “Numpy ” as “Numpty”?

2010-11-10 Thread Arnaud Delobelle
rantingrick writes: >[...] it's "Num-pee" for me. If the "py" is appended i use "x-pee" and >if it is pre i use "pie- x". So pypy is "pie-pee", not "pie-pie" or "pee-pee". With that edifying thought, I'm off to bed. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: How to test if a module exists?

2010-11-10 Thread Steve Holden
On 11/10/2010 4: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 away. I'

Re: Looping through files in a directory

2010-11-10 Thread Steve Holden
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 few > thousand times from a bash scri

Re: Looping through files in a directory

2010-11-10 Thread James Mills
On Thu, Nov 11, 2010 at 8:46 AM, 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

Re: Enumeration of strings and export of the constants

2010-11-10 Thread Ian
On Nov 10, 6:12 am, lnenov wrote: > Is there a better and more common way to do this? from itertools import count, izip class APINamespace(object): def __init__(self): self._named_values = [] def enumerate(self, names, start=0, step=1): self._named_values.extend(izip(na

Re: DTD Parsing

2010-11-10 Thread Christian Heimes
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 Shibboleth XML configs popping up. -- http:

Re: Is Eval *always* Evil?

2010-11-10 Thread Christian Heimes
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.tag for y in x.xpath("//houses/*") ]', >

Re: Development Vs Release

2010-11-10 Thread Lawrence D'Oliveiro
In message <201011100749474192-nom...@thisaddresscom>, Sven wrote: > I don't like the idea of flags inside the code as they can often get > missed when developers release their code, ending up with released > versions that import modules from the developer's working directory. I have used a flag,

Re: Questions: While And List Comprehension

2010-11-10 Thread James Mills
On Wed, Nov 10, 2010 at 10:36 PM, Felipe Vinturini wrote: > 1. Is there a way to limit the number of times a list comprehension will > execute? E.g. I want to read from input only 5 values, so I would like > something like (the values between # # are what I want): > ===

Re: Curses Programming

2010-11-10 Thread James Mills
On Thu, Nov 11, 2010 at 12:42 AM, alexander wrote: > Could any give a hand? Assignment ? Homework ? cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list

Re: Questions: While And List Comprehension

2010-11-10 Thread Emile van Sebille
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 want to read from input only 5 values, so I

Re: DTD Parsing

2010-11-10 Thread Stefan Behnel
Felipe Bastos Nunes, 10.11.2010 13:34: Does any, libxml2 or lxml, collect children like jdom does in java? List children = myRoot.getChildren(); Bah, that's *so* Java. ;) ElementTree and lxml.etree do it like this: children = list(myRoot) lxml also supports XPath and lots of other

Looping through files in a directory

2010-11-10 Thread Matty Sarro
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 input or pointers to functions that'd help

Re: Is Eval *always* Evil?

2010-11-10 Thread Hrvoje Niksic
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. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to test if a module exists?

2010-11-10 Thread Robert Kern
On 11/10/10 2:27 PM, Robert Kern wrote: On 11/10/10 3: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

Re: How to read the Python tutorial?

2010-11-10 Thread Ian
On Nov 10, 8:13 am, Zeynel wrote: > But when I try > > datetime.datetime.mDATE.toordinal()) > > I get AttributeError. Others have already explained why "mDATE.seconds" does not work, but I wanted to touch on this as well. The above fails because "mDATE" is not an attribute of the "datetime.datet

Embedded python issue with gtk

2010-11-10 Thread Oliver Marks
I have already emailed about this issue, but have still not got any where. I have reduced the plugin down to its bare minimum it simple loads the the python interpreter and imports gtk library. If i do this outside the embedded python it imports and i can use the gtk library, so why does it not w

Re: ANN: PyQt v4.8.1 Released

2010-11-10 Thread Hans-Peter Jansen
Am Monday 08 November 2010 02:26:51 schrieb Robert Kern: > On 2010-11-07 18:53 , Lawrence D'Oliveiro wrote: > > In message, Robert > > Kern > > > > wrote: > >> Everyone here knew exactly what he meant. > > > > But if you don’t banana the right tomato, everybody could be grapefruit, > > right? > > >

Re: Silly newbie question - Caret character (^)

2010-11-10 Thread Seebs
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. -s -- Copyright 2010, all wrongs reversed. Peter Seebach /

Re: multiple discontinued ranges

2010-11-10 Thread Paul Rubin
xoff writes: > I am curious, why wouldn't you advise something like this: > for i in chain(range(3,7) + range(17,23)): First of all, the outer chain does nothing. Second, concatenating the two lists creates a new list, consuming storage and taking time copying all the elements. Third, if there

Re: Enumeration of strings and export of the constants

2010-11-10 Thread Emile van Sebille
On 11/10/2010 5:12 AM lnenov said... Hi, I need to enumerate a couple hundred strings to constants and export them to another module(s) globals. Do they really need to be globals? Why not a constants in an object/container that would neither pollute the global namespace nor risk being shado

Re: Curses Programming

2010-11-10 Thread Chris Rebert
On Wed, Nov 10, 2010 at 6:42 AM, alexander wrote: > Subject: Curses Programming This has nothing whatsoever to do with the (n)curses library or even console programming. Lying in your subject line does not help gain you goodwill. > Hi, all > >     Here is the test. Plz help. If you want ho

Re: How to read the Python tutorial?

2010-11-10 Thread Terry Reedy
On 11/10/2010 10:13 AM, Zeynel wrote: For instance, when the tutorial has http://docs.python.org/release/2.6/library/datetime.html class datetime.datetime A combination of a date and a time. Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo. Note 'second' singular, a

Re: How to test if a module exists?

2010-11-10 Thread Ethan Furman
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 away. I'm assuming this was a momentary la

Re: multiple discontinued ranges

2010-11-10 Thread MRAB
On 10/11/2010 17:34, xoff wrote: On 10 nov, 18:15, Paul Rubin wrote: you could use itertools.chain: from itertools import chain for i in chain(range(3,7), range(17,23)): ... I'm assuming you're using python 3. In python 2 each of those ranges expands immediately to a list, so on

Re: How to read the Python tutorial?

2010-11-10 Thread MRAB
On 10/11/2010 15:13, Zeynel wrote: For instance, when the tutorial has http://docs.python.org/release/2.6/library/datetime.html class datetime.datetime A combination of a date and a time. Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo. What does this mean? How do I

Re: Deditor 0.2.2

2010-11-10 Thread TheSeeker
On Nov 10, 7:51 am, Kruptein wrote: > On Nov 10, 12:49 pm, TheSeeker wrote: > > > > > > > > > > > On Nov 9, 10:04 am, Kruptein wrote: > > > > On Nov 8, 3:01 pm, Jean-Michel Pichavant > > > wrote: > > > > > TheSeeker wrote: > > > > > On Nov 6, 7:06 am, Kruptein wrote: > > > > > >> Hey, > > > >

Re: Feed subscription IM bot

2010-11-10 Thread Emile van Sebille
On 11/10/2010 6:49 AM alexander said... Hi, Can anyone help on this? / Probably most of us, but as it's obviously homework, and expected to take you 1-2 hours for the level class you're taking, and that it's now six hours later, why not post where you're at and we can help you wrap

Re: Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-10 Thread macm
... and this works! >>> def intersect(s1, s2): ... d = {} ... e = {} ... r1 = filter(s1.has_key, s2.keys()) ... for x in r1: ... d[x]= filter(lambda z:z in s1[x][0],s2[x][0]) ... if len(d[x]) > 0: ... e[x] = d[x] ... return e ... >>> intersect(dict1,

Re: DTD Parsing

2010-11-10 Thread Ian
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 will take > me lo

Re: multiple discontinued ranges

2010-11-10 Thread Emile van Sebille
On 11/10/2010 9:34 AM xoff said... On 10 nov, 18:15, Paul Rubin wrote: potentially lots of storage (you should use xrange instead). On the other hand you could just concatenate the lists with +, but I wouldn't advise that. I am curious, why wouldn't you advise something like this: for i in c

Re: How to read the Python tutorial?

2010-11-10 Thread Emile van Sebille
On 11/10/2010 8:19 AM rantingrick said... I would start at the loop and figure out what is going on from there with some print statements and the functions i showed you. Debugging is a large part of any programming project. We all do it everyday. So the sooner you learn the better. If you have a

Re: ANN: PyGUI 2.3

2010-11-10 Thread Bill Janssen
Gregory Ewing wrote: > Daniel Fetchinson wrote: > > > Any reason your project is not easy_installable? > > Mainly because I'm not a setuptools user and haven't been > motivated to learn how to do this so far. Applause!! Bill -- http://mail.python.org/mailman/listinfo/python-list

Questions: While And List Comprehension

2010-11-10 Thread Felipe Vinturini
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 want to read from input only 5 values, so I would like something like (the values between # #

Re: How to test if a module exists?

2010-11-10 Thread Robert Kern
On 11/10/10 3: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 away. I'm assuming this

Is Eval *always* Evil?

2010-11-10 Thread Simon Mullis
Hi All, I'm writing a Django App to webify a Python script I wrote that parses some big XML docs and summarizes certain data contained within. This app will be used by a closed group of people, all with their own login credentials to the system (backed off to the corp SSO system). I've already got

Re: Feed subscription IM bot

2010-11-10 Thread Chris Rebert
On Wed, Nov 10, 2010 at 6:49 AM, alexander wrote: > Hi, > >   Can anyone help on this? http://stackoverflow.com/questions/1901828/best-python-xmpp-jabber-client-library http://www.djangoproject.com/ Come back when you have a much less nebulous question. And try googling first next time. Regards

Re: http error 301 for urlopen

2010-11-10 Thread Hans-Peter Jansen
On Tuesday 09 November 2010, 03:10:24 Lawrence D'Oliveiro wrote: > In message <4cd7987e$0$1674$742ec...@news.sonic.net>, John Nagle wrote: > >It's the New York Times' paywall. They're trying to set a > > cookie, and will redirect the URL until you store and return the > > cookie. > > And if t

Re: A matter of queues, tasks and multiprocessing

2010-11-10 Thread danmcle...@yahoo.com
If you are using Python 2.6 or greater, look into the multiprocessing module. It may contain 90% of what you need. -- http://mail.python.org/mailman/listinfo/python-list

Re: DTD Parsing

2010-11-10 Thread Felipe Bastos Nunes
I'll look at the options. But anyway, only to give an example of the configs I told, the ShoX project (at sourceforge.net) has xml as config files. I'm not talking about common users to edit the xmls, it's about the developer edit them :-) I'm working in a python wireless sensor network simulator,

Re: Allowing comments after the line continuation backslash

2010-11-10 Thread Robert Kern
On 11/10/10 12:26 AM, Lawrence D'Oliveiro wrote: In message, Robert Kern wrote: For me, putting the brackets on their own lines (and using a trailing comma) has little to do with increasing readability. It's for making editing easier. Keeping all of the items consistent means that in order to a

Re: Class extension confusion :(

2010-11-10 Thread Teenan
If memory serves, the following should work fine, as long as your happy for these vars to have the same value for all instances of the RequestHandler (static) MyHandler = PlainAJAXRequestHandler MyHandler.paths = my_paths_var webServer = HTTPServer( server_address, MyHandler) An alternative I've

Re: Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-10 Thread macm
Hi Folks I am studing yet (with fever, grasp and headache). I know I can do better, but first I should learn more about "dictionary comprehension syntax" in python 2.65 >>> dict1 = {'ab':[[1,2,3,'d3','d4',5],12],'ac':[[1,3,'78a','79b'],54],'ad': >>> [[56,57,58,59],34], 'ax': [[56,57,58,59],34]

Enumeration of strings and export of the constants

2010-11-10 Thread lnenov
Hi, I need to enumerate a couple hundred strings to constants and export them to another module(s) globals. In the mean time I want to keep my module's namespace as clear as I can and I don't want to use "import *" later. Here is the code I intend to use: test.py 1 class Apinamespace()

Re: An easier way to do this? (spoiler if you're using pyschools for fun)

2010-11-10 Thread Matteo Landi
I agree with Peter: * iterate over the list directly * use %10 instead of string conversion + slice (*) use genexps Good luck, Matteo On Tue, Nov 9, 2010 at 8:18 PM, Terry Reedy wrote: > On 11/9/2010 2:00 PM, Matty Sarro wrote: > >> I'm working on one of the puzzles on pyschools.com >>

multiple discontinued ranges

2010-11-10 Thread xoff
I was wondering what the best method was in Python programming for 2 discontinued ranges. e.g. I want to use the range 3 to 7 and 17 to 23. Am I obliged to use 2 for loops defining the 2 ranges like this: for i in range (3,7): do bla for i in range (7,17): do bla or is there a more clever way t

How to read the Python tutorial?

2010-11-10 Thread Zeynel
For instance, when the tutorial has http://docs.python.org/release/2.6/library/datetime.html class datetime.datetime A combination of a date and a time. Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo. What does this mean? How do I use it? For instance, I have a Date

Re: multiple discontinued ranges

2010-11-10 Thread Paul Rudin
xoff writes: > I was wondering what the best method was in Python programming for 2 > discontinued ranges. e.g. I want to use the range 3 to 7 and 17 to 23. > Am I obliged to use 2 for loops defining the 2 ranges like this: > > for i in range (3,7): > do bla > for i in range (7,17): > do bla >

Re: How to test if a module exists?

2010-11-10 Thread Mark Wooding
Lawrence D'Oliveiro writes: > 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 judgement, for which I expect an apology. > Otherwise, it becomes grounds for an

A matter of queues, tasks and multiprocessing

2010-11-10 Thread Emanuele D'Arrigo
Greetings everybody, I've tried to come up with this message for a couple of weeks now and it doesn't look like I'm getting any clearer in my thoughts so I decided that it's probably best to take the plunge and ask you guys to kindly throw me a rope... What I'm trying to come up with is some kind

Re: How to read the Python tutorial?

2010-11-10 Thread rantingrick
On Nov 10, 10:05 am, Zeynel wrote: > AttributeError: 'datetime.datetime' object has no attribute 'seconds' First of all put some scaffolding in this code. What is scaffolding. Basically some debug print statements so you can follow the trail of errors. You need to learn how to debug code and be

Re: Deditor 0.2.2

2010-11-10 Thread TheSeeker
On Nov 9, 10:04 am, Kruptein wrote: > On Nov 8, 3:01 pm, Jean-Michel Pichavant > wrote: > > > > > > > > > > > TheSeeker wrote: > > > On Nov 6, 7:06 am, Kruptein wrote: > > > >> Hey, > > > >> I released version 0.2.2 of my pythonic text-editor  Deditor. > > >> It adds the use of projects, a proje

Re: Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-10 Thread Paul Rudin
Lawrence D'Oliveiro writes: > In message , Terry Reedy > wrote: > >> To echo John Nagle's point, if you want non-masochist volunteers to read >> your code, write something readable like: >> >> dict1 = {'ab': [[1,2,3,'d3','d4',5], 12], >> 'ac': [[1,3,'78a','79b'], 54], >> 'ad

Re: Commercial or Famous Applicattions.?

2010-11-10 Thread Martin Gregorie
On Wed, 10 Nov 2010 17:01:05 +1300, Lawrence D'Oliveiro wrote: > In message , Martin Gregorie wrote: > >> ...and don't forget getmail, a better behaved replacement for >> fetchmail. > > I was just looking this up in the Getmail FAQ, since I didn’t know about > the issues with Fetchmail. > FWIW

Re: Allowing comments after the line continuation backslash

2010-11-10 Thread Mark Wooding
Lawrence D'Oliveiro writes: > In message <878w12kt5x.fsf@metalzone.distorted.org.uk>, Mark Wooding > wrote: > > 2. The MainWindow class only has the `Window' attribute described in > > its definition. Apparently there are other attributes as well (the > > ColorMumbleList family

Re: Am I The Only One Who Keeps Reading ?Numpy? as ?Numpty??

2010-11-10 Thread Grant Edwards
On 2010-11-10, Mark Wooding wrote: > Lou Pecora writes: >> Bigger question: How do you pronouce it? > > Rhymes with `grumpy'. Num-Pie -- Grant Edwards grant.b.edwardsYow! Boys, you have ALL at been selected to LEAVE th'

Re: Am I The Only One Who Keeps Reading ?Numpy? as ?Numpty??

2010-11-10 Thread Sven
On 2010-11-10 01:53:58 -0500, Lawrence D'Oliveiro said: Sorry... no. -- ./Sven -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-10 Thread Lawrence D'Oliveiro
In message , Terry Reedy wrote: > To echo John Nagle's point, if you want non-masochist volunteers to read > your code, write something readable like: > > dict1 = {'ab': [[1,2,3,'d3','d4',5], 12], > 'ac': [[1,3,'78a','79b'], 54], > 'ad': [[56,57,58,59], 34], > 'ax':

Feed subscription IM bot

2010-11-10 Thread alexander
Hi, Can anyone help on this? / / The project should either be hosted online and usable from there, or can be run locally. Complete ource code should be delivered along with

Re: multiple discontinued ranges

2010-11-10 Thread Mel
xoff wrote: > I was wondering what the best method was in Python programming for 2 > discontinued ranges. e.g. I want to use the range 3 to 7 and 17 to 23. > Am I obliged to use 2 for loops defining the 2 ranges like this: > > for i in range (3,7): > do bla > for i in range (7,17): > do bla >

  1   2   >