Re: Boolean Search using Strings

2015-04-23 Thread Jack Diederich
Here is an old one I wrote. Good for small collections of documents and uncomplicated queries. https://github.com/jackdied/boolmatch -Jack On Thu, Apr 23, 2015 at 10:50 AM, wrote: > Dear Group, > > I want to do the Boolean search over various sentences or documents. > I do not want to use spec

Re: OAuth 2.0 implementation

2012-03-26 Thread Jack Diederich
On Tue, Mar 27, 2012 at 12:24 AM, Ben Finney wrote: > Roy Smith writes: > >> In article <878vimhfdp@benfinney.id.au>, >>  Ben Finney wrote: >> > So, if I want to be free to choose an identity provider I trust, and >> > it's not Facebook or Google or Twitter or other privacy-hostile >> > serv

Re: Guide to: Learning Python Decorators

2012-02-12 Thread Jack Diederich
just google "jack diederich decorators" it costs nothing and you get a free pycon talk out of it. -Jack -- http://mail.python.org/mailman/listinfo/python-list

Re: Debugging a difficult refcount issue.

2011-12-18 Thread Jack Diederich
I don't have any great advice, that kind of issue is hard to pin down. That said, do try using a python compile with --with-debug enabled, with that you can turn your unit tests on and off to pinpoint where the refcounts are getting messed up. It also causes python to use plain malloc()s so valgr

Re: Implementing Python-OAuth2

2011-10-11 Thread Jack Diederich
On Thu, Oct 6, 2011 at 12:15 PM, Jeff Gaynor wrote: > On 10/06/2011 08:34 AM, Kayode Odeyemi wrote: >> I'm working on a pretty large application that I will like to use oauth2 >> on as an authentication and authorization mechanism. > > There are *no* usable OAuth version 2..0 implementation in an

Re: with statement and context managers

