Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, George Sakkis <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >> What bothers me a bit about the rejection of PEP 326 is that one of the >> reasons stated is: >> >> http://mail.python.org/pipermail/python-dev/2004-January/042306.html >> >> - it is easily implemented when you

Re: Difference between two dates in seconds

2006-09-28 Thread flupke
Fredrik Lundh schreef: > def get_seconds(td): > ... return td.days * (24*60*60) + td.seconds > ... import dis dis.dis(get_seconds) > 2 0 LOAD_FAST0 (td) > 3 LOAD_ATTR0 (days) > 6 LOAD_CONST 4

Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Michele Simionato
John J. Lee wrote: > ISTM that there's a vast amount of mostly-tacit knowledge about the > way things work, and they way they should work, good practices, design > techniques, rules of thumb, Bad Ideas ;-), etc. etc. that good > programmers do have and bad or inexperienced programmers don't. Yep,

Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread [EMAIL PROTECTED]
Hi, String formatting can be used to converting an integer to its octal or hexadecimal form: >>> a = 199 >>> "%o" % a '307' >>> "%x" % a 'c7' But, can string formatting be used to convert an integer to its binary form ? Thanks in advance. xiaojf -- http://mail.python.org/mailman/listinfo

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, OKB (not okblacke) <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >> To begin with this already fails: >> > for i in xrange(Top): >> ... print i > > What do you expect this to do? Loop forever? Yes that is what I would expect. If someone would ask me to implement

Re: a query on sorting

