Re: File processing

2005-09-23 Thread Bryan Olson
Peter Hansen wrote: > Gopal wrote: >> [...] I'm >> thinking of going with this format by having "Param Name - value". Note >> that the value is a string/number; something like this: >> >> PROJECT_ID = "E4208506" >> SW_VERSION = "18d" >> HW_VERSION = "2" >> >> In my script, I need to parse

Re: Question About Logic In Python

2005-09-23 Thread Bryan Olson
Steven D'Aprano wrote: > Or wait, I have thought of one usage case: if you are returning a value > that you know will be used only as a flag, you should convert it into a > bool. Are there any other uses for bool()? We could, of course, get along without it. One use for canonical true and false v

Re: CRC16

2005-09-23 Thread Bryan Olson
Tuvas wrote: > Anyone know a module that does CRC16 for Python? I have an aplication > that I need to run it, and am not having alot of sucess. I have a > program in C that uses a CRC16 according to CCITT standards, but need > to get a program that tests it with python as well. Thanks! I'll includ

Re: Sorting with only a partial order definition

2005-10-27 Thread Bryan Olson
Lasse Vågsæther Karlsen wrote: > I have a list of items and a "rule" for ordering them. > > Unfortunately, the rule is not complete so it won't define the correct > order for any two items in that list. This is called a "partial ordering". [...] > If there isn't anything built in, does anyon

PEP submission broken?

2005-11-02 Thread Bryan Olson
Though I tried to submit a (pre-) PEP in the proper form through the proper channels, it has disappeared into the ether. In building a class that supports Python's slicing interface, http://groups.google.com/group/comp.lang.python/msg/8f35464483aa7d7b I encountered a Python bug, which, upon

Catch stderr in non-console applications

2005-11-04 Thread Bryan Olson
how it does on other systems. Thanks to George ([EMAIL PROTECTED]) for testing a previous version. Thanks to Robert Kern for pointing me to a bug solution. --Bryan cut --- #!/usr/bin/env python # Python module "errorwindow.py", by Bryan Olson,

Re: strange sockets

2005-11-04 Thread Bryan Olson
Skink wrote: [...] > what's wrong here? Sion Arrowsmith is right about what causes the delay. Just in case your real code looks like this, I'll note: > len, = struct.unpack("!i", s.recv(4)) > data = s.recv(len) First, you almost certainly don't want to use the name 'len'. Ought not to b

Re: random number generator

2005-11-04 Thread Bryan Olson
Fredrik Lundh wrote: >>How to generate a random number in Python. Is there any build in >>function I can call? > > > >>> import random > >>> help(random) If you need crypto-quality randomness: >>> import os >>> help(os.urandom) -- --Bryan -- http://mail.python.org/mailman/listinfo

Re: python gc performance in large apps

2005-11-04 Thread Bryan Olson
Robby Dermody wrote: > [...] However, on a > simulated call center environment (constant 50 conversations, switching > every 300 seconds) the director component still consumes an average of > 1MB more per hour and the harvester is taking an average of 4MB more per > hour. With the director, 2/3

Re: MainThread blocks all others

2005-08-09 Thread Bryan Olson
Nodir Gulyamov wrote: > Hello All! > I met some strange situation. In MainThread my program wating changes of > some variable. This variable should be changed in another thread, but loop, > which wait changing variable blocks all other threads. > Code below: > > class class1: > def __ini

Re: MainThread blocks all others

2005-08-09 Thread Bryan Olson
I wrote: > Make self.counter a semaphore. Untested code: A little clean-up. Still untested: import threading class class1: def __init__(self): self.counter = threading.semaphore(0) result = self.doSomeJob() def increaseCounter(self): self.counter.release()

Re: Putting function references in a Queue

2005-08-09 Thread Bryan Olson
Richard Townsend wrote: > I've been experimenting putting a reference to a function into a Queue > object and was wondering what actually gets put in the Queue - is it the > function's code object? It's a Python-internal-reference-thingy. > If I read from the Queue in a different module, it a

Re: Creating a virtual file system

2005-08-09 Thread Bryan Olson
Atila Olah wrote: > My question is: How do I implement a virtual partition that acts like a > real file-system and is compleatly transparent to other programs? > Should I make a virtual file allocation table for a FAT32 partition or > simulate an NTFS? Or even further: How do I create a juncti

Re: zipped socket

