Re: Overriding "__setattr__" of a module - possible?

2010-06-15 Thread John Nagle
On 6/15/2010 9:33 PM, Stephen Hansen wrote: On 6/15/10 9:16 PM, John Nagle wrote: Cute, but it doesn't work in general. Faking a module as a class fails when you simply call x() within the module. Huh? Explain how it doesn't work? I've done it at least twice (shamef

Re: Overriding "__setattr__" of a module - possible?

2010-06-16 Thread John Nagle
On 6/15/2010 8:34 PM, Michele Simionato wrote: On Jun 16, 4:43 am, John Nagle wrote: Is it possible to override "__setattr__" of a module? I want to capture changes to global variables for debug purposes. None of the following seem to have any effect. modu._

Re: Overriding "__setattr__" of a module - possible?

2010-06-16 Thread John Nagle
On 6/16/2010 1:10 PM, Ian Kelly wrote: On Wed, Jun 16, 2010 at 12:55 PM, John Nagle wrote: Note that there are now two copies of "a", one bound to the module and referenced in "f", and a second bound to the class, and referenced by "x.a". Uh oh. The problem he

Re: Overriding "__setattr__" of a module - possible?

2010-06-17 Thread John Nagle
on this once I have something people can download and try. I'm doing a test implementation in Python so people can try the concept and see if it works in practice. It won't go fast; it's just to give a feel for what it would be like. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQLdb and bits

2010-06-20 Thread John Nagle
e as the client. After all, the server and client don't even have to be on the same machine. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: If Not CGI...

2010-06-20 Thread John Nagle
eload every time.) A FCGI/WSGI module for Python is here: http://svn.saddi.com/py-lib/trunk/fcgi.py John Nagle #!/usr/local/bin/python2.6 import fcgi # # "Hello World" for FCGI/WSGI # def simpleApp(environ, start_response): status

"isinstance" question

2010-06-22 Thread John Nagle
constructor, we get an "instance". With a constructor, we get an "object", one which is not an InstanceType. One might think that testing for types.ObjectType would help. But no, everything is an ObjectType: >>> isinstance(1, types.ObjectType) True >>> isinstance(None, types.ObjectType) True So that's useless. I have to be missing something obvious here. (CPython 2.6) John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: "isinstance" question

2010-06-22 Thread John Nagle
On 6/22/2010 8:13 PM, Ben Finney wrote: John Nagle writes: I want to test whether an object is an instance of any user-defined class. "isinstance" is less helpful than one would expect. Right. The type hierarchy is now unified; there's essentially no difference in later

Does a '_sre.SRE_Pattern' have state,or is it thread-safe?

2010-06-23 Thread John Nagle
conditions in existing code, which is why all these obscure introspection-related questions.) John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Does "distutils" support "python setup.py test"?

2010-06-23 Thread John Nagle
name" but that doesn't seem to do anything with the stock core.distutils. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Types missing from "types"module

2010-06-23 Thread John Nagle
#x27;LongType', 'MemberDescriptorType', 'MethodType', 'ModuleType', 'NoneType','NotImplementedType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', &#x

Re: Another MySQL Problem

2010-06-23 Thread John Nagle
. Yes. Please post your CREATE statements, so we can see your database schema. If you really have one table per client, you're doing it wrong. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Types missing from "types"module

2010-06-23 Thread John Nagle
On 6/23/2010 10:08 PM, Stephen Hansen wrote: On Jun 23, 2010, at 9:24 PM, John Nagle wrote: Here's dir(types), in Python 2.6.5: ['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType&#x

Re: mod_python and css

2010-06-24 Thread John Nagle
If you send back a content type of "text/plain", your output will not be rendered as HTML by a browser; it will just be displayed as plain text. Try "text/html". John Nagle On 6/24/2010 12:19 PM, Thomas Jollans wrote: On 06/24/20

Re: Why Is Escaping Data Considered So Magical?

2010-06-25 Thread John Nagle
he code, I now realize that it would have been better to add sections to the SQL string with standard escapes, and at the same time, append the key items to a list. Then the list can be converted to a tuple for submission to "cursor.execute". John Nagle -- http://mail.python.org/mailman/listinfo/python-list

(test - ignore)

2010-06-25 Thread John Nagle
Having posting problems - ignore -- http://mail.python.org/mailman/listinfo/python-list