2011-08-02 Thread Jack Diederich
On Tue, Aug 2, 2011 at 10:15 PM, Steven D'Aprano wrote: > I'm not greatly experienced with context managers and the with statement, so > I would like to check my logic. > > Somebody (doesn't matter who, or where) stated that they frequently use this > idiom: > > spam = MyContextManager(*args) > fo

Re: Generator Frustration

2011-06-04 Thread Jack Diederich
On Sat, Jun 4, 2011 at 9:43 PM, Gregory Ewing wrote: > Steven D'Aprano wrote: > >> A nice piece of syntax that has been proposed for Python is "yield from", >> which will do the same thing, but you can't use that yet. You can also patch the library to always return lists instead of generators. d

Re: Problems with read_eager and Telnet

2011-02-28 Thread Jack Diederich
On Mon, Feb 28, 2011 at 12:13 PM, Roberto Inzerillo wrote: > Yes. read_eager() will never actually read from the socket, if it has >> >> any data it has already read & processed it will return those.  If you >> call it enough times it will just start returning empty strings >> because it never ask

Re: Problems with read_eager and Telnet

2011-02-28 Thread Jack Diederich
On Mon, Feb 28, 2011 at 11:50 AM, Robi wrote: >> Telnet sends two kinds of data over the same channel (a simple TCP >> stream).  It sends the bytes you actually see in your terminal and it >> sends control commands that do things like turn echo on/off and >> negotiate what terminal type to use.  E

Re: Problems with read_eager and Telnet

2011-02-28 Thread Jack Diederich
On Mon, Feb 28, 2011 at 10:54 AM, Robi wrote: > Hi everybody, >  I'm totally new to Python but well motivated :-) > > I'm fooling around with Python in order to interface with FlightGear > using a telnet connection. > > I can do what I had in mind (send some commands and read output from > Flightg

Re: Use the Source Luke

2011-01-28 Thread Jack Diederich
On Fri, Jan 28, 2011 at 1:32 PM, Raymond Hettinger wrote: > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > >  http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > li

Re: Python Programmer needed in the LA area

2010-10-07 Thread Jack Diederich
On Thu, Oct 7, 2010 at 11:55 AM, Capstick, Antony H wrote: > I am looking for an experienced Person .. to develop and implement a > graphical track map operating in MS > Windows that will be used to display graphical information for a new Disney > attraction. 1) http://www.python.org/community/j

Re: ConFoo spam?

2010-10-07 Thread Jack Diederich
On Thu, Oct 7, 2010 at 7:56 AM, Diez B. Roggisch wrote: > Chris Withers writes: >> >> Is it just me or does the mailing of just about every single >> python-based project mailing list with a 90% form email advertising a >> conference that only has one python track *and* clashes with PyCon >> feel

Re: "is not" operator?

2010-07-08 Thread Jack Diederich
On Thu, Jul 8, 2010 at 10:02 PM, MRAB wrote: > sturlamolden wrote: >> It seems "y is not x" fits well with spoken English, but it is also a >> bit surprising that "y is not x" does not mean "y is (not x)" but "not >> (y is x)". Why does Python reorder is and not operators, and what are >> the form

Re: Efficiency/style issues of import vs. from import , ...

2010-06-17 Thread Jack Diederich
On Thu, Jun 17, 2010 at 12:58 PM, Stephen Hansen wrote: > On 6/17/10 10:01 AM, Ethan Furman wrote: >> Stephen Hansen wrote: >>> On 6/17/10 9:12 AM, pyt...@bdurham.com wrote: >>> >>> Now, this is all IMHO: the style guide does not define any 'guidelines' >>> on this, except that its okay to use "fr

Re: Community (A Modest Proposal)

2010-06-12 Thread Jack Diederich
On Sat, Jun 12, 2010 at 11:09 PM, rantingrick wrote: > > - >  Where is the community? > - [snip] > > You people need to get a life, drop your narcissistic attitudes and be > more helpful, friendly, and welcoming to the wider world. This > community i

Re: Non Sequitur: Re: Python Forum

2010-06-08 Thread Jack Diederich
On Tue, Jun 8, 2010 at 6:47 PM, Mark Young wrote: > According to the Oxford Dictionary: > > fish noun, verb noun (pl.fish or fishes)Fish is the usual plural form. The > older form, fishes, can be used to refer to different kinds of fish... > > However, I would correct anyone that ever used "fishes

Re: Ugly modification of a class, can it be done better ?

2010-05-20 Thread Jack Diederich
On Thu, May 20, 2010 at 8:13 PM, Stef Mientki wrote: > hello, > > This might be a strange question, but as a practical guy, I'm not searching > for the best solution, but for a practical solution. > > I've a class which I've used very extensively. > Now I want to extend that class with an action o

Re: Performance of list vs. set equality operations

2010-04-06 Thread Jack Diederich
On Tue, Apr 6, 2010 at 2:11 PM, Gustavo Narea wrote: > Hello! > > Could you please confirm whether my understanding of equality > operations in sets and lists is correct? This is how I think things > work, partially based on experimentation and the online documentation > for Python: > > When you c

Re: Classes as namespaces?

2010-03-26 Thread Jack Diederich
On Fri, Mar 26, 2010 at 10:49 AM, kj wrote: > > > What's the word on using "classes as namespaces"?  E.g. > > class _cfg(object): >    spam = 1 >    jambon = 3 >    huevos = 2 > > breakfast = (_cfg.spam, _cfg.jambon, _cfg.huevos) Classes as namespaces are a valid use case (I do it all the time).

Re: Dynamic Class Creation

2010-03-16 Thread Jack Diederich
On Tue, Mar 16, 2010 at 2:18 AM, Chris Rebert wrote: > On Mon, Mar 15, 2010 at 11:01 PM, Josh English > wrote: >> I have a large program with lots of data stored in XML. I'm upgrading >> my GUI to use ObjectListView, but with my data in XML, I don't have >> regular objects to interact with the OL

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jack Diederich
On Sat, Mar 13, 2010 at 12:10 PM, Jon Clements wrote: > On 13 Mar, 16:42, Jack Diederich wrote: >> On Sat, Mar 13, 2010 at 11:19 AM, Jon Clements wrote: >> > This is semi-experimental and I'd appreciate opinions of whether it's >> > the correct design appro

Re: class inheritance

2010-03-13 Thread Jack Diederich
On Sat, Mar 13, 2010 at 12:03 PM, JLundell wrote: > I've got a subclass of fractions.Fraction called Value; it's a mostly > trivial class, except that it overrides __eq__ to mean 'nearly equal'. > However, since Fraction's operations result in a Fraction, not a > Value, I end up with stuff like th

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jack Diederich
On Sat, Mar 13, 2010 at 11:19 AM, Jon Clements wrote: > This is semi-experimental and I'd appreciate opinions of whether it's > the correct design approach or not. It seems like a good idea, but it > doesn't mean it is. > > I have a class 'A', this provides standard support functions and > excepti

Re: isinstance(False, int)

2010-03-05 Thread Jack Diederich
On Fri, Mar 5, 2010 at 6:09 PM, Steven D'Aprano wrote: > On Fri, 05 Mar 2010 15:58:01 -0500, Jack Diederich wrote: > >>>> So, the pythonic way to check for True/False should be: >>>> >>>>>>> 1 is True >>>> False >>> &

Re: isinstance(False, int)

2010-03-05 Thread Jack Diederich
On Fri, Mar 5, 2010 at 2:54 PM, Steven D'Aprano wrote: > On Fri, 05 Mar 2010 15:01:23 -0400, Rolando Espinoza La Fuente wrote: > >> On Fri, Mar 5, 2010 at 2:32 PM, mk wrote: >>> Arnaud Delobelle wrote: >>> >>> 1 == True True >>> >>> 0 == False True So wha

Re: Generic singleton

2010-03-03 Thread Jack Diederich
On Wed, Mar 3, 2010 at 5:18 PM, Jonathan Gardner wrote: > On Wed, Mar 3, 2010 at 1:11 PM, mk wrote: >> >> Or I could make my life simpler and use global variable. :-) >> > > Ding ding ding! > > 90% of Design Patterns is making Java suck less. > > Other languages don't necessarily suffer from Java

