Re: Timeline for Python?

2006-09-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Blair P. Houghton wrote: > wesley chun wrote: >> >> 1. never write against older versions of Python... you will only >> obsolete your book even faster (well, "sooner") > > I believe there is some market for documentation of older > versions of software. Many i

Re: A critique of cgi.escape

2006-09-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Jon Ribbens wrote: > >> Making cgi.escape always escape the '"' character would not break >> anything, and would probably fix a few bugs in existing code. Yes, >> those bugs are not cgi.escape's fault, but that's no reason not to >> be helpfu

Re: Automatic import PEP

2006-09-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Connelly Barnes wrote: > The main point of autoimp is to make usage of the interactive Python > prompt more productive by including "from autoimp import *" in the > PYTHONSTARTUP file. The main problem I have with your idea is that any kind of import statement with

Re: QuoteSQL

2006-09-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Lawrence D'Oliveiro enlightened us with: >> Why doesn't MySQLdb provide a function like this: > > Because generally you're able to pass newlines and the like just fine. > You can even store binary dat

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Lawrence D'Oliveiro enlightened us with: >> Yes, I have done blobs. Still need a quoting function for the >> specials, though. > > Why? What makes your data so different from mine? "select

Re: A critique of cgi.escape

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Georg Brandl wrote: > >> A function is broken if its implementation doesn't match the >> documentation. > > or if it doesn't match the designer's intent. cgi.escape is old enough > that we would have noticed that, by now... _We_ certainly

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Lawrence D'Oliveiro enlightened us with: >> "select * from details where person_name like" >> " concat(\"%%\", %s, \"%%\")" \ >> % \

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > Sybren Stuvel <[EMAIL PROTECTED]> wrote: > >> Ok, should have tested it better. This works fine on my machine, >> though: >> >> curs.execute( >> "select * from details where person_name like ?", >> ('%' + name + '%', ) >> ) >> >> Inc

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > >>> This could be an argument for having a utility function to escape the >>> wildcards for this sort of situation, but certainly not an argument for

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Duncan Booth enlightened us with: >> I think his point was that any '%' characters inside name act like >> wildcards whereas his version looked for literal percents. > > But of course. > >> This could be an argument for having a utility func

Re: License / Registration key enabled software

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, T wrote: > We all know that there are many softwares that require some license key > or registration key to enable them. How does one implement something > like this in python? Reliably? Can't be done, in Python or any other language. -- http://mail.python.org/ma

Re: License / Registration key enabled software

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, T wrote: >Umm...I was hoping for something simpler and more straight forward. It cannot be done simply or straightforwardly. Or reliably, for that matter. -- http://mail.python.org/mailman/listinfo/python-list

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Duncan Booth enlightened us with: >> I think his point was that any '%' characters inside name act like >> wildcards whereas his version looked for literal percents. > > But of course. > >> This could be an argument for having a utility func

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Lawrence D'Oliveiro enlightened us with: >>> An escaping function should be small and not do all kinds of >>> escaping for different situations at once. >> >> Even when the two situations are relate

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve Holden wrote: > When you use the DB API correctly and paramterise your queries you still > need to quote wildcards in search arguments, but you absolutely > shouldn't quote the other SQL specials. > > That's what parameterised queries are for on the first pla

Re: QuoteSQL

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Jon Ribbens wrote: > In article <[EMAIL PROTECTED]>, Lawrence D'Oliveiro wrote: >> You're proposing two separate functions: >> >> 1) quoting of non-wildcard specials >> 2) quoting of wildcard specials &g

Re: A critique of cgi.escape

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > If I have a unicode string such as: u'\u201d' (right double quote), then I > want that encoded in my html as '”' (or ” but the numeric form > is better). Right-double-quote is not an HTML special, so there's no need to quote it. I'm only conce

Re: A critique of cgi.escape

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Max M wrote: > Lawrence is right that the escape method doesn't work the way he expects > it to. > > Rewriting a library module simply because a developer is surprised is a > *very* bad idea. I'm not surprised. Disappointed, yes. Verging on disgust at some comment

