Re: Beginner: Portable Python, BeautifulSoup & ScrapeNFeed

2009-04-17 Thread Brian
Was this code a complete waste of my time? On Wed, Apr 15, 2009 at 1:09 AM, Brian wrote: > On Ubuntu: > > sudo apt-get install python-pyrss2gen python-beautifulsoup # download > ScrapeNFeed > > Python: > Not sure what's wrong with this but it's most of the code you'll need: > --- > from

Re: question about xrange performance

2009-04-17 Thread bearophileHUGS
Paul McGuire: >xrange is not really intended for "in" testing,< Let's add the semantic of a good and fast "in" to xrange (and to the range of Python3). It hurts no one, allows for a natural idiom (especially when you have a stride you don't want to re-invent the logic of skipping absent numbers),

Re: Domain Driven Design and Python

2009-04-17 Thread Terry Reedy
José María wrote: DDD is more or less a methodology. I've used it with C# and I like it very much. The objetive of DDD is to create software that mirror the domain of the problem, you isolate this domain from the technical "problems" (persistence, services,GUI). I presume that many Python prog

Re: Overriding methods per-object

2009-04-17 Thread George Sakkis
On Apr 17, 9:22 pm, Pavel Panchekha wrote: > I've got an object which has a method, __nonzero__ > The problem is, that method is attached to that object not that class > > > a = GeneralTypeOfObject() > > a.__nonzero__ = lambda: False > > a.__nonzero__() > > False > > But: > > > bool(a) > > True >

Re: unpythonic use of property()?

2009-04-17 Thread Carl Banks
On Apr 17, 4:00 pm, Scott David Daniels wrote: > Carl Banks wrote: > > On Apr 17, 10:21 am, J Kenneth King wrote: > >> Consider: > > >> code: > >> > > >> class MyInterface(object): > > >>     def __get_id(self): > >>        

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread norseman
Steven D'Aprano wrote: On Fri, 17 Apr 2009 14:00:18 -0700, Mensanator wrote: ...(snip) Pascal has GOTOs. People rarely used them, because even in the 1970s and 80s they knew that unstructured gotos to arbitrary places was a terrible idea. Even in primarily assembly only days that was true

Re: Domain Driven Design and Python

2009-04-17 Thread Kay Schluehr
On 16 Apr., 19:44, José María wrote: > Hi, > > I've been searching for information about the application of DDD > principles in > Python and I did'nt found anything! > Is DDD obvious in Python or is DDD inherent to static languages like > Java or C#? If you couldn't find anything I conclude that

Re: Condition.wait(0.5) doesn't respect it's timeout

2009-04-17 Thread Gabriel Genellina
En Fri, 17 Apr 2009 22:20:11 -0300, escribió: I have a problem with Condition.wait(), it doesn't return after the given timeout. The thing is that if I try to create a simple program, it works as expected, but in the actual code, the timeout is not respected (albeit the notify()s work as expect

Re: Something weird about re.finditer()

2009-04-17 Thread Aaron Brady
On Apr 17, 9:37 pm, Steven D'Aprano wrote: > On Sat, 18 Apr 2009 12:37:09 +1200, Lawrence D'Oliveiro wrote: > > In message , > > Steven D'Aprano wrote: > > >> BTW, testing for None with == is not recommended, because one day > >> somebody might pass your function some strange object that compares

Variables vs attributes [was Re: Inheriting dictionary attributes and manipulate them in subclasses]

2009-04-17 Thread Steven D'Aprano
On Fri, 17 Apr 2009 17:48:55 +0200, Diez B. Roggisch wrote: > No, because you are creating *classvariables* when declaring things like > this: ... > OTOH, when assigning to an instance, this will create an > *instance*-variable. Which is what If an integer variable is an integer, and a string va

Re: binary file compare...

2009-04-17 Thread Steven D'Aprano
On Fri, 17 Apr 2009 11:19:31 -0700, Adam Olsen wrote: > Actually, *cryptographic* hashes handle that just fine. Even for files > with just a 1 bit change the output is totally different. This is known > as the Avalanche Effect. Otherwise they'd be vulnerable to attacks. > > Which isn't to say

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Mensanator
On Apr 17, 9:43 pm, Steven D'Aprano wrote: > On Fri, 17 Apr 2009 14:00:18 -0700, Mensanator wrote: > > On Apr 17, 3:37 pm, baykus wrote: > >> Hi > > >> I am looking for one of those experimental languages that might be > >> combination of python+basic. Now thta sounds weird and awkward I know. >

