Re: Python presentations

2012-09-13 Thread Cameron Simpson
s straight off my brain. Ideally, two projectors: the current slides and an interactive python environment for demos. That way people can cross reference. But otherwise: a few slides, then a short demo if what was just spoken about, then slides... -- Cameron Simpson Standing on the faces of midg

Re: Decorators not worth the effort

2012-09-13 Thread Cameron Simpson
orator:-) But if I get it right and name it well I find it dramaticly _decreases_ the cognitive burden of the code using the decorator... -- Cameron Simpson Observing the first balloon ascent in Paris, [Ben] Franklin heard a scoffer ask, "What good is it?" He spoke for a generation of sci

Re: Batching HTTP requests with httplib (Python 2.7)

2012-09-13 Thread Cameron Simpson
at am I missing about the larger context? -- Cameron Simpson Clymer's photographs of this procedure show a very clean head. This is a lie. There is oil in here, and lots of it. - Mike Mitten, rec.moto, 29sep1993 -- http://mail.python.org/mailman/listinfo/python-list

Re: Batching HTTP requests with httplib (Python 2.7)

2012-09-15 Thread Cameron Simpson
On 14Sep2012 10:53, Chicken McNuggets wrote: | On 14/09/2012 03:31, Cameron Simpson wrote: | > On 13Sep2012 19:34, Chicken McNuggets wrote: | > | I'm writing a simple library that communicates with a web service and am | > | wondering if there are any generally well regarded method

Re: How to limit CPU usage in Python

2012-09-21 Thread Cameron Simpson
| piped-back output. If you're limiting yourself, os.getpid(). -- Cameron Simpson -- http://mail.python.org/mailman/listinfo/python-list

Re: + in regular expression

2012-10-04 Thread Cameron Simpson
On 03Oct2012 21:17, Ian Kelly wrote: | On Wed, Oct 3, 2012 at 9:01 PM, contro opinion wrote: | > why the "\s{6}+" is not a regular pattern? | | Use a group: "(?:\s{6})+" Yeah, it is probably a precedence issue in the grammar. "(\s{6})+" is also accepted.

Re: + in regular expression

2012-10-05 Thread Cameron Simpson
d | quantifiers cause problems with the parsing techniques that actually get | used? There are certainly constructs that can cause an exponential amount of backtracking is misused. One could make a case for discouragement (though not a case for forbidding them). Just my 2c, -- Cameron Simps

trouble with nested closures: one of my variables is missing...

2012-10-13 Thread Cameron Simpson
def getprop(self): with getattr(self, lock_name): # innards removed here pass return getattr(self, attr_name, unset_object) return property(getprop) return made_file_property @file_property def f(self, foo=1): print "foo=%r" % (foo,) @make

Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Cameron Simpson
On 13Oct2012 22:07, Chris Rebert wrote: | On Saturday, October 13, 2012, Cameron Simpson wrote: | > I'm having some trouble with closures when defining a decorator. | | | > However, I can't make my make_file_property function work. I've stripped | > the co

Re: Understanding http proxies

2012-10-14 Thread Cameron Simpson
roxy Servers http://tools.ietf.org/html/rfc2616#section-8.1.3 Proxy Authenticate http://tools.ietf.org/html/rfc2616#section-14.33 Cheers, -- Cameron Simpson There's two kinds of climbers...smart ones, and dead ones. - Don Whillans -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Cameron Simpson
On 14Oct2012 18:32, Ian Kelly wrote: | On Sun, Oct 14, 2012 at 3:54 PM, Cameron Simpson wrote: | > | You assign to it, but there's no nonlocal declaration, so Python thinks | > | it's a local var, hence your error. | > | > But 'unset_object' is in loc

Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Cameron Simpson
On 14Oct2012 19:27, Ian Kelly wrote: | On Sun, Oct 14, 2012 at 7:08 PM, Cameron Simpson wrote: | > Is attr_name omitted from locals() in made_file_property _because_ I | > have an assignment statement? | | Yes. Syntactically, a variable is treated as local to a function if | it is assig

Re: 'generator ignored GeneratorExit''