2006-09-28 Thread Steve Holden
Paul McGuire wrote: > "Steve Holden" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > >>> [x for x in enumerate(a)] > [(0, 9), (1, 4), (2, 3), (3, 5), (4, 2), (5, 6), (6, 7), (7, 1), (8, 2)] > > > Just curious, Steve, but why do this list comprehension when: > > list(enum

Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Michele Simionato
Ben Finney wrote: > I submit that a programmer who knows *only* one programming language > can never be an expert in that language; it is only exposure to > multiple tools and ways of programming that can grow a one-trick pony > into an expert. Well, it all depends on the definition of "expert". P

Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Michele Simionato
Roy Smith wrote: > The problem is, if the complex features are there, people will use them. > On any large project, there will always be some people who revel in using > every obscure feature of a language. That forces everybody else on the > team (and all future members of the team) to know (or l

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread flupke
[EMAIL PROTECTED] schreef: > Hi, > > String formatting can be used to converting an integer to its octal or > hexadecimal form: a = 199 "%o" % a > '307' "%x" % a > 'c7' > > But, can string formatting be used to convert an integer to its binary > form ? > > > Thanks in advance. >

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, Tim Chase <[EMAIL PROTECTED]> wrote: >>> To begin with this already fails: >>> >> for i in xrange(Top): >>> ... print i >> >> What do you expect this to do? Loop forever? > > Perhaps the infinite loop should take half as long as > > >>> for i in xrange(Bottom, Top): prin

Re: QuoteSQL

2006-09-28 Thread Duncan Booth
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > In message <[EMAIL PROTECTED]>, Duncan Booth wrote: >> Deary me. Did you actually test out that bit of code before you >> posted it? > execfile("QuoteSQL.py") EscapeSQLWild(r"\%") > '%' SQLString("%" + EscapeSQLWild(r"\%") + "%")

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 27 Sep 2006 13:37:40 +, Paul McGuire wrote: > >> Here's a little more refined version of my previous post: >> >> class StubbornInt(int): >> def invariantOp(self,other): >> return self >> __add__ = invariantOp >

Re: A critique of cgi.escape

2006-09-28 Thread Duncan Booth
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: >> Also, because Python has a >> conservative policy on backwards incompatible changes, you are protected >> from some wanker going and changing the HTML safe mappings arbitrarily, >> say using numerical entity references instead of >, < and &. > >

Re: XSLT speed comparisons

2006-09-28 Thread Damian
Sorted! I installed msxml4 and then struggled for an hour or so with an encoding error (UnicodeEncodeError: 'ascii' codec etc) which was fixed by altering your code from: return proc.output --> return proc.output.encode('utf-8') The performance of MSXML over 4suite is substantial. 4suite: ht

Re: Difference between two dates in seconds

2006-09-28 Thread Duncan Booth
flupke <[EMAIL PROTECTED]> wrote: > Using 86400 instead of (24*60*60) is faster s/is/was/ upgrade to Python 2.5 -- http://mail.python.org/mailman/listinfo/python-list

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
efrat wrote: > Hello, > > I'm planning to use Python in order to teach a DSA (data structures > and algorithms) course in an academic institute. If you could help out > with the following questions, I'd sure appreciate it: (snip) > 2. Suppose I have some file example.py, and I'd like to incorp

Re: Difference between two dates in seconds

2006-09-28 Thread flupke
Duncan Booth schreef: > flupke <[EMAIL PROTECTED]> wrote: > >> Using 86400 instead of (24*60*60) is faster > > s/is/was/ > > upgrade to Python 2.5 Indeed, i'm still on 2.4. I thought 2.5 might give a different result :) Thanks for the info Benedict -- http://mail.python.org/mailman/listinfo/p

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
Antoon Pardon wrote: > On 2006-09-27, George Sakkis <[EMAIL PROTECTED]> wrote: >> Antoon Pardon wrote: >> >>> What bothers me a bit about the rejection of PEP 326 is that one of the >>> reasons stated is: >>> >>> http://mail.python.org/pipermail/python-dev/2004-January/042306.html >>> >>> - it

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Mirco Wahab
Thus spoke [EMAIL PROTECTED] (on 2006-09-28 09:10): > String formatting can be used to converting an integer to its octal or > hexadecimal form: > >>> a = 199 > >>> "%o" % a > '307' > >>> "%x" % a > 'c7' > > But, can string formatting be used to convert an integer to its binary > form ? I d

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
Antoon Pardon wrote: > On 2006-09-27, OKB (not okblacke) <[EMAIL PROTECTED]> wrote: >> Antoon Pardon wrote: >> >>> To begin with this already fails: >>> >> for i in xrange(Top): >>> ... print i >> >> What do you expect this to do? Loop forever? > > Yes that is what I would expect. Fo

Re: windev vs python SOS

2006-09-28 Thread Bruno Desthuilliers
stéphane bard wrote: > hello, my boss ask me to prefer windev to python. Find another job. (I'm serious. I've 2+ years of pain with Windev, and if your boss is clueless enough to believe all the marketing crap from PCSoft's droids, you really don't want to work for him). > I have to argue > >

Re: windev vs python SOS

2006-09-28 Thread Bruno Desthuilliers
John Henry wrote: > I don't know what windev is A french (highly proprietary) so-called "CASE-Tool" with a so-called "5th generation language" (lol) that is mostly a dumbed-down mix of basic and pascal. It's so bad that it makes you regret VB6. -- bruno desthuilliers python -c "print '@'.join(

Re: does anybody earn a living programming in python?

2006-09-28 Thread Magnus Lycka
Stuart Bishop wrote: > My personal experience is that there is a shortage of good Python > programmers. In Melbourne, Australia for example there is a continual need > for about 2 more - one Python shop there just hires clueful developers and > makes their first task 'learn Python'. We generally ha

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Gabriel Genellina
At Thursday 28/9/2006 05:22, Mirco Wahab wrote: > String formatting can be used to converting an integer to its octal or > hexadecimal form: > >>> a = 199 > >>> "%o" % a > '307' > >>> "%x" % a > 'c7' > > But, can string formatting be used to convert an integer to its binary > form ? a = 19

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-28, Georg Brandl <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> On 2006-09-27, OKB (not okblacke) <[EMAIL PROTECTED]> wrote: >>> Antoon Pardon wrote: >>> To begin with this already fails: >>> for i in xrange(Top): ... print i >>> >>> What do you ex

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-28 Thread Steve Holden
Stuart Bishop wrote: [...] > If you are using a modern PostgreSQL (8.1 for sure, maybe 8.0), this is > better spelt: > > cur.execute("SELECT currval(pg_get_serial_sequence(%s, %s))" % ( > tableid, columnid)) > > (Assuming of course your table name and column name don't contain odd > character

Re: License / Registration key enabled software

2006-09-28 Thread Steve Holden
Ben Finney wrote: > Mike Playle <[EMAIL PROTECTED]> writes: > > >>License keys exist to make it easier for honest users to remain >>honest. > > > What doubletalk. If usage restrictions were in *any* way what end users > wanted, they'd choose software that has it over software that does > not. >

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread sturlamolden
efrat wrote: > 1. What exactly is a Python list? If one writes a[n], then is the > complexity Theta(n)? If this is O(1), then why was the name "list" > chosen? If this is indeed Theta(n), then what alternative should be > used? (array does not seem suited for teaching purposes.) A Python list is

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-28, Georg Brandl <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> On 2006-09-27, George Sakkis <[EMAIL PROTECTED]> wrote: >>> Antoon Pardon wrote: >>> What bothers me a bit about the rejection of PEP 326 is that one of the reasons stated is: http://mail.python.o

Re: Auto color selection PIL

2006-09-28 Thread Leif K-Brooks
Gabriel Genellina wrote: > Try this. It first chooses 0, 1/2, then 1/4, 3/4, then */8... > It's the best I could make if you don't know the number of colors > beforehand. If you *do* know how many colors, your previous response is OK. Um, that's the same thing my second suggestion does: >>> h

Writing 2d array in an ascci file

2006-09-28 Thread [EMAIL PROTECTED]
Hi, I want to write an 2d array in an ascii file using numpy. There's the - tofile / fromfile - function but it doesn't work with nd array. Thanks, CH. -- http://mail.python.org/mailman/listinfo/python-list

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > It is something worth investigating, but I'm not sure it > will suite my purpose. You see I have a table module, > a table is like a list except the base index doesn't need > to be 0. So I could have a table that is indexable from > sys.maxint - 3 to sys.

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
Some of your Lisp translations are subtly off... > Date: 28 Sep 2006 02:49:50 -0700 > From: "sturlamolden" <[EMAIL PROTECTED]> > Subject: Re: Questions on Using Python to Teach Data Structures and > Algorithms > To: python-list@python.org > > If you want to make a chained structure, then pe

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Paul Rubin
Paul Rubin writes: > > sys.maxint - 3 to sys.maxint + 7. I'm not sure tbl[:Top] > > would do what it is supposed to do in those circumstances. > Top = object() > class Table(list): ... Oh wait, I missed the : in your tbl[:Top] example. Yeah, you could hair up Table to

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Mirco Wahab
Thus spoke Gabriel Genellina (on 2006-09-28 11:05): > At Thursday 28/9/2006 05:22, Mirco Wahab wrote: >> > But, can string formatting be used to convert an integer to its binary >> > form ? >> >> a = 199 >> a_bin_str = pack('L', a) > > Notice that the OP was looking for another thing, given

Re: Writing 2d array in an ascci file

2006-09-28 Thread Jeremy Sanders
[EMAIL PROTECTED] wrote: > I want to write an 2d array in an ascii file using numpy. There's the - > tofile / fromfile - function but it doesn't work with nd array. Is this good enough? x = numpy.zeros( (10, 10) ) f = open('out.txt', 'w') print >>f, str(x).replace('[',' ').replace(']', ' ') f.cl

Re: Computer Language Popularity Trend

2006-09-28 Thread Steve Holden
Xah Lee wrote: > Computer Language Popularity Trend > > This page gives a visual report of computer languages's popularity, as > indicated by their traffic level in newsgroups. This is not a > comprehensive or fair survey, but does give some indications of > popularity trends. > > http://xahlee.o

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
Brendon Towle wrote: > Some of your Lisp translations are subtly off... Seems correct to me. Lisp lists are linked lists, not arrays. > >> Date: 28 Sep 2006 02:49:50 -0700 >> From: "sturlamolden" <[EMAIL PROTECTED]> >> Subject: Re: Questions on Using Python to Teach Data Structures and >> Al

Python and Win95B

2006-09-28 Thread Ciar�n � Duibh
I've just installed Python 2.5 under Win95B, and when run it says "The PYTHON25.DLL file is linked to missing export KERNEL32.DLL.GetFileAttributesExA". Does Python 2.5 not run under Win95? If not, is there an earlier version of Python which does? Thanks, Ciarán Ó Duibhín. -- http://mail.

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bryan Olson
efrat wrote: > I'm planning to use Python in order to teach a DSA (data structures > and algorithms) course in an academic institute. If you could help out > with the following questions, I'd sure appreciate it: > 1. What exactly is a Python list? It's almost exactly what the doc says (and exa

Re: does anybody earn a living programming in python?

2006-09-28 Thread rzed
"Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: [...] > Oh dont be so pedantic - countless - without count - probably > just means that nobody has bothered to count them... Without being particularly pedantic: no, it doesn't. It means "too many to count". Though I woul

Re: Starting Win32 Service

2006-09-28 Thread Roger Upole
Tim Golden wrote: ... > Yes, sorry about that, it's a well-known (to me) gotcha. > Basically there's no way I can extract the params from > the COM interface in a way which implies order, so I > can't take them in positionally. (Corrections to this > statement will be gratefully received). > > TJG

RE: Starting Win32 Service

2006-09-28 Thread Tim Golden
| Tim Golden wrote: | ... | > Yes, sorry about that, it's a well-known (to me) gotcha. | > Basically there's no way I can extract the params from | > the COM interface in a way which implies order, so I | > can't take them in positionally. (Corrections to this | > statement will be gratefully recei

Writing python extensions for libburn & libisofs

2006-09-28 Thread mario . danic
Hello, If there is anyone familiar with python C api, and would like to get involved with writing python extensions for above two libs (http://libburn.pykix.org) please contact me. Kind regards, Mario -- http://mail.python.org/mailman/listinfo/python-list

Continuing after error

2006-09-28 Thread Sheldon
Hi, Does anyone know if it is possible to resume the execution of a program after it stops at an error in the code and the error was corrected? Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: Continuing after error

2006-09-28 Thread Georg Brandl
Sheldon wrote: > Hi, > > Does anyone know if it is possible to resume the execution of a program > after it stops at an error in the code and the error was corrected? try: do something except SomeException: correct the error do something else i.e. you handle the error in the except cl

Re: License / Registration key enabled software

2006-09-28 Thread Mike Playle
On Thu, 28 Sep 2006 10:19:37 +1000, Ben Finney wrote: >> For instance a customer might want to buy a license to use your >> software on up to 5 machines at once, but still have the software >> installed on every machine in the company. > > This need is adequately served by not imposing usage restr

Resuming a program's execution after correcting error

2006-09-28 Thread Sheldon
Hi. Does anyone know if one can resume a python script at the error point after the error is corrected? I have a large program that take forever if I have to restart from scratch everytime. The error was the data writing a file so it seemed such a waste if all the data was lost and must be recalcu

Re: License / Registration key enabled software

2006-09-28 Thread Mike Playle
On Wed, 27 Sep 2006 12:21:08 -0500, Robert Kern wrote: > Mike Playle wrote: >> For instance a customer might want to buy a license to >> use your software on up to 5 machines at once, but still >> have the software installed on every machine in the >> company. License systems like FlexLM can work

Re: a query on sorting

2006-09-28 Thread Steve Holden
Paul Rubin wrote: > Gabriel Genellina <[EMAIL PROTECTED]> writes: > >>> >>> sorted((x[1], x[0]) for x in enumerate(a)) >>>[(1, 7), (2, 4), (2, 8), (3, 2), (4, 1), (5, 3), (6, 5), (7, 6), (9, 0)] >> >>Why forcing to use enumerate if it doesn't fit? And a generator won't >>help here since you have

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote: > From: Bruno Desthuilliers <[EMAIL PROTECTED]> > Subject: Re: Questions on Using Python to Teach Data Structures and > Algorithms > To: python-list@python.org > > Brendon Towle wrote: >> Some of your Lisp translations are subtly off... >

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-28, Paul Rubin wrote: > Paul Rubin writes: >> > sys.maxint - 3 to sys.maxint + 7. I'm not sure tbl[:Top] >> > would do what it is supposed to do in those circumstances. > >> Top = object() >> class Table(list): > ... > > Oh wait, I missed the : in your tbl[:To

Re: Extra Newby question - Trying to create md5 File Listing

2006-09-28 Thread Jim
Gabriel and Dennis, than you for all your help. I ended up talking to a friend a work about it and here's what we cam up with. It's very similar to your suggestions so again, thanks. I just need to add a machine name so I can get a md5 log from multiple machines and put it in a database for vers

Re: Resuming a program's execution after correcting error

2006-09-28 Thread Georg Brandl
Sheldon wrote: > Hi. > > Does anyone know if one can resume a python script at the error point > after the error is corrected? > I have a large program that take forever if I have to restart from > scratch everytime. The error was the data writing a file so it seemed > such a waste if all the data

Re: XSLT speed comparisons

2006-09-28 Thread Larry Bates
Damian wrote: > Hi, I'm from an ASP.NET background an am considering making the switch > to Python. I decided to develop my next project in tandem to test the > waters and everything is working well, loving the language, etc. > > What I've got is: > two websites, one in ASP.NET v2 and one in Pytho

Re: windev vs python SOS

2006-09-28 Thread Steve Holden
stéphane bard wrote: > hello, my boss ask me to prefer windev to python. > I have to argue > > - python work on multiple platform (linux, mac, windows) > A good point but it didn't interest him. Because > we want to choose a language for prototyping. > So multi platform is not

Re: OT: productivity and long computing delays

2006-09-28 Thread Steve Holden
Paul Rubin wrote: > [EMAIL PROTECTED] writes: > >>Paul> Anyway, I did the same build on a 2 ghz Athlon 64 and was >>Paul> surprised that the speedup was only 35% or so. I'd have to get a >>Paul> multiprocessor box to obtain really substantial gains. >> >>Maybe your build process is i/

Re: sqlite3 error

2006-09-28 Thread John Salerno
John Machin wrote: > John Salerno wrote: >> CREATE TABLE Researchers ( >> researcherID varchar(9) PRIMARY KEY NOT NULL, >> birthYear int(4) DEFAULT NULL, >> birthMonth int(2) DEFAULT NULL, >> birthDay int(2) DEFAULT NULL, >> birthCountry varchar(50) DEFAULT NULL, >> bi

Re: sqlite3 error

2006-09-28 Thread John Salerno
Dennis Lee Bieber wrote: > On Wed, 27 Sep 2006 18:41:54 GMT, John Salerno > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> You're right! I think that must have been leftover from when it wasn't >> the last line in the query. Thanks! > > You also, based upon the cut&p

startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread metaperl
I just finished answering a question in #python because someone tried to match using ... well.. match() but did not realize that match() is actually startswith() for regexps. I suggest: re.compile('blah').atstartof(string) re.compile('blah').atendof(string) But it will never happen. -- http://m

remove the last character or the newline character?

2006-09-28 Thread Daniel Mark
Hello all: I have the following snippet: In [1]: fileName = 'Perfect Setup.txt\n' In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' character In [3]: fileName Out[3]: 'Perfect Setup.txt' Question one: Does python provide any function that can remove the last character of a stri

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Steve Holden
[EMAIL PROTECTED] wrote: > efrat: [...] > >>then why was the name "list" chosen? > > > I'd too love to know why the wrong "list" name was chosen for them, > instead of "array". (Maybe because "list" is shorter, or because ABC > called them "lists"...) > I suspect it's because of their intrinsic

Re: remove the last character or the newline character?

2006-09-28 Thread John Salerno
Daniel Mark wrote: > Question one: > Does python provide any function that can remove the last character of > a string? > I don't know whether or not the method I used is efficient Doing fileName[-1] lets you access the last character, but I'm not sure about removing it since strings are immutab

Re: remove the last character or the newline character?

2006-09-28 Thread Georg Brandl
Daniel Mark wrote: > Hello all: > > I have the following snippet: > > In [1]: fileName = 'Perfect Setup.txt\n' > In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' > character > In [3]: fileName > Out[3]: 'Perfect Setup.txt' > > Question one: > Does python provide any function t

Re: remove the last character or the newline character?

2006-09-28 Thread Tim Chase
> In [1]: fileName = 'Perfect Setup.txt\n' > In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' > character > In [3]: fileName > Out[3]: 'Perfect Setup.txt' > > Question one: > Does python provide any function that can remove the last character of > a string? > I don't know whethe

Re: remove the last character or the newline character?

2006-09-28 Thread Bruno Desthuilliers
Daniel Mark wrote: > Hello all: > > I have the following snippet: > > In [1]: fileName = 'Perfect Setup.txt\n' > In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' fileName = fileName.rstrip('\n') or just a plain: fileName = fileName.strip() > character > In [3]: fileName >

best way to get data into a new instance?

2006-09-28 Thread John Salerno
Let's pretend I'm creating an Employee class, which I will later subclass for more specific jobs. Each instance will have stuff like a name, title, degrees held, etc. etc. So I'm wondering, is the best way to get all this information into the object to just have a really long __init__ method th

Re: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread Bruno Desthuilliers
metaperl wrote: > I just finished answering a question in #python because someone tried > to match using ... well.. match() > but did not realize that match() is actually startswith() for regexps. Yet someone else that failed to read the Fine Manual(tm). > I suggest: > re.compile('blah').atstarto

Re: remove the last character or the newline character?

2006-09-28 Thread Duncan Booth
"Daniel Mark" <[EMAIL PROTECTED]> wrote: > In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' To chop the last character regardless of what it is: fileName = fileName[:-1] You don't need the 0 since thats the default, and you can use a negative index instead of subtracting

Re: remove the last character or the newline character?

2006-09-28 Thread Tim Chase
>> Does python provide any function that can remove the newline character >> from a string if it exists? > > >>> fileName = 'Perfect Setup.txt\n' > >>> fileName.strip() > 'Perfect Setup.txt' > >>> > > Or you can use lstrip() or rstrip() to remove just the left or right side. Just a caveat wit

Re: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread John Salerno
Bruno Desthuilliers wrote: > metaperl wrote: >> I just finished answering a question in #python because someone tried >> to match using ... well.. match() >> but did not realize that match() is actually startswith() for regexps. > > Yet someone else that failed to read the Fine Manual(tm). > >> I

Re: XSLT speed comparisons

2006-09-28 Thread Istvan Albert
Microsoft has put a lot of effort into their XML libraries as they are (or will be) the foundation of most of their software suites. I think you'll be hard pressed to find a library that exceeds it in both breadth of functionality and performance. Istvan -- http://mail.python.org/mailman/listin

Re: XSLT speed comparisons

2006-09-28 Thread Jan Dries
Larry Bates wrote: > Damian wrote: [...] > > What I've got is: > > two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for > > XML/XSLT) > > both on the same box (Windows Server 2003) > > both using the same XML, XSLT, CSS > > > > The problem is, the Python version is (at a guess) a

Re: best way to get data into a new instance?

2006-09-28 Thread Diez B. Roggisch
John Salerno schrieb: > Let's pretend I'm creating an Employee class, which I will later > subclass for more specific jobs. Each instance will have stuff like a > name, title, degrees held, etc. etc. > > So I'm wondering, is the best way to get all this information into the > object to just hav

Re: Python and Win95B

2006-09-28 Thread Fredrik Lundh
Ciarán Ó Duibhín wrote: > I've just installed Python 2.5 under Win95B, and when run it says "The > PYTHON25.DLL file is linked to missing export > KERNEL32.DLL.GetFileAttributesExA". > > Does Python 2.5 not run under Win95? If not, is there an earlier version of > Python which does? Windows 95

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread bearophileHUGS
Mirco Wahab: > But where is the %b in Python? Python doesn't have that. You can convert the number to a hex, and then map the hex digitds to binary strings using a dictionary, like this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528 Bye, bearophile -- http://mail.python.org/mai

Re: How to update my web automatically by python?

2006-09-28 Thread tobiah
If you are in a dynamic web environment, then please post the components of that environment. If you only want to update your static web pages, look at ftplib, or scripting scp commands. [EMAIL PROTECTED] wrote: > How to update my web automatically by python? > > I have one twiki web page > https

Re: Finding the file referred to in a Python traceback

2006-09-28 Thread Sion Arrowsmith
<[EMAIL PROTECTED]> wrote: >In this traceback, the path to 3 different SQL Alchemy source files is >a relative directory. However, no such directory is below my current >working directory. > >Traceback (most recent call last): > File "", line 1, in ? > File "conf/__init__.py", line 34, in __init

Re: best way to get data into a new instance?

2006-09-28 Thread tobiah
> So I'm wondering, is the best way to get all this information into the > object to just have a really long __init__ method that takes each argument? As was pointed out, you might ask that absolutely essential information be passed to the constructor such as employee id#, but other then that, I

Re: Battlefield Weapon Popularity Trend

2006-09-28 Thread Chris Mattern
In article <[EMAIL PROTECTED]>, Mirco Wahab wrote: >Thus spoke Chris Mattern (on 2006-09-27 19:09): >> In article <[EMAIL PROTECTED]>, Mirco Wahab wrote: >>> >>>When the Samurai of medieval Japan were confronted >>>with new 'battlefield language', e.g. early Shotguns, >> >> "early Shotguns" :D. Y

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Ramon Diaz-Uriarte
Going back to the original question, a related question: does anybody know why there are so few books on data structures and algorithms that use Python? I remember that, at least ~ 12 years ago there were many (and very good) books that used Pascal for this topic. So when I did my own search for o

Re: Whither binary search?

2006-09-28 Thread Sion Arrowsmith
John Machin <[EMAIL PROTECTED]> wrote: >Fredrik Lundh wrote: >> well, people tend to use dictionaries when they need to look things up >> quickly... >... like those paper dictionaries with the words in alphabetical order >:-) ... where you'll notice that the really big ones are divided up into buc

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
Brendon Towle wrote: > On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote: > >> From: Bruno Desthuilliers <[EMAIL PROTECTED]> >> >> Brendon Towle wrote: >>> Some of your Lisp translations are subtly off... >> >> Seems correct to me. Lisp lists are linked lists, not arrays. >> >>> From: "stur

Re: best way to get data into a new instance?

2006-09-28 Thread Fredrik Lundh
John Salerno wrote: > So I'm wondering, is the best way to get all this information into the > object to just have a really long __init__ method that takes each argument? really long __init__ argument lists only work if most argument have reasonable defaults, and you're prepared to use keyword

Re: XML parser that sorts elements?

2006-09-28 Thread jmike
Paul McGuire wrote: > >>> doc.childNodes[0].childNodes = sorted( > ... [n for n in doc.childNodes[0].childNodes > ... if n.nodeType==doc.ELEMENT_NODE], > ... key=lambda n:n.nodeName) > >>> print doc.toprettyxml() > > > > goodbye > > >

Re: best way to get data into a new instance?

2006-09-28 Thread Bruno Desthuilliers
John Salerno wrote: > Let's pretend I'm creating an Employee class, which I will later > subclass for more specific jobs. Let's pretend it might be a good design... > Each instance will have stuff like a > name, title, degrees held, etc. etc. > > So I'm wondering, is the best way to get all thi

Re: for: else: - any practical uses for the else clause?

2006-09-28 Thread Sion Arrowsmith
Ben Sizer <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: >> Yeah, I use it from time to time: >> >> for foo in bar: >> if foo matches some condition: >> print "sail to tahiti!" >> break >> else: >> print "abandon ship!" > >As a C++ programmer (w

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Fredrik Lundh
Ramon Diaz-Uriarte wrote: > Going back to the original question, a related question: does anybody > know why there are so few books on data structures and algorithms that > use Python? Probably because Python has "better than textbook" implementations of core structures, and "better than textboo

Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Steve Holden enlightened us with: > Otherwise you might as well say that any costs associated with using > a piece of software (including purchase pricing) are "hostile to the > wants of the user". It's true. People pay because they have to, but they'd rather not. Sybren -- Sybren Stüvel Stüve

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Steve Holden
Brendon Towle wrote: > Some of your Lisp translations are subtly off... > > > >>Date: 28 Sep 2006 02:49:50 -0700 >>From: "sturlamolden" <[EMAIL PROTECTED]> >>Subject: Re: Questions on Using Python to Teach Data Structures and >> Algorithms >>To: python-list@python.org >> >>If you want to ma

Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Mike Playle enlightened us with: > Imagine you're an IT manager for a medium-to-large company who wants > to use some expensive piece of software. You talk to the vendor and > buy a licence to use the software on up to 5 machines at once, but > you don't know who in the company will want to use it,

Re: best way to get data into a new instance?

2006-09-28 Thread John Salerno
John Salerno wrote: > Let's pretend I'm creating an Employee class, which I will later > subclass for more specific jobs. Each instance will have stuff like a > name, title, degrees held, etc. etc. > > So I'm wondering, is the best way to get all this information into the > object to just have

Re: Whither binary search?

2006-09-28 Thread Neil Cerutti
On 2006-09-28, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > John Machin <[EMAIL PROTECTED]> wrote: >>Fredrik Lundh wrote: >>> well, people tend to use dictionaries when they need to look things up >>> quickly... >>... like those paper dictionaries with the words in alphabetical order >>:-) > > ...

Re: License / Registration key enabled software

2006-09-28 Thread Steve Holden
Sybren Stuvel wrote: > Mike Playle enlightened us with: > >>Imagine you're an IT manager for a medium-to-large company who wants >>to use some expensive piece of software. You talk to the vendor and >>buy a licence to use the software on up to 5 machines at once, but >>you don't know who in the co

Re: windev vs python SOS

2006-09-28 Thread Sebastian Kaliszewski
stéphane bard wrote: > hello, my boss ask me to prefer windev to python. > I have to argue > > - python work on multiple platform (linux, mac, windows) > A good point but it didn't interest him. Because > we want to choose a language for prototyping. > So multi platform is not enough.

Re: XSLT speed comparisons

2006-09-28 Thread Larry Bates
Jan Dries wrote: > Larry Bates wrote: >> Damian wrote: > [...] >> > What I've got is: >> > two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for >> > XML/XSLT) >> > both on the same box (Windows Server 2003) >> > both using the same XML, XSLT, CSS >> > >> > The problem is, the Pyt

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread MonkeeSage
Bruno Desthuilliers wrote: > Brendon Towle wrote: > > Some of your Lisp translations are subtly off... > > Seems correct to me. Lisp lists are linked lists, not arrays. Actually, Brendon was correct. In lisp / scheme: (cons 1 '(2 3)) -> (1 2 3) (car '(1 2 3)) -> 1 (cdr '(1 2 3)) -> (2 3) But Bre

Re: XSLT speed comparisons

2006-09-28 Thread Fredrik Lundh
Jan Dries wrote: >> For max speed you might want to try pyrxp: >> >> http://www.reportlab.org/pyrxp.html > > Except that pyrxp, to the best of my knowledge, is an XML parser and > doesn't support XSLT, which is a requirement for Damian. and last time I checked, both cElementTree and libxml2 (lx

Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Steve Holden enlightened us with: > And you guarantee that the contents of the smartcard is only used by > one user at a time by building a licensing system for the > smartcards? We can never, ever make a 100% guarantee that people won't copy what you supply them. The only way to do that is to tho

Re: ctypes pointer to pointer

2006-09-28 Thread Podi
Thanks for the help. I've figured it out. BTW, DLL_API is defined as #ifdef MYDLL_EXPORTS #define DLL_API __declspec(dllexport) #else #define DLL_API __declspec(dllimport) #endif size = c_int() data = c_char_p('\0' * 8) mydll = cdll.mydll # Use cdll instead of windll to avoid warnings status = m

  1   2   3   >