RE: Hooking exceptions outside of call stack

2007-06-10 Thread Warren Stringer
Hey Josiah, I just spent a couple hours with your example, and it explains a lot. Some of your interactive session got garbled, so am reposting your merged_namespace example, with tweaks: #- def merged_namespace(*ns): try: __builti

RE: Is PEP-8 a Code or More of a Guideline?

2007-05-29 Thread Warren Stringer
y project? Perhaps a few lines of script to add CamelBack support, using an amplitude increase for initial caps and maybe lingering on the initial phoneme for an extra 100 milliseconds. So then, the above example would read: "camel link dot set Parse Action between parens emit Link H T M L j

c[:]()

2007-05-30 Thread Warren Stringer
# huh? a >>> [i() for i in c] # too long and ...huh? a b [None,None] #-- Why? Because I want to make Python calls from a cell phone. Every keystroke is precious; even list comprehension is too much. Is there something obvious that I'm mis

RE: c[:]()

2007-05-30 Thread Warren Stringer
oster) ... \~/ > -Original Message- > From: [EMAIL PROTECTED] [mailto:python-list- > [EMAIL PROTECTED] On Behalf Of Carsten Haese > Sent: Wednesday, May 30, 2007 12:55 PM > To: python-list@python.org > Subject: Re: c[:]() > > On Wed, 2007-05-30 at 11:48 -0700, Warren Stringer wrote: > &g

RE: c[:]()

2007-05-30 Thread Warren Stringer
; [EMAIL PROTECTED] On Behalf Of Brian van den Broek > Sent: Wednesday, May 30, 2007 3:00 PM > To: python-list@python.org > Subject: Re: c[:]() > > Warren Stringer said unto the world upon 05/30/2007 05:31 PM: > > Hmmm, this is for neither programmer nor computer; this is f

RE: c[:]()

2007-05-30 Thread Warren Stringer
python list. Cheers, \~/ > -Original Message- > From: [EMAIL PROTECTED] [mailto:python-list- > [EMAIL PROTECTED] On Behalf Of Dustan > Sent: Wednesday, May 30, 2007 4:14 PM > To: python-list@python.org > Subject: Re: c[:]() > > On May 30, 5:37 pm, "Warre

RE: c[:]()

2007-05-30 Thread Warren Stringer
Oops! guess I should have tested my rather hasty complaint about executable containers. This is nice: def a(): return 'b' def b(): print 'polly! wakey wakey' c = {} c['a'] = b c[a()]() #works! c[a()]() is a switch statement with an amorphous selector- very handy in its own right. But, using a()

RE: c[:]()

2007-05-31 Thread Warren Stringer
Hey Douglas, Perhaps I was being too abstract? Here goes: ,--- | def selector(): |... |return funcKey #get down get down | | def func(): |... | funcSwitch = {} | funcSwitch[funcKey] = func | ... | funcSwitch[selector()]() even more intere

RE: c[:]()

2007-05-31 Thread Warren Stringer
On Behalf Of Mikael Olofsson > Sent: Thursday, May 31, 2007 1:52 AM > To: python-list@python.org > Subject: Re: c[:]() > > Warren Stringer wrote: > > I want to call every object in a tupple, like so: > > [snip examples] > > Why? Because I want to make Python call

RE: c[:]()

2007-05-31 Thread Warren Stringer
Hey Marc, > > [d() for d in c] > > If you are using the list comprehension just for the side effect of > calling `d` then consider this bad style. You are building a list of > `None` objects just to have a "cool" one liner then. Yep, you're right > for func in funcs: > func() > > Becaus

RE: c[:]()

2007-05-31 Thread Warren Stringer
> > > > But that still isn't as simple or as direct as: > > > > c[:]() > > Why do you always use a _copy_ of c in your examples? As long > as you're wishing, why not just > > c() Oh hey Grant, yes, I misunderstood your question for a bit. I thought you meant the difference between List compr

RE: Is PEP-8 a Code or More of a Guideline?

2007-05-31 Thread Warren Stringer
Perhaps a foot pedal? Hmmm My two cellphones don't like underbars very much. And the shift key -- while much easier -- still is cumbersome. If outlook didn't autocaps on me, this message would be in all lowercase. In fact, when communicating with friends from outlook, to their sms, I take the

RE: c[:]()

2007-05-31 Thread Warren Stringer
> How is it more expressive? In the context you're concerned > with, c[:] is the exactly same thing as c. You seem to be > worried about saving keystrokes, yet you use c[:] instead of c. > > It's like having an integer variable i and using ((i+0)*1) > instead of i. Nope, different. c[:] holds

Passing a tuple to a function as multiple arguments

2007-09-06 Thread Ben Warren
Hello, Let's say I have a function with a variable number of arguments (please ignore syntax errors): def myfunc(a,b,c,d,...): and I have a tuple whose contents I want to pass to the function. The number of elements in the tuple will not always be the same. T = A,B,C,D,... Is there a way th

logging module and trailing newlines

2007-10-02 Thread Russell Warren
I was just setting up some logging in a make script and decided to give the built-in logging module a go, but I just found out that the base StreamHandler always puts a newline at the end of each log. There is a comment in the code that says "The record is then written to the stream with a trailin

Re: logging module and trailing newlines

2007-10-03 Thread Russell Warren
Both are very good responses... thanks! I had forgotten the ease of "monkey-patching" in python and the Stream class is certainly cleaner than the way I had been doing it. On Oct 3, 3:15 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Russell Warren wrote: > > All I'

Re: Looking for a good Python environment

2007-11-11 Thread Russell Warren
> While we're at it, do any of these debuggers implement a good way to > debug multi-threaded Python programs? Wing now has multi-threaded debugging. I'm a big Wing (pro) fan. To be fair, when I undertook my huge IDE evaluation undertaking it was approx 2 years ago... at the time as far as what

Speed of shutil.copy vs os.system("copy src dest") in win32

2006-04-26 Thread Russell Warren
I just did a comparison of the copying speed of shutil.copy against the speed of a direct windows copy using os.system. I copied a file that was 1083 KB. I'm very interested to see that the shutil.copy copyfileobj implementation of hacking through the file and writing a new one is significantly f

Re: win32com short path name on 2k

2006-04-26 Thread Russell Warren
I've been driven crazy by this type of thing in the past. In my case it was with the same application (not two like you), but on different machines, with all supposedly having the same OS load. In some cases I would get short path names and in others I would get long path names. I could never fig

Popping from the middle of a deque + deque rotation speed

2006-04-28 Thread Russell Warren
Does anyone have an easier/faster/better way of popping from the middle of a deque than this? class mydeque(deque): def popmiddle(self, pos): self.rotate(-pos) ret = self.popleft() self.rotate(pos) return ret I do recognize that this is not the intent of a deque, given the clear

Re: Popping from the middle of a deque + deque rotation speed

2006-05-01 Thread Russell Warren
Thanks for the responses. > It seems to work with my Python2.4 here. If you're > interested in efficiency, I'll leave their comparison as an > exercise to the reader... :) Ok, exercise complete! :) For the record, they are pretty much the same speed... >>> s = """ ... from collections import d

Re: Popping from the middle of a deque + deque rotation speed

2006-05-01 Thread Russell Warren
> So does the speed of the remaining 0.001 cases really matter? Note > that even just indexing into a deque takes O(index) time. It doesn't matter as much, of course, but I was looking to make every step as efficient as possible (while staying in python). As to indexing into a deque being O(inde

Re: embedded python in c++ packaging

2008-02-07 Thread Warren Myers
The Python byte-code files are already pretty dense, so compressing them further is unlikely to work if you try to put them in a zip. WMM On Feb 7, 2008 11:39 AM, Furkan Kuru <[EMAIL PROTECTED]> wrote: > Hello, > > I have been developing an application in C++ that embeds Python > interpreter. >

Re: dream hardware

2008-02-12 Thread Warren Myers
/me no longer wishes to know about your dreams. WMM On Feb 12, 2008 4:56 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote: > > > What is dream hardware for the Python interpreter? > > I'm not sure that the Python interpreter actually does dream

Re: dream hardware

2008-02-12 Thread Warren Myers
A Cray? What are you trying to do? "dream" hardware is a very wide question. WMM On Feb 12, 2008 1:05 PM, <[EMAIL PROTECTED]> wrote: > What is dream hardware for the Python interpreter? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://warrenmyers.com "God may not play

Is crawling the stack "bad"? Why?

2008-02-24 Thread Russell Warren
I've got a case where I would like to know exactly what IP address a client made an RPC request from. This info needs to be known inside the RPC function. I also want to make sure that the IP address obtained is definitely the correct one for the client being served by the immediate function call

Re: Is crawling the stack "bad"? Why?

2008-02-24 Thread Russell Warren
Argh... the code wrapped... I thought I made it narrow enough. Here is the same code (sorry), but now actually pasteable. --- import SimpleXMLRPCServer, xmlrpclib, threading, sys def GetCallerNameAndArgs(StackDepth = 1): """This function returns a tuple (a,b) where: a = The name of the ca

