Re: Upgrading standard library module

2009-02-17 Thread Bryan
On Feb 17, 12:34 am, "Gabriel Genellina" wrote: > En Fri, 13 Feb 2009 20:17:35 -0200, Bryan escribió: > > > > > On Feb 13, 1:52 pm, Jason Scheirer wrote: > >> On Feb 13, 12:42 pm, Bryan wrote: > > >> > I have a Python v2.5.2 server running

Decorator for validation - inefficient?

2008-10-31 Thread Bryan
I want my business objects to be able to do this: class Person(base): def __init__(self): self.name = None @base.validator def validate_name(self): if not self.name: return ['Name cannot be empty'] p = Person() print p.invalid # Prints ['Name cannot be empty'] p.name

Re: Decorator for validation - inefficient?

2008-11-01 Thread Bryan
Steven D'Aprano wrote: > On Fri, 31 Oct 2008 11:26:19 -0700, Bryan wrote: > > > I want my business objects to be able to do this: > [snip code] > > The code you show is quite long and complex and frankly I don't have the > time to study it in detail at the

Re: Decorator for validation - inefficient?

2008-11-02 Thread Bryan
On Nov 1, 6:57 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 01 Nov 2008 17:12:33 -0700, Bryan wrote: > > The list of validation error descriptions is returned instead of raising > > exceptions so clients can show the errors to the us

Re: Decorator for validation - inefficient?

2008-11-03 Thread Bryan
Steven D'Aprano wrote: > On Sun, 02 Nov 2008 09:33:41 -0800, Bryan wrote: > > > I'm coming from a .Net background, and yes, one of the reasons I did not > > consider raising exceptions was to avoid the overhead of an exception > > handler clause, which in .N

Re: complementary lists?