Re: NoSQL Movement?

2010-03-03 Thread Jack Diederich
On Wed, Mar 3, 2010 at 12:36 PM, Xah Lee wrote: [snip] Xah Lee is a longstanding usenet troll. Don't feed the trolls. -- http://mail.python.org/mailman/listinfo/python-list

Re: Docstrings considered too complicated

2010-02-24 Thread Jack Diederich
On Wed, Feb 24, 2010 at 4:54 PM, Jonathan Gardner wrote: > On Wed, Feb 24, 2010 at 12:23 PM, Andreas Waldenburger > wrote: >> >> Now my question is this: How do I kill these people without the >> authorities thinking they didn't deserve it? >> > > kill -9 seems to work for me. kill -1 -1 Back i

Re: list.extend([]) Question

2010-02-05 Thread Jack Diederich
On Fri, Feb 5, 2010 at 11:31 AM, Gerald Britton wrote: > I think it's because when you do ['a'].extend([]) or whatever, the > result is whatever the method "extend" returns.  But "extend" has no > return value, hence you will see None if you do this interactively. > That sums it up. In Python th

Re: [Python-Dev] [RELEASED] Python 2.7 alpha 2

2010-01-09 Thread Jack Diederich
On Sat, Jan 9, 2010 at 2:53 PM, Jan Kaliszewski wrote: > Hello, > > I have a question: are class decorator planned to be backported from 3.x? > Eh? Class decorators have been in the 2.x series since 2.6. If you want to know more about class decorators check out this talk from PyCon 2009 http://p

Re: Any Swisses here?

2010-01-03 Thread Jack Diederich
On Sat, Jan 2, 2010 at 10:38 PM, n00m wrote: > On Jan 3, 5:30 am, Steve Holden wrote: >> Zhu Sha Zang wrote: >> >> [stuff and nonsense from a third party] >> > WTF? >> >> We do get the occasional bigot dropping in from time to time. Best to >> ignore them 'til they go away. >> > And who are YOU?

Re: My own accounting python euler problem

2009-11-07 Thread Jack Diederich
On Sat, Nov 7, 2009 at 4:39 PM, vsoler wrote: > In the accounting department I am working for we are from time to time > confronted to the following problem: [snip] > For example, say that the customer has the following outstanding > invoices:  $300, $200, $50; and say that the check is for $250.

Re: Haskell's new logo, and the idiocy of tech geekers

2009-10-03 Thread Jack Diederich
It's Xah Lee, he's been trolling this and every other programing language group for over 10 years (preferably all at once). Let it go. On Sat, Oct 3, 2009 at 2:53 AM, Chris Withers wrote: > Xah Lee wrote: >> >> Haskell has a new logo. A fantastic one. Beautiful. For creator, >> context, detail,

Re: Python RPG Codebase

2009-10-01 Thread Jack Diederich
On Thu, Oct 1, 2009 at 1:22 AM, Lanny wrote: > I've been thinking about putting together a text based RPG written > fully in Python, possibly expanding to a MUD system. I'd like to know > if anyone feels any kind of need for this thing or if I'd be wasting > my time, and also if anyone would be in

Re: socket send O(N**2) complexity

2009-09-22 Thread Jack Diederich
On Tue, Sep 22, 2009 at 7:25 PM, Nobody wrote: > On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote: > >>> AIUI, as a python string is imutable, a slice of a string is a >>> new string which points (C char *) to the start of the slice data >>> and with a

Re: socket send O(N**2) complexity

2009-09-21 Thread Jack Diederich
On Mon, Sep 21, 2009 at 4:00 PM, Rob Williscroft wrote: > AIUI, as a python string is imutable, a slice of a string is a > new string which points (C char *) to the start of the slice data > and with a length that is the length of the slice, about 8 bytes > on 32 bit machine. Not in CPython. Whi

Re: Mutable Strings - Any libraries that offer this?