Re: question about xrange performance

2009-04-17 Thread Steven D'Aprano
On Fri, 17 Apr 2009 13:58:54 -0700, ~flow wrote: >> One might wonder why you are even writing code to test for existence >> "in" a range list, when "blee <= blah < bloo" is obviously going to >> outperform this kind of code. >> -- Paul > > the reason is simply the idiomacy and convenience. i use

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Steven D'Aprano
On Fri, 17 Apr 2009 14:00:18 -0700, Mensanator wrote: > On Apr 17, 3:37 pm, baykus wrote: >> Hi >> >> I am looking for one of those experimental languages that might be >> combination of python+basic. Now thta sounds weird and awkward I know. > > That's a clue you won't find anyone seriously con

Re: Overriding methods per-object

2009-04-17 Thread Steven D'Aprano
On Fri, 17 Apr 2009 18:22:49 -0700, Pavel Panchekha wrote: > I've got an object which has a method, __nonzero__ The problem is, that > method is attached to that object not that class > >> a = GeneralTypeOfObject() >> a.__nonzero__ = lambda: False >> a.__nonzero__() > False > > But: > >> bool(a

Re: Python Goes Mercurial

2009-04-17 Thread Lawrence D'Oliveiro
Python and Git should get along great. -- http://mail.python.org/mailman/listinfo/python-list

Re: Something weird about re.finditer()

2009-04-17 Thread Steven D'Aprano
On Sat, 18 Apr 2009 12:37:09 +1200, Lawrence D'Oliveiro wrote: > In message , > Steven D'Aprano wrote: > >> BTW, testing for None with == is not recommended, because one day >> somebody might pass your function some strange object that compares >> equal to None. > > Presumably if it compares equ

Re: Overriding methods per-object

2009-04-17 Thread Aaron Brady
On Apr 17, 9:28 pm, Pavel Panchekha wrote: > > The docs don't say you can do that: > > Thanks, hadn't noticed that. > > > Should you be able to? > > I'd say so. In my case, I need a class that can encapsulate any > object, add a few methods to it, and spit something back that works > just like the

Re: Overriding methods per-object

2009-04-17 Thread Pavel Panchekha
> The docs don't say you can do that: Thanks, hadn't noticed that. > Should you be able to? I'd say so. In my case, I need a class that can encapsulate any object, add a few methods to it, and spit something back that works just like the object, but also has those extra methods. I can't just add

Re: Puzzled about this regex

2009-04-17 Thread Chris Rebert
On Fri, Apr 17, 2009 at 7:17 PM, Jean-Claude Neveu wrote: > Hello, > > I wonder if someone could tell me where I am going wrong with my regular > expression, please. My regex only matches the text I'm looking for (a number > followed by a distance unit) when it appears at the beginning of the stri

Puzzled about this regex

2009-04-17 Thread Jean-Claude Neveu
Hello, I wonder if someone could tell me where I am going wrong with my regular expression, please. My regex only matches the text I'm looking for (a number followed by a distance unit) when it appears at the beginning of the string. But I am not using the ^ character (which would indicate th

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-17 Thread Aaron Brady
On Apr 17, 3:59 pm, Dale Roberts wrote: > I've started using generators for some "real" work (love them!), and I > need to use send() to send values back into the yield inside the > generator. When I want to use the generator, though, I have to > essentially duplicate the machinery of a "for" loop

Re: large db question about no joins

2009-04-17 Thread Aaron Brady
On Apr 17, 3:16 pm, "Martin P. Hellwig" wrote: > Daniel Fetchinson wrote: > > > > > > > In an relational database setting you would have a table for artists, > > a table for cd's and a table for songs and a table for comments where > > people can comment on songs. All of this with obvious foreign

Re: Overriding methods per-object

2009-04-17 Thread Aaron Brady
On Apr 17, 8:22 pm, Pavel Panchekha wrote: > I've got an object which has a method, __nonzero__ > The problem is, that method is attached to that object not that class > > > a = GeneralTypeOfObject() > > a.__nonzero__ = lambda: False > > a.__nonzero__() > > False > > But: > > > bool(a) > > True >