Re: Is crawling the stack "bad"? Why?

2008-02-24 Thread Russell Warren
> That is just madness. What specifically makes it madness? Is it because sys._frame is "for internal and specialized purposes only"? :) > The incoming ip address is available to the request handler, see the > SocketServer docs I know... that is exactly where I get the address, just in a mad wa

Re: Is crawling the stack "bad"? Why?

2008-02-25 Thread Russell Warren
> How about a dictionary indexed by by the thread name. Ok... a functional implementation doing precisely that is at the bottom of this (using thread.get_ident), but making it possible to hand around this info cleanly seems a bit convoluted. Have I made it more complicated than I need to? There

Re: Is crawling the stack "bad"? Why?

2008-02-25 Thread Russell Warren
convincing argument yet on why crawling the stack is considered bad? I kind of hoped to come out of this with a convincing argument that would stick with me... On Feb 25, 12:30 pm, Ian Clark <[EMAIL PROTECTED]> wrote: > On 2008-02-25, Russell Warren <[EMAIL PROTECTED]> wrote: > > &

Re: Is crawling the stack "bad"? Why?

2008-02-28 Thread Russell Warren
> OK, if you crawl the stack I will seek you out and hit you with a big > stick. Does that affect your decision-making? How big a stick? :) > Seriously, crawling the stack introduces the potential for disaster in > your program, since there is no guarantee that the calling code will > provide the