2009-07-26 Thread Jack Diederich
On Mon, Jul 20, 2009 at 5:57 AM, casebash wrote: > Hi, > > I have searched this list and found out that Python doesn't have a > mutable string class (it had an inefficient one, but this was removed > in 3.0). Are there any libraries outside the core that offer this? It depends on how mutable you w

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-20 Thread Jack Diederich
On Mon, Jul 20, 2009 at 10:00 AM, Steven D'Aprano wrote: > On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: > >> Terry Reedy   wrote: >>>Sion Arrowsmith wrote: >>>> Jack Diederich   wrote: >>>>> It isn't an OrderedDict thing, it

Re: Try... except....Try again?

2009-07-17 Thread Jack Diederich
On Fri, Jul 17, 2009 at 10:35 AM, Xavier Ho wrote: > I changed my code to the following: > >     def nPrime(self, n): >     "Returns nth prime number, the first one being 2, where n = 0. When > n = 1, it returns 3." >     for x in range(n+2): >     try: >     return sel

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Jack Diederich
On Thu, Jul 16, 2009 at 2:21 AM, Mark Summerfield wrote: > Hi, > > I'm just wondering why <, <=, >=, and > are not supported by > collections.OrderedDict: > >    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) >    >>> d2 = d1.copy() >    >>> d2["z"] = 4 >    >>> d1 == d2 >    False >  

Re: decorators - would be nice if...

2009-07-14 Thread Jack Diederich
On Tue, Jul 14, 2009 at 5:44 PM, Ken Seehart wrote: > Almost every time I use decorators, I find myself wishing I had access > to the local namespace of the context from which the decorator is > executed.  In practice, decorator is being applied to a method, so the > namespace in question would be

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-03 Thread Jack Diederich
On Thu, Jul 2, 2009 at 2:36 PM, Carl Banks wrote: > On Jul 2, 3:12 am, Ulrich Eckhardt wrote: >> Bearophile wrote: >> > Ulrich Eckhardt: >> >> a way to automatically release the resource, something >> >> which I would do in the destructor in C++. >> >> > Is this helpful? >> >http://effbot.org/pyre

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Jack Diederich
On Sat, Jun 13, 2009 at 2:11 PM, kj wrote: > > > Switching from Perl here, and having a hard time letting go... > > Suppose I have an "array" foo, and that I'm interested in the 4th, 8th, > second, and last element in that array.  In Perl I could write: > >  my @wanted = @foo[3, 7, 1, -1]; > > I wa

Re: itertools.intersect?

2009-06-11 Thread Jack Diederich
On Thu, Jun 11, 2009 at 2:54 PM, Terry Reedy wrote: > Jack Diederich wrote: >> >> On Thu, Jun 11, 2009 at 12:03 AM, David M. Wilson wrote: >> [snip] >>> >>> I found my answer: Python 2.6 introduces heap.merge(), which is >>> designed exactly for th

Re: itertools.intersect?

2009-06-10 Thread Jack Diederich
On Thu, Jun 11, 2009 at 12:03 AM, David M. Wilson wrote: [snip] > I found my answer: Python 2.6 introduces heap.merge(), which is > designed exactly for this. Thanks, I knew Raymond added something like that but I couldn't find it in itertools. That said .. it doesn't help. Aside, heapq.merge fit

Re: itertools.intersect?

2009-06-10 Thread Jack Diederich
On Wed, Jun 10, 2009 at 6:24 PM, David Wilson wrote: > During a fun coding session yesterday, I came across a problem that I > thought was already solved by itertools, but on investigation it seems > it isn't. > > The problem is simple: given one or more ordered sequences, return > only the objects

Re: telnetlib in python-3.0

2009-04-29 Thread Jack Diederich
On Wed, Apr 29, 2009 at 11:31 PM, wrote: > Is anyone using telnetlib in python-3.0? If so are you having any > success? Using the example at the bottom of the telnetlib doc page I > cannot seem to get any joy at all. I can make a connection, but write > (command) seems to do nothing. 3.0 had

Re: Measuring time of a telnet connect

2009-04-15 Thread Jack diederich
On Wed, Apr 15, 2009 at 3:41 AM, Fabian Lanze wrote: > > I want to realize the following: I want to measure the time it takes to > build up a telnet connection to a known host (ip/port). I tried to use > subprocess.Popen to build the telnet connection and then to catch the > "Trying to connect..."

Know Your Python-Devs!

2008-03-22 Thread Jack Diederich
At the PyCon core python sprint I suggested this game and it got some laughs. So I put together a webpage for the game of: German, American, or Other? There is a list of about 30 core devs' last names. Highlight the white text on white background for the [mostly correct] answers. http://jackd

Re: Python object overhead?

2007-03-23 Thread Jack Diederich
On Fri, Mar 23, 2007 at 03:11:35PM -0600, Matt Garman wrote: > I'm trying to use Python to work with large pipe ('|') delimited data > files. The files range in size from 25 MB to 200 MB. > > Since each line corresponds to a record, what I'm trying to do is > create an object from each record. H