[ANN]: "newthreading" - an approach to simplified thread usage, and a path to getting rid of the GIL

2010-06-25 Thread John Nagle
keeps climbing. This may in time become a Python Enhancement Proposal. We'd like to get some experience with it first. Try it out and report back. The SourceForge forum for the project is the best place to report problems. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

[ANN]: "newthreading" - an approach to simplified thread usage, and a path to getting rid of the GIL

2010-06-25 Thread John Nagle
keeps climbing. This may in time become a Python Enhancement Proposal. We'd like to get some experience with it first. Try it out and report back. The SourceForge forum for the project is the best place to report problems. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN]: "newthreading" - an approach to simplified thread usage, and a path to getting rid of the GIL

2010-06-25 Thread John Nagle
'm focusing on usability of the approach. It can be made to go fast; the question is whether it can be made popular. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Why Python3

2010-06-27 Thread John Nagle
thon 2.5. Unladen Swallow targets Python 2.6.1. IronPython targets Python 2.6. C module support for CPython 3.x is still very spotty. We have a long way to go before Python 3.x is ready for prime time. Yes, it's a better language, but it's just not there yet.

Re: Python as a scripting language. Alternative to bash script?

2010-06-28 Thread John Nagle
In the 1970s, all you could return was an "int" or a "float". But that got fixed. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread John Nagle
you want, in in the situation you describe, is an optional callback, to be called in case of a fixable problem. Then the caller gets control, but without stack unwinding. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: I strongly dislike Python 3

2010-06-30 Thread John Nagle
announcement of PERL 6 is coming up on July 19th, and it still hasn't displaced PERL 5 as the "primary" version. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: [farther OT] Re: Why Is Escaping Data Considered So Magical?

2010-07-01 Thread John Nagle
still suffering from that mistake. But this isn't a Python issue. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Is there a reference manual for "pyparsing"?

2010-07-01 Thread John Nagle
Is there a reference manual for "pyparsing"? Not a tutorial. Not a wiki. Not a set of examples. Not a "getting started guide". Something that actually documents what each primitive does? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a reference manual for "pyparsing"?

2010-07-01 Thread John Nagle
On 7/1/2010 10:02 PM, Chris Rebert wrote: On Thu, Jul 1, 2010 at 9:50 PM, John Nagle wrote: Is there a reference manual for "pyparsing"? Not a tutorial. Not a wiki. Not a set of examples. Not a "getting started guide". Something that actually documents what each pr

The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-02 Thread John Nagle
to support Python 3. 7. Publicize some success stories. Unless the Python 3 enthusiasts get their act together and work much harder on providing an easy transition experience, it's not going to happen. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-02 Thread John Nagle
On 7/2/2010 3:00 PM, Aahz wrote: In article<4c2e38f5.10...@animats.com>, John Nagle wrote: 5. Get at least two major hosting services to put up Python 3. webfaction.com has python3.1 WebFaction's big thing is that they have a really good system for installing anythi

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-02 Thread John Nagle
g to Vex's published package list: http://www.vex.net/info/tech/pkglist/ They list packages only for Python 2.6. "vex.net" isn't exactly a major hosting service. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: The real problem with Python 3 - no business case for conversion

2010-07-03 Thread John Nagle
On 7/3/2010 5:46 AM, D'Arcy J.M. Cain wrote: On Fri, 02 Jul 2010 22:40:34 -0700 John Nagle wrote: Not according to Vex's published package list: http://www.vex.net/info/tech/pkglist/ Hold on. That *is* the generated list and Python 3.1 is on it. We have both 2

Re: Lua is faster than Fortran???

2010-07-04 Thread John Nagle
le to reach that level of performance. (Both groups are employed at Google. So their effectiveness will be compared.) John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-04 Thread John Nagle
On 7/4/2010 1:20 PM, sturlamolden wrote: On 2 Jul, 21:07, John Nagle wrote: http://jens.mooseyard.com/2008/12/python-30-whats-the-point/ He is right on. The only thing Python 3k will do for me, is break all my code and be incompatible with all extension modules I need. "What's

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-04 Thread John Nagle
On 7/4/2010 5:34 PM, sturlamolden wrote: On 5 Jul, 01:58, John Nagle wrote: Exactly. The "incompatible with all extension modules I need" part is the problem right now. A good first step would be to identify the top 5 or 10 modules that are blocking a move to Python 3 by major pro