Re: Python and XML Help

2009-04-17 Thread ookrin
On Apr 15, 9:43 am, Scott David Daniels wrote: > ookrin wrote: > > I am still learning. And it's not that I won't take the advice > > for using ElementTree, I just currently don't know anything about it. > > I just didn't want to say, "I have no idea what you're talking about!" > > to Scott c

Re: Overriding methods per-object

2009-04-17 Thread Chris Rebert
On Fri, Apr 17, 2009 at 6:22 PM, Pavel Panchekha wrote: > I've got an object which has a method, __nonzero__ > The problem is, that method is attached to that object not that class > >> a = GeneralTypeOfObject() >> a.__nonzero__ = lambda: False >> a.__nonzero__() > False > > But: > >> bool(a) > Tr

Re: Man Bites Python

2009-04-17 Thread Aaron Brady
On Apr 17, 7:03 pm, "AD." wrote: > On Apr 17, 11:11 pm, Aaron Brady wrote: > > > Man bites python. > > Python bites dog. > > Dog bites man. > > or just: > > man,python bites python,man > > No need for the temporary value in Python. Is Python a mutable type? Just don't pass it by reference. -- ht

Overriding methods per-object

2009-04-17 Thread Pavel Panchekha
I've got an object which has a method, __nonzero__ The problem is, that method is attached to that object not that class > a = GeneralTypeOfObject() > a.__nonzero__ = lambda: False > a.__nonzero__() False But: > bool(a) True What to do? -- http://mail.python.org/mailman/listinfo/python-list

Condition.wait(0.5) doesn't respect it's timeout

2009-04-17 Thread stephane . bisinger
Hi all, I have a problem with Condition.wait(), it doesn't return after the given timeout. The thing is that if I try to create a simple program, it works as expected, but in the actual code, the timeout is not respected (albeit the notify()s work as expected). You can find the code I am talking ab

Are there any python modules available to extract form field names and form data from a non-flatten pdf file?

2009-04-17 Thread monogeo
I tried pyPdf, it doesn't extract form field names and form data from a non-flatten pdf file, thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: regex alternation problem

2009-04-17 Thread Jesse Aldridge
On Apr 17, 5:30 pm, Paul McGuire wrote: > On Apr 17, 5:28 pm, Paul McGuire wrote:> -- Paul > > > Your find pattern includes (and consumes) a leading AND trailing space > > around each word.  In the first string "I am an american", there is a > > leading and trailing space around "am", but the tra

Re: Something weird about re.finditer()

2009-04-17 Thread Lawrence D'Oliveiro
In message , Steven D'Aprano wrote: > BTW, testing for None with == is not recommended, because one day > somebody might pass your function some strange object that compares equal > to None. Presumably if it compares equal to None, that is by design, precisely so it would work in this way. --

Re: [OT] large db question about no joins

2009-04-17 Thread Daniel Fetchinson
>> In an relational database setting you would have a table for artists, >> a table for cd's and a table for songs and a table for comments where >> people can comment on songs. All of this with obvious foreign keys. >> Now you want to display on your website the total number of cd's, the >> total

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread norseman
baykus wrote: Hi I am looking for one of those experimental languages that might be combination of python+basic. Now thta sounds weird and awkward I know. The reason I am asking is that I always liked how I could reference- call certain line number back in the days. It would be interesting to ge

Re: binary file compare...

2009-04-17 Thread Lawrence D'Oliveiro
In message , Nigel Rantor wrote: > Adam Olsen wrote: > >> The chance of *accidentally* producing a collision, although >> technically possible, is so extraordinarily rare that it's completely >> overshadowed by the risk of a hardware or software failure producing >> an incorrect result. > > Not

Re: Registering Cron using CronTab

2009-04-17 Thread Lawrence D'Oliveiro
In message , Philip Semanchuk wrote: > > On Apr 17, 2009, at 9:51 AM, gurcharan.sa...@gmail.com wrote: > >> I'm stuck with the issue - if we execute the code from Apache the >> crontab is not getting updated, while it get updated if we run it from >> Django in-built webserver. > > Sure sounds

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Martin P. Hellwig
Michael Torrie wrote: Aahz wrote: Why do you want to do that? Before you answer, make sure to read this: http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html Somebody better tell the Linux kernel developers about that! They apparently haven't read that yet.