Re: Descriptor/Decorator challenge

2007-03-07 Thread Jack Diederich
On Tue, Mar 06, 2007 at 11:44:48AM -0800, Arnaud Delobelle wrote: > On 5 Mar, 18:59, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > [snip] > > Well in fact I couldn't help but try to improve it a bit. Objects now > > don't need a callerclass attribute, instead all necessary info is > > stored in a

Re: Py_BuildValue or PyList_SetItem()

2007-01-03 Thread Jack Diederich
On Wed, Jan 03, 2007 at 01:16:38PM -0800, Sheldon wrote: > I have a function that creates python objects out of C arrays and > returns them to Python. Below is a working example that I later want to > expand to return 12 arrays back to Python. The problem is that when I > print out the values in Py

Re: permutations - fast & with low memory consumption?

2006-12-19 Thread Jack Diederich
On Tue, Dec 19, 2006 at 03:14:51PM +0100, Christian Meesters wrote: > Hi, > > I'd like to hack a function which returns all possible permutations as lists > (or tuples) of two from a given list. So far, I came up with this solution, > but it turned out to be too slow for the given problem, because

Re: Mark Lutz Python interview

2006-12-13 Thread Jack Diederich
They eventually got this once posted on the website. http://techtalk.imi-us.com/Archives/2006/20061001/ The Lutz interview starts at 10:00 minutes in. -Jack On Fri, Sep 29, 2006 at 11:25:34AM -0700, Mark Lutz wrote: > Python author and trainer Mark Lutz will be interviewed > on the radio show Te

Re: bz2.readline() slow ?

2006-11-27 Thread Jack Diederich
On Fri, Nov 24, 2006 at 10:11:06AM +, Soeren Sonnenburg wrote: > Dear all, > > I am a bit puzzled, as > > -snip- > import bz2 > f=bz2.BZ2File('data/data.bz2'); > > while f.readline(): > pass > -snip- > > takes twice the time (10 seconds) to read/decode a bz2 file > c

Re: itertools.count(-3)

2006-09-21 Thread Jack Diederich
On Thu, Sep 21, 2006 at 08:29:11AM -0700, Carl Banks wrote: > > [EMAIL PROTECTED] wrote: > > itertools.count docs say: > > Does not currently support python long integers. > > Note, count() does not check for overflow and will return negative > > numbers after exceeding sys.maxint. This behavior m

Re: new string method in 2.5 (partition)

2006-09-19 Thread Jack Diederich
On Tue, Sep 19, 2006 at 07:23:50PM +, John Salerno wrote: > Bruno Desthuilliers wrote: > > > Err... is it me being dumb, or is it a perfect use case for str.split ? > > Hmm, I suppose you could get nearly the same functionality as using > split(':', 1), but with partition you also get the se

Dr. Dobb's Python-URL! - weekly Python news and links (Sep 14)

2006-09-14 Thread Jack Diederich
QOTW: "Regexps are a brittle tool, best tolerated in small doses." - Tim Peters "Simplicity is prerequisite for reliability" - Edsger W. Dijkstra eval(repr(var)) sometimes works for serialization but don't count on it. http://groups.google.com/group/comp.lang.python/browse_thread/t

Dr. Dobb's Python-URL! - weekly Python news and links (Sep 6)

2006-09-06 Thread Jack Diederich
QOTW: "The bad news is that I seem to be an anti-channeler, so my interest is perhaps not a *good* sign" - Jim Jewett "I'm sorry this letter is so long. I didn't have time to write a shorter one." - Blaise Pascal (1657) The Python 2.5 release date is now September 19th. http://www.p

Re: How ahead are you guys in the (Python) real world?

2006-08-30 Thread Jack Diederich
On Wed, Aug 30, 2006 at 08:01:02PM -0700, Aahz wrote: > In article <[EMAIL PROTECTED]>, > Neil Schemenauer <[EMAIL PROTECTED]> wrote: > >Aahz <[EMAIL PROTECTED]> wrote: > >> > >> My company uses 2.2 and 2.3; we hope to drop 2.2 Real Soon Now. > > > >This has been an interesting thread. There has

Dr. Dobb's Python-URL! - weekly Python news and links (Aug 30)

2006-08-30 Thread Jack Diederich
QOTW: "The best working hypothesis is that upgrading will break things." - Grant Edwards "Should I take this to mean: "Don't go near TNEF because your underwear will become carnivorous and consume your genitalia?" - Hendrik van Rooyen Which is better, Turbogears or Rails? Flame on.

Dr. Dobb's Python-URL! - weekly Python news and links (Aug 23)