Re: A critique of cgi.escape

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Max M wrote: > >> It also makes the escaped html harder to read for standard cases. > > and slows things down a bit. > > (cgi.escape(s, True) is slower than cgi.escape(s), for reasons that are > obvious for anyone who's looked at the code)

Re: A critique of cgi.escape

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Max M wrote: > Jon Ribbens skrev: >> In article <[EMAIL PROTECTED]>, Fredrik >> Lundh wrote: There's nothing to say that cgi.escape should take them both into account in the one function >>> so what exactly are you using cgi.escape for in your code ? >> >

Re: A critique of cgi.escape

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > In article <[EMAIL PROTECTED]>, Georg Brandl wrote: >>> I'm sorry, that's not good enough. How, precisely, would it break >>> "existing code"? Can you come up with an example, or even an >>> explanation of how it could break existing code? >>

Re: A critique of cgi.escape

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Lawrence D'Oliveiro wrote: > >>> Georg Brandl wrote: >>> >>>> A function is broken if its implementation doesn't match the >>>> documentation. >>> >>> or if i

Re: Remap Mysql tuple to dictionary

2006-09-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Pom wrote: > I want to convert a Mysql resulset to a dictionary. Here's a function that does this one row at a time: def GetEachRecord(TableName, Fields, Condition, Values, Extra = "") : """generator which does an SQL query which can return 0 or more resul

Re: Remap Mysql tuple to dictionary

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Lawrence D'Oliveiro wrote: > >> yield dict(zip(Fields, NextRow)) > > the OP didn't ask for a field name => value mapping, though. What other kind of mapping could you produce? -- http://mail.python.org/mailman/listinfo/python-list

Re: Remap Mysql tuple to dictionary

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, I wrote: > In message <[EMAIL PROTECTED]>, Fredrik > Lundh wrote: > >> Lawrence D'Oliveiro wrote: >> >>> yield dict(zip(Fields, NextRow)) >> >> the OP didn't ask for a field name => value

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve Holden wrote: > Lawrence D'Oliveiro wrote: >> >> In message <[EMAIL PROTECTED]>, Steve >> Holden wrote: >> >> >>>When you use the DB API correctly and paramterise your queries you still >>

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Fredrik >> Lundh wrote: >> >>> Lawrence D'Oliveiro wrote: >>> >>>>> Georg Brandl wrot

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Gabriel G wrote: > At Monday 25/9/2006 11:08, Jon Ribbens wrote: > >> >> What precisely do you think it would "break"? >> > >> > existing code, and existing tests. >> >>I'm sorry, that's not good enough. How, precisely, would it break >>"existing code"? Can you com

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Max M wrote: >> >>> Lawrence is right that the escape method doesn't work the way he expects >>> it to. >>> >&g

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > The spurious escaping of the apostrophe does no harm, but spuriously > escaping a newline makes the select match the letter 'n' insteal of > matching a newline. And how would you get my QuoteSQL routine, as written, to make the same mistake yo

Re: Printing a percent sign

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, John Machin wrote: > 1. Reasoning: How do you get a literal "'" into an SQL string constant? > How do you get a literal "\" into a Python string constant? How do you > get a literal "$" into some *x shell command lines? Do you detect a > pattern? None of which appl

Re: Remap Mysql tuple to dictionary

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Lawrence D'Oliveiro wrote: > > > SQL databases like MySQL are _designed_ for efficiency. > > unlike the Python data types, you mean ? Did I say it was unlike anything? -- http://mail.python.org/mailman/listinfo/python-list

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Lawrence D'Oliveiro enlightened us with: >> The trouble with this is that, instead of offering extra functionality, >> it leaves the door open to making two stupid mistakes: >> >> 2) quoting of wil

Re: SSL meta data

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, BerndWill wrote: > The only solution from me and my colleagues view (as poor at it sounds) > is to setup a little python script "pinging" an amount of about 2.000 > servers in daily intervals checking for the validity of those SSL > certificates. There's no need t

Re: Algorithm Question

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Andrew McLean wrote: > I have the ability to query a database in a legacy system and extract > records which match a particular pattern. Specifically, I can perform > queries for records that contain a given search term as a sub-string of > a particular column. Wha

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > However, your QuoteSQL messes up every time because it wraps double > quotes round the whole string, so it isn't suitable for use with > parameterised queries at all. If you care to modify it to work in that > situation I think you'll find that

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Lawrence D'Oliveiro enlightened us with: >> You're proposing two separate functions: >> >> 1) quoting of non-wildcard specials >> 2) quoting of wildcard specials > > I'm suggesti

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Georg Brandl wrote: >> >>> Lawrence D'Oliveiro wrote: >>>> In message <[EMAIL PROTECTED]>, Max M >>>>

