Re: Question on for loop

2013-03-04 Thread Bryan Devaney
> if character not in lettersGuessed: > > return True > > return False assuming a function is being used to pass each letter of the letters guessed inside a loop itself that only continues checking if true is returned, then that could work. It is however more work than is need

PyWart fixed mostly, was: Re: Python Gotcha's?

2013-01-22 Thread Bryan
ot;, should work on Unix. And everywhere it runs it should respect shebang lines that name itself. The modern shebang line ought to be "#!/usr/bin/env py -3" (but it's not yet so don't use it). The other big idea in supporting multiple Pythons is virtual environmen

Re: Standard Asynchronous Python

2012-09-15 Thread Bryan
eads. Dustin, I hope you carry on with your plan. I request, please, report back here what you find. As law professor James Duane said in pre- introduction of police officer George Bruch, "I'm sure [you'll] have a lot to teach all of us, including myself." -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner Q: What does the double underscore __ mean?

2012-09-09 Thread Bryan
pecial within the particular class. To the Python language it's just another name, but the authors of the class have coded it to look up that name and do something interesting with the associated value. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Standard Asynchronous Python

2012-09-09 Thread Bryan
the edge on asynchronous facilities but Python treats Windows like a Unix wanna-be. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: simple client data base

2012-09-09 Thread Bryan
Mark R Rivet wrote: > Well I have to say that this is most discouraging. Sorry to to be a drag, but the thread needed a bit a realism. -- http://mail.python.org/mailman/listinfo/python-list

Re: simple client data base

2012-09-06 Thread Bryan
;re reading about lists, tuples, and dictionary data? Great, but other home accounting businesses have their client databases automatically synced with their smart-phones and their time-charging and their invoicing. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: sockets,threads and interupts

2012-09-05 Thread Bryan
bably unwise" according to Linux man page on close(2). Do you really need to worry about it? If your process is being forcibly terminated you probably cannot do anything better than the OS will do by default. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: tornado.web ioloop add_timeout eats CPU

2012-09-03 Thread Bryan
fix? I'm not a Tornado user; I don't have a patch. Obviously Laszlo's polling strategy is not performing, and the solution is to adopt the event-driven approach that epoll and Tornado do well. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.6 and Sqlite3 - Slow

2012-08-27 Thread Bryan
n a few weeks. We'd use some open-source tools, WireShark among them, plus some Microsoft tools for which we might have to pay, plus the SQLite3 project's C library. With that investment I'd bet we could diagnose, but not cure. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.6 and Sqlite3 - Slow

2012-08-27 Thread Bryan
don't know where your 17 seconds is going. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Framework for a beginner

2012-04-20 Thread Bryan
e in one short thread: Last I heard -- please correct me if I'm wrong -- Web2py had no plan for to move to Python 3. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Framework for a beginner

2012-04-17 Thread Bryan
Roy Smith wrote: > Bryan wrote: > > Django has emphasized backwards compatibility with the > > down-side that, last I heard, there was no plan to move to Python 3. > > Hardly.  Seehttps://www.djangoproject.com/weblog/2012/mar/13/py3k/ Ah, I'm behind the times again

Re: Framework for a beginner

2012-04-17 Thread Bryan
han the purpose-built automatic table-generators of Django and Web2Py. Then there are the less than full-stack frameworks and libraries. But this post is probably too long already. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-15 Thread Bryan
se they both use the same file extension. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-15 Thread Bryan
raries to catch up. Of course they can, as I am, but the gotchas are really annoying. With minor versions its not a big deal if most users simply wait to do an upgrade. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Whither paramiko?

2012-04-15 Thread Bryan
the stated reason why paramiko did not yet play with Python 3. Even more recently, PyCrypto has gone green on the Python 3 Wall of Shame. Anyone know recent news on the status of paramiko? Thanks, -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-15 Thread Bryan
Steven D'Aprano wrote: > Bryan wrote: > > Python 3(K) likes to use the same '.py' file extension as its > > incompatible predecessors, > > And so it should. We disagree. Not surprising in a "gotcha's" thread. > > and in some/many/most