2006-08-23 Thread Jack Diederich
QOTW: "Because there's no chance that the original request is sane." - Georg Brandl (responding to a question involving a Banana) "this is one of your last chances to test the new code in 2.5 before the final release. *Please* try this release out and let us know about any problems you find" - An

Re: PyThreadState_Swap(NULL)

2006-08-19 Thread Jack Diederich
On Sat, Aug 19, 2006 at 09:08:21AM -0700, Bryan wrote: > Jack Diederich wrote: > > On Fri, Aug 18, 2006 at 02:21:40PM -0700, Bryan wrote: > >> i've written a program that uses python c api code that lives in a > >> shared library that is loaded by a custo

Re: PyThreadState_Swap(NULL)

2006-08-19 Thread Jack Diederich
On Fri, Aug 18, 2006 at 02:21:40PM -0700, Bryan wrote: > > i've written a program that uses python c api code that lives in a > shared library that is loaded by a custom apache module (mod_xxx). this > python c api code all works correctly under our test server and under > apache but only if mo

Re: PySequence_SetItem

2006-08-17 Thread Jack Diederich
On Thu, Aug 17, 2006 at 02:35:11PM +0200, Fredrik Lundh wrote: > John Machin wrote: > > > 1. It's also documented as being the recommended way of filling up a > > list after PyList_New. > > since it doesn't work in any existing Python release, it's hardly > "recommended". > > the Python documen

Re: PySequence_SetItem

2006-08-16 Thread Jack Diederich
On Wed, Aug 16, 2006 at 05:13:23PM -0700, John Machin wrote: > > Jack Diederich wrote: > > On Wed, Aug 16, 2006 at 03:25:39PM -0700, John Machin wrote: > > > > > > > > > > > Not the OP's problem, but a bug in the manual: example in the chapter &g

Re: PySequence_SetItem

2006-08-16 Thread Jack Diederich
On Wed, Aug 16, 2006 at 03:25:39PM -0700, John Machin wrote: > > Jack Diederich wrote: > > On Wed, Aug 16, 2006 at 02:39:24PM -0700, John Machin wrote: > > > > > > Jack Diederich wrote: > > > > > > > Changing the PySequence_SetItem to PyList_S

Re: PySequence_SetItem

2006-08-16 Thread Jack Diederich
On Wed, Aug 16, 2006 at 02:39:24PM -0700, John Machin wrote: > > Jack Diederich wrote: > > > Changing the PySequence_SetItem to PyList_SetItem and dropping the > > DECREF works for me too (PyList functions steal a reference). I also > > tried setting the list to le

Re: PySequence_SetItem

2006-08-16 Thread Jack Diederich
On Wed, Aug 16, 2006 at 01:45:44PM -0700, John Machin wrote: > Bill Pursell wrote: > > Bill Pursell wrote: > > > > Also note that the problem goes away if I replace > > the call to PySequence_SetItem with: > > PySequence_SetItem(l, 0, PyInt_FromLong(1L)); > > Are you sure? It should make absolut

Dr. Dobb's Python-URL! - weekly Python news and links (Aug 15)

2006-08-15 Thread Jack Diederich
QOTW: "Consider changing your business plan: write crappy software, charge heaps for support -- it's not a novel idea" - John Machin "To make it run fast, use psyco. To make it even faster, implement the compare function in C." - Raymond Hettinger A Perl convert gladly announces his convers

Dr. Dobb's Python-URL! - weekly Python news and links (Aug 8)

2006-08-08 Thread Jack Diederich
QOTW: "being able to cook an egg" - Guido Van Rossum in response to the question, "What do you think is the most important skill every programmer should posses?" "I am asking for your forgiveness" - an open letter to Guido by someone who took the "D" in "BDFL" too literally. Parsing a Gramm

Re: Writing to a certain line?

2006-06-07 Thread Jack Diederich
On Wed, Jun 07, 2006 at 08:17:22PM +0200, Fredrik Lundh wrote: > Christophe wrote: > > > Use /dev/zero as source and /dev/null as destination :D > > have you tried looping over an endless null-byte stream? > > on a random Linux server, this statement > > >>> for line in open("/dev/zero"): > ..

Re: how not to run out of memory in cursor.execute

2006-06-05 Thread Jack Diederich
On Mon, Jun 05, 2006 at 07:34:05PM +0100, Steve Holden wrote: > amberite wrote: > > [EMAIL PROTECTED] wrote: > > > >>I am using cx_Oracle and MySQLdb to pull a lot of data from some tables > >>and I find that the cursor.execute method uses a lot of memory that > >>never gets garbage collected. Usi

Re: Programming language productivity