Re: Remap Mysql tuple to dictionary

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Lawrence D'Oliveiro wrote: > > > Kind of defeats the point of having SQL, but there you go... > > there are plenty of reasons to use Python data structures instead of the > SQL engine for data crunchin

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Dan Bishop wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Fredrik >> Lundh wrote: >> >> > Max M wrote: >> > >> >> It also makes the escaped html harder to read for standard

Re: Printing a percent sign

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, John Machin wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, John >> Machin wrote: >> >> > 1. Reasoning: How do you get a literal "'" into an SQL string constant? >> >

Re: Remap Mysql tuple to dictionary

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve Holden wrote: > I suppose you are using a generator to avoid data duplication, but for > 100,000 records this could be regarded as a premature optimisation on > modern computers. I was using a generator to avoid loading all those 100,000 records into memory

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Tim Chase enlightened us with: >> >>> cur.execute("select * from people where last_name in (%s)" % >> ','.join('%s' for i in xrange(len(t))), >> t) > > But since the value of 'i' isn't used at all, it can be abbreviated > to: > cur.exec

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve Holden wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Steve >> Holden wrote: >> >> >>>Lawrence D'Oliveiro wrote: >>> >>>>In message <[EMAIL PROTECTE

Re: QuoteSQL

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve Holden wrote: > Lawrence D'Oliveiro wrote: > >> In message <[EMAIL PROTECTED]>, Duncan Booth wrote: >> >>>In particular it currently turns newlines in backslash followed by n >>>which (since MySQL

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Jon Ribbens wrote: > >> This has nothing to do with character encodings. > > it has *everything* to do with encoding of existing data into HTML so it > can be safely transported to, and recreated by, an HTML-aware client. > > does the word

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, John Bokma wrote: > Brian Quinlan <[EMAIL PROTECTED]> wrote: > >> o escaping attribute values is less common than escaping element >>text > > Again, you must be kidding... I don't think Brian Quinlan was seriously trying to claim that was true, only that was

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve Holden wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Georg Brandl wrote: >> >> >>>Lawrence D'Oliveiro wrote: >>> >>>>In message <[EMAIL PROTECTED]>

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > Lawrence D'Oliveiro wrote: > >>> (cgi.escape(s, True) is slower than cgi.escape(s), for reasons that are >>> obvious for anyone who's looked at the code). >> >> What you're d

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Gabriel G wrote: > At Tuesday 26/9/2006 04:16, Lawrence D'Oliveiro wrote: > >> >> >> What precisely do you think it would "break"? >> > FWIW, a *lot* of unit tests on *my* generated html code would break... &

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, George Sakkis wrote: > Lawrence D'Oliveiro wrote: > >> Fredrik Lundh wrote: >> > you're not the designer... >> >> I don't have to be. Whoever the designer was, they had not properly >> thought through th