Re: Python Gotcha's?

2012-04-14 Thread Bryan
o I'm as much blame as anyone. Something to keep in mind for Python 4. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: multithreading

2012-04-08 Thread Bryan
mports like any other competent module. The tricky part doesn't start until you actually use its facilities. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: multithreading

2012-04-07 Thread Bryan
threading' will fail. There's a standard library module dummy_threading which offers fake versions of the facilities in threading. It suggests: try: import threading as _threading except ImportError: import dummy_threading as _threading --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: multithreading

2012-04-07 Thread Bryan
global variabel. It could be a class for which users can make any number of instances. Third, there are cases where you want a single global. Most of the time I'd recommend warning users about threading assumptions. -Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-18 Thread Bryan
SherjilOzair wrote: > Has it been considered to add shell features > to python, such that it can be used as a > default shell, as a replacement for bash, etc. I think yes, but rather than become a shell, Python makes easy programming a shell that can execute Python code. The tendency has been to e

Re: Hash stability

2012-01-15 Thread Bryan
Chris Angelico wrote: > Suggestion: Create a subclass of dict, the SecureDict or something, > which could either perturb the hashes or even use a proper > cryptographic hash function; normal dictionaries can continue to use > the current algorithm. The description in Objects/dictnotes.txt > suggest

Re: socketserver question

2012-01-08 Thread Bryan
untested) is to relax being single-threader for just a bit. import thread thread.start_new_thread(server.shutdown, ()) -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Mathematical Operations on Array

2011-04-01 Thread Fodness, Bryan C - GS
I am loading text into an array and would like to convert the values. from math import * from numpy import * from pylab import * data=loadtxt('raw.dat') mincos=degrees(acos(data[:,0])) minazi=degrees(data[:,1]) minthick=data[:,2]/0.006858 I am not sure why degrees() works, but acos() does not.

Re: WxPython versus Tkinter.

2011-01-28 Thread Bryan
On Jan 28, 10:16 am, Kevin Walzer wrote: > On 1/28/11 9:18 AM, rantingrick wrote: > > > Everyone on this list knows that Kevin and myself are the *only* > > people who know how to wield Tkinter past some simple utility GUI's. > > I strongly disagree with this statement. > (BTW, Kevin, Congrats on

Re: WxPython versus Tkinter.

2011-01-28 Thread Bryan
On Jan 28, 8:18 am, rantingrick wrote: > On Jan 27, 12:13 pm, Stephen Hansen wrote: > > > Seriously. Octavian's attitude in this thread makes me want to go use > > Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working > > on a project that I thought accessibility for the blind w

Re: Need GUI pop-up to edit a (unicode ?) string

2011-01-26 Thread Bryan
On Jan 25, 5:02 pm, rantingrick wrote: > On Jan 25, 3:54 pm, Bryan wrote: > ... And you people wonder why i hate Tkinter! Honestly, I don't think anyone wonders why _you_ hate Tkinter, you've made that abundantly clear. -- http://mail.python.org/mailman/listinfo/python-list

Re: WxPython versus Tkinter.

2011-01-26 Thread Bryan
On Jan 26, 2:37 pm, rantingrick wrote: > On Jan 26, 2:07 pm, Stephen Hansen wrote: > > > And some people have absolutely no need-- no need at all-- for any sort > > of GUI programming at all. This group is actually really, really big. > > Stephen "Strawman" Hansen: If he only had a brain! :-) > >

Re: WxPython versus Tkinter.

2011-01-26 Thread Bryan
On Jan 26, 9:47 am, "Octavian Rasnita" wrote: > I couldn't find the word soapbox in the dictionary so I don't know what it > means. I guess that not the soap + box. > Please be more clear and not talk like the high school kids. http://en.wikipedia.org/wiki/Soapbox -- http://mail.python.org/m