2006-05-19 Thread Jack Diederich
On Fri, May 19, 2006 at 02:21:39AM -0700, malv wrote: > Once you get involved in larger projects, the dynamic nature of the > programming tool becomes much more important. I mean by this, the > ability to stop running code, modify or add to it and continue without > having to re-establish the state

Re: Google-API Bad-Gateway-Error

2006-05-16 Thread Jack Diederich
On Tue, May 16, 2006 at 01:24:25PM +, John Bokma wrote: > [EMAIL PROTECTED] wrote: > > > It's quite strange, after calling the script several times it started > > to work; but sometimes the error occurs again. Maybe google has > > technical probs. > > Yup, I've seen exactly the same behavoir.

Re: interactive shell -- reload definitions?

2006-05-10 Thread Jack Diederich
On Wed, May 10, 2006 at 10:00:38AM -0700, malv wrote: > This is a question that comes up almost continuously for at least six > years now. > For Python users having to deal with major real-life applications, this > may make them think twice about the future suitability of Python as a > competitive

Re: A critic of Guido's blog on Python's lambda

2006-05-05 Thread Jack Diederich
On Fri, May 05, 2006 at 05:26:26PM -0700, Xah Lee wrote: > Python, Lambda, and Guido van Rossum [snip] Foxtrot Oscar Alpha Delta Others have said banning this troll would be wrong or undemocratic but let's be sane: he has wasted hundreds of hours of other people's time and hurt newbies especially

Re: Why does built-in set not take keyword arguments?

2006-05-04 Thread Jack Diederich
On Thu, May 04, 2006 at 02:08:30PM -0400, Steven Watanabe wrote: > I'm trying to do something like this in Python 2.4.3: > > class NamedSet(set): > def __init__(self, items=(), name=''): > set.__init__(self, items) > self.name = name > > class NamedList(list): > def __init__(self, ite

Re: Queue can result in nested monitor deadlock

2006-04-17 Thread Jack Diederich
On Mon, Apr 17, 2006 at 09:41:37AM -0700, Jonathan Amsterdam wrote: > If you don't want to call it deadlock, fine, but the program execution > I describe will make no progress to the end of time. Thread 2 can never > put anything in the queue, because Thread 1 holds M, and Thread 1 will > never rel

Re: Writing backwards compatible code

2006-04-14 Thread Jack Diederich
On Sat, Apr 15, 2006 at 04:04:44AM +1000, Steven D'Aprano wrote: > I came across an interesting (as in the Chinese curse) problem today. I > had to modify a piece of code using generator expressions written with > Python 2.4 in mind to run under version 2.3, but I wanted the code to > continue to u

Re: Manipulating sets from the 2.4 C API?

2006-04-11 Thread Jack Diederich
On Tue, Apr 11, 2006 at 09:29:10AM -0700, Dave Opstad wrote: > I just looked through the Python/C API reference for 2.4.3 and didn't > see anything about using sets. I'd been expecting things like PySet_New, > PySet_Check etc. There is a public C API starting in 2.5, the progression for sets was

Re: DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE

2006-04-01 Thread Jack Diederich
Xah, is that you? -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance profiling Python code

2006-03-24 Thread Jack Diederich
On Fri, Mar 24, 2006 at 09:33:55PM +0100, Andreas R?sdal wrote: > Hi, > > I'm using the Python profiler to optimize a pathfinding algorithm of a > game, and would like some help from someone who knows how to improve the > performance of Python code. The algorithm is A-Star, and it works > correctl

Re: Markov process representation