Re: Man Bites Python

2009-04-17 Thread AD.
On Apr 17, 11:11 pm, Aaron Brady wrote: > Man bites python. > Python bites dog. > Dog bites man. or just: man,python bites python,man No need for the temporary value in Python. -- Cheers Anton -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Tim Rowe
2009/4/17 Michael Torrie : > Spaghetti code can be written in *any* language. I challenge you to write spahgetti code in SPARK! -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Mensanator
On Apr 17, 5:02 pm, Michael Torrie wrote: > Mensanator wrote: > > I once translated a BASIC program to Pascal (hint: no goto allowed). > > The original code had GOSUBs that never executed a REURN because > > the programmer jumped away to line numbers on a whim. Biggest piece > > of crap I ever had

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Scott David Daniels
Michael Torrie wrote: baykus wrote: I am looking for one of those experimental languages that might be combination of python+basic. Now thta sounds weird and awkward I know. The reason I am asking is that I always liked how I could reference- call certain line number back in the days. It would b

RE: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Leguia, Tony
>Somebody better tell the Linux kernel developers about that! They >apparently haven't read that yet. Better tell CPU makers too. In >assembly it's all gotos. There a very big difference between high level programming, and assembly programming. Python is a high level language. I shouldn't ha

Re: [Python-Dev] RELEASED Python 2.6.2

2009-04-17 Thread Ned Deily
In article , "Russell E. Owen" wrote: > In article , > Ned Deily wrote: > > In article , > > Russell Owen wrote: > > > I installed the Mac binary on my Intel 10.5.6 system and it works, > > > except it still uses Apple's system Tcl/Tk 8.4.7 instead of my > > > ActiveState 8.4.19 (which is

Re: QT , Wxwidgets are not just UI framework ?

2009-04-17 Thread Дамјан Георгиевски
>> However, mostly people agree that Qt is the most powerful, but often >> was debunked because of it's licensing. This has changed to the much >> more liberal LGPL for Qt4.5. >> >> Now it might be though that you'd still need to buy a license from >> Phil Thompson for his excellent PyQt-wrapping -

http://wwwx.cs.unc.edu/~gb/wp/blog/2007/02/04/python-opencv-wrapper-using-ctypes/

2009-04-17 Thread r-w
http://wwwx.cs.unc.edu/~gb/wp/blog/2007/02/04/python-opencv-wrapper-using-ctypes/ -- http://mail.python.org/mailman/listinfo/python-list

Re: unpythonic use of property()?

2009-04-17 Thread Scott David Daniels
Carl Banks wrote: On Apr 17, 10:21 am, J Kenneth King wrote: Consider: code: class MyInterface(object): def __get_id(self): return self.__id id = property(fget=__get_id) def __init__(self, id, foo)

Re: [Python-Dev] RELEASED Python 2.6.2

2009-04-17 Thread Russell E. Owen
In article , Ned Deily wrote: > In article , > Russell Owen wrote: > > I installed the Mac binary on my Intel 10.5.6 system and it works, > > except it still uses Apple's system Tcl/Tk 8.4.7 instead of my > > ActiveState 8.4.19 (which is in /Library/Frameworks where one would > > expect)

Re: regex alternation problem

2009-04-17 Thread Paul McGuire
On Apr 17, 5:28 pm, Paul McGuire wrote: > -- Paul > > Your find pattern includes (and consumes) a leading AND trailing space > around each word.  In the first string "I am an american", there is a > leading and trailing space around "am", but the trailing space for > "am" is the leading space for

Re: Sending directory with files in it via sockets

2009-04-17 Thread MRAB
Ryniek90 wrote: Hi. Last time i've got problem with sending big files, but i've already dealt with it. Now, when i want send directory (with some files in it) i iterate that directory for files in it, and then in while loop open iterated files, read them and send. But something's not working.

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread baykus
On Apr 17, 5:02 pm, Michael Torrie wrote: > Mensanator wrote: > > It's clear that you haven't done anything in BASIC since the 80s. And > probably the original poster hasn't either. So let's just clear the air > here. Michael you are kind of rigtht, I did use basic in early 90s :) Thanks for t

