Re: socket setdefaulttimeout

2005-08-12 Thread Bryan Olson
ystems offer an asynchronous gethostbyname, but that doesn't help users of Python's library. Some programmers would keep around a few extra processes to handle their hosts lookups. Fortunately, threading systems are now much better, and should only block the thread waiting for gethos

Re: thread limit in python

2005-08-12 Thread Bryan Olson
s are good, see: http://www.usenix.org/events/hotos03/tech/vonbehren.html For an example of a high-performance server that uses massive threading, I'd nominate MySQL. Prediction: Ten years from now, someone will ask that same "What possible use..." question, except the number of

Re: Catching stderr output from graphical apps

2005-08-12 Thread Bryan Olson
Thanks. Yeah, guess I was naive to test on Windows and expect that kind of process stuff to be portable. I'll be away from Linux for a week or so, so this will take me a while. Further bulletins as events warrant. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: MainThread blocks all others

2005-08-11 Thread Bryan Olson
Nodir Gulyamov wrote: > [...]I should show you real code [...] > Please find below real code. Sorry for amount of sources. Yeah, it's too much for me. Can you construct a minimal example that doesn't do what you think it should? -- --Bryan -- http://mail.python.org/mailman

Re: constructing bytestrings

2005-08-11 Thread Bryan Olson
7;s3 = s1+s', but I > don't know how to construct s1 dynamically (i.e., given N, construct > "N" followed by N-1 "0", where "N" and "0" are single byte values with > N<16). How do I do this? chr(N) + '\x00' * (N - 1) -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression to match a #

2005-08-11 Thread Bryan Olson
ather-than-on-experimentation assertion, or redefine "not > dopey" to mean "surely nobody would search for ^x when match x would do, > so it would be dopey to optimise re for that" :-) No question, there's some dopiness to searching for the beginning of the string a

Re: Bug in slice type

2005-08-11 Thread Bryan Olson
range(9, -1, -2)] > [9, 7, 5, 3, 1] > >>> > > Looks good to me. indices has returned a usable (start, stop, step). > Maybe the docs need expanding. But not a usable [start: stop: step], which is what 'slice' is all about. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in slice type

2005-08-11 Thread Bryan Olson
port. > BTW, a simpler example of the same phenomenon is: > > py> range(10)[slice(None, None, -2)] > [9, 7, 5, 3, 1] > py> slice(None, None, -2).indices(10) > (9, -1, -2) > py> range(10)[9:-1:-2] > [] Ah, thanks. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: thread limit in python

2005-08-11 Thread Bryan Olson
kely problem is that the stack size is too large, so you're running out of virtual address space. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: zipfile library - problem..

2005-08-11 Thread Bryan Olson
Sorry to sound like an old guy, but wow, how times change. Incidentally, since your files are jpegs, they're already compressed, and thus TarFile should be just as good as ZipFile anyway. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython and threads again

2005-08-10 Thread Bryan Olson
from foreign thread.') And then begin each non-thread-safe function like: def SomeUpdateFunction(*args): check_thread() # ... [...] > Even simpler for some purposes is wx.CallAfter(), Ah, Nice. Same method under the hood, but hides the complexity. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching stderr output from graphical apps

2005-08-10 Thread Bryan Olson
eback (most recent call last):$ > > Any idea what's wrong? Darn. Are you on Windoze/Mac/Unix/, and what version? If you can spare the time, could you please try: import errorwindow import sys sys.stderr.write("Hello\nWorld.\n") x = 7 + nosuchvariable and t

Re: wxPython and threads again

2005-08-10 Thread Bryan Olson
le thread just to manage a download process which is motly IO and a little bookkeeping is > silly. Twisted's approach just makes a lot more sense and simplifies the code too. I couldn't disagree more about that being easier and simplifying the code. "Creating a whole thread" is trivial. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Bug in slice type

2005-08-10 Thread Bryan Olson
Good start-stop-step values are (9, None, -2), or (9, -11, -2), or (-1, -11, -2). The later two have the advantage of being consistend with the documented behavior of returning three integers. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: MainThread blocks all others

2005-08-10 Thread Bryan Olson
in doSomeJob, so no one can ever trigger the even. > > Actually I have 2 threads. One of them is MainThread and second one is > created by Observer in which update method called. Whatever other thread you have in other code, this code is whacked. Who do you think calls cl1.increaseCounter(), and how did they get a reference to cl1? -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: how to write thread-safe module ? and pytz

2005-08-10 Thread Bryan Olson
? > > Can someone give me a hint ? In the current Python implementation, more things are atomic than the language guarantees to be atomic. Programmers should not depend on that behavior. Again, I don't know anything about pytz, but we wouldn't bother with locks and semaphores an

Re: Why is this?

2005-08-10 Thread Bryan Olson
: > > a, b, c, d = [], [], [], [] Incidentally, to create a list of 37 distinct empty lists, you can use: [[] for _ in range(37)] -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: MainThread blocks all others