Re: WxPython versus Tkinter.

2011-01-25 Thread Bryan
On Jan 25, 7:07 pm, rantingrick wrote: > What is it going to take for you (and others) to take me seriously? If somebody answers that question, will you listen? That will be the first step. I know that may sound facetious but that's not my intention. It's my honest opinion based entirely on this

Re: Need GUI pop-up to edit a (unicode ?) string

2011-01-25 Thread Bryan
On Jan 22, 2:22 pm, Rikishi42 wrote: > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > Something like this: > +--

Re: WxPython versus Tkinter.

2011-01-25 Thread Bryan
On Jan 25, 6:03 am, Bob Martin wrote: > in 650672 20110125 115033 Bryan wrote: > >> Do you think the whole world speaks US English? > > >No, absolutely not. I don't see how you go from "I don't think all > >developers think about i18n" to "I th

Re: WxPython versus Tkinter.

2011-01-25 Thread Bryan
On Jan 25, 2:02 am, Bob Martin wrote: > in 650595 20110124 192332 Bryan wrote: > > > > > > >On Jan 24, 12:05=A0pm, rantingrick wrote: > >> On Jan 24, 12:00=A0pm, Bryan wrote: > > >> > Accessibility, like internationalization, is something few p

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 4:16 pm, rantingrick wrote: > ... > Good, and again i cannot stress how little we care about your opinion. You keep using the word "we". I do not think it means what you think it means. -- http://mail.python.org/mailman/listinfo/python-list

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 2:33 pm, rantingrick wrote: > > Yes and you made your selfishness quite clear! Be careful my friend, > because as Tyler found out, this mindset becomes a slippery slope > *very* quickly! I merely made the observation that most programmers don't think about these topics and it would be

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 12:31 pm, "Littlefield, Tyler" wrote: > Bryan: Here's a pretty good list for you. > Windows: > Jaws for Windows (http://freedomscientific.com). Not free, but you get a > 40 minute demo before you need to reboot. > Nonvisual Desktop Access:http://www.

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 12:05 pm, rantingrick wrote: > On Jan 24, 12:00 pm, Bryan wrote: > > > Accessibility, like internationalization, is something few programmers > > spend much time thinking about. > > Thats another uninformed statement by you we can add to the mountains >

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 8:49 am, Mike Driscoll wrote: > > Bryan, on the other hand, has been aTkinterluminary who has helped > me in the past when I was learningTkinterand I won't be too > surprised if he helps me again. I'm sorry he's had so much trouble > with wx though.

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 8:15 am, rantingrick wrote: > On Jan 24, 6:33 am, Bryan wrote: > > > I think I'm qualified, though I guess only you can tell me if I > > measure up to your standards. > > Go on... > > > I have 15 years or so of tk development, > > though ad

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 7:32 am, rantingrick wrote: > On Jan 24, 7:24 am, Bryan wrote: > > > On Jan 24, 12:06 am, rusi wrote: > > > > On Jan 24, 9:16 am, "Littlefield, Tyler" wrote: > > > > Of course as Steven pointed out wx is written in C++ which is almos

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 7:27 am, "Octavian Rasnita" wrote: > From: "Bryan" > > > It would be hard (but not impossible, by any > > stretch) for me to duplicate your code. Certainly, it would take more > > lines of code but that's about it. OTOH, it would be ve

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 24, 12:06 am, rusi wrote: > On Jan 24, 9:16 am, "Littlefield, Tyler" wrote: > > Of course as Steven pointed out wx is written in C++ which is almost > certainly where the crash is occurring. > But this is technical nitpicking. > The real issue is that when coding in C/C++ segfaults are a d

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 23, 7:33 pm, rantingrick wrote: > On Jan 23, 7:16 pm, Kevin Walzer wrote: > > > > > > > On 1/23/11 8:12 PM, rantingrick wrote: > > > > The only way i can respond to this is to quite the requirements for my > > > challenge... > > > > --- > > >   Challenge

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 23, 7:12 pm, rantingrick wrote: > On Jan 23, 5:23 pm, Kevin Walzer wrote: > > > I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 > > source distribution. I'm NOT the author (credit should probably go to > > Guilherme Polo, developer of the Tkinter wrapper for the ttk

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 23, 5:13 pm, Steven D'Aprano wrote: > On Sun, 23 Jan 2011 12:23:13 -0800, rantingrick wrote: > > I am not > > trying to create a working file browser so you can steal my code. > > Dammit! There goes my brilliant idea for getting rich. > > Step 1: Start company. > Step 2: Steal working file