Re: regex alternation problem

2009-04-17 Thread Paul McGuire
On Apr 17, 4:49 pm, Jesse Aldridge wrote: > import re > > s1 = "I am an american" > > s2 = "I am american an " > > for s in [s1, s2]: >     print re.findall(" (am|an) ", s) > > # Results: > # ['am'] > # ['am', 'an'] > > --- > > I want the results to be the same for each string.  What am I doin

Re: Find and replace is appending when run more than once ...

2009-04-17 Thread MRAB
paul.scipi...@aps.com wrote: Hello, I grabbed some sample code from the web and put together this python script which searches all subdirectories for a specific file type, then replaces a string with a new one. Out of curiosity I ran it again. Here's what happens (this also happens for the

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Brian Blais
On Apr 17, 2009, at 16:37 , baykus wrote: Hi I am looking for one of those experimental languages that might be combination of python+basic. Now thta sounds weird and awkward I know. The reason I am asking is that I always liked how I could reference- call certain line number back in the days.

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Michael Torrie
Aahz wrote: > Why do you want to do that? Before you answer, make sure to read this: > http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html Somebody better tell the Linux kernel developers about that! They apparently haven't read that yet. Better tell CPU makers

Re: regex alternation problem

2009-04-17 Thread Tim Chase
s1 = "I am an american" s2 = "I am american an " for s in [s1, s2]: print re.findall(" (am|an) ", s) # Results: # ['am'] # ['am', 'an'] --- I want the results to be the same for each string. What am I doing wrong? In your first case, the regexp is consuming the " am " (four charac

Re: regex alternation problem

2009-04-17 Thread Robert Kern
On 2009-04-17 16:49, Jesse Aldridge wrote: import re s1 = "I am an american" s2 = "I am american an " for s in [s1, s2]: print re.findall(" (am|an) ", s) # Results: # ['am'] # ['am', 'an'] --- I want the results to be the same for each string. What am I doing wrong? findall() fi

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Michael Torrie
Mensanator wrote: > I once translated a BASIC program to Pascal (hint: no goto allowed). > The original code had GOSUBs that never executed a REURN because > the programmer jumped away to line numbers on a whim. Biggest piece > of crap I ever had to misfortune to deal with. It's clear that you hav

Re: regex alternation problem

2009-04-17 Thread Robert Kern
On 2009-04-17 16:57, Eugene Perederey wrote: According to documentation re.findall takes a compiled pattern as a first argument. So try patt = re.compile(r'(am|an)') re.findall(patt, s1) re.findall(patt, s2) No, it will take a string pattern, too. -- Robert Kern "I have come to believe that t

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Michael Torrie
baykus wrote: > I am looking for one of those experimental languages that might be > combination of python+basic. Now thta sounds weird and awkward I know. > The reason I am asking is that I always liked how I could reference- > call certain line number back in the days. It would be interesting to

Re: regex alternation problem

2009-04-17 Thread Eugene Perederey
According to documentation re.findall takes a compiled pattern as a first argument. So try patt = re.compile(r'(am|an)') re.findall(patt, s1) re.findall(patt, s2) 2009/4/18 Jesse Aldridge : > import re > > s1 = "I am an american" > > s2 = "I am american an " > > for s in [s1, s2]: >    print re.fi

regex alternation problem

2009-04-17 Thread Jesse Aldridge
import re s1 = "I am an american" s2 = "I am american an " for s in [s1, s2]: print re.findall(" (am|an) ", s) # Results: # ['am'] # ['am', 'an'] --- I want the results to be the same for each string. What am I doing wrong? -- http://mail.python.org/mailman/listinfo/python-list

Re: question about xrange performance

2009-04-17 Thread MRAB
~flow wrote: One might wonder why you are even writing code to test for existence "in" a range list, when "blee <= blah < bloo" is obviously going to outperform this kind of code. -- Paul the reason is simply the idiomacy and convenience. i use (x)xranges to implement unicode blocks and similar

class variables and class methods