2009-04-29 Thread Bryan
On Apr 28, 11:16 pm, Arnaud Delobelle wrote: > Kay Schluehr writes: > > On 29 Apr., 05:41, Ross wrote: > >> If I have a list x = [1,2,3,4,5,6,7,8,9] and another list that is a > >> subset of x:  y = [1,4,7] , is there a quick way that I could return > >> the complementary subset to y z=[2,3,

Re: complementary lists?

2009-04-29 Thread Bryan
On Apr 28, 11:16 pm, Arnaud Delobelle wrote: > Kay Schluehr writes: > > On 29 Apr., 05:41, Ross wrote: > >> If I have a list x = [1,2,3,4,5,6,7,8,9] and another list that is a > >> subset of x:  y = [1,4,7] , is there a quick way that I could return > >> the complementary subset to y z=[2,3,

Re: What text editor is everyone using for Python

2009-05-27 Thread Bryan
ouching that horrible mouse contraption. Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening files without closing them

2006-03-07 Thread Bryan
level routine that cares or knows what to do. f = open('file') try: # do something finally: f.close() if i really want to handle the exception, then i handle it at a conceptually "higher" level by wrapping it in an exception which is basically what some higher-level routine would do anyways. try: f = open('file) try: # do something finally: f.close() except IOError: # handle exceptions bryan -- http://mail.python.org/mailman/listinfo/python-list

can't send large messages over SSL socket

2006-03-09 Thread Bryan
#x27;POST', '/foo', message, header) res = con.getresponse().read() thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: pywinauto 0.3.0 released - now localization proof

2006-03-21 Thread Bryan
emo and it's very nice. the only thing was in the demo it shows one Click() method to close the notepadabout dialog. but for me on windows xp media edition, it took two Click() methods. the first click clearly had the button depressed and the second click released the button back up. is this a bug in 0.3.0? or is it the new way of doing it... two clicks for each button? also, i would be really nice if the FAQ mentioned where you could get free or opensourced spy utilities so you could spy on controls and get their id values or internal names. thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

Using hash to see if object's attributes have changed

2009-12-11 Thread Bryan
When a user submits a request to update an object in my web app, I make the changes in the DB, along w/ who last updated it and when. I only want to update the updated/updatedBy columns in the DB if the data has actually changed however. I'm thinking of having the object in question be able to re

Re: Using hash to see if object's attributes have changed

2009-12-11 Thread Bryan
On Dec 11, 10:17 am, Robert Kern wrote: > On 2009-12-11 12:03 PM, Bryan wrote: > > > When a user submits a request to update an object in my web app, I > > make the changes in the DB, along w/ who last updated it and when.  I > > only want to update the updated/updatedBy

How to use list type generated by SWIG?

2010-01-10 Thread Bryan
I am writing a small script to manage my ipod. I am using the python bindings for libgpod. I have never used swig, or used python to program against a c/c++ library. I can get the library to find my ipod, and parse its DB format, but I'm not sure how to interact with the types that some of the f

How would you design scalable solution?

2009-10-28 Thread Bryan
I'm designing a system and wanted to get some feedback on a potential performance problem down the road while it is still cheap to fix. The system is similar to an accounting system where a system tracks "Things" which move between different "Buckets". The system answers these questions: - How ma

Re: Newbie advice

2009-10-29 Thread Bryan
as tons of useful libraries bla bla bla. This post describes the IDS vs language divide that I crossed over: http://osteele.com/archives/2004/11/ides Python can do everything you ask in your post, and their are many resources to help you do those things. I just wanted to give you some advice for the bigger picture. Bryan -- http://mail.python.org/mailman/listinfo/python-list

Dynamic property names on class

2009-11-13 Thread Bryan
I have several properties on a class that have very similar behavior. If one of the properties is set, all the other properties need to be set to None. So I wanted to create these properties in a loop like: class Test(object): for prop in ['foo', 'bar', 'spam']: # Attribut

Re: Dynamic property names on class

2009-11-13 Thread Bryan
On Nov 13, 9:34 am, "Diez B. Roggisch" wrote: > Bryan schrieb: > > > > > I have several properties on a class that have very similar behavior. > > If one of the properties is set, all the other properties need to be > > set to None.  So I wanted t

Efficiently building ordered dict

2010-02-22 Thread Bryan
I am looping through a list and creating a regular dictionary. From that dict, I create an ordered dict. I can't think of a way to build the ordered dict while going through the original loop. Is there a way I can avoid creating the first unordered dict just to get the ordered dict? Also, I am

Re: Efficiently building ordered dict

2010-02-22 Thread Bryan
On Feb 22, 9:19 am, MRAB wrote: > Bryan wrote: > > I am looping through a list and creating a regular dictionary.  From > > that dict, I create an ordered dict.  I can't think of a way to build > > the ordered dict while going through the original loop.  Is there a &g

Re: Efficiently building ordered dict

2010-02-22 Thread Bryan
On Feb 22, 10:57 am, "Alf P. Steinbach" wrote: > * Bryan: > > > > > I am looping through a list and creating a regular dictionary.  From > > that dict, I create an ordered dict.  I can't think of a way to build > > the ordered dict while going through

Re: Efficiently building ordered dict

2010-02-22 Thread Bryan
On Feb 22, 2:16 pm, "Diez B. Roggisch" wrote: > Am 22.02.10 22:29, schrieb Bryan: > > > > > On Feb 22, 10:57 am, "Alf P. Steinbach"  wrote: > >> * Bryan: > > >>> I am looping through a list and creating a regular dictionary.  From >

Re: Efficiently building ordered dict

2010-02-22 Thread Bryan
On Feb 22, 3:00 pm, "Diez B. Roggisch" wrote: > Am 22.02.10 23:48, schrieb Bryan: > > > > > On Feb 22, 2:16 pm, "Diez B. Roggisch"  wrote: > >> Am 22.02.10 22:29, schrieb Bryan: > > >>> On Feb 22, 10:57 am, "Alf P. Steinbach&q

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

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, 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, 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 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 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, 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, 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, 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, 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, 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, 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, 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-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-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: 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, 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: 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-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: 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-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: 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: any modules having a function to partition a list by predicate provided?

2010-04-20 Thread Bryan
I'll suggest the generalization: def partition(target, predicate): result = {} for item in target: result.setdefault(predicate(item), []).append(item) return result > true, false = [1,2,3,4].partition(lambda x: x >1) > > print true, false &g

Re: Write web apps in Python?

2010-04-20 Thread Bryan
atures -- how efficiently a web app gets invoked is not among them. It's not a language issue. What was the theory here? Did we think the PHP community too stupid to understand FastCGI? -- --Bryan Olson -- http://mail.python.org/mailman/listinfo/python-list

Re: Write web apps in Python?

2010-04-20 Thread Bryan
Bruno wrote: > Bryan a écrit : > > I think you guys got some incorrect info about PHP. A variety of > > execution options are available, such as FastCGI and in-server > > modules. > > mod_php, yes, but that doesn't change anything to the fact that it has > to

Re: Write web apps in Python?

2010-04-21 Thread Bryan
didn't say when that was, but PHP caching has come a long way. Google is your friend. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Write web apps in Python?

2010-04-21 Thread Bryan
Bruno Desthuilliers wrote: > Bryan a écrit : > > > Bruno Desthuilliers wrote: > >> Nope. I want to keep all my settings parsed, my librairies loaded, all > >> my connections opened etc. That is, all the time consuming stuff at app > >> startup - which, with

Re: Write web apps in Python?

2010-04-22 Thread Bryan
-- how efficiently a web app gets invoked is not among them. It's not a language issue." Bruno disagreed when it comes to PHP. But obviously Bruno and I don't communicate all that well. -- --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

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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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-25 Thread Bryan
abandon the naive algorithm. -- --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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

Get name of class without instance

2009-06-24 Thread Bryan
Given a class: class Foo(object): pass How can I get the name "Foo" without having an instance of the class? str(Foo) gives me more than just the name Foo. "__main__.Account" Foo.__class__.__name__ gives me "type" I don't want to do: Foo().__class__.__name__ if possible. I would rather a

Re: Get name of class without instance

2009-06-24 Thread Bryan
On Jun 24, 9:25 am, Tim Golden wrote: > Bryan wrote: > > Given a class: > > > class Foo(object): > >     pass > > > How can I get the name "Foo" without having an instance of the class? > > > str(Foo) gives me more than just the name Foo.   &q

Automate rsync w/ authentication

2009-07-10 Thread Bryan
I am trying to automate rsync to backup server A from server B. I have set up a private/public key between the two servers so I don't have to enter a password when using rsync. Running rsync manually with the following command works fine: rsync -av --dry-run -e "/usr/bin/ssh -i /home/bry/keys/bry

Re: Automate rsync w/ authentication

2009-07-10 Thread Bryan
On Jul 10, 12:43 pm, Piet van Oostrum wrote: > >>>>> Chris Rebert (CR) wrote: > >CR> On Fri, Jul 10, 2009 at 9:13 AM, Bryan wrote: > >>> I am trying to automate rsync to backup server A from server B.  I > >>> have set up a private/public k

Re: Automate rsync w/ authentication

2009-07-13 Thread Bryan
On Jul 10, 12:03 pm, mgi...@motorola.com (Gary Duzan) wrote: > In article > <3af970b1-b454-4d56-a33f-889ecfaca...@l28g2000vba.googlegroups.com>, > > Bryan   wrote: > > >rsyncExec = '/usr/bin/ssh' > >source = 'r...@10.0.45.67:/home/bry/jquery.lookup&

Script runs manually, but cron fails

2009-07-24 Thread Bryan
I have a backup script that runs fine when I run it manually from the command line. When I run it with cron, the script stops running at random points in the source code. The script calls rsync with the subprocess module, which in turn uses ssh to backup files from a box on my lan. It also uses

<    1   2   3   4   5   6   7   8   >