Re: some OT: how to solve this kind of problem in our program?

2006-12-26 Thread John Krukoff
ome kind of tree with bitwise digit packing?) would not fit in memory on any box I own. I would wonder if loading that much data isn't slower than solving the puzzle. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

RE: Accessing global namespace from module

2007-06-11 Thread John Krukoff
ule = new.module( 'plot' ) >>> plotModule.AddPlot = AddPlot >>> plotModule.DrawPlots = DrawPlots >>> sys.modules[ 'plot' ] = plotModule Then, you can import your fake module from anywhere, and access its contents. >>> import plot >>> plot >>> plot.AddPlot Hope that helps. - John Krukoff [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

RE: Accessing global namespace from module

2007-06-11 Thread John Krukoff
are > > >> responsible for bringing AddPlot and DrawPlots into the current > > >> namespace? > > >> Import the same things in your second module. > > > > > > No, I *don't* have any import statement mainscript.py. When using this > > > software

RE: Questions about mathematical and statistical functionality in Python

2007-06-14 Thread John Krukoff
ilman/listinfo/python-list It is worth noting that there's a bridge available to allow python to integrate cleanly with R, the Rpy project: http://rpy.sourceforge.net/ Which should allow you to use python for whatever it is you need without abandoning R for your mathematical/statistical work. - John Krukoff [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

RE: Reading multiline values using ConfigParser

2007-06-20 Thread John Krukoff
as there is a space or tab character imeediately after the CRLF. If my interpretation is correct (I've never tried this), then this would be a legal multi-line value. Testcases: tct123 tct124 tct101 It looks like you'd just get this back as the string 'tct123 tct124 tct101' though, so you'd have to split on whitespace to get the individual values. And, well, if you want to support whitespace in your value names, I don't think this will work at all. - John Krukoff [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

RE: Reading multiline values using ConfigParser

2007-06-21 Thread John Krukoff
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Phoe6 > Sent: Wednesday, June 20, 2007 8:51 PM > To: python-list@python.org > Subject: Re: Reading multiline values using ConfigParser > > On Jun 20, 10:35 pm, "Jo

RE: 'Advanced' list comprehension? query

2007-08-08 Thread John Krukoff
how in listItem, noShowList ) ) ) ) == len( noShowList) else False, myList ) ) ['item four'] Which can be made to look much better by breaking the 'noShow in listItem' test out into a separate function, and does have the advantage that by using itertools.ifilter this is a lazy approach. There's got to be a better way to do the test to see if takewhile bailed early than using len, though. - John Krukoff [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

RE: 'Advanced' list comprehension? query

2007-08-08 Thread John Krukoff
John Krukoff wrote: > > [EMAIL PROTECTED] wrote: > > Hi, > > > > I'm playing around with list comprehension, and I'm trying to find the > > most aesthetic way to do the following: > > > > I have two lists: > > > > noShowList =

RE: GC performance with lists