2009-04-17 Thread krishnapostings
I have a class whose job is to serve several other objects, this object is in a module 'M1', let's say it writes logs, no matter who calls it, (once it started writing to a file) it must continue writing to the same file, the file pointer could be a class variable here and there is also no need to

Re: Help improve program for parsing simple rules

2009-04-17 Thread Paul McGuire
On Apr 17, 2:40 pm, prueba...@latinmail.com wrote: > On Apr 17, 11:26 am, Paul McGuire wrote: > > > > > > > On Apr 16, 10:57 am, prueba...@latinmail.com wrote: > > > > Another interesting task for those that are looking for some > > > interesting problem: > > > I inherited some rule system that ch

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Arnaud Delobelle
baykus writes: > Hi > > I am looking for one of those experimental languages that might be > combination of python+basic. Now thta sounds weird and awkward I know. > The reason I am asking is that I always liked how I could reference- > call certain line number back in the days. It would be inter

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread baykus
I guess I did not articulate myself well enough. I was just looking for a toy to play around. I never suggested that Python+Basic would be better than Python and everyone should use it. Python is Python and Basic is Basic. I am not comparing them at all. I understand the merits of Python but that d

Sending directory with files in it via sockets

2009-04-17 Thread Ryniek90
Hi. Last time i've got problem with sending big files, but i've already dealt with it. Now, when i want send directory (with some files in it) i iterate that directory for files in it, and then in while loop open iterated files, read them and send. But something's not working. It iterate's firs

RE: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Leguia, Tony
Though I don't know why you would want to reference lines numbers, I assume it's for goto statements or something similar. With that said please read: 1) http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html I would also like to put forth my opinion, shared by m

Re: cPickle and subclassing lists?

2009-04-17 Thread Carl Banks
On Apr 17, 10:13 am, Reckoner wrote: > I have a large class that is a child of list. I need to pickle it, but > it's not working. For example, I have reduced it to the following: > > class Mylist(list): >     def __init__(self,x=[]): >         list.__init__(self,x) > > and I cannot even get this t

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Mensanator
On Apr 17, 3:37 pm, baykus wrote: > Hi > > I am looking for one of those experimental languages that might be > combination of python+basic. Now thta sounds weird and awkward I know. That's a clue you won't find anyone seriously contemplating such idiocy. > The reason I am asking is that I alway

Re: script question

2009-04-17 Thread python
Peter, > Another eval-free variant: > > [x() for x in vars().values() if hasattr(x, "_included")] > > If you use getattr(x, "_included", False) instead of hasattr() > you can "un-include" functions with ... YES! That's what I was struggling to do with my in-elegant use of eval(), eg. replacing

Find and replace is appending when run more than once ...

2009-04-17 Thread Paul . Scipione
Hello, I grabbed some sample code from the web and put together this python script which searches all subdirectories for a specific file type, then replaces a string with a new one. Out of curiosity I ran it again. Here's what happens (this also happens for the files I am looking to replace O

send() to a generator in a "for" loop with continue(val)??

2009-04-17 Thread Dale Roberts
I've started using generators for some "real" work (love them!), and I need to use send() to send values back into the yield inside the generator. When I want to use the generator, though, I have to essentially duplicate the machinery of a "for" loop, because the "for" loop does not have a mechanis

Re: question about xrange performance

2009-04-17 Thread ~flow
> One might wonder why you are even writing code to test for existence > "in" a range list, when "blee <= blah < bloo" is obviously going to > outperform this kind of code. > -- Paul the reason is simply the idiomacy and convenience. i use (x)xranges to implement unicode blocks and similar things.

Re: cPickle and subclassing lists?

2009-04-17 Thread Reckoner
On Apr 17, 11:16 am, Piet van Oostrum wrote: > > Reckoner (R) wrote: > >R> I have a large class that is a child of list. I need to pickle it, but > >R> it's not working. For example, I have reduced it to the following: > >R> class Mylist(list): > >R> def __init__(self,x=[]): > >R> l

Re: unpythonic use of property()?

2009-04-17 Thread Carl Banks
On Apr 17, 10:21 am, J Kenneth King wrote: > Consider: > > code: > > > class MyInterface(object): > >     def __get_id(self): >         return self.__id > >     id = property(fget=__get_id) > >     def __init__(self, id, foo)