2012-10-20 Thread Cameron Simpson
On 20Oct2012 16:41, Charles Hixson wrote: | On 10/20/2012 04:28 PM, Ian Kelly wrote: | > On Sat, Oct 20, 2012 at 2:03 PM, Charles Hixson | >> try: | >> fil=open (path, encoding = "utf-8-sig") | >> yieldfil | >> except: [...] |

Re: while expression feature proposal

2012-10-24 Thread Cameron Simpson
/while/etc is visible at the left. With statements and except statements have concrete use cases for the "as" part that aren't doable without it, but the while/if...as form can always be written in the current convention. Cheers, -- Cameron Simpson -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-24 Thread Cameron Simpson
On 25Oct2012 09:40, Chris Angelico wrote: | On Thu, Oct 25, 2012 at 9:26 AM, Cameron Simpson wrote: | > If I could write this as: | > | > if re_FUNKYPATTERN.match(test_string) as m: | > do stuff with the results of the match, using "m" | | Then you'd be right

Re: while expression feature proposal

2012-10-24 Thread Cameron Simpson
On 24Oct2012 15:37, Paul Rubin wrote: | Cameron Simpson writes: | > if re_FUNKYPATTERN.match(test_string) as m: | > do stuff with the results of the match, using "m" | | class memo: | def __call__(f, *args, **kw): | self.result = f(*args, **kw) | | m

Re: a.index(float('nan')) fails

2012-10-25 Thread Cameron Simpson
ting point FTW! You're using index incorrectly, but only because it relies on == returning True, which it won't. You can use math.isnan: http://docs.python.org/library/math.html#math.isnan http://docs.python.org/py3k/library/math.html#math.isnan for the test instead. Nan requires

Re: a.index(float('nan')) fails

2012-10-25 Thread Cameron Simpson
t you were making the point that another NaN is distinct, but it didn't seem clear to me. Cheers, -- Cameron Simpson In article 1t8n9hinn...@dns1.nmsu.edu, mcri...@acca.nmsu.edu (Mcrider) writes: >Could one of you physicist-type cyber-riders give a lucid description/ >explanation of

Re: while expression feature proposal

2012-10-26 Thread Cameron Simpson
the except/with "as" uses back into expressions and out of the control-structural part of the grammar. I can't see that that would actually break any existing code though - anyone else? Cheers, -- Cameron Simpson UNIX was not designed to stop you from doing stupid things, because that w

Re: while expression feature proposal

2012-10-26 Thread Cameron Simpson
On 26Oct2012 19:41, Devin Jeanpierre wrote: | On Fri, Oct 26, 2012 at 6:03 PM, Cameron Simpson wrote: | > Any doco would need to make it clear that no order of operation is | > implied, so that this: | > | > x = 1 | > y = (2 as x) + x | > | > does not have a defined answ

Re: while expression feature proposal

2012-10-26 Thread Cameron Simpson
On 26Oct2012 18:26, Tim Chase wrote: | On 10/26/12 17:03, Cameron Simpson wrote: | > On 26Oct2012 09:10, Paul Rubin wrote: | > | while (client.spop("profile_ids") as profile_id) is not None: | > | > Now this pulls me from a -0 to a +0.5. | > | > Any doco woul

Re: while expression feature proposal

2012-10-26 Thread Cameron Simpson
ggested "as" operator. -- Cameron Simpson Well, if you didn't struggle so much, you wouldn't get rope burns. -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-26 Thread Cameron Simpson
On 26Oct2012 16:48, Ian Kelly wrote: | On Fri, Oct 26, 2012 at 4:03 PM, Cameron Simpson wrote: | > It will work anywhere an expression is allowed, and superficially | > doesn't break stuff that exists if "as" has the lowest precedence. | | Please, no. There is no need fo

Re: while expression feature proposal

2012-10-26 Thread Cameron Simpson
mething as oft used as an assignment. Visually, yes, it's good. I was happy with it in Pascal and its like, though I find the succinctness of plain "=" very attractive given that it is only available on the left in Python, where it is easy to see and not prone to mixups with == late

Re: SSH Connection with Python

2012-10-27 Thread Cameron Simpson
ws python 2.7 without having to try to | recompile pycrypto myself) Many years ago we ran an ssh executable on Windows; it was a tiny standalone kit consisting, IIRC, of the Cygwin libc and ssh. Or you could just install Cygwin... That would let you use Python's subprocess module to invoke