Re: Shared object access problems

2010-07-04 Thread John Nagle
i686/egg/_mysql.py", line 6, in __bootstrap__ ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory Did you install the development libraries for MySQL first? Those are needed to build MySQLdb yourself. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-05 Thread John Nagle
On 7/4/2010 10:44 PM, Terry Reedy wrote: On 7/4/2010 7:58 PM, John Nagle wrote: The "incompatible with all extension modules I need" part is the problem right now. A good first step would be to identify the top 5 or 10 modules that are blocking a move to Python 3 by major projects

Getting pyparsing to backtrack

2010-07-05 Thread John Nagle
en it hit the end of the expression without satisfying the OneOrMore clause. Pyparsing does some backup, but I'm not clear on how much, or how to force it to happen. There's some discussion at "http://www.mail-archive.com/python-list@python.org/msg169559.html";. Apparently the "Or" operator will force some backup, but it's not clear how much lookahead and backtracking is supported. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-05 Thread John Nagle
On 7/5/2010 12:35 PM, Kevin Walzer wrote: On 7/5/10 2:56 AM, John Nagle wrote: * PyCrypto * PyOpenSSL These, and Mark Pilgrim's feedparser, need to be 3.x compatible before I can think about Python 3.x. There's been an attempt to port "feedparser" to 3.0, but t

Re: Getting pyparsing to backtrack

2010-07-05 Thread John Nagle
On 7/5/2010 3:19 PM, John Nagle wrote: I'm working on street address parsing again, and I'm trying to deal with some of the harder cases. The approach below works for the cases given. The "Or" operator ("^") supports backtracking, but "Optional()

Re: Is This Open To SQL Injection?

2010-07-08 Thread John Nagle
x27; sql = "INSERT INTO personaldatakeys VALUES (" + valuesql + ")" cursor.execute(sql, values) # execute INSERT "valuefields" is always some number of repeats of comma-separated "%s" Anything in "values" will be escaped properly. No SQL injection vulnerability. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

How is Unladen Swallow coming along?

2010-07-08 Thread John Nagle
t plan. ("http://code.google.com/p/unladen-swallow/wiki/ProjectPlan";) John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: How is Unladen Swallow coming along?

2010-07-08 Thread John Nagle
On 7/8/2010 12:19 PM, Luis M. González wrote: On Jul 8, 1:42 pm, John Nagle wrote: How is Unladen Swallow coming along? Looking at the site, code is being checked in and issues are being reported, but the last quarterly release was 2009 Q3. They missed their January 2010 release date

Inheriting from "dict" (was: Python dynamic attribute creation)

2010-07-08 Thread John Nagle
n problems because external data overrode a member name or some crucial data attribute. If you find yourself having to write code to avoid any of those problems, like prefixing dynamic attribute names with some symbol to avoid name clashes (or realize, after reading this, that your cod

Re: any issues with long running python apps?

2010-07-09 Thread John Nagle
hich comes with a tool for building customized boot images. Basically, you take out everything except what your application needs. Do you get Embedded Systems Journal? You should. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you do a count of a result set?

2010-07-09 Thread John Nagle
king how many hits there are can cost almost as much as actually retrieving them. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: any issues with long running python apps?

2010-07-10 Thread John Nagle
ou're listening to is read-only, and you're just listening, make a cable to feed the serial data into two machines, and have them both log it. Put them on separate UPSs and in a place where nobody can knock them over or mess with them. John Nagle -- http://

Re: Web page special characters encoding

2010-07-10 Thread John Nagle
, lambda m: entitydefs[m.group(1)], webpage) Thanks, very useful, didn't know about the entitydefs dictionary. You also need to decode the HTML numerical escapes. Expect that in real-world HTML, out of range values will occasionally appear. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: any issues with long running python apps?

2010-07-12 Thread John Nagle
rolled by Windows XP. This is a machine that moves around a plasma torch that cuts thick steel plate. A "New Java update is available" window popped up while I was working. Not good. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't python's list append() method return the list itself?

2010-07-12 Thread John Nagle
everything is considered to return some value, even control structures. LISP is like that. But Python isn't one of those languages. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Identify the Color of an Image

2010-07-14 Thread John Nagle
text"? Selected how? "Selected" implies some form of user interface, like a browser. If you're doing something in a browser, look into Firefox and Greasemonkey. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: floatref