Re: Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread Aahz
In article , baykus wrote: > >I am looking for one of those experimental languages that might be >combination of python+basic. Now thta sounds weird and awkward I know. >The reason I am asking is that I always liked how I could reference- >call certain line number back in the days. It would be in

Re: Pathological regular expression

2009-04-17 Thread franck
> To my mind, this is a bug in the RE engine. Is there any reason to not > treat it as a bug? It's not a bug, it's a feature! ;-) Indeed, in order to handle constructs like (?P=name), RE engines have to use inefficient algorithms. In my opinion, this is not the problem of using a pathological regu

Re: Lambda alternative?

2009-04-17 Thread Hrvoje Niksic
"J. Cliff Dyer" writes: > On Thu, 2009-04-16 at 13:33 +0200, Hrvoje Niksic wrote: >> mousemeat writes: >> >> > Correct me if i am wrong, but i can pickle an object that contains a >> > bound method (it's own bound method). >> >> No, you can't: >> >> >>> import cPickle as p >> >>> p.dumps([])

Is there a programming language that is combination of Python and Basic?

2009-04-17 Thread baykus
Hi I am looking for one of those experimental languages that might be combination of python+basic. Now thta sounds weird and awkward I know. The reason I am asking is that I always liked how I could reference- call certain line number back in the days. It would be interesting to get similar functi

after_cancel?

2009-04-17 Thread W. eWatson
I'm looking a program that I'm not real familiar with that uses an after_cancel method and after_id variable. Are they related to some particular widget and what is there function? Perhaps they are related to a Cancel button on a widget? -- W. eWatson

Re: [OT] large db question about no joins

2009-04-17 Thread Martin P. Hellwig
Daniel Fetchinson wrote: In an relational database setting you would have a table for artists, a table for cd's and a table for songs and a table for comments where people can comment on songs. All of this with obvious foreign keys. Now you want to display on your website the total number of cd'

Re: script question

2009-04-17 Thread Peter Otten
pyt...@bdurham.com wrote: > For completeness, here is the corrected version of my original code for > the archives: > > [ eval(x)() for x in dir() if hasattr( eval(x), '_included') ] Another eval-free variant: [x() for x in vars().values() if hasattr(x, "_included")] If you use getattr(x, "_in

Re: Help improve program for parsing simple rules

2009-04-17 Thread Aaron Brady
On Apr 17, 2:01 pm, Paul McGuire wrote: > On Apr 17, 1:26 pm, Aaron Brady wrote: > > > Hi, not to offend; I don't know your background.   > > Courtesy on Usenet!!!  I'm going to go buy a lottery ticket! > > Not to worry, I'm a big boy.  People have even called my baby ugly, > and I manage to keep

Re: script question

2009-04-17 Thread python
Scott, Thank you for your example - very clean. For completeness, here is the corrected version of my original code for the archives: [ eval(x)() for x in dir() if hasattr( eval(x), '_included') ] Regards, Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: Help improve program for parsing simple rules

2009-04-17 Thread pruebauno
On Apr 17, 11:26 am, Paul McGuire wrote: > On Apr 16, 10:57 am, prueba...@latinmail.com wrote: > > > Another interesting task for those that are looking for some > > interesting problem: > > I inherited some rule system that checks for programmers program > > outputs that to be ported: given some

Re: script question

2009-04-17 Thread Arnaud Delobelle
"D'Arcy J.M. Cain" writes: > On 17 Apr 2009 07:03:18 -0700 > a...@pythoncraft.com (Aahz) wrote: >> Go to all that trouble, you might as well make it easier: >> >> for func in funclist: >> func() > > And if you need the return values: > > retlist = [func() for func in funclist] And if yo

Re: script question

2009-04-17 Thread Scott David Daniels
pyt...@bdurham.com wrote: Scott, Newbie question (and I'm not the OP): What are your thoughts on having your decorator add an attribute to the functions vs. placing the functions in a global variable? def _included(f): f._included = True return f I tried experimenting with this techniq

Re: question about xrange performance

2009-04-17 Thread Paul McGuire
On Apr 17, 1:39 pm, _wolf wrote: > > can it be that a simple diy-class outperforms a python built-in by a > factor of 180? is there something i have done the wrong way? > omissions, oversights? do other people get similar figures? > > cheers I wouldn't say you are outperforming xrange until your

Re: question about xrange performance

2009-04-17 Thread Peter Otten
_wolf wrote: > lately i realized a slow running portion of my application, and a > quick profiling nourished the suspicion that, of all things, calls to > `xrange().__contains__` (`x in b` where `b = xrange(L,H)`) is the > culprit. to avoid any other influences, i wrote this test script with > cla

Re: Help improve program for parsing simple rules

2009-04-17 Thread Paul McGuire
On Apr 17, 1:26 pm, Aaron Brady wrote: > Hi, not to offend; I don't know your background.   Courtesy on Usenet!!! I'm going to go buy a lottery ticket! Not to worry, I'm a big boy. People have even called my baby ugly, and I manage to keep my blood pressure under control. > One thing I like >

Re: Lambda alternative?

2009-04-17 Thread Aaron Brady
On Apr 17, 1:43 pm, "J. Cliff Dyer" wrote: > On Thu, 2009-04-16 at 13:33 +0200, Hrvoje Niksic wrote: > > mousemeat writes: > > > > Correct me if i am wrong, but i can pickle an object that contains a > > > bound method (it's own bound method). > > > No, you can't: > > > >>> import cPickle as p >

Re: question about xrange performance

2009-04-17 Thread MRAB
_wolf wrote: lately i realized a slow running portion of my application, and a quick profiling nourished the suspicion that, of all things, calls to `xrange().__contains__` (`x in b` where `b = xrange(L,H)`) is the culprit. to avoid any other influences, i wrote this test script with class `xxran

Re: [OT] large db question about no joins

2009-04-17 Thread J. Cliff Dyer
On Thu, 2009-04-16 at 14:11 -0700, John Fabiani wrote: > Daniel Fetchinson wrote: > > > Hi folks, I've come across many times the claim that 'joins are bad' > > for large databases because they don't scale > > IMO that's bull... OK. That makes four legs so far > -- > http://mail.python.org

Re: Lambda alternative?

2009-04-17 Thread J. Cliff Dyer
On Thu, 2009-04-16 at 13:33 +0200, Hrvoje Niksic wrote: > mousemeat writes: > > > Correct me if i am wrong, but i can pickle an object that contains a > > bound method (it's own bound method). > > No, you can't: > > >>> import cPickle as p > >>> p.dumps([]) > '(l.' > >>> p.dumps([].append) > Tr

question about xrange performance

2009-04-17 Thread _wolf
lately i realized a slow running portion of my application, and a quick profiling nourished the suspicion that, of all things, calls to `xrange().__contains__` (`x in b` where `b = xrange(L,H)`) is the culprit. to avoid any other influences, i wrote this test script with class `xxrange` being a poo

Re: need to start a new project , can python do all that ?

2009-04-17 Thread Hyuga
On Apr 15, 10:54 am, Deep_Feelings wrote: > On Apr 15, 4:05 pm, Tim Rowe wrote: > > > > > 2009/4/15 Deep_Feelings : > > > > I want to start programming a new program (electronic health care > > > center) in python and before start learning python i wanna make sure > > > that python does have all

Re: binary file compare...

2009-04-17 Thread Adam Olsen
On Apr 17, 9:59 am, SpreadTooThin wrote: > You know this is just insane.  I'd be satisfied with a CRC16 or > something in the situation i'm in. > I have two large files, one local and one remote.  Transferring every > byte across the internet to be sure that the two files are identical > is just n

ANN: ConfigObj 4.6.0 and Validate 1.0.0 released

2009-04-17 Thread Fuzzyman
Finally a fresh release ConfigObj and Validate. * ConfigObj Home page: http://www.voidspace.org.uk/python/configobj.html * Validate Home page: http://www.voidspace.org.uk/python/validate.html **ConfigObj** is a simple to use but powerful Python library for the reading and writing of configuration

Re: binary file compare...

2009-04-17 Thread Adam Olsen
On Apr 17, 9:59 am, norseman wrote: > The more complicated the math the harder it is to keep a higher form of > math from checking (or improperly displacing) a lower one.  Which, of > course, breaks the rules.  Commonly called improper thinking. A number > of math teasers make use of that. Of cou

  1   2   >