Re: lazy properties?

2012-11-01 Thread Cameron Simpson
s with a deeper level of nesting to support chaning lock_name, prop_name and unset_object if the caller desires, but for what you want it will work out of the box. I've got a similar thing that watches files for modification and reloads at need. Cheers, -- Cameron Simpson Cordless hos

Re: accepting file path or file object?

2012-11-05 Thread Cameron Simpson
objects, since that is what you would be converting any passed filename into, and put a self call at the top to convert a filename into a file object if that is a reasonable use case in your app. Cheers, -- Cameron Simpson ...valve spreeengs? VALVE _*SPRENGS*_!?! We don' nd

Re: A gnarly little python loop

2012-11-11 Thread Cameron Simpson
from_iterable(valid_pages) | > return tweets | | I'd prefer the original code ten times over this inaccessible beast. Me too. -- Cameron Simpson In an insane society, the sane man must appear insane. - Keith A. Schauer -- http://mail.python.org/mailman/listinfo/python-list

Re: A gnarly little python loop

2012-11-11 Thread Cameron Simpson
On 11Nov2012 11:16, Steve Howell wrote: | On Nov 11, 10:34 am, Peter Otten <__pete...@web.de> wrote: | > Steve Howell wrote: | > > On Nov 11, 1:09 am, Paul Rubin wrote: | > >> Cameron Simpson writes: | > >> > | I'd prefer the original code ten times over

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Cameron Simpson
nsider case sensitivity in has_header and get_header to be a bug, absent a compelling argument against it. -- Cameron Simpson When a man rides a Motorader he stays forever young.- German saying -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching exceptions from Python 2.4 to 3.x

2012-11-16 Thread Cameron Simpson
ome other trick to grab the current exception from inside an | except block? sys.exc_info ? -- Cameron Simpson Peeve: Going to our favorite breakfast place, only to find that they were hit by a car...AND WE MISSED IT. - Don Baldwin, -- http://mail.python.org/mailman/

Re: Question on Socket Timeouts

2012-11-18 Thread Cameron Simpson
ime has elapsed, close the socket yourself. So, not via an interface to the socket but as logic in your own code. Cheers, -- Cameron Simpson Their are thre mistakes in this sentence. - Rob Ray DoD#3 -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on Socket Timeouts

2012-11-18 Thread Cameron Simpson
On 19Nov2012 14:40, I wrote: | Not the time you set up the socket, or when you accept the client's | connection. Thereafter, ever time you get some data, look at the clock. | If enough time has elapsed, close the socket yourself. That would be "Note", not "Not". Sorry.

Re: Linux compatibility

2012-11-19 Thread Cameron Simpson
a platform. The price for that is that pretty soon the versions of things supplied are quite dated. Anyway, qualify what "compatible" is supposed to mean for you. -- Cameron Simpson in rec.moto, jsh wrote: > Dan Nitschke wrote: > > Ged Martin wrote: > > > On Sat,

Re: Why queue.empty() returns False even after put() is called?

2012-11-23 Thread Cameron Simpson
ed? Or is there end-to-end handshaking controlling what .empty() tests? (Though again, the far end may have grabbed them already too.) -- Cameron Simpson The ZZR-1100 is not the bike for me, but the day they invent "nerf" roads and ban radars I'll be the first in line..AMCN -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it bad style to override the built-in function `type`?

2012-11-23 Thread Cameron Simpson
ng the parameter "type_" at the receiving end. For the calling end, as in your case, you want to use: type(blah) Is it at all possible to make all uses of your "type" function method calls? Eg: something.type("text to type") It avoids the overloading while k

Re: Is it bad style to override the built-in function `type`?

2012-11-24 Thread Cameron Simpson
On 24Nov2012 14:32, Michael Herrmann wrote: | how about "write" instead of "type"? Just came to me in a flash of inspiration. I know it's also pretty general but at least it's not a built-in! +1 -- Cameron Simpson Cars making a sudden U-turn are the most da

Re: Is it bad style to override the built-in function `type`?