2005-08-10 Thread Bryan Olson
self.c.increaseCounter() > > if __name__ == "__main__": > cl1 = class1() > m = monitor(cl1) > mo = MonitorObserver(m) Obviously that won't work. You only have one thread, and it blocks in doSomeJob, so no one can ever trigger the even. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: MainThread blocks all others

2005-08-10 Thread Bryan Olson
Nodir Gulyamov wrote: > Hi Bryan, > Thanks for your reply. > I tried to test your solution, but it doesn't work, hence > threading.Semaphore object hasn't method to get value of semaphore. > I looked to source code of semaphore.py and find out that value is p

Re: Catching stderr output from graphical apps

2005-08-10 Thread Bryan Olson
Peter Hansen wrote: > Bryan Olson wrote: > >> Here's a module to show stderr output from console-less Python >> apps, and stay out of the way otherwise. I plan to make a ASPN >> recipe of it, but I thought I'd run it by this group first. > > For wha

Catching stderr output from graphical apps

2005-08-09 Thread Bryan Olson
indow a = 3 + 1 + nonesuchdefined should cause a window to appear, showing the traceback of a Python NameError. -- --Bryan """ Import this module into graphical Python apps to provide a sys.stderr. No

Re: Creating a virtual file system

2005-08-09 Thread Bryan Olson
way to make resources show up in Network > Neighborhood. [...] Hmmm, you have a point. Looks like he has elements of both local file systems and networking protocols. To make his special filesystem transparent to MS-Windows programs is an installable- filesystem problem, which is what I was looking at. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a virtual file system

2005-08-09 Thread Bryan Olson
Jeff Schwab wrote: > You don't have to pay Microsoft to develop a Windows-compatible > filesystem. See http://ubiqx.org/cifs/. That's a different usage of "filesystem" than what is at issue here. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: zipped socket

2005-08-09 Thread Bryan Olson
er strings of data and are used to allow partial error recovery on decompression That's not correct. Z_FULL_FLUSH allows recovery after errors, but Z_SYNC_FLUSH is just to allow pushing all the compressor's input to the decompressor's output. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a virtual file system

2005-08-09 Thread Bryan Olson
ows IFS (Installable File System) Developer's Kit costs like $900. Doing it well would be a large and expensive project. Read their posts for more discouragement. > Thanks forward for help. Not exactly helpful was I? Sorry. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Putting function references in a Queue

2005-08-09 Thread Bryan Olson
27;s a good thing to do. The tricky part is getting an event loop to wait on both the queue and other kinds of events. Periodic polling works, but kind of sucks. What's the 'done' argument? A lock maybe? -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: MainThread blocks all others

2005-08-09 Thread Bryan Olson
ase() def doSomeJob(self): # Busy-waiting sucks. # while counter != 1: #pass self.counter.acquire() # ... continue... -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: MainThread blocks all others

2005-08-09 Thread Bryan Olson
mport threading class class1: def __init__(self): self.counter = threading.semaphore(0) result = doSomeJob() def increaseCounter(self): self.counter.release() doSomeJob(self): # Busy-waiting sucks. # while counter != 1: #pass

Re: os._exit vs. sys.exit

2005-07-29 Thread Bryan
arifications. One more question, can I catch this exception in my main thread and then do another sys.exit() to kill the whole process? Apparently sys.exit() allows the program to clean up resources and exit gracefully, while os._exit() is rather abrupt. Bryan -- http://mail.python.org/mailman/listinfo/python-list

os._exit vs. sys.exit

2005-07-28 Thread Bryan
Quick question: Why does os._exit called from a Python Timer kill the whole process while sys.exit does not? On Suse. Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: PyGTK or wxPython (not a flame war) on Windows

2005-07-24 Thread Bryan
to see wx included in the standard distrubution. bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: checking for when a file or folder exists, typing

2005-06-12 Thread Bryan Rasmussen
>Hi Bryan, >Here's a potential idea. Try converting the variable to a string by >using the following syntax: > thePath = str(thePathArg) Actually it was a stupid thing, what happened was I was looping through the commandline to build a file path in cases where there

checking for when a file or folder exists, typing problems?

2005-06-12 Thread Bryan Rasmussen
tting something unexpected obviously. Any help on what this error is? Thanks -- Bryan Rasmussen -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python regex Doc

2005-05-05 Thread Bryan
i have never found these interpreters to be anything but very robust and *IT IS SUITABLE* as trial'n'error pad for real-world programming. the above comment can possible only be made by someone who doesn't actually use it for real world programming. bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Which IDE is recommended?

2005-05-02 Thread Bryan
tocompletion feature you talk, and I think this feature is very > important. Where it is? > > Daniel > i saw this message too and i've been using it for the last couple days, but i don't see the class/functions browser you are talking about. where is it??? thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming Language for Systems Administrator

2005-04-13 Thread Bryan
27;t speak to that, but i've never experienced an IO hang related to perforce. bryan -- http://mail.python.org/mailman/listinfo/python-list

collaborative text editor

2005-03-28 Thread Bryan
olest things i've ever seen :) thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: determine os language

2005-03-19 Thread Bryan
Bryan wrote: is there a way to determine the operating system's language? i can't seem to find a method that returns the value. thanks, bryan found it myself, thanks... >>> import locale >>> locale.getdefaultlocale() ('en_US', 'cp1252') >>> -- http://mail.python.org/mailman/listinfo/python-list

determine os language

2005-03-19 Thread Bryan
is there a way to determine the operating system's language? i can't seem to find a method that returns the value. thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: code for Computer Language Shootout

2005-03-18 Thread Bryan
i:i+60] couldn't you change the above for loop to: print wraptext.fill(seq, 60) bryan def main(): seq = [] for line in sys.stdin: if line[0] in ';>': show(''.join(seq)) print line, del seq[:] else:

Re: [perl-python] generic equivalence partition

2005-02-24 Thread Bryan
http://xahlee.org/PageTwo_dir/more.html this is the first thing that came to my mind. i'm sure there are more clever ways to do this. elements = [['x', 'x', 'x', '1'], ['x', 'x', 'x', '2'], ['x', 'x', 'x', '2'], ['x', 'x', 'x', '2'], ['x', 'x', 'x', '3'], ['x', 'x', 'x', '4'], ['x', 'x', 'x', '5'], ['x', 'x', 'x', '5']] pos = {} for i, element in enumerate(elements): pos.setdefault(element[-1], []).append(i+1) p = pos.values() p.sort() [[1], [2, 3, 4], [5], [6], [7, 8]] bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Bryan
Duncan Booth wrote: Bryan wrote: is to reset the rightmost (less significant) '1' bit of a number (ie change it to '0'). i tried c &= c - 1 but i'm not getting the least significant or rightmost bit reset to zero. am i misunderstanding something? 2 & 1 # 2

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Bryan
ange it to '0'). i tried c &= c - 1 but i'm not getting the least significant or rightmost bit reset to zero. am i misunderstanding something? >>> 2 & 1 # 2 = 0x10; reset right most would be 0x10 0 >>> 10 & 9 # 10 = 0x1010; reset right most would be 0x1010 8 bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Where are list methods documented?

2005-02-01 Thread Bryan
modules index page open and i always wished there was an explicit link to lists, tuples, dict, set, etc. maybe these explicit links could be at the top of the __builtins__ page. bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Regarding exception handling

2005-01-30 Thread Bryan
Fredrik Lundh wrote: "Bryan" wrote the above is not the same. make the a = ... raise an exception and you'll see the difference. s = ... # a = 1/0 s.close() as you can see, s.close() will never be called. also, in this example, i intentionally didn't put the extra try/e

Re: Regarding exception handling

2005-01-30 Thread Bryan
Dan Perl wrote: "Bryan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] IMO, that is not the reason for the try/finally statement and it is not redundant. the try/finally statement guarantees the resource is closed and the try/finally statement only gets execute

Re: Regarding exception handling

2005-01-30 Thread Bryan
nt only gets executed if and only if the opening of the resource doesn't raise an exception. it has nothing to do with exception handling. in the previous 2 examples s = ... was placed inside the try/finally, but if an exception occures and s doesn't get bound to an object, then s.

Re: The next Xah-lee post contest

2005-01-30 Thread Bryan
Eric Pederson wrote: From: Arthur <[EMAIL PROTECTED]> Not sure how Xah got himself into all this. One can easily see that Java programmers are geeks who secretly wanted to make the football team and are now trying to conform, ignoring their language's critical lack of Prolog syntax. Python c

Re: PyCon Preliminary Program Announced!

2005-01-20 Thread Bryan
can anyone tell me how the talks work? there are between 9 and 12 talks for each time slot. do all talks start at the same time? or are there just four talks at a time and the columns show what talks are in a given room? is it easy to go to the talks you want? thanks, bryan -- http

Re: what would you like to see in a 2nd edition Nutshell?

2005-01-01 Thread Bryan
ny gui toolkits, and instead use that space for more core funcionality. thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

SimpleHTTPServer, queries unhandled?

2004-12-26 Thread Bryan Rasmussen
Hey just doing some preliminary testing with SimpleHTTPServer, and i noticed that when i request a resource with a query string parameters that this was not handled. is this correct, or is there a method to set query string handling? -- Bryan Rasmussen -- http://mail.python.org/mailman

Re: deferred decorator

2004-12-08 Thread Bryan
Nick Coghlan wrote: Bryan wrote: i'm also curious if it's possible to write this recipe using the new class style for the Deffered class.it appears you can nolonger delegate all attributes including special methods to the contained object by using the __getattr__ or the new __geta

deferred decorator

2004-12-07 Thread Bryan
attr__ or the new __getattribute__ methods. does anyone know how to port this recipe to the new class style? thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Versioning Libraries

2004-12-02 Thread Bryan
, 3, 3) True >>> sys.hex_version Traceback (most recent call last): File "", line 1, in ? AttributeError: 'module' object has no attribute 'hex_version' bryan -- http://mail.python.org/mailman/listinfo/python-list

<    3   4   5   6   7   8