"as" keyword woes

2008-12-03 Thread Warren DeLano
preserve compatibility with existing third-party scripts & infrastructure which routinely rely upon "as" as an object method. Sigh.) Cheers, Warren -- http://mail.python.org/mailman/listinfo/python-list

Re: "as" keyword woes

2008-12-03 Thread Warren DeLano
> Because it can be used at the import statement to let the imported thing > be known under another name? > Something like: > > >>> import xml.etree.ElementTree as ET Yes, but that syntax worked fine for years without "as" actually having to be a keyword. There must be something more going on h

"as" keyword woes

2008-12-03 Thread Warren DeLano
ut an "as" keyword. I do sincerely hope I am wrong about this, but it is seems quite possible that C/Python's glory days are now behind us. And if so, then thank you all for so many wonderful years of effort and participation! C/Python has had a great run, and Python syntax, i

Re: "as" keyword woes

2008-12-04 Thread Warren DeLano
thon will easily transcend the limitations of its flagship implementation (if or to the extent that such an implementation cannot keep pace with the times). That's all well and good -- it may even end up being the next great leap forward for the language. I believe Guido has even said as much himself. Warren -- http://mail.python.org/mailman/listinfo/python-list

"as" keyword woes

2008-12-04 Thread Warren DeLano
e indeed the optimal solution to certain problems, and those problems are still not solvable with CPython 3.0. Is it too much to hold out hope for a native Pythonic solution to the multithreading performance issues inside of the CPython VM itself? Only time will tell... but time is rapidly running out. Warren -- http://mail.python.org/mailman/listinfo/python-list

To Troll or Not To Troll

2008-12-04 Thread Warren DeLano
> Yet Another Python Troll (the ivory tower reference, as well as the > abrupt shift from complaining about keywords to multiprocessing), I > have to point out that Python does add new keywords, it has done so in > the past, and there was a considerable amount of warning, including an > automated d

RE: To Troll or Not To Troll

2008-12-04 Thread Warren DeLano
> I still would have to call your management of the problem considerably > into question - your expertise at writing mathematical software may > not be in question, but your skills and producing and managing a > software product are. You have nobody at your organization, which > sells a product tha

"as" keyword woes