2010-07-15 Thread John Nagle
floatref(1.0) y = x print(x.val) x.val = 10.0 print(x.val) print(y.val) Are you happy now? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-15 Thread John Nagle
OS X. From the errors, though, I suspect that not all the components involved are consistent with 32/64 bit width. John Nagle On 7/14/2010 10:05 PM, Adam Mercer wrote: Anyone have any ideas about this? Cheers Adam On Tue, Jul 13, 2010 at 16:18, Adam Mercer

Re: MySQL One More Again

2010-07-16 Thread John Nagle
ntranet-Databases-Dummies-Paul-Litwin/dp/0764502212 John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't python's list append() method return the list itself?

2010-07-16 Thread John Nagle
On 7/13/2010 4:22 AM, Gregory Ewing wrote: John Nagle wrote: Arguably, if a function just does a "return", it should be an error to try to use its return value. It's been suggested at least once before that the default return value for a function should be some special value

Re: Pickle MemoryError - any ideas?

2010-07-20 Thread John Nagle
ill memory unnecessarily. See "http://groups.google.com/group/comp.lang.python/browse_thread/thread/3f8b999c25af263a"; John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Accumulate function in python

2010-07-21 Thread John Nagle
and the performance isn't any better. Nor is any concurrency provided by "map" or "reduce". So there's no win in trying to develop cute one-liners. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Did class inheritance from "dict" work in early Python?

2010-07-21 Thread John Nagle
Did class inheritance from "dict" work in early Python? Or did that only start working when "new objects" came in? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: time between now and the next 2:30 am?

2010-07-24 Thread John Nagle
)) % DAYSECS This is for UT; the adjustment for timezone should be obvious. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: non-blocking IO EAGAIN on write