2006-03-15 Thread Jack Diederich
On Wed, Mar 15, 2006 at 04:50:31PM -0800, Paul Rubin wrote: > "kpp9c" <[EMAIL PROTECTED]> writes: > > self._all_states |= set(key[i] for key in probabilities) > > I am running: > > Python 2.3 (#1, Sep 13 2003, 00:49:11) > > generator comprehensions are new in 2.4. Try: > >self._all_state

Re: Silly import question (__file__ attribute)

2006-03-09 Thread Jack Diederich
On Thu, Mar 09, 2006 at 02:04:45PM -0800, mh wrote: > So on most modules I import, I can access the .__file__ attribute to > find the implementation. ie: > >>> import time > >>> time.__file__ > '/data1/virtualpython/lib/python2.3/lib-dynload/timemodule.so' > >>> import socket > >>> socket.__file__

Re: Proper class initialization

2006-03-01 Thread Jack Diederich
On Wed, Mar 01, 2006 at 09:25:36PM +0100, Christoph Zwerschke wrote: > Usually, you initialize class variables like that: > > class A: > sum = 45 > > But what is the proper way to initialize class variables if they are the > result of some computation or processing as in the following silly

Re: Soduku

2006-02-15 Thread Jack Diederich
On Wed, Feb 15, 2006 at 06:56:56PM -0800, Raymond Hettinger wrote: > [Jack Diederich] > > Is my math off or does 27ms mean 0.027 seconds? On my laptop (1.3GHz) > > an empty python program takes 10ms to run (0.010 secs). I ask out of > > vanity, my own solver takes .15 secon

Re: Soduku

2006-02-14 Thread Jack Diederich
On Tue, Feb 14, 2006 at 05:32:48PM -0800, Jonathan Gardner wrote: > Here at my job, Python gets no respect. > > A programmer here wanted to see which language among Python, Perl, and > Java was better. So he wrote a Python, perl, and Java version. Except > the Python version was 20x slower than th

Re: how do you pronounce 'tuple'?

2006-02-14 Thread Jack Diederich
On Tue, Feb 14, 2006 at 10:40:09AM -0500, Tim Peters wrote: > > the-acid-test-is-whether-you-say-"xor"-with-one-syllable-or-three-ly y'rs - > tim "Zorr!" of course. Saying "All hail the mighty Exclusive Or!" would just sound silly. -jackdied -- http://mail.python.org/mailman/listinfo/python-

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Jack Diederich
On Mon, Feb 13, 2006 at 08:52:06PM +, John Salerno wrote: > Terry Hancock wrote: > > > So what's a 1-element tuple, anyway? A "mople"? "monople"? > > It does seem like this lopsided pythonic creature (1,) ought > > to have a name to reflect its ugly, newbie-unfriendly > > nature. > > > > Are

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread Jack Diederich
liberally snipped out parts On Thu, Feb 09, 2006 at 03:25:18PM -0800, [EMAIL PROTECTED] wrote: > Jack Diederich wrote: > > > > On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote: > > > > > > > > > > I've got a reasonably sized list

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread Jack Diederich
On Thu, Feb 09, 2006 at 10:23:12AM -0800, [EMAIL PROTECTED] wrote: > Jack Diederich wrote: > > On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote: > > > Hi there, > > > > > > I've got a reasonably sized list of objects that I'd like to pull ou

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread Jack Diederich
On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote: > Hi there, > > I've got a reasonably sized list of objects that I'd like to pull out > all combinations of five elements from. Right now I have a way to do > this that's quite slow, but manageable. I know there must be a better > way to d

Re: Fast generation of permutations

2006-01-25 Thread Jack Diederich
On Wed, Jan 25, 2006 at 03:33:48PM +0100, Frode ?ijord wrote: > Hi all, > given a sequence of n elements i need to generate all possible > permutations of length k <= n. > > I found an elegant way to do this recursively: > > def comb(items, n): > if n==0: yield [] > else: > for i

Re: Guido at Google

2005-12-21 Thread Jack Diederich
On Wed, Dec 21, 2005 at 01:36:42PM -0500, rbt wrote: > Alex Martelli wrote: > > I don't think there was any official announcement, but it's true -- he > > sits about 15 meters away from me;-). > > For Americans: 15 meters is roughly 50 feet. Right, so that is about three and a half stone? -- ht

Re: Looking for small, impressive 3D-related Python script

2005-11-28 Thread Jack Diederich
On Mon, Nov 28, 2005 at 04:44:56PM -0600, Kenneth McDonald wrote: > I'm not trying to persuade my company to offer Python as a scripting > language for their product, but I am trying to give them examples of > things that Python can do easily that cannot be done easily with > their current pr

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-16 Thread Jack Diederich
On Tue, Nov 15, 2005 at 10:10:42PM -0800, Neal Norwitz wrote: > Alex Martelli wrote: > > matt <[EMAIL PROTECTED]> wrote: > > > > > Perhaps you could extend Valgrind (http://www.valgrind.org) so it works > > > with python C extensions? (x86 only) > > > > Alas, if it's x86 only I won't even look in

Re: When someone from Britain speaks, Americans hear a "British accent"...

2005-10-07 Thread Jack Diederich
On Fri, Oct 07, 2005 at 10:28:18PM -, Grant Edwards wrote: > On 2005-10-07, Jack Diederich <[EMAIL PROTECTED]> wrote: > > > > It is a bit odd that You'uns, yins, and yous are confined to Pennsylvania > > and very distinct east-west regions inside PA at that

Re: When someone from Britain speaks, Americans hear a "British accent"...

2005-10-07 Thread Jack Diederich
On Fri, Oct 07, 2005 at 09:14:51PM -, Grant Edwards wrote: > On 2005-10-07, Terry Hancock <[EMAIL PROTECTED]> wrote: > > > Of course, just to keep y'all on your toes, we Texans have not only > > construed "their" to singular, but also "you", and added a new > > plural "y'all". > > AFAICT, in

  1   2   >