2005-08-09 Thread Bryan Olson
[EMAIL PROTECTED] wrote: > As far as I know, there is not a prefabbed solution for this problem. One > issue that you must solve is the issue of buffering (when must some data you've > written to the compressor really go out to the other side) and the issue of > what to do when a read() or

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: Creating a virtual file system

2005-08-09 Thread Bryan Olson
Jeff Schwab wrote: > I agree that you & I are probably discussing different things, but I > think this is exactly what the OP was seeking. He said: > > > I'm working on a project to implement a simple cross-platform file > > sharing protocol (using Python) that is similar to HTTP, and I >

Catching stderr output from graphical apps

2005-08-09 Thread Bryan Olson
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. To use it, import the module. That's it. Upon import it will assign sys.stderr. In the normal case, your code

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

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 private > variable. Your code

Re: MainThread blocks all others

2005-08-10 Thread Bryan Olson
Nodir Gulyamov wrote: > Tried to rewrite using Event() just as experiment, but unfortunately > MainThread will blocking all others. > Code below: > > import threading > > class class1: > def __init__(self): > self.myEvent = threading.Event() > result = doSomeJob() >

Re: Why is this?

2005-08-10 Thread Bryan Olson
Jiri Barton wrote: > Yes, now it is clear! > > As always, I should have RTFM, the operator* is not just a syntactic sugar > and thus does not make copies. That issue bites, like, everyone. > You know, my actual scenario was with four > variables at the time: > > a, b, c, d = [], [], [],

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

2005-08-10 Thread Bryan Olson
nicolas_riesch wrote: > Does someone know if the module pytz > (http://sourceforge.net/projects/pytz/) is thread-safe ? On that, I don't know. > That's because in the file pytz/tzinfo.py, I see global variables > _timedelta_cache, _datetime_cache, _ttinfo_cache, which are > dictionnaries and

Re: MainThread blocks all others

2005-08-10 Thread Bryan Olson
Nodir Gulyamov wrote: > Hi again, comments below: > > >>>doSomeJob(self): >>># BLOCKING HERE ### >>>if not self.myEvent.isSet(): >>>self.myEvent.wait() >> >>The initial 'if' is superflous. > > Excuse me, please explain. The code: if some_event.i

Bug in slice type

2005-08-10 Thread Bryan Olson
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would describe if applied to a sequence of length items. It returns a tuple of three int

Re: wxPython and threads again

2005-08-10 Thread Bryan Olson
David E. Konerding DSD staff wrote: [...] > You need another way to pass completion information between the downloader > thread and the main thread; the simplest way is to define a custom wx > Event, and wxPostEvent from the downloader thread when it completes ( > and when the gauge should be

Re: Catching stderr output from graphical apps

2005-08-10 Thread Bryan Olson
gry@ll.mit.edu wrote: > Python 2.3.3, Tkinter.__version__'$Revision: 1.177 $' > > Hmm, the error window pops up with appropriate title, but contains no > text. > I stuck an unbuffered write to a log file in ErrorPipe.write and got > only one line: Traceback (most recent call last):$ > > Any

Re: wxPython and threads again

2005-08-10 Thread Bryan Olson
Peter Hansen wrote: > David E. Konerding DSD staff wrote: >> Further, calling wx from a thread other than the one running the >> event loop is deep voodoo and should typically be avoided. > > "Typically"? Let's just say "always" and maybe use the phrase "certain > to corrupt wx and crash the

Re: zipfile library - problem..

2005-08-11 Thread Bryan Olson
Renzo wrote: > Renzo ha scritto: > > I've seen that the error is a known bug: > > "zipfile still has 2GB boundary bug" > > > so I've used the module TarFile instead ZipFile, and now the script > works perfectly. Thanks;

Re: thread limit in python

2005-08-11 Thread Bryan Olson
[EMAIL PROTECTED] wrote: > disregard the C example. wasn't checking the return code of > pthread_create. the C program breaks in the same place, when creating > the 1021st thread. So that's pretty good evidence that it's an OS limit, not a Python limit. The most likely problem is that the sta

Re: Bug in slice type

2005-08-11 Thread Bryan Olson
Steven Bethard wrote: > I suspect there's a reason that it's done this way, but I agree with you > that this seems strange. Have you filed a bug report on Sourceforge? I gather that the slice class is young, so my guess is bug. I filed the report -- my first Sourceforge bug report. > BTW, a s

Re: Bug in slice type

2005-08-11 Thread Bryan Olson
John Machin wrote: > Steven Bethard wrote: [...] >> 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] >> [] >> > > >>> rt = range(10) > >>>

Re: Regular expression to match a #

2005-08-11 Thread Bryan Olson
John Machin wrote: [...] > Observation: factoring out the compile step makes the difference much > more apparent. > > >>> ["%.3f" % t.timeit() for t in t3, t4, t5, t6] > ['1.578', '1.175', '2.283', '1.174'] > >>> ["%.3f" % t.timeit() for t in t3, t4, t5, t6] > ['1.582', '1.179', '2.284', '

Re: constructing bytestrings

2005-08-11 Thread Bryan Olson
Lenny G. wrote: > I use 's = os.read(fd, 12)' to grab 12 bytes from a file. Now, I want > to create a string, s1, which contains 16-12=4 bytes: 4,0,0,0, followed > by the contents of s. > > I know how to 's1 = "\x04\x00\x00\x00"' and how to 's3 = s1+s', but I > don't know how to construct s1

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/listinfo/python-li

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: thread limit in python

2005-08-12 Thread Bryan Olson
Peter Hansen wrote: > Probably, but I haven't yet seen anyone ask the real important question. > What possible use could you have for more than 1000 *simultaneously > active* threads? There are very likely several alternative approaches > that will fit your use case and have better characteri

Re: socket setdefaulttimeout

2005-08-12 Thread Bryan Olson
Sheila King wrote: > I'm doing DNS lookups [...] it is important to make sure > that the socket doesn't just hang there waiting for a response. > > After a recent system upgrade to Python 2.4.1 (from 2.2.2) I thought I > could take advantage of the setdefaulttimeout in the socket module, to >

Re: socket setdefaulttimeout

2005-08-12 Thread Bryan Olson
Sheila King wrote: > Bryan Olson wrote: [...] >>Under some older threading systems, any system call would block every >>thread in the process, and gethostbyname was notorious for holding things >>up. Some systems offer an asynchronous gethostbyname, but that doesn't

Re: thread limit in python

2005-08-13 Thread Bryan Olson
Peter Hansen wrote: > My question was in the context of the OP's situation. What possible use > for 1000 OS threads could he have? Is this a language thing? Surely you realize that "what possible use could be" carries an insinuation that is not such a good idea. Possible uses are many and per

Re: Catching stderr output from graphical apps

2005-08-13 Thread Bryan Olson
Robert Kern wrote: > Christopher Subich wrote: >> If you can get a cross-platform solution, please re-annoucne it; this >> sounds like a really neat module to have handy for graphical programs. > > > Look at py.io[1]. It seems to have implemented a probably-cross-platform > solution. Please

Re: thread limit in python

2005-08-13 Thread Bryan Olson
Peter Hansen wrote: > Bryan Olson wrote: > >> Peter Hansen wrote: >> > My question was in the context of the OP's situation. What >> possible use >> > for 1000 OS threads could he have? >> >> Is this a language thing? Surely you real

Re: global interpreter lock

2005-08-19 Thread Bryan Olson
km wrote: > Hi all, > > is true parallelism possible in python ? or atleast in the > coming versions ? is global interpreter lock a bane in this > context ? No; maybe; and currently, not usually. On a uniprocessor system, the GIL is no problem. On multi- processor/core systems, it's a big lo

Re: __del__ pattern?

2005-08-19 Thread Bryan Olson
BranoZ wrote: > [EMAIL PROTECTED] wrote: > >>For a reasonably portable solution, leave the lock file open. >>On most systems, you cannot delete an open file,.. > > On most UNIXes, you can delete an open file. > Even flock-ed. This is BTW also an hack around flock. Yes, sorry; my bad. > Us

Re: global interpreter lock

2005-08-19 Thread Bryan Olson
Donn Cave wrote: > Bryan Olson wrote: >>On a uniprocessor system, the GIL is no problem. On multi- >>processor/core systems, it's a big loser. > > > I rather suspect it's a bigger winner there. > > Someone who needs to execute Python instructions

Re: global interpreter lock

2005-08-20 Thread Bryan Olson
Mike Meyer wrote: > The real problem is that the concurrency models available in currently > popular languages are still at the "goto" stage of language > development. Better models exist, have existed for decades, and are > available in a variety of languages. That's not "the real problem";

Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-20 Thread Bryan Olson
Steven Bethard wrote: > Well, I couldn't find where the general semantics of a negative stride > index are defined, but for sequences at least[1]: > > "The slice of s from i to j with step k is defined as the sequence of > items with index x = i + n*k such that 0 <= n < (j-i)/k." > > This se

Re: global interpreter lock

2005-08-24 Thread Bryan Olson
Mike Meyer wrote: > Bryan Olson writes: > >>Mike Meyer wrote: >> > The rule I follow in choosing my tools is "Use the least complex tool >> > that will get the job done." >> >>Even if a more complex tool could do the job better? &g

Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-24 Thread Bryan Olson
Paul Rubin wrote: > Bryan Olson writes: > >> seq[3 : -4] >> >>we write: >> >> seq[3 ; $ - 4] > > > +1 I think you're wrong about the "+1". I defined '$' to stand for the length of the sequence (not the addre

Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-24 Thread Bryan Olson
Kay Schluehr wrote: > Bryan Olson wrote: > >>Steven Bethard wrote: >> > Well, I couldn't find where the general semantics of a negative stride >> > index are defined, but for sequences at least[1]: >> > >> > "The slice of s from i

Re: Bug in slice type

2005-08-24 Thread Bryan Olson
Kay Schluehr wrote: > Steven Bethard wrote: >>"The slice of s from i to j with step k is defined as the sequence of >>items with index x = i + n*k such that 0 <= n < (j-i)/k." >> >>This seems to contradict list behavior though. >> range(10)[9:-1:-2] == [] > > > No, both is correct. But

Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-24 Thread Bryan Olson
Steven Bethard wrote: > Bryan Olson wrote: > >> Steven Bethard wrote: >> > Well, I couldn't find where the general semantics of a negative stride >> > index are defined, but for sequences at least[1]: >> > >> > "The slice

Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-24 Thread Bryan Olson
Robert Kern wrote: > By "+1" he means, "I like it." He's not correcting you. Ah, O.K. Thanks. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-24 Thread Bryan Olson
The doc for the find() method of string objects, which is essentially the same as the string.find() function, states: find(sub[, start[, end]]) Return the lowest index in the string where substring sub is found, such that sub is contained in the range [start, end). Optio

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-25 Thread Bryan Olson
Steve Holden asked: > Do you just go round looking for trouble? In the course of programming, yes, absolutly. > As far as position reporting goes, it seems pretty clear that find() > will always report positive index values. In a five-character string > then -1 and 4 are effectively equivalen

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-26 Thread Bryan Olson
Antoon Pardon wrote: > Bryan Olson schreef: > >>Steve Holden asked: >>>And what are you proposing that >>>find() should return if the substring isn't found at all? please don't >>>suggest it should raise an exception, as index() exists to p

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-26 Thread Bryan Olson
Steve Holden wrote: > Bryan Olson wrote: >> Antoon Pardon wrote: >> > It probably is too late now, but I always felt, find should >> > have returned None when the substring isn't found. >> >> None is certainly a reasonable candidate. [...] &g

Virtual Slicing

2005-08-27 Thread Bryan Olson
I recently wrote a module supporting value-shared slicing. I don't know if this functionality already existed somewhere, but I think it's useful enough that other Pythoners might want it, so here it is. Also, my recent notes on Python warts with respect to negative indexes were based on problems

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-27 Thread Bryan Olson
Steve Holden wrote: > Bryan Olson wrote: >> [...] I see no good reason for the following >> to happily print 'y'. >> >> s = 'buggy' >> print s[s.find('w')] >> >> > Before using the result you always

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-28 Thread Bryan Olson
Steve Holden wrote: > Paul Rubin wrote: > We are arguing about trivialities here. Let's stop before it gets > interesting :-) Some of us are looking beyond the trivia of what string.find() should return, at an unfortunate interaction of Python features, brought on by the special-casing of negat

Re: global interpreter lock

2005-08-28 Thread Bryan Olson
phil hunt wrote: > It's not the number of paths that's important. Absolutely right. Non-trivial software always has too many paths to consider them individually, so we have to reason generally. > What's important is *predictability*, e.g. which instruction will > the computer execute next? >

Re: global interpreter lock

2005-08-28 Thread Bryan Olson
Piet van Oostrum wrote: >>Paul Rubin (PR) wrote: >>PR> Really, the essence of programming is to find ways of organizing the >>PR> program to stay reliable and maintainable in the face of that >>PR> combinatorial explosion. That means facing the problem and findin

Re: Virtual Slicing

2005-08-29 Thread Bryan Olson
Sybren Stuvel wrote: > Bryan Olson enlightened us with: > >>I recently wrote a module supporting value-shared slicing. > > Maybe I'm dumb, but could you explain this concept? Why would someone > whant this? My original motivation was reduce the amount of copyin

Re: global interpreter lock

2005-08-29 Thread Bryan Olson
Mike Meyer wrote: > Bryan Olson writes: > phil hunt wrote: > >> > What's important is *predictability*, e.g. which instruction will >> > the computer execute next? >> > >> > If you only have one thread, you can tell by looking at the co

Re: global interpreter lock

2005-08-29 Thread Bryan Olson
Mike Meyer wrote: > Bryan Olson <[EMAIL PROTECTED]> writes: >> > Bryan Olson writes: >> > Trivially, an 'if' statement that depends upon input >> >>data is statically predictable. Use of async I/O means makes the >> >>programs

Re: OpenSource documentation problems

2005-08-30 Thread Bryan Olson
Adriaan Renting wrote: [...] > I do agree that a lot of OSS projects seem to lack somewhat in > the documentation department, compared to a lot of commercial > software. I would give the man page of gcc as an example, it's > just one 6600 line blurb. I don't see any need to look beyond Python

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-30 Thread Bryan Olson
Steve Holden wrote: > I'm all in favor of discussions to make 3.0 a better > language. This one should definitely be two-phase. First, the non-code- breaking change that replaces-and-deprecates the warty handling of negative indexes, and later the removal of the old style. For the former, there'

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-30 Thread Bryan Olson
Terry Reedy wrote: > "Paul Rubin" wrote: > >>Really it's x[-1]'s behavior that should go, not find/rfind. > > I complete disagree, x[-1] as an abbreviation of x[len(x)-1] is extremely > useful, especially when 'x' is an expression instead of a name. Hear us out; your disagreement might not

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-30 Thread Bryan Olson
Robert Kern wrote: > Bryan Olson wrote: > > >> Currently, user-defined classes can implement Python >> subscripting and slicing without implementing Python's len() >> function. In our proposal, the '$' symbol stands for the >>

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-31 Thread Bryan Olson
Paul Rubin wrote: > Not every sequence needs __len__; for example, infinite sequences, or > sequences that implement slicing and subscripts by doing lazy > evaluation of iterators: > > digits_of_pi = memoize(generate_pi_digits()) # 3,1,4,1,5,9,2,... > print digits_of_pi[5] # computes 6

Re: OpenSource documentation problems

2005-08-31 Thread Bryan Olson
Terry Hancock wrote: > Bryan Olson wrote: > >>I don't see any need to look beyond Python for a good example of >>poor documentation. Are there serious Python programmers who >>don't constantly struggle with errors and omissions in the doc? > > Uh,

Re: OpenSource documentation problems

2005-08-31 Thread Bryan Olson
A.M. Kuchling wrote: > Bryan Olson wrote: > >>I use dir() all the time; help() not so much. Typing help(help) >>shows: >> >> Help on _Helper in module site: >> >> Type help() for interactive help, or help(object) for help >>

Re: global interpreter lock

2005-08-31 Thread Bryan Olson
Bengt Richter wrote: > Bryan Olson wrote: >>For a long time, >>the most sophisticated software services generally have used >>multiple lines of execution, and now that's mostly in the form >>of threads. No one actually disagrees, but they go right on >&g

Re: Sockets: code works locally but fails over LAN

2005-08-31 Thread Bryan Olson
Grant Edwards wrote: > Peter Hansen wrote: > > >>2. I'm not at all sure that accessing the same socket object >>simultaneously from two threads is safe. > > It's OK under Unix. Having one thread handle rx and a > different one handle tx is a pretty widely used method. > > Don't know abou

Re: Sockets: code works locally but fails over LAN

2005-08-31 Thread Bryan Olson
n00m wrote: > import socket, thread > host, port = '192.168.0.3', 1434 Consider using INADDR_ANY instead of the specific host IP address. The empty string will resolve to INADDR_ANY if passed as the host to bind(). (Though that's not the problem.) > s1 = socket.socket(socket.AF_INET, socket.S

Command-line arguments; was -- same thing

2005-08-31 Thread Bryan Olson
Peter Hansen wrote: > I would approach this as a usability issue for your users, rather than > from the point of view of which is "a little messier" in the code. I agree, yet in my own programs, the command-option support tends to suck. I think I can work out function/class/module interfaces wel

Re: OpenSource documentation problems

2005-08-31 Thread Bryan Olson
Fredrik Lundh wrote: > Bryan Olson wrote: >>[...] >> > What additions to that string would you suggest? >> >>Since "help *is* pydoc.help, or at least...", the call could >>show the same thing as help(pydoc.help) > > >>>>i

Re: OpenSource documentation problems

2005-08-31 Thread Bryan Olson
Sybren Stuvel wrote: > I don't have any problems with the documentation. It just works for > me. If you find any errors or omissions, fix them and send the > document maintainer an email. Why don't you help us by improving the > documentation? Workin' on it. -- --Bryan -- http://mail.pytho

Re: OpenSource documentation problems

2005-08-31 Thread Bryan Olson
Michael Sparks wrote: > Bryan Olson wrote: >>A plausible theory. I have some possibly-illustrative examples >>of what I ran into within the last few weeks. > > > Did you take what you learnt, and use that to create better > documentation to be posted on pyt

Re: global interpreter lock

2005-08-31 Thread Bryan Olson
Mike Meyer wrote: > Bryan Olson writes: >>System support for threads has advanced far beyond what Mr. Meyer >>dealt with in programming the Amiga. > > I don't think it has - but see below. > >>In industry, the two major camps are Posix threads, and Mic

Re: OpenSource documentation problems

2005-09-01 Thread Bryan Olson
Fredrik Lundh wrote: > Bryan Olson wrote: >> >>>>import pydoc >> >>>>help is pydoc.help >> > >> > False >> >>Say Fredrik, if you're going to proclaim "False" > > oh, I didn't proclaim anyth

Re: Considering moving from PowerBuilder to Python

2005-09-01 Thread Bryan Olson
Norm Goertzen wrote: > I've posted a previous question about IDEs [...] Python is a fine scripting language; it isn't centered on a particular IDE, and doesn't really serve the same market as Powerbuilder. Building an app in Python is a far lower-level process than building one in Powerbuilder, a

Re: global interpreter lock

2005-09-01 Thread Bryan Olson
Dennis Lee Bieber wrote: > Well, at that point, you could substitute "waiting on a queue" with > "waiting on a socket" and still have the same problem -- regardless of > the nature of the language/libraries for threading; it's a problem with > the design of the classes as applied to a thre

Re: Sockets: code works locally but fails over LAN

2005-09-01 Thread Bryan Olson
n00m wrote: >>Bryan; > > I tested your code locally (in I*D*L*E) - it works fine! Glad it worked, but I'd still disrecommend IDLE for that version. Threads may live after the program seems to be done (and may still own the port you need). Below is a version that respects ^C to terminate more-or

Re: global interpreter lock

2005-09-01 Thread Bryan Olson
Mike Meyer wrote: > Bryan Olson writes: >>With Python threads/queues how do I wait for two queues (or >>locks or semaphores) at one call? (I know some methods to >>accomplish the same effect, but they suck.) > > By "not as good as", I meant the model they

Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread Bryan Olson
Dennis Lee Bieber wrote: > I'm going to go back a few messages... Looking for a > simplification... [...] > TWO threads, both just infinite loops of the same nature (you could > actually have done ONE def and passed different arguments in to > differentiate the two thread invocations

Re: Sockets: code works locally but fails over LAN

2005-09-02 Thread Bryan Olson
I wrote: > Below is a version that respects ^C to terminate > more-or-less cleanly. Oops, one more bug^H^H^H improvement. I forgot to shutdown writing. > import socket, threading, select > > sqls_host, sqls_port = '192.168.0.3', 1443 > proxy_host, proxy_port = '', 1434 > > > def start_d

Re: Sockets: code works locally but fails over LAN

2005-09-02 Thread Bryan Olson
n00m wrote: > My today's tests (over LAN). > I think *it* will drive me mad very soon. Network programming is like that. Just because something worked once doesn't mean it really works. I had guessed two causes for the behavior you were seeing, and either could result in sporadic failures. >

Re: Sockets: code works locally but fails over LAN

2005-09-03 Thread Bryan Olson
n00m wrote: > Your last version works like a champ. It easily handles up > to 5 instances of my.vbs! Except of this thing: > >>AttributeError: 'module' object has no attribute 'SHUT_WR' > > Seems it's a pure Unix constant. No, my guess is that you're running an old version of Python. The con

Re: Sockets: code works locally but fails over LAN

2005-09-03 Thread Bryan Olson
Dennis Lee Bieber wrote: > Bryan Olson declaimed the following in comp.lang.python: > >>No, my guess is that you're running an old version of Python. >>The constant was added in the source on 27 Nov 2003; I'm not > > > Are you sure of that 2003?

Re: Sockets: code works locally but fails over LAN

2005-09-04 Thread Bryan Olson
n00m wrote: > Bryan; > Look at how I corrected your the very first version > (see added arguments in both functions). And now it > really can handle multiple connections! Ah, yes, I see. (In my defense, I had already fixed that bug in my second version.) -- --Bryan -- http://mail.python.or

Re: documentation error

2005-09-04 Thread Bryan Olson
Reinhold Birkenfeld wrote: > tiissa wrote: > >>bill wrote: >> From 3.2 in the Reference Manual "The Standard Type Hierarchy": >>> >>>"Integers >>>These represent elements from the mathematical set of whole >>>numbers." >>> >>>The generally recognized definition of a 'whole number

Re: documentation error

2005-09-04 Thread Bryan Olson
Bengt Richter wrote: > Bryan Olson wrote: >>Consider deleting the sentence in which the Python doc tries to >>define mathematical integers. > This is a nice site: > > http://mathworld.wolfram.com/WholeNumber.html > http://mathworld.wolfram.com/topics/Integers.htm

Re: Pervasive Database Connection

2005-09-06 Thread Bryan Olson
Alex Le Dain wrote, in entirety: > What is the best way to access a Pervasive database on another machine? The best way, is, well ... Pervasively! Sorry. I can be kida a jerk like that. People often do get get hundreds, sometimes thousands of dollars worth of consultation from these groups, for

Re: killing thread after timeout

2005-09-06 Thread Bryan Olson
Jacek Poplawski had written: >> I am going to write python script which will read python >> command from socket, run it and return some values back to >> socket. >> >> My problem is, that I need some timeout. Jacek Poplawski wrote: > After reading more archive I think that solution may be t

Re: killing thread after timeout

2005-09-06 Thread Bryan Olson
Bryan Olson wrote: [Some stuff he thinks is right, but might not answer the real question] Definitely look into Peter Hanson's answer. Olson's answer was about timing-out one's own Python code. Bryan Olson has heretofore avoided referring to himself in the third person, and w

Re: assign dict by value to list

2005-09-07 Thread Bryan Olson
Phill Atwood wrote: [...] > So how do I add a dictionary into a list by value rather than > by reference? Is rec.items() what you want? It returns a list of (key, value) tuples. > The complete code is here: [...] Looks like you could use Python's ConfigParser module. http://docs.python

Re: dict and __cmp__() question

2005-09-07 Thread Bryan Olson
Alex wrote: > But what are those with double underscore? For instance __cmp__(...)? Those are these: http://docs.python.org/ref/specialnames.html -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Sockets: code works locally but fails over LAN

2005-09-07 Thread Bryan Olson
n00m wrote: > Btw, why we need send() if there is sendall()? Mostly because sendall() can block, even if you do all the select() and setblocking() magic. That's no problem in the threaded architecture we're using, but a deal-breaker for a single-threaded server. -- --Bryan -- http://mail.pytho

Re: killing thread after timeout

2005-09-08 Thread Bryan Olson
Paul Rubin wrote: > To get even more OS-specific, AF_UNIX sockets (at least on Linux) have > a feature called ancillary messages that allow passing file > descriptors between processes. It's currently not supported by the > Python socket lib, but one of these days... . But I don't think > Windows

Re: List of integers & L.I.S. (SPOILER)

2005-09-08 Thread Bryan Olson
n00m wrote: > Firstly I find ordering numbers when moving from left to the right; > then I find ord. numbers for backward direction AND for DECREASING > subsequences: Sounds good. > Btw, I did it in Pascal. Honestly, I don't believe it can > be done in Python (of course I mean only the impo

  1   2   3   4   >