2010-07-24 Thread John Nagle
oesn't work on pipes under Windows. Since your code isn't doing anything else while waiting for a write to complete on the pipe, why use non-blocking I/O at all? (I know, the Python I/O timeout logic is broken in some versions. You're probably working around that.) John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Socket performance

2010-07-24 Thread John Nagle
ait for input from multiple sources by using "select". (But be aware that "select" doesn't work for Windows pipes.) John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare two nested dictionaries

2010-07-26 Thread John Nagle
et(d1.items()) - set(d2.items())) print (diff) {'c': 3, 'b': 2} That's the true "difference", with all entries in d1 not identically in d2 listed. Is that what you wanted? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is there no platform independent way of clearing a terminal?

2010-07-27 Thread John Nagle
es" module, but that's UNIX-only, or at least it's not in the ActiveState Python distro. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: python terminology on classes

2010-07-27 Thread John Nagle
s, but setting your own object up for "with" requires adding special methods to the object. "with" is less convenient and more limited than RAII, but that's the direction Python is going. This may be in preparation for a move to a real garbage collector. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are String Formatted Queries Considered So Magical? (Spammer analysis)

2010-07-27 Thread John Nagle
On 7/26/2010 4:19 PM, Justin Smith wrote: Seeking industry expert candidates I’m Justin Smith, Director of Tech Recruiting at Express Seattle. I am currently seeking candidates to fill Tech Positions for multiple A- List Clients: Spammer detected. Injection-Info: r27g2000yqb.googlegroup

Re: Which multiprocessing methods use shared memory?

2010-07-27 Thread John Nagle
locking actually takes place via messages over pipes. There's no dynamic allocation in the shared area. Realistically, if you're using Python, you're not that concerned about compute speed. So don't bother with shared memory, which is a performance optimization.

Re: urllib timeout

2010-07-28 Thread John Nagle
tps://adds.aviationweather.gov/data/satellite/latest_BWI_vis.jpg The aviationweather.gov site will accept a HTTPS request. Maybe that will bypass whatever lame web proxy is in the way. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Ascii to Unicode.

2010-07-28 Thread John Nagle
file. for rawline in input : unicodeline = unicode(line,'latin1')# Latin-1 to Unicode output.write(unicodeline.encode('utf-8')) # Unicode to as UTF-8 John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question regarding SSL and certificate verification

2010-07-28 Thread John Nagle
t, this means "you get to talk securely with your attacker." As long as the site or proxy has some valid SSL cert, any valid SSL cert copied from anywhere, the new Python SSL module will tell you everything is just fine. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Nice way to cast a homogeneous tuple

2010-07-28 Thread John Nagle
thon implementations. The implications for multiple inheritance are difficult. It's really a hack for CPython. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question regarding SSL and certificate verification

2010-07-29 Thread John Nagle
On 7/28/2010 10:23 PM, geremy condra wrote: On Wed, Jul 28, 2010 at 10:08 PM, John Nagle wrote: On 7/28/2010 6:26 PM, geremy condra wrote: On Wed, Jul 28, 2010 at 4:41 PM, Jeffrey Gaynorwrote: The new Python SSL module in 2.6 and later has a huge built-in security hole - it doesn&#

Re: Multiprocessing taking too much time

2010-07-29 Thread John Nagle
opriately-sized tasks to send out to another process are things like "parse large web page" or "compress video file", not "access element of array". John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Ascii to Unicode.

2010-07-29 Thread John Nagle
ack of where each Unicode character begins. So it's not a suitable format for data being actively worked on in memory; it can't be easily indexed. That's why it's necessary to convert to UTF-8 before writing to a file or socket. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: default behavior

2010-07-29 Thread John Nagle
ght expect. There are some C libraries for handling large arrays if you really need to crunch numbers. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Use cases for "setattr" in existing code

2010-07-30 Thread John Nagle
ruction. It's rarely used on "live" objects. For the above cases, a mechanism for constructing general objects would do the job. Something like attrdict = { 'a' : 1, 'b' : 2 } obj = make_object('classname', attrdict) There are clearly use c

Re: Normalizing A Vector

2010-07-31 Thread John Nagle
the function. That has to be supported. Shed Skin might do it, but it restricts the language and doesn't allow the full dynamism of Python. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Behavior of re.split on empty strings is unexpected

2010-08-02 Thread John Nagle
;>> " HELLO THERE ".split() ['HELLO', 'THERE'] If I try to get the functionality of string split with re: >>> s2 = " HELLO THERE " >>> kresplit4 = re.compile(r'\W+', re.UNICODE) >>> kresplit4.split(s2) [&#x

Re: Behavior of re.split on empty strings is unexpected

2010-08-02 Thread John Nagle
On 8/2/2010 11:02 AM, MRAB wrote: John Nagle wrote: The regular expression "split" behaves slightly differently than string split: occurrences of pattern", which is not too helpful. It's the plain str.split() which is unusual in that: 1. it splits on sequences of white

Re: Behavior of re.split on empty strings is unexpected

2010-08-02 Thread John Nagle
On 8/2/2010 12:52 PM, Thomas Jollans wrote: On 08/02/2010 09:41 PM, John Nagle wrote: On 8/2/2010 11:02 AM, MRAB wrote: John Nagle wrote: The regular expression "split" behaves slightly differently than string split: occurrences of pattern", which is not too helpful.

Re: Behavior of re.split on empty strings is unexpected

2010-08-03 Thread John Nagle
On 8/2/2010 5:53 PM, samwyse wrote: On Aug 2, 12:34 pm, John Nagle wrote: The regular expression "split" behaves slightly differently than string split: I'm going to argue that it's the string split that's behaving oddly. I tend to agree. It doesn't

Re: Why is python not written in C++ ?

2010-08-03 Thread John Nagle
her C compiler on the same box, the odds are pretty good they'll interoperate without any problems. Not for Python. Extensions have to be built with essentially the same version of the same C compiler used for building Python. This is a major headache.

Re: __init__ as a lambda

2010-08-04 Thread John Nagle
one into Python. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

A useful, but painful, one-liner to edit money amounts

2010-08-04 Thread John Nagle
ist. Hence the "reduce" and lambda to get rid of them. Any better ideas? (Yes, I know there's a built-in feature for this scheduled for Python 2.7.) John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Struggling to convert a mysql datetime object to a python string of a different format

2010-08-05 Thread John Nagle
value like 100 ; DELETE FROM visitors; SELECT * FROM visitors you just lost your data. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Python "why" questions

2010-08-07 Thread John Nagle
rather than arrays of arrays, tend to use 1-based subscripts. That reflects standard practice in mathematics. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

urllib "quote" problem

2010-08-08 Thread John Nagle
ce the message; probably a URL in Unicode. This looks like code that will do the wrong thing in Python 2.6 for characters in the range 128-255. Those are illegal in type "str", but this code is constructing such values with "chr". John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Win7. Why Don't Matplotlib, ... Show up in Control Panel Add-Remove?

2010-08-08 Thread John Nagle
some level of quality control, PyPi is just a link farm. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Is there a Python equivalent to Perl's File::Listing::parse_dir

2010-08-11 Thread John Nagle
? I'm converting some old Perl code. Even the Python FTP module doesn't have a directory parser. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

urllib2 does not implement "with" Python 2.6

2010-08-11 Thread John Nagle
Somewhat to my surprise, in Python 2.6, with urllib2.urlopen(url) as fh : doesn't work. It fails with "AttributeError: addinfourl instance has no attribute '__exit__'". I thought that all the file-like objects supported "with" in 2.6. No?

Decompressing a file retrieved by URL seems too complex

2010-08-12 Thread John Nagle
om access, and tries to do "seek" and "tell". Nor is the output descriptor from gzip general; it fails on "readline", but accepts "read". (No good reason for that.) So I had to make a second copy.

Decompressing a file retrieved by URL seems too complex

2010-08-12 Thread John Nagle
e, reasonably enough, needs random access, and tries to do "seek" and "tell". Nor is the output descriptor from gzip general; it fails on "readline", but accepts "read". (No good reason for that.) So I had to make a second copy.

Re: Python "why" questions

2010-08-15 Thread John Nagle
't know how big it is. The syntax should have been something like int read(int fd, &char[n] buf, size_t n); This says the type of the argument is an array of char of length n, and it's being passed by reference. "read" then knows how big "buf" is. This desig

Re: Pop return from stack?

2010-08-15 Thread John Nagle
Fix "func". That's terrible Python. No standard Python library module calls system exit to handle an error. So that must be in your code. Standard procedure for errors is to raise an exception. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-18 Thread John Nagle
demonstrate. There's a big win in the simple optimization of identifying "non-keep" parameters, especially in mathematical work where they're very common. It's not clear that getting fancier than that is a win. Does Shed Skin have this optimization? It should.

Re: expression in an if statement

2010-08-18 Thread John Nagle
On 8/18/2010 11:24 AM, ernest wrote: Hi, In this code: if set(a).union(b) == set(a): pass Does Python compute set(a) twice? CPython does. Shed Skin might optimize. Don't know about Iron Python. John Nagle -- http://mail.python.org/ma

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-18 Thread John Nagle
ster, and it bulks up the program by 2x or so. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: String substitution VS proper mysql escaping

2010-08-19 Thread John Nagle
quotedstr = sqlstring % map(MySQLdb.escape_string, values) cursor.execute(quotedstr) It just applies "MySQLdb.escape_string to each arg. If PHP did that, we'd have far fewer "SQL injection attacks". Most programs shouldn't use "MySQLdb.escape", and should let the built-in call do it. It's useful, though, if you're constructing a data file for LOAD DATA to do a bulk database load. The same escaping works for LOAD DATA INFILE with the default input format. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterative vs. Recursive coding

2010-08-19 Thread John Nagle
dall(esckey, target)) # find all key and count print('%s is %d times in the target string' %(key,cnt)) >>> countSubStringMatch("atgacatgcacaagtatgcat","ca") ca is 4 times in the target string Enjoy. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: expression in an if statement

2010-08-19 Thread John Nagle
On 8/18/2010 3:12 PM, Thomas Jollans wrote: On Wednesday 18 August 2010, it occurred to John Nagle to exclaim: On 8/18/2010 11:24 AM, ernest wrote: Hi, In this code: if set(a).union(b) == set(a): pass Does Python compute set(a) twice? CPython does. Shed Skin might optimize. Don&#

Re: Iterative vs. Recursive coding

2010-08-20 Thread John Nagle
. That's a real-life use case for such a construct, and led to much shorter code than a non-recursive implementation. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib "quote" problem

2010-08-20 Thread John Nagle
On 8/20/2010 8:41 AM, Aahz wrote: In article<4c5eef7f$0$1609$742ec...@news.sonic.net>, John Nagle wrote: This looks like code that will do the wrong thing in Python 2.6 for characters in the range 128-255. Those are illegal in type "str", but this code is constructing

Re: Looking for an appropriate encoding standard that supports all languages

2010-08-20 Thread John Nagle
saving your script in? Very few of the text editors I've used save to UTF-16 by default. Most editors that will do Unicode save files as "utf-8". Try that. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

<    6   7   8   9   10   11   12   13   >