2012-11-24 Thread Cameron Simpson
nd acts like other write()s it is cause for confusion. My argument is that using the name "write" is a good thing, _because_ his usage looks and acts like the other common uses of write. So I maintain it should cause less confusion. Cheers, -- Cameron Simpson It is a tale told by an idiot, full of sound and fury, signifying nothing. - William Shakespeare -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert tuples into string

2012-11-25 Thread Cameron Simpson
your are asking for the table names - the tuple itself you get back Printing repr(the-tuple-you-got-back) should present something meaningful. I'd imagine it is just a tuple of table name strings, but really I have no idea from what you have said. Cheers, -- Cameron Simpson What&

Re: Splitting Tree

2012-12-02 Thread Cameron Simpson
n the data, and then does a simplistic textual split to find the third column. Obviously you woldn't really do that for something this simple; it is to show the issue. But your situation where manipulating a tree was tricky and you converted it to a string is very similar conceptually. Hoping this shows you the issue, -- Cameron Simpson I'm not making any of this up you know. - Anna Russell -- http://mail.python.org/mailman/listinfo/python-list

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2012-12-11 Thread Cameron Simpson
as 'now'. Both have their downsides. So at the cost of shoutier but still effective code I accepted only .UPPERCASE attribute names as mapping to keys. This compromise also makes subclassing much easier, because the subclasser is free to use conventional lowercase attribute names. Che

Re: MySQLdb compare lower

2012-12-11 Thread Cameron Simpson
lised to lower case (or upper case, your call provided it is consistent), you can normalise the values in the db if they've been put in unnormalised. And then get on with your life as above. Cheers, -- Cameron Simpson Hal, open the file Hal, open the damn file, Hal open the, please Hal - Haiku Error Messages http://www.salonmagazine.com/21st/chal/1998/02/10chal2.html -- http://mail.python.org/mailman/listinfo/python-list

Re: why does dead code costs time?

2012-12-12 Thread Cameron Simpson
hree meanings? Nope. But they're separate sentiments (weasel words:-) I tend to end messages with "Cheers" myself. Though I also tend to strip it out if I am being annoyed. As you say, it is inconsistent. Cheers, -- Cameron Simpson It looked good-natured, she thought; Still it h

Re: MySQLdb compare lower