2007-09-04 Thread John Krukoff
g anything after creating this data structure as it starts swapping to disc. My architechtural suggestion would be to refactor this as an iterator if at all possible, so as to avoid the massive allocation burden. - John Krukoff [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

RE: Any way to refactor this?

2007-04-13 Thread John Krukoff
3D_xhatches(): list_of_kwargs = [ {pos:[ x, -hatch_length, 0], axis:[0, 2 * hatch_length, 0 ]}, {pos:[ x, 0, -hatch_length], axis:[0, 0, 2 * hatch_length ]}, And so on for all permutations... ] for x in xrange(-axis_length, axis_length + 1): if x == 0: con

Re: Does __import__ require a module to have a .py suffix?

2008-03-12 Thread John Krukoff
x27;ServiceModule' ) >>> compiled = compile( '''...some code here...''', '', 'exec', 0, 1 ) >>> exec compiled in service.__dict__ You could probably shorten it for your needs by using execfile instead. If it's not in

Re: [ANN]: circuits-1.0b1 released!

2008-12-30 Thread John Krukoff
.kamaelia.org/Home). Are these actually similar or am I missing something important that differentiates circuits? -- John Krukoff Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.5: wrong number of arguments given in TypeError for function argument aggregation (dictionary input vs the norm)

2008-10-30 Thread John Krukoff
t;", line 1, in TypeError: foo() takes exactly 3 non-keyword arguments (2 given) Is it even possible to get an error message in terms of required keyword arguments? I seem to remember seeing a note about keyword only arguments recently... -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Class instantiation fails when passed in a file but work via line by line interpreter

2008-11-18 Thread John Krukoff
gt; os.doesnotexist Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'doesnotexist' >>> class os( object ): ... pass ... >>> os.doesnotexist Traceback (most recent call last): File "", line 1, in AttributeError: type object 'os' has no attribute 'doesnotexist' -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-23 Thread John Krukoff
people who argued for this came from. But, if you'd just like a bit of discouragement, here's GvR arguing that there's just no good way to mix statements and expressions in python: http://www.artima.com/weblogs/viewpost.jsp?thread=147358 -- John Krukoff Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Best library to make XSLT 2.0 transformation

2009-05-19 Thread John Krukoff
t; > Diez While I firmly believe lxml is the best python XML library available, being built on libxml2 means that it only supports XSLT 1.0. As far as I know, if you want 2.0 support, you still need to be using one of the Java XSLT processors. -- John Krukoff Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

RE: no inputstream?

2008-05-15 Thread John Krukoff
ar as I know it's the only way to get partial transfers, though. Also, are you sure you're dealing with v1 tags and not v2? Since v2 tags are stored at the beginning (or sometimes end with v2.4) of the file. You might be better off just opening the file with urllib2 and handing it off

Re: no inputstream?

2008-05-15 Thread John Krukoff
n.org/mailman/listinfo/python-list It doesn't look like you can, with mutagen. So, time to find a different library that supports arbitrary file objects instead of only file paths. I'd suggest starting here: http://pypi.python.org/pypi?%3Aaction=search&term=id3&submit=search Possibly one with actual documentation, since that would also be a step up from mutagen. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: no inputstream?

2008-05-15 Thread John Krukoff
On Thu, 2008-05-15 at 17:11 -0600, John Krukoff wrote: > On Thu, 2008-05-15 at 15:35 -0700, max wrote: > > On May 15, 6:18 pm, MRAB <[EMAIL PROTECTED]> wrote: > > > On May 15, 9:00 pm, max <[EMAIL PROTECTED]> wrote: > > > > > > > you're r

Re: no inputstream?

2008-05-15 Thread John Krukoff
On Thu, 2008-05-15 at 17:32 -0600, John Krukoff wrote: > On Thu, 2008-05-15 at 17:11 -0600, John Krukoff wrote: > > On Thu, 2008-05-15 at 15:35 -0700, max wrote: > > > On May 15, 6:18 pm, MRAB <[EMAIL PROTECTED]> wrote: > > > > On May 15, 9:

Re: no inputstream?

2008-05-15 Thread John Krukoff
On Thu, 2008-05-15 at 17:42 -0600, John Krukoff wrote: > On Thu, 2008-05-15 at 17:32 -0600, John Krukoff wrote: > > On Thu, 2008-05-15 at 17:11 -0600, John Krukoff wrote: > > > On Thu, 2008-05-15 at 15:35 -0700, max wrote: > > > > On May 15, 6:18 pm, MRAB <[EMAI

Re: Question by someone coming from C...

2008-06-09 Thread John Krukoff
even then it'd be easy to make a wrapper function that made that easy given a collection of loggers. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Question by someone coming from C...

2008-06-10 Thread John Krukoff
On Wed, 2008-06-11 at 00:43 +0200, Christian Heimes wrote: > John Krukoff wrote: > > Since you probably want access to these from many different places in > > your code, I find the simplest way is to create a logging module of your > > own (not called logging, obviously) a

Re: seemingly simple list indexing problem

2008-07-28 Thread John Krukoff
t; Which'll work fine, unless you end up with a repeated value such as: a = [ 108, 58, 68, 108 ] If you have to deal with that, would need a more complicated solution to find the first free index slot of the available choices. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: seemingly simple list indexing problem

2008-07-28 Thread John Krukoff
108, 0), (58, 1), (68, 2)] >>> result = [ None, ] * len( listToSort ) >>> for sortedIndex, ( ignoredValue, originalIndex ) in enumerate( sorted( decorated ) ): ... result[ originalIndex ] = sortedIndex ... >>> result [2, 0, 1] -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: seemingly simple list indexing problem

2008-07-28 Thread John Krukoff
> Any help would be appreciated. > >> > >> -- > >> http://mail.python.org/mailman/listinfo/python-list > >> > >> > > > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list Sorry, problem was

Re: seemingly simple list indexing problem

2008-07-28 Thread John Krukoff
On Mon, 2008-07-28 at 16:00 -0700, iu2 wrote: > On Jul 29, 12:10 am, John Krukoff <[EMAIL PROTECTED]> wrote: > > On Mon, 2008-07-28 at 16:24 -0500, Ervan Ensis wrote: > > > My programming skills are pretty rusty and I'm just learning Python so > > > this pro

Re: seemingly simple list indexing problem

2008-07-30 Thread John Krukoff
On Wed, 2008-07-30 at 12:06 -0700, Tobiah wrote: > On Mon, 28 Jul 2008 23:41:51 -0700, iu2 wrote: > > > On Jul 29, 3:59 am, John Machin <[EMAIL PROTECTED]> wrote: > >> On Jul 29, 8:10 am, John Krukoff <[EMAIL PROTECTED]> wrote: > >> > >> >

Re: seemingly simple list indexing problem

2008-07-30 Thread John Krukoff
t;>> sorted(range(len(s)), key=s.__getitem__) > > > > [1, 2, 0] > > > > To get the desired output you have to apply it twice: > >>> sorted(range(len(s)), key=sorted(range(len(s)), > >>> key=s.__getitem__).__getitem__) > [2, 0, 1] > >

Re: when does the GIL really block?

2008-08-01 Thread John Krukoff
rinting a number to the screen certainly counts as. You might try again with a set of loops that only increment, and don't print, and you may more obviously see the GIL in action. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Best practise implementation for equal by value objects

2008-08-06 Thread John Krukoff
My question is: Is there a robust generic type of implementation of > __repr__ which I can use instead? > > This is something I plan to reuse for many different Value classes, so > I would like to get it robust. > > Thanks, > Slaunger > -- > http://mail.python.org/

Re: Calculate sha1 hash of a binary file

2008-08-06 Thread John Krukoff
our hashing code, that looks fine, if I were you I'd try and figure out what's going wrong with your file handles. I would suspect that in where ever you saw your short read, you were likely not opening the file in the correct mode or did not rewind the file ( with file.seek( 0 ) ) af

Re: Psycho question

2008-08-08 Thread John Krukoff
there's no expectation of a python 3.0 compatible version of psyco, either. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace Several Items

2008-08-13 Thread John Krukoff
-list The maketrans interface is a bit clunky, but this is what string.translate is best at: >>> import string >>> '-./other'.translate( string.maketrans( '', '' ), '-./' ) 'other' It'd be interesting to see where it falls in the benchmarks, though. It's worth noting that the interface for translate is quite different for unicode strings. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a tuple to a list

2008-04-08 Thread John Krukoff
Another solution using the itertools module: >>> import itertools >>> t = ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) ) >>> list( itertools.chain( *t ) ) [1, 2, 3, 4, 5, 6] Though the list part is probably unnecessary for most uses. The problem gets interesting when you want to recursively flatten an iterable of arbitratrily deeply nested iterables. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Recurring patterns: Am I missing it, or can we get these added to the language?

2008-04-15 Thread John Krukoff
__builtin__ module, and it'll be automatically imported whenever you run python. I'd doubt there's a case for getting this functionality added to the language, as your use case seems pretty specific, and it's just not that hard to write the function that does what you want to do. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Recurring patterns: Am I missing it, or can we get these added to the language?

2008-04-15 Thread John Krukoff
te match what the OP's nsplit function did, as his n parameter (maxsplit here) actually specified the number of list items in the result, not the number of splits to perform. Which makes matching the default split parameters kind of pointless, as why bother doing all this work to return a

RE: convert xhtml back to html

2008-04-24 Thread John Krukoff
d an external dependency. As far as I know, both 4suite and lxml (my personal favorite: http://codespeak.net/lxml/) support XSLT in python. It might work out fine for you, but mixing regexps and XML always seems to work out badly in the end for me. - John Krukoff [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: i want to add a timeout to my code

2008-04-29 Thread John Krukoff
ne > signal.signal(signal.SIGSLRM, handler), an attributeError appeared > reading that 'module' object has no attribute 'SIGALRM' > -- > http://mail.python.org/mailman/listinfo/python-list Are you writing your program on windows, or some other platform which is not unix? -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Create a process with a "time to live"

2008-08-15 Thread John Krukoff
15:38:58) [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import signal >>> signal.alarm( 1 ) 0 >>> Alarm clock (Interpreter exits) -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Digitally sign PDF files

2008-08-15 Thread John Krukoff
ttp://marketing.openoffice.org/ooocon2004/presentations/friday/timmermann_digital_signatures.pdf > [2] http://xmlsig.sourceforge.net/build.html > [3] http://kelpi.com/script/00cd7c > [4] > http://java.sun.com/javase/6/docs/technotes/guides/security/xmldsig/XMLDigitalSignature.html > -- > h

Re: iterparse and unicode

2008-08-20 Thread John Krukoff
... If you encode using UTF-8, you don't need to worry about the http://codespeak.net/lxml/parsing.html#python-unicode-strings You may also find the target parser interface to be more accepting of unicode than iterparse, though it requires a different parsing interface: http://codespeak.net/lxml/parsing.html#the-target-parser-interface -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle passing client/server design

2008-08-22 Thread John Krukoff
stening on a domain socket? > > I'm am thinking there would be a need to have a semaphore, and some > ACK or NACK that the server process got the whole pickle. > -- > http://mail.python.org/mailman/listinfo/python-list Quick bit of advice, don't reinvent the wheel, use PYRO:

Re: python/xpath question..

2008-09-03 Thread John Krukoff
man/listinfo/python-list Well, you could just do the test (and the count!) in the xpath expression: count( //tr/td[ text() != "" ] ) It sounds like you're not familiar with xpath? I would recommend the O'Reilly XSLT book, it has an excellent introduction to xpath in chapter 3. -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread John Krukoff
ython.org/mailman/listinfo/python-list -- John Krukoff <[EMAIL PROTECTED]> Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Overcoming python performance penalty for multicore CPU

2010-02-08 Thread John Krukoff
standard level of broken one finds most often on the web. And, when it falls down, it's easy to integrate BeautifulSoup as a slow backup for when things go really wrong (as J Kenneth King mentioned earlier): http://codespeak.net/lxml/lxmlhtml.html#parsing-html At least in my experience, I h

Re: Queue peek?

2010-03-02 Thread John Krukoff
s, whatever they are. This is one of those places where the GIL is a good thing, and makes your life simpler. You could consider it that the interpreter does the locking for you for such primitive operations, if you like. -- John Krukoff Land Title Guarantee Company -- http://mail.python.org/mai

Re: "is not" operator?

2010-07-08 Thread John Krukoff
e > the formal rules for this behavior? Don't forget about the similar "not in", as in: >>> 'a' not in 'abc' False This is probably the section of documentation you want: http://docs.python.org/reference/expressions.html#notin -- John Krukoff Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Pretty printing with ElementTree

2010-07-09 Thread John Krukoff
It's pretty simple minded, but this recipe from the element tree documentation may do what you want: http://effbot.org/zone/element-lib.htm#prettyprint -- John Krukoff Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: Best Pythonic Approach to Annotation/Metadata?

2010-07-15 Thread John Krukoff
of what you're running for development. -- John Krukoff Land Title Guarantee Company -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN]VTD-XML 2.9

2010-08-20 Thread John Krukoff
ng, but it doesn't look like this project even has a python version. So, why is it on the python-announce list? -- John Krukoff Land Title Guarantee Company jkruk...@ltgc.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Very strange issues with collections.Mapping

2018-01-19 Thread John Krukoff via Python-list
Have you ruled out the possibility that collections.Mapping has been (perhaps temporarily) assigned to something else? On Thu, Jan 18, 2018 at 2:37 PM, Jason Swails wrote: > Hello! > > I am running into a very perplexing issue that is very rare, but creeps up > and is crashing my app. > > The ro