2008-12-04 Thread Warren DeLano
on, I recognize that there will be ancillary casualties in every major battle. Though I may whine incessantly about all of our pre-2.5 log-file/documents being one such casualty (your various accusations notwithstanding, we did indeed patch our own code as soon as the deprecation warnings appeared

Re: To Troll or Not To Troll (aka: "as" keyword woes)

2008-12-04 Thread Warren DeLano
'll put this more bluntly: Warren's messages to date > egregiously break the flow of discussion. > > Warren, in the interest of sane discussion in these forums, please: > > * preserve attribution lines on quoted material so we can see who > wrote what. > > * use the conve

Re: "as" keyword woes

2008-12-06 Thread Warren DeLano
standalone keyword " as ". It seems to me that it should be possible to unambiguously separate the two without ambiguity or undue complication of the parser. So, assuming I now wish to propose a corrective PEP to remedy this situation for Python 3.1 and beyond, what is the best way to get started on such a proposal? Cheers, Warren -- http://mail.python.org/mailman/listinfo/python-list

Re: "as" keyword woes

2008-12-06 Thread Warren DeLano
ot;, as a Python keyword, is a here to stay: Love it or leave it. -> Likewise ditto for the GIL: if you truly need Python concurrency within a single process, then use a Python implementation other than CPython. Season's greetings to all! Peace. Cheers, Warren -- http://mail.python.org/mailman/listinfo/python-list

Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Warren DeLano
above approach is NOT secure since object attributes can still be accessed... So is there an equally convenient yet secure alternative available for parsing strings containing Python data structure definitions? Thanks in advance for any pointers! Cheers, Warren -- http://mail.python.org/mailman/listinfo/python-list

RE: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Warren DeLano
ay's web apps wouldn't exist without safe forms of untrusted eval/exec (Javascript anyone?). Such dogma is appropriate when dealing with the CPython VM, but not as a general principle. "Rocket fuel may be dangerous, but you ain't shooting the moon without it!" Cheers, Wa

RE: Python-list Digest, Vol 61, Issue 368

2008-10-24 Thread Warren DeLano
done much more easily from Python than from C (e.g. data organization, U.I. survey/present tasks, rarely used transformations, ad hoc scripting experiments, etc.). Cheers, Warren -- http://mail.python.org/mailman/listinfo/python-list

"proper"/best way to hack SimpleXmlRpcServer to support datetime?

2008-07-18 Thread Russell Warren
I'm running python 2.5.1 and it seems that SimpleXmlRpcServer is not setup to support the base datetime module in the same way xmlrpclib has been with "use_datetime". I see that someone (Virgil Dupras) has recently submitted a fix to address this, but I don't want to patch my python distro. I wan

Re: Python Written in C?

2008-07-29 Thread Warren Myers
d"< instruction count was significantly higher for C++. I expect any sort > of C++ objects you used to implement Python structures will be slower > than the equivalent in C. So even if writing it in C++ would reduce > the overhead for deleting from a list, I expect you would lose a lot > more. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Warren Myers http://warrenmyers.com -- http://mail.python.org/mailman/listinfo/python-list

Seems like I want a pre-processor, but...

2006-03-28 Thread Russell Warren
After some digging it seems that python does not have any equivalent to C's #if directives, and I don't get it... For example, I've got a bit of python 2.3 code that uses collections.deque.pop(0) in order to pop the leftmost item. In python 2.4 this is no longer valid - there is no argument on po

Re: Seems like I want a pre-processor, but...

2006-03-28 Thread Russell Warren
> the collections module was added in 2.4 Ah... sorry about that. I should have checked my example more closely. What I'm actually doing is rebinding some Queue.Queue behaviour in a "safe" location like this: def _get(self): ret = self.queue.popleft() DoSomethingSimple() return ret And se

Re: Seems like I want a pre-processor, but...

2006-03-28 Thread Russell Warren
Thanks guys - all great responses that answered my question in a few different ways with the addition of some other useful tidbits! This is a nice summary: > In general the idea is to move the test from 'every time I need to do > something' to 'once when some name is defined'. Gotta love the resp

Re: Seems like I want a pre-processor, but...

2006-03-29 Thread Russell Warren
Yes, I definitely should have done that for that case. I'm not entirely sure why I didn't. If I had, though, I may not have been prompted to ask the question and get all the other great little tidbits! -- http://mail.python.org/mailman/listinfo/python-list

* for generic unpacking and not just for arguments?

2009-11-29 Thread Russell Warren
Is there a reason that this is fine: >>> def f(a,b,c): ... return a+b+c ... >>> f(1, *(2,3)) 6 but the code below is not? >>> x = (3, 4) >>> (1, 2, *x) == (1, 2, 3, 4) Traceback (most recent call last): File "", line 1, in invalid syntax: , line 1, pos 8 Why does it only work when unpackin

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Russell Warren
On Nov 29, 11:09 am, Christian Heimes wrote: > The feature is available in Python 3.x: > > >>> a, b, *c = 1, 2, 3, 4, 5 > >>> a, b, c > (1, 2, [3, 4, 5]) > >>> a, *b, c = 1, 2, 3, 4, 5 > >>> a, b, c > > (1, [2, 3, 4], 5) Interesting... especially the recognition of how both ends work with the "a,

Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Russell Warren
I'm having trouble understanding when variables are added to namespaces. I thought I understood it, but my nested function examples below have me very confused. In each test function below I have an x variable (so "x" is in the namespace of each test function). I also have a nested function in e

Re: Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Russell Warren
My tests were run in python 2.6.5. -- http://mail.python.org/mailman/listinfo/python-list

Python script produces "sem_trywait: Permission denied"

2005-01-11 Thread Brown, Warren R
tell me if a more serious problem is looming.   --- warren.     -- http://mail.python.org/mailman/listinfo/python-list

<    1   2