2012-12-12 Thread Cameron Simpson
for English). | """ I'm flabbergasted. [... consults the internets ...] It is still the case today:-( Ouch. Thank you for this reality check. -- Cameron Simpson Outside of a dog, a book is a man's best friend. Inside of a dog, it's too dark to read. - Groucho Marx -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQLdb compare lower

2012-12-13 Thread Cameron Simpson
On 13Dec2012 18:39, Dennis Lee Bieber wrote: | On Thu, 13 Dec 2012 18:00:48 +1100, Cameron Simpson | declaimed the following in gmane.comp.python.general: | > On 12Dec2012 02:03, Dennis Lee Bieber wrote: | > | According to the old "MySQL Language Reference" | > | "&qu

Re: Running a python script under Linux

2012-12-13 Thread Cameron Simpson
On 14Dec2012 02:45, Steven D'Aprano wrote: | I understand this is not exactly a Python question, but it may be of | interest to other Python programmers, so I'm asking it here instead of a | more generic Linux group. | | I have a Centos system which uses Python 2.4 as the system Python, so I

Re: What are the minimum requirements to get a job in?

2012-12-14 Thread Cameron Simpson
rom the end rather than the | start). If you're going to be picky, memcpy() is not required to allow for that. That allows a high speed implementation. memmove() exists to cover the more general case. -- Cameron Simpson NOTWORK: n. A network when it is acting flaky. Origin (?) IBM. - Hackers' Dictionary -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system and subprocess odd behavior

2012-12-18 Thread Cameron Simpson
process table slot; it costs the system almost nothing. It is untidy but except in extreme cases, not a performance or resource issue. OTOH, a child process that is still active (pointlessly) might be a problem... -- Cameron Simpson My initial work-around is to rebuild history. - g

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Cameron Simpson
ects from each module and hands them to whoever needs to work with them. Does this clarify your namespace issues? Cheers, -- Cameron Simpson Whatever is not nailed down is mine. What I can pry loose is not nailed down. - Collis P. Huntingdon -- http://mail.python.org/mailman/listinfo/python-list

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Cameron Simpson
quot;helpdesk" :-), If I'm at the wrong | group to get some Ideas how to solve my "issues" If you're after theoretic advice, please ask it in the context of real working example code. It removes a lot of vagueness and ambiguity. Especially if you are having trouble with

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-27 Thread Cameron Simpson
back, and hadn;t realised: - how many batteries are already included in the stdlib - how little of that library was current; re-implement the live stuff (better and cleaner) and move on - very liberating Cheers, -- Cameron Simpson Avoid bickering and petty arguments by immediately punc

Re: ignore case only for a part of the regex?

2012-12-30 Thread Cameron Simpson
ally). It should be a matter of taste. Of course, some people have bad taste:-) However if you need fuzzy matching, it is very handy if there's a library to hand that offers it. Cheers, -- Cameron Simpson Yes, sometimes Perl looks like line-noise to the uninitiated, but to the season

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Cameron Simpson
the time I would have searched for the right | command to use, decided which of the (multiple) matching commands is the | right one, then used the command, it would have been quicker and less | distracting to have just done the editing by hand. But now I'm just | repeating myself. To repeat yours

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-04 Thread Cameron Simpson
ell script called "scr" to do some common things with "screen". With no arguments: [/Users/cameron]fleet*> scr 13455.ADZAPPER 2 59094.CONSOLE_FW1 3 28691.MACPORTS 43649.PORTFWD So 4 named screen sessions

Re: how to download internet files by python ?

2013-01-07 Thread Cameron Simpson
it ? | It would be better to show me an example :) thanks !!! Look at urllib2. -- Cameron Simpson If God had intended Man to fly, He would have given him more money. - Jeff Cauhape, cauh...@twg.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Cancel threads after timeout

2013-01-26 Thread Cameron Simpson
). Snapshot each latest result. Compute your report from the latest pair of snapshots at any given time on an independent schedule. It may not be valid for what you need, but if it is then this decouples you from the query time completely. Cheers, -- Cameron Simpson Do not taunt Happy Fun Coder. -- http

Re: Cancel threads after timeout

2013-01-27 Thread Cameron Simpson
: while :; do run-sql-query1-with-snapshot-of-result; sleep 900; done & while :; do run-sql-query2-with-snapshot-of-result; sleep 900; done & while : do report on latest pair of snapshots sleep 7200 done Then he doesn't need any timeouts. Cheers, -- Cameron Simpson -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a serial stream too slowly

2012-01-23 Thread Cameron Simpson
d!") mark2 = buffer.find('$', 1) if mark2 < 0: # end of token not present # look again later break token = buffer[1:mark2] buffer = buffer[mark2+1:] if not token:

Re: Parsing a serial stream too slowly

2012-01-24 Thread Cameron Simpson
On 24Jan2012 05:08, Steven D'Aprano wrote: | On Tue, 24 Jan 2012 10:49:41 +1100, Cameron Simpson wrote: | | > | def OnSerialRead(self, event): | > | text = event.data | > | self.sensorabuffer = self.sensorabuffer + text | > | self.sensorbbuffer = self.sen

Re: Distributing methods of a class across multiple files

2012-01-24 Thread Cameron Simpson
Class really is a well defined standalone piece of functionality, this is probably more contortation than it is worth. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Hello, my name is Yog-Sothoth, and I'll be your eldritch horror today. - Heather Keith -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterate from 2nd element of a huge list

2012-01-31 Thread Cameron Simpson
ested): process1(mylist[0]) for i in xrange(1,len(mylist)): process2(mylist[i]) Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The truth is, I will not give myself the trouble to write sense long, for I would as soon please fools as wise men; because fools are

Re: Iterate from 2nd element of a huge list

2012-01-31 Thread Cameron Simpson
e cost of copying mylist[1:]. Do your timings suggest this? (Remembering also that for most benchmarking you need to run things many times unless the effect is quite large). Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Any company large enough to have a research lab is

Re: python file synchronization

2012-02-07 Thread Cameron Simpson
a files. Reading the filenames from a directory is very fast if you don't stat() them (i.e. just os.listdir). Just open and scan any new files that appear. That would be my first cut. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Performing random acts of moral ambiguit

Re: python file synchronization

2012-02-08 Thread Cameron Simpson
[ Please reply inline; it makes the discussion read like a converation, with context. - Cameron ] On 08Feb2012 08:57, Sherif Shehab Aldin wrote: | Thanks a lot for your help, I just forgot to state that the FTP server is | not under my command, I can't control how the file grow, or ho

Re: how to tell a method is classmethod or static method or instance method

2012-02-12 Thread Cameron Simpson
k and answer this question. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Reason #173 to fear technology: o o o o o o ^|\ ^|^ v|^ v|v |/v

Re: how to tell a method is classmethod or static method or instance method

2012-02-14 Thread Cameron Simpson
brought up the specific question. Simple curiosity is sufficient reason, of course. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Too young to rest on the weekend, too old to rest during the week. - Mark Randol -- http://mail.python.org/mailman/listinfo/python-list

Re: python file synchronization

2012-02-16 Thread Cameron Simpson
that your mailer files then in a "python" mail folder when they arrive so they do not clutter your inbox. | Many thanks to you, and I will keep you posted if I got other ideas. :) Excellent. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Q: How does a hacker fix a function which doesn't work for all of the elements in its domain? A: He changes the domain. -- http://mail.python.org/mailman/listinfo/python-list

Re: parse a profile

2012-02-18 Thread Cameron Simpson
', 1) except ValueError: # ouch! continue oldvalue = os.environ.get(var) if oldvalue is None or oldvalue != value: newvars[var] = value You can put the wrapper script as a single inline piece of shell to avoid the separate file once debugged. Just a thought. Cheer

Re: webbrowser.open always opens up Safari on Lion

2012-02-25 Thread Cameron Simpson
prompt in a Terminal: open file://localhost/nonexistingfile and open http://www.python.org/ Do they both open Chome for you? -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ DRM doesn't inconvenience pirates ¿ indeed, over time it trains law-abiding users to beco

this afternoon's duck typing exercise ...

2012-03-01 Thread Cameron Simpson
Sorry, little technical content here, just a newly hatched programmer: duck typing, an intro http://www.flickr.com/photos/cskk/6799351990/in/photostream/ duck typing, resting after the demo http://www.flickr.com/photos/cskk/6945461405/in/photostream/ Cheers, -- Cameron Simpson DoD#743

Re: html5lib not thread safe. Is the Python SAX library thread-safe?

2012-03-11 Thread Cameron Simpson
lf, prop_name, p) return p return property(getprop) It tries to be lockless in the common case. I suspect it is only safe in CPython where there is a GIL. If raw python assignments and fetches can overlap (eg Jypthon I think?) I probably need shared "read" lock around the fir

Re: Launching A Truly Disjoint Process

2012-03-11 Thread Cameron Simpson
run("execfile(os.environ[\"bdb_execfile\"])")', ) ) That "import..." string is all one line. Of course various arguments to Popen as required, etc. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Here's a great .sig I wrote, so good it doesn't rhyme. Jon Benger -- http://mail.python.org/mailman/listinfo/python-list

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Cameron Simpson
nd, and potentially saves a lot of code verbiage (gratuitous type= prarameters). I say "gratuitous" because unless `default` is a sentinel for "no option supplied", the `type` should always match type(default). Or am I wrong about that? Cheers, -- Cameron Simpson DoD#743 http://ww

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-15 Thread Cameron Simpson
On 15Mar2012 10:06, Robert Kern wrote: | On 3/15/12 5:59 AM, Cameron Simpson wrote: | > On 15Mar2012 12:22, Ben Finney wrote: | > | Roy Smith writes: | > |> I'll admit I hadn't considered that, but I don't see it as a major | > |> problem. The type intuition c

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-15 Thread Cameron Simpson
ackwards | compatability). It's really hard to get your head around "type=open". "factory"? Anyway, far too late to change this now! -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ all coders are created equal; that they are endowed with certain unalienabl

Re: Is there a ConfigParser which keeps comments

2012-03-15 Thread Cameron Simpson
_simpson/css/src/ef42896872b5/bin/winclauseappend One could imagine an efficient python implementation and a ConfigParser subclass that patched the file if a setting got changed, or had a .patch method to apply particular setting changes as desired. Cheers, -- Cameron Simpson DoD#743 http://www.cs

Re: Daemonization / Popen / pipe issue

2012-03-17 Thread Cameron Simpson
efore firing off any subprocesses or threads. Is this correct? If the daemonising happened per thread that would be very bad. BTW, Lee, there is an external module for daemonising things in the UNIX sense: http://pypi.python.org/pypi/python-daemon I recommend you use it. Cheer

Python-URL! - weekly Python news and links (Mar 31)

2012-04-02 Thread Cameron Laird
I pine for the fjords. And it's time to bring "Python-URL!" to a close. "Python-URL!", which Jean-Claude Wippler and I appear to have launched in 1998, has reached the end of its utility. We still have many loyal and enthusiastic readers--one subscription request arrived within the last day, in

Python-URL! - weekly Python news and links (Mar 31)

2012-04-02 Thread Cameron Laird
I pine for the fjords. And it's time to bring "Python-URL!" to a close. "Python-URL!", which Jean-Claude Wippler and I appear to have launched in 1998, has reached the end of its utility. We still have many loyal and enthusiastic readers--one subscription request arrived within the last day, in

Re: Python Gotcha's?

2012-04-04 Thread Cameron Simpson
ng "return" means "return None". One only has to miss a control path to have this happen. Easy enough to accomodate, if only by having a return or raise at the end of the function, but ... -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ I really don't like :-

Re: Python Gotcha's?

2012-04-04 Thread Cameron Simpson
tor uses functools.wraps(). There's a functools.wraps()? [*smacks forehead with palm*] Thanks. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ A pessimist is an optimist in full possession of the facts. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-04 Thread Cameron Simpson
d "module/package". In general I have a nagging desire that modules were more like classes. But the details remain nebulous in my mind. The property thing is the only concrete thing I trip over at present. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Louis Pasteu

Re: Python Gotcha's?

2012-04-05 Thread Cameron Simpson
er... (I guess I should test that instead of asking such a dumb question). -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ You see, wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. Do you understand this? And rad

Re: Python Gotcha's?

2012-04-05 Thread Cameron Simpson
much if you need both, but it covers a common use. Personally I'm ok with JSON accepting only one kind of quote. And I _have_ been bitten by it and surprised in the past. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ This telephone has too many shortcomings to be serious

Re: 'string_escape' in python 3

2012-04-06 Thread Cameron Simpson
ugly (and slightly 'wrong'). Is there no way to do | > this without using bytes? Have I missed something? | | >>> eval("'"+s+"'") | 'Hello: this is a test' https://xkcd.com/327/ -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Every \item command in item_list must have an optional argument. - Leslie Lamport, LaTeX -- http://mail.python.org/mailman/listinfo/python-list

Re: Python randomly exits with Linux OS error -9 or -15

2012-04-09 Thread Cameron Simpson
The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet. A negative value -N indicates that the child was terminated by signal N (Unix only). So there you go. SIGKILL and SIGTERM, definitely. R

is this foolish?

2012-04-12 Thread Cameron Simpson
to use their own. I can think of a few potential downsides, but on the whole this is going to do exactly what I want in this case. Would experienced users please mock me? -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Real Daleks don't climb stairs Real Daleks level the b

Re: is this foolish?

2012-04-12 Thread Cameron Simpson
On 12Apr2012 19:43, Chris Angelico wrote: | On Thu, Apr 12, 2012 at 7:35 PM, Cameron Simpson wrote: | > I've found myself using a Python gotcha as a feature. | > I've got a budding mail filter program which keeps rule state in a | > little class instance. Slightly paraphrase

Re: is this foolish?

2012-04-12 Thread Cameron Simpson
On 12Apr2012 10:44, gene heskett wrote: | On Thursday, April 12, 2012 10:40:47 AM Tim Golden did opine: | > On 12/04/2012 10:35, Cameron Simpson wrote: | > > I've found myself using a Python gotcha as a feature. | > | Tim: your setup of using the CC: line for every thin

Re: Naming future objects and their methods

2012-04-15 Thread Cameron Simpson
t; way to name the | future returned by `put_bytes` and possibly the `was_sent` | method attached to it? Can you even come up with nice naming | rules for futures and their methods? :-) I'd call it "packet", and was_sent just "sent". if packet.sent(timeout=1.0): Cheers

Re: A case for "real" multiline comments

2012-04-18 Thread Cameron Simpson
ould say you've made a case _against_ multiline coments. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Sam Jones on the Nine Types of User: Frying Pan/Fire Tactician - "It didn't work with the data set we had, so I fed in my a

Re: A case for "real" multiline comments

2012-04-18 Thread Cameron Simpson
On 19Apr2012 15:13, Chris Angelico wrote: | On Thu, Apr 19, 2012 at 2:29 PM, Cameron Simpson wrote: | > On 18Apr2012 22:07, Jordan Perr wrote: | > | I came across this case while debugging some Python code that contained an | > | error stemming from the use of multiline strings as comm

Re: Regular expressions, help?

2012-04-18 Thread Cameron Simpson
): death toll\D*(\d+) or death toll\D*(\d[\d,.]*) and also use re.find instead of re.match; re.find will find the first match anywhere in the string, avoiding complicating the regexp with a leading ".*". \D is a non-digit. "+" means one or more like "*" means ze

Re: How do you refer to an iterator in docs?

2012-04-19 Thread Cameron Simpson
On 19Apr2012 14:32, Terry Reedy wrote: | On 4/19/2012 11:51 AM, Jacob MacDonald wrote: | > When I talk about an iterable, I say "iterable". | | Ditto. I used to, but find myself saying "sequence" these days. It reads better, but is it the same thing? Cheers, -- Camero

Re: How do you refer to an iterator in docs?

2012-04-19 Thread Cameron Simpson
On 19Apr2012 18:07, Terry Reedy wrote: | On 4/19/2012 5:32 PM, Cameron Simpson wrote: | > On 19Apr2012 14:32, Terry Reedy wrote: | > | On 4/19/2012 11:51 AM, Jacob MacDonald wrote: | > |> When I talk about an iterable, I say "iterable". | > | | > | Ditto. | >

Re: Communication between C++ server and Python app

2012-04-28 Thread Cameron Simpson
want to consider a Unix socket too. A UNIX socket or even a named pipe has the benefit of: - not being available remotely - access control with normal UNIX permissions and of course efficiency as you say. Generalising to a TCP socket later shouldn't be too hard if the need arises. Cheers

Re: Learn Technical Writing from Unix Man in 10 Days

2012-04-28 Thread Cameron Simpson
mponent": "installation is the reverse of the disassembly". Fair enough. However, I notice that my Haynes manuals on livestock do not include this sentence in the butchering chapters:-) Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Ride Free, Ride Nude! - David Jevans -- http://mail.python.org/mailman/listinfo/python-list

Re: Communication between C++ server and Python app

2012-04-29 Thread Cameron Simpson
On 29Apr2012 21:08, Chris Angelico wrote: | On Sun, Apr 29, 2012 at 4:24 PM, Cameron Simpson wrote: | > On 29Apr2012 11:42, Chris Angelico wrote: | > | Personally, I would recommend a TCP socket, because that allows the | > | flexibility of splitting across multiple computers. | >

Re: Converting a string to list for submission to easygui multenterb​ox

2012-05-01 Thread Cameron Simpson
. Call the | built-in function list() and pass the tuple as an intializer: Supposedly he should not need to. From: http://www.ferg.org/easygui/tutorial.html#contents_item_10.2 the sentence: "The choices are specified in a sequence (a tuple or a list)." I do not believe that ksals needs to cha

Re: Converting a string to list for submission to easygui multenterb​ox

2012-05-01 Thread Cameron Simpson
7;s', "'", ',', ' ', "'", | "'", ',', ' ', "'", "'", ',', ' ', "'", "'", | ')'] Ok, that really does look like "choice" is a string. I'm really very surprised. What does this do? choices = easygui.multchoicebox(msg1, title, qstack) print("type(choices) =", type(choices)) print("choices =", repr(choices)) Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ If you lie to the compiler, it will get its revenge.- Henry Spencer -- http://mail.python.org/mailman/listinfo/python-list

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