Re: WxPython versus Tkinter.

2011-01-24 Thread Bryan
On Jan 23, 11:31 am, rantingrick wrote: > On Jan 22, 6:07 pm, rantingrick wrote: > > > I await any challengers... > > So far only trolls (besides Terry, Octavian, D'Aprano) have replied. > In my time here within the Python community i have only met one person > who shares my in-depth knowledge of

Why is pdb messing with STDIN? I can't step through my code, or enter any data accurately.

2010-11-18 Thread Bryan Wheelock
ep = OpenIDServiceEndpoint() ep.claimed_id = base + "/id/bob" ep.server_url = base + "/openidserver" ep.type_uris = [OPENID_1_1_TYPE] return ep Here is the behavior: -- Ran 2 tests in 0.029s FAILED (error

Re: Twisted on Windows

2010-11-18 Thread Bryan Richardson
Thanks Jean-Paul, I added the following to my server.py file and things work perfectly on both Windows and Linux now. sys.path.insert(0, os.getcwd()) On Thu, Nov 18, 2010 at 9:52 AM, Jean-Paul Calderone wrote: > On Nov 18, 9:58 am, Bryan Richardson wrote: >> Hello All, >> >

Twisted on Windows

2010-11-18 Thread Bryan Richardson
deas why this is? -- Thanks! Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Bryan
Nobody wrote: > Bryan wrote: > > this is a case where we might want to be better > > than correct. BaseHTTPRequestHandler in the Python standard library > > accommodates clients that incorrectly omit the '\r' and end header lines > > with just '\n'. S

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Bryan
Robert Kern wrote: > Please > follow our advice. Split using b'\r\n\r\n' and use the maxsplit=1 argument to > make sure that you do not split on spurious b'\r\n\r\n' sequences inside the > JPEG body. Do not decode the bytes. Correct, and I'll add that this is a case where we might want to be bette

RE: Issues compiling 2.6.5 on AIX 6.1

2010-07-09 Thread Stopp, Bryan
n.org [mailto:python-list-bounces+cbds=argushealth@python.org] On Behalf Of Thomas Jollans Sent: Friday, July 09, 2010 7:10 AM To: python-list@python.org Subject: Re: Issues compiling 2.6.5 on AIX 6.1 On 07/08/2010 04:36 PM, Stopp, Bryan wrote: > building '_struct' extension > >

RE: Issues compiling 2.6.5 on AIX 6.1

2010-07-08 Thread Stopp, Bryan
On 07/08/2010 04:36 PM, Stopp, Bryan wrote: > I've seen other threads on this issue, but the resolution still doesn't > seem to exist for me. > > > > I'm running the configure script with these parameters: > > > > ./configure --prefix=/build/t

RE: Issues compiling 2.6.5 on AIX 6.1

2010-07-08 Thread Stopp, Bryan
f Thomas Jollans Sent: Thursday, July 08, 2010 11:51 AM To: python-list@python.org Subject: Re: Issues compiling 2.6.5 on AIX 6.1 On 07/08/2010 04:36 PM, Stopp, Bryan wrote: > I've seen other threads on this issue, but the resolution still doesn't > seem to exist for me. &

Issues compiling 2.6.5 on AIX 6.1

2010-07-08 Thread Stopp, Bryan
I've seen other threads on this issue, but the resolution still doesn't seem to exist for me. I'm running the configure script with these parameters: ./configure --prefix=/build/tools \ --exec-prefix=/build/tools \ --enable-shared \ --enable-ipv6 \

Re: safer ctype? (was GUIs - A modest Proposal)

2010-06-12 Thread Bryan
allows a known set of functions to be called? > My gut feeling is that you open a can of worms here but I would > appreciate your opinion. Perhaps instead of restricting what functions ctypes can use, we could restrict what modules can use ctypes. For example, maybe only modules in ce

Re: function that counts...

2010-06-11 Thread Bryan
it's adaptable to efficiently handle bases much larger than 10. Richard Thomas's algorithm is poly-time and efficient as long as the base is small. I'll take the liberty of tweaking your code to handle the 1 or 2 digit case, and write the more general form. I'll also memoize fac

Re: function that counts...

2010-06-09 Thread Bryan
clusion-exclusion >         sign *= -1 > >         # if M = 32, then 32, 22, 12, 2, -8 >         M -= 10 >     return s It doesn't seem to work. I get no answer at all, because it recursion- loops out when it calls fact() with a negative integer. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Bryan
ard to diagnose: The OP got the UnboundLocalError, so he looked stuff up and tried various things, such as the global declaration, but still got an exception. In writing it up, he copied the initial exception, but a latter version of the function. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Which objects are expanded by double-star ** operator?

2010-06-08 Thread Bryan
kkumer wrote: > Bryan wrote: > > I get the same bug-like behavior in 3.1. I think Peter is right that > > it's probably a side-effect of an optimization. kkumer seems to have > > completely over-ridden the methods of dict, but if we insert into his > > hubDic

Re: Which objects are expanded by double-star ** operator?

2010-06-08 Thread Bryan
In 2.6, the requirement changed from '(subclass of) dictionary' to > 'mapping' so this is a bit strange. It sort of looks like a bug. I will > test with 3.1 tomorrow (later today, actually). I get the same bug-like behavior in 3.1. I think Peter is right that it's p

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Bryan
import: from reportlab.pdfgen import canvas in the mkTable.py file. That brings 'canvas' into the mkTable module's namespace. Python programs commonly import the same module multiple times. Only the first import runs the body of the imported module. Subsequent imports merely bring the names into the importing module's namespace. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: Diff of Text

2010-06-05 Thread Bryan
more than most of us ever wanted to know about the subject. I don't know of a module that does what GZ asks. There are scores of line-oriented diff implementations, and there are minimal-edit- distance diffs, but the combination is rare at best. Problem domains that call for a true minimal d

Re: getting MemoryError with dicts; suspect memory fragmentation

2010-06-04 Thread Bryan
e on that level, but Emin seems to have worked his problem and gotten a bunch of stuff right. There is no good reason why constructing a 50 kilobyte dict should fail with a MemoryError while constructing 50 megabyte lists succeeds. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: getting MemoryError with dicts; suspect memory fragmentation

2010-06-04 Thread Bryan
of them hard to diagnose. I'd suggest checking easy stuff first. Make sure 'dict' is still . If you can test again in the debugger in the error case, see how large a set you can make, as the set implementation is similar to dict except the hash table entries are one pointer shorter at 8 bytes. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: questions about how to parse a string and put it in a dictionary

2010-06-03 Thread Bryan
;attribute2': ['attribute_value2'], 'attribute1': ['attribute_value']} You'll note the values are lists, to handle the cases where a name is equated to more than one simple value. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: CTYPES structure passing

2010-06-03 Thread Bryan
nt failed: FrameFormat.XUnion.subSample = 0 Without _fields_, ctypes did not create a FrameFormat.XUnion member, so the assignment fails with "AttributeError: 'LUCAM_FRAME_FORMAT' object has no attribute 'XUnion'". -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: CTYPES structure passing

2010-06-03 Thread Bryan
Sample = 0 or FrameFormat.XUnion.binning = 0 And same for FrameFormat.YUnion. If you spell _fields_ as ctypes requires, it will complain about your assignments, in that you are trying to assign an in to a union. As your code is, those assignments just make a new attribute to which you can assign anything. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing and accessing server's stdout

2010-06-02 Thread Bryan
t, and we want to deliver the output of that command back to the client. A brilliantly efficient method is to direct the command's stdout to the client's connection. Below is a demo server that sends the host's words file to any client that connects. It assumes Unix. --Bryan Olson

Re: multiprocessing and accessing server's stdout

2010-06-02 Thread Bryan
ork() then hook stdout directly to socket connected to the client with dup2(), then exec() the command. But no need for that just to capture LaTeX's output. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: dbf files and indexes

2010-05-29 Thread Bryan
to the same thing either way, so we might as well write it to be readable by people. I can read D'Arcy's at a glance. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: A Friday Python Programming Pearl: random sampling

2010-05-29 Thread Bryan
t". As Mark Dickinson's version uses a normal dict(), which Bentley had already introduced under the name "associate array", I'd say Mark's version is an improvement. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: function that counts...

2010-05-26 Thread Bryan
I wrote: > > I came up with a recursive memo-izing algorithm that > > handles 100-digit n's. Oops. I missed Richard Thomas's post. He posted the same algorithm a couple days before. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: function that counts...

2010-05-26 Thread Bryan
I wrote: > My prttn() calls ndsums() once for each > digit, so the whole thing is polynomial in the number of digits. Correction: my prttn() function calls ndsums() at most 9 times per digit of n. That still provides run time polynomial in the length of the input. -- --Bryan --

Re: Need some Python 3 help

2010-05-25 Thread Bryan
arsing_py3 *does* work > on Python 3.  It is a puzzle. I suspect in most cases you use bytes consistently. You got the exception from: instring[loc] in wt If instring and wt are both bytes, that's fine. If they're both str, also fine. If one is bytes and one is str, exception. --

Re: Need some Python 3 help

2010-05-25 Thread Bryan
es, and the elements of a bytes object are ints. Something to check. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: function that counts...

2010-05-25 Thread Bryan
of the memo- table and the work per entry. My prttn() calls ndsums() once for each digit, so the whole thing is polynomial in the number of digits. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: function that counts...

2010-05-25 Thread Bryan
abandon the naive algorithm. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: function that counts...

2010-05-22 Thread Bryan
I wrote: > I came up with a recursive memo-izing algorithm that > handles 100-digit n's. [...] I made a couple improvements. Code below. -Bryan #- _nds = {} def ndsums(m, d): """ Count d-digit ints with digits suming to m. ""

Re: function that counts...

2010-05-21 Thread Bryan
sted this against the initial algorithm plus Peter Pearson's optimization for numbers up to several thousand, and it agrees... well, after I fixed stuff that is. -Bryan Olson # --- _nds = {} def ndsums(m, d): """ How many d-digit ints' digits sum to m? &

Re: max time wait for a function

2010-05-18 Thread Bryan
it creates a new pool of processes for each function call that it might need to time-out. That's fixable, but the question here is about a 30-second-plus processing problem, and in that kind of case the overhead of creating one or a few new processes is lost in the noise. -Bryan Olson #

Re: Encoding troubles

2010-05-17 Thread Bryan
(raw_bytes, 'Windows-1252') Of course this all assumes that JB's database likes Unicode. If it chokes, then alternatives include encoding back to utf-8 and storing as binary, or translating characters to some best-fit in the set the database supports. -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: Some help needed with small multi-threaded program!

2010-05-17 Thread Bryan
ing a user then trying to log her in is a nice sequential unit of work that one thread could handle. The reason for threading in this problem is so that when one user's work is waiting for the network, you can make progress on other users. Hope that helps. -Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: an element from a set

2010-05-17 Thread Bryan
;in'. The trick is to keep each element in both a list and a hash table. Implementing Python's entire set interface is a bit of project, so the code below just supports enough for a demo. -Bryan Olson # from random import choice class SetWithRandom: def __init__(self, *arg

Re: Iterating over dict and removing some elements

2010-05-14 Thread Bryan
Adi Eyal wrote: > > Bryan: > > Terry Reedy wrote: > > [...] > >> for k in [k for k in d if d[k] == 'two']: > >>          d.pop(k) > > > We have a winner. > > also > > foo = lambda k, d : d[k] == "two" > d = dict([(k,

Re: Iterating over dict and removing some elements

2010-05-12 Thread Bryan
that's a reasonable solution. On subtler issues, it constucts an unnecessarily long temporary list in current Python 2.X, and fails in Python 3.x, as Terry Ready explained. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterating over dict and removing some elements

2010-05-12 Thread Bryan
Terry Reedy wrote: [...] > for k in [k for k in d if d[k] == 'two']: >          d.pop(k) We have a winner. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Extract all words that begin with x

2010-05-12 Thread Bryan
If a major portion of the strings are in fact empty superpollo's condition should do even better. But I didn't test and time that. Yet. -Bryan Olson # - timeit code - from random import choice from string import ascii_lowercase as letters from timeit import Timer strs = ['

Re: Extract all words that begin with x

2010-05-11 Thread Bryan
edy was right: startswith() is slower. I would, nevertheless, use startswith(). Later, if users want my program to run faster and my profiling shows a lot of the run-time is spent finding words that start with 'a', I might switch. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: fast regex

2010-05-11 Thread Bryan
ssume you're not actually suggesting hand-writing a state machine for the problem at issue here, which requires recognizing about 5000 different words. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: fast regex

2010-05-08 Thread Bryan
;s, I can re.compile one with 4000 words randomly chosen from a Unix words file, but 5000 results in "regular expression code size limit exceeded". Tim's version which doesn't combine prefixes tops out a little lower. This is on 32-bit Windows, standard distribution. One could, of

Re: Fast Efficient way to transfer an object to another list

2010-05-07 Thread Bryan
for n in old_list: assert n.code != 3 assert n in original_new_list or n in original_old_list assert old_list == [s for s in original_old_list if s in old_list] -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: HTTP server + SQLite?

2010-05-03 Thread Bryan
persistent data were stored via pickle. The SQLite developers state the situation brilliantly at http://www.sqlite.org/whentouse.html: "SQLite is not designed to replace Oracle. It is designed to replace fopen()." -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: matching strings in a large set of strings

2010-05-03 Thread Bryan
n sset If building the set is too slow, and you know you don't have a lot of duplicate strings, you can use a faster insert method that doesn't check whether the string is already in the set: def add_quick(self, s): assert len(s) == self.strlen self.table[self._hashstr(s)] += s -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast Efficient way to transfer an object to another list

2010-05-02 Thread Bryan
for n in source: assert not pred(n) assert n in original assert sorted(extracted) == extracted for n in extracted: assert pred(n) assert n in original -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: recommended way to insert data into a one to many relationship using python

2010-05-02 Thread Bryan
, number INTEGER, PRIMARY KEY (floor, number) ); CREATE TABLE employees ( eid INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, floor TEXT, room_number INTEGER, FOREIGN KEY (floor, room_number) REFERENCES rooms ) """ con = sqlite3.connect(":memory:") for cmd in schema.split(';'): con.execute(cmd) con.close() -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling multiple programs with subprocess

2010-04-23 Thread Bryan
ws, don't commit to modules devoted to rockin' on Unix. Python has multiple ways to run "wrenv.exe", then "make clean". In particular, check out os.system. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-23 Thread Bryan
he length of the entire sequence dominates n. I figure the worst-case run time is Theta(s lg(n)) where s in the length of the sequence. > Interestingly, nsmallest does use two different algorithms, > depending on how many items you ask for. See the source code. That is interesting. The

<    1   2   3   4   5   6   7   8   >