Re: A critique of cgi.escape

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fredrik Lundh wrote: > most HTML attributes cannot even contain things that would need > to be escaped ... sys.stdout.write \ ( "Email: \n" % QuoteHTML(WhateverTheUserPreviouslyTyped) ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Making search on the other site and getting data and writing in xml

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steven D'Aprano wrote: > If Google wants to write legal > contracts that won't stand up in court (speaking as somebody who isn't a > lawyer and whose legal advice is worthless), they can. What they define as their terms of service doesn't have to stand up in court.

Re: Makin search on the other site and getting data and writing in xml

2006-09-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steve Holden wrote: > The fact remains that Google can chop your searching ability off at the > knees ... No they can't. They can only chop off your ability to use Google. -- http://mail.python.org/mailman/listinfo/python-list

Re: Top and Bottom Values [PEP: 326]

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Antoon Pardon wrote: > I need this Top value in > a context where it can be used as a start or stop value > in a slice. But the only valid values allowed for indices are 0 up to the length of the array inclusive. Larger integers are not allowed, so why should Top b

Re: Makin search on the other site and getting data and writing in xml

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Ben Finney wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > >> Lawrence D'Oliveiro wrote: >> > Steve Holden wrote: >> >>The fact remains that Google can chop your searching ability off >> >>at

Re: QuoteSQL

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > >> def EscapeSQLWild(Str) : >> """escapes MySQL pattern wildcards in Str.""" >> Result

Re: What's the best way to communicate between processes?

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > I'm thinking about coding some sort of 'local notify server' in twisted > (basically just listening to a socket and then passing the information > to the IM bot), then connecting to it via a python socket in django and > passing some seria

Re: re.compile().split(): why it produces empty string as a first element of the list

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, alf wrote: > Fredrik Lundh wrote: >> alf wrote: >> >>> Let's run following: >>> >>> >>> re.compile('(\[.*?\])').split('[aa]bb[11]22') >>> ['', '[aa]', 'bb', '[11]', '22'] >>> >>> Why does it return '' as a first element of the list? >> >> >> because the string s

Re: QuoteSQL

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > >> In message <[EMAIL PROTECTED]>, Duncan Booth >> wrote: >> >>> Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: >>&

Re: Python/MySQL problem on Windows

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Eric Smith wrote: > I could have sworn that I got the use of connection() from published > sample code, but I must be mistaken. If all else fails, read the documentation , -- http://mail.python.org/mailman/listinfo/python-

Re: QuoteSQL

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > >>> You are still missing the point. I'm not talking about generating a >>> MySQL string literal, I'm talking about preventing wildcards >

Re: QuoteSQL

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > >> I'm assuming you mean, how would you get from a Python expression to a >> MySQL clause that looks like >> >> name like "

Re: Splitting device addresses into parts

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Fabian Steiner wrote: > I often have to deal with strings like "PCI:2:3.0" or "PCI:3.4:0" and > need the single numbers as tuple (2, 3, 0) or (3, 4, 0). Is there any > simple way to achieve this? So far I am using regular expressions but I > would like to avoid them

Re: Difference between two dates in seconds

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steven D'Aprano wrote: > On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote: > >> Claes at work wrote: >> >>> Please tell me there is a simpler way than subtracting two datetimes >>> to get a timedelta and then compute >>> >>> days * number of seconds per da

Re: A critique of cgi.escape

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Stuart Bishop wrote: > People also use that function to escape non-HTML too - if they are using > it as documented, and it produces the correct results for them, great. > Note that the documentation doesn't say that input has to be HTML, nor > that output must be us

Re: Making sure script only runs once instance at a time.

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Hari Sekhon wrote: > I have written a script and I would like to ensure that the script is > never run more than once at any given time. -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the best way to communicate between processes?

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > ... Don't top-post. -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive descent algorithm able to parse Python?

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > [EMAIL PROTECTED] schrieb: >> I'm a compiler newbie and curious if Python grammar is able to >> be parsed by a recursive descent parser or if it requires >> a more powerful algorithm. > > I might be mistaken, but isn't recursive descent on

Re: QuoteSQL

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, I wrote: > def EscapeSQLWild(Str) : > """escapes MySQL pattern wildcards in Str.""" > Result = [] > for Ch in str(Str) : > if Ch == "%" or Ch == "_" : > Result.append("\\") > #end if > R

Re: QuoteSQL

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, LI wrote: execfile("QuoteSQL.py") EscapeSQLWild(r"\%") > '%' SQLString("%" + EscapeSQLWild(r"\%") + "%") > '"%%%"' EscapeSQLWild(r"\%") == r"\\%" > True SQLString("%" + EscapeSQLWild(r"\%") + "%") == r'"%%%"' > True With the

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

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, metaperl wrote: > There is also nothing wrong with > > re.match('blah', somestring) > > but it does read as well as > > re.atstartof('blah', something) > > and the counterpart for EOS is not there. The only reason for those special cases for simple string match

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

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > 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/

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

2006-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, I wrote: > "".join([["0", "1"][(1 << i & n) != 0] for i in > range(int(math.ceil(math.log(n, 2))) - 1, -1, -1)]) Uh, make that "".join([["0", "1"][(1 << i & n) != 0] for i in range(int(math.floor(math.log(n, 2))), -1, -1)]) Need to check those corner ca

Re: License / Registration key enabled software

2006-09-29 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Mike Playle wrote: > License keys exist to make it easier for honest users to > remain honest. It was Ed Felten who said that "keeping honest people honest is like keeping tall people tall". -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find number of characters in a unicode string?

2006-09-29 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, > Preben Randhol wrote: > >> Is there a way to calculate in characters >> and not in bytes to represent the characters. > > Decode the byte string and use `len()` on the unicode string. Hmmm, for some reas

Multi-line docstrings

2006-12-23 Thread Lawrence D'Oliveiro
The Python docs recommend the use of triple-quoted string literals for docstrings, e.g. def Meet(Alice, Bob) : """arranges a meeting between Alice and Bob. Returns a reference to the meeting booking object.""" ... #end Meet However, these tend to get messed up by i

Re: Multi-line docstrings

2006-12-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Duncan Booth wrote: > Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > >> The Python docs recommend the use of triple-quoted string literals for >> docstrings, e.g. >> >> def Meet(Alice, Bob) : >>

Re: Unescaping URLs in Python

2006-12-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, John Nagle wrote: > Here's a URL from a link on the home page of a major company. > > About Us > > What's the appropriate Python function to call to unescape a URL > which might contain things like that? Just use any HTML-parsing library. I think the standard Pyt

Re: find login name of user?

2006-12-30 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Is there a function/module to find the login name of the user under > UNIX environment? Note that there isn't really an important concept of "login name" under *NIX systems. There is the current process UID and GID, effective UID and GID

Re: a question on python dict

2006-12-30 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Tim Peters wrote: > You should also note that copying a dict key or value (no matter of > what type) consists in its entirety of copying one machine address (a > 4- or 8-byte pointer, depending on platform). Actually, no. It also consists of updating reference coun

Re: a question on python dict

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Tim Peters wrote: > [Tim Peters] >>> You should also note that copying a dict key or value (no matter of >>> what type) consists in its entirety of copying one machine address (a >>> 4- or 8-byte pointer, depending on

Re: DOS, UNIX and tabs

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Paul McNett > wrote: > >> Everyone can choose their own number of spaces-per-tab and >> it'll look right, as long as everyone uses a monospace font. > > You never tried that with tabs plus additional spaces

Re: a question on python dict

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Tim Peters wrote: > [Tim Peters] >>>>> You should also note that copying a dict key or value (no matter of >>>>> what type) consists in its entirety of copying one machine address (a >>>>> 4- or 8-byte poin

Re: DOS, UNIX and tabs

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Tom Plunket wrote: > Perhaps interestingly, for development I have my editor set to show tabs > as fairly short, but my diff program shows them as eight characters. I > find that makes indentation changes easier to spot in the diffs. I think there should be a sing

Re: Anyone persuaded by "merits of Lisp vs Python"?

2007-01-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > [3] I thought it was particularly cool how Tcl could bolt on a class > based object oriented system as a library. The word "class" isn't > built into the language, but that kind of evaluator lets you add it. I have written about two notr

Re: Anyone persuaded by "merits of Lisp vs Python"?

2007-01-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Paul Hummer wrote: > I learned PHP for ease of web application development ... PHP is great for easily developing _insecure_ web applications. But if you want them not to leak like a sieve, things get a bit more complicated. -- http://mail.python.org/mailman/listi

Re: How do I add users using Python scripts on a Linux machine

2007-01-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Piet van Oostrum wrote: > The scenario is as follows: Suppose the script starts with the line: > #!/usr/bin/python > > (using #!/usr/bin/env python would be disastrous because the user could > supply his own `python interpreter' in his PATH.) > > Now a malicious u

Re: regexp problem in Python

2007-08-06 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Ehsan wrote: > I use this pattern : > "http.*?\.(wmv|3gp).*"" > > but it returns only 'wmv' and '3gp' instead of "http://www.2shared.com/ > download/1716611/e2000f22/Jadeed_Mlak14.wmv? > tsid=20070803-164051-9d637d11" What's the actual Python code that uses this r

Re: question: how to transfer objects between server and client?

2007-08-12 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, OpenPavilion wrote: > just found out, that if I use "pickle.dumps(object)" (on client side) > and "pickle.loads(object)" (on server side) before and after sending, > I have access to the object. That's assuming that the client and server can trust each other. If yo

Re: Error calling module

2007-08-12 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, fartknuckle wrote: > When I try to call gtk like so: > > > import gtk > > I get the error: > > ImportError: No module named gtk > > > I installed a new Python and a new pygtk. > Is the gtk module not a part of pygtk??? > > I have PYTHONPATH=/usr/local/lib/pyt

Re: python socket usage

2007-08-17 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Oğuz Yarımtepe wrote: > Is it possible to send a data object like a tuple or a list in socket > programming? You'll have to define a bytestream encoding to send over the connection. I recently wrote up some Python code

Re: encrypting files + filestreams?

2007-08-17 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, per9000 wrote: > crptz = AES.new("my-secret_passwd") You're using ECB mode. Never use ECB mode. At a minimum, use CBC mode. Also, another common thing is, don't use the actual password to encrypt the entire file. Instead, randomly generate a "session key" to u

Re: What Are These Import/From Statements about?

2007-08-23 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Robert Kern wrote: > os.path. It's a sub-module of the standard os module. Actually, there are no such things as sub-modules (as you'll find out if you try to define one). What it really is is a variable in that module, which points to another module (e.g. posixpat

Re: curses library

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Ghirai wrote: > I need to write a console application. Why not just use VT100 escape sequences directly? Terminal emulators don't support anything else. -- http://mail.python.org/mailman/listinfo/python-list

Re: accessing keys in dict

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, james_027 wrote: > is there any difference between .. > > for key in a_dict: > > from > > for key in a_dict.keys(): I'm assuming the former is equivalent to for key in a_dict.iterkeys() : -- http://mail.python.org/mailman/listinfo/python-list

Re: make images with python

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Boris Borcic wrote: > Lawrence Oluyede wrote: > >> stefano <[EMAIL PROTECTED]> wrote: >>> I need make some images using python but i'm lost :P >> >> >> > > If you want to do antialiased drawings into images, > you might r

Re: Threading problem when many sockets open

2007-08-25 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Philip Zigoris wrote: > ... and the server > would go into a state where the master thread repeatedly polled the > socket and printed an error. Is that because it cannot create a new socket to accept the connection on? -- http://mail.python.org/mailman/listinfo/py

Re: Making a file-like object for manipulating a large file

2007-08-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sean Davis wrote: > I have a VERY large file that I would > like to load a line at a time, do some manipulations on it, and then > make it available to as a file-like object for use as input to a > database module (psycopg2) that wants a file-like object (with read

Re: expat error, help to debug?

2007-08-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Andreas Lobinger wrote: > Anyone any idea where the error is produced? Do you want to try adding an EndElementHandler as well, just to get more information on where the error might be happening? -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   10   >