Issues with `codecs.register` and `codecs.CodecInfo` objects

2012-07-06 Thread Karl Knechtel
Hello all, While attempting to make a wrapper for opening multiple types of UTF-encoded files (more on that later, in a separate post, I guess), I ran into some oddities with the `codecs` module, specifically to do with `.register` ing `CodecInfo` objects. I'd like to report a bug or something, bu

Re: append method

2012-05-23 Thread Karl Knechtel
On Wed, May 23, 2012 at 8:23 AM, 水静流深 <1248283...@qq.com> wrote: s=[1,2,3] s.append(5) s > [1, 2, 3, 5] s=s.append(5) s print s > None > > why can't  s=s.append(5)  ,what is the reason? For the same reason that you don't see `[1, 2, 3, 5]` immediately after doing `s.a

Re: print XML

2012-05-19 Thread Karl Knechtel
What do you want the contents of the file to look like? Why are you parsing the XML in the first place? (What do you want to happen if the data on `sys.stdin` isn't actually valid XML?) On Thu, May 17, 2012 at 9:52 AM, Nibin V M wrote: > Hello, > > I have the following code, which will assign  XM

Re: dynamically selecting a class to instantiate based on the object attributes.

2012-05-14 Thread Karl Knechtel
On Wed, May 9, 2012 at 7:02 AM, J. Mwebaze wrote: > > During object instantiaton, i would like to use  the specific class, that > corresponds to the version of the class that was used to create the object. I don't understand; "the version of the class that was used to create" **what** object? We'

Re: Good data structure for finding date intervals including a given date

2012-05-14 Thread Karl Knechtel
On Sat, May 12, 2012 at 10:18 AM, Jean-Daniel wrote: >> Since you say "intervals" in plural here, I assume that they can overlap? > > Yes, > > For instance, there are the following intervals : > [[1, 10], > [4, 7], > [6, 15], > [11, 17]] > > asking for the intervals including  5, the returned valu

Re: Dealing with the __str__ method in classes with lots of attributes

2012-05-14 Thread Karl Knechtel
On Sat, May 12, 2012 at 9:10 AM, Ethan Furman wrote: > > Firstly, __slots__ is a tuple. I object: conceptually, the "slots" of a class are set in stone, but the `__slots__` attribute of a class object is just an attribute, and any iterable (as long as it yields valid identifier names) can be used

Re: Dealing with the __str__ method in classes with lots of attributes

2012-05-12 Thread Karl Knechtel
On Thu, May 10, 2012 at 9:33 AM, Andreas Tawn wrote: > And there's also something like... > > return "\n".join((": ".join((str(k), str(self.__dict__[k]))) for k in > self.__dict__)) > > which is a nice length, but I lose control of the order of the attributes and > the formatting is fixed. It al

Re: Good data structure for finding date intervals including a given date

2012-05-12 Thread Karl Knechtel
On Sat, May 12, 2012 at 8:17 AM, Jean-Daniel wrote: > I am looking for a fast way to find the intervals > containing a given date, without having to check all intervals (less > than O(n)). Since you say "intervals" in plural here, I assume that they can overlap? -- ~Zahlman {:> -- http://mail.

Fwd: Newbie naive question ... int() throws ValueError

2012-05-12 Thread Karl Knechtel
I really wish gmail picked up the mailing list as a default reply-to address... -- Forwarded message -- From: Karl Knechtel Date: Sat, May 12, 2012 at 8:25 AM Subject: Re: Newbie naive question ... int() throws ValueError To: Devin Jeanpierre On Sat, May 12, 2012 at 12:11 AM

Re: can I overload operators like "=>", "->" or something like that?

2012-04-19 Thread Karl Knechtel
On Fri, Apr 20, 2012 at 12:43 AM, Chris Angelico wrote: > On Fri, Apr 20, 2012 at 2:38 PM, alex23 wrote: >> On Apr 20, 5:54 am, Jacob MacDonald wrote: >> >>> On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote: >>> > can I somehow overload operators like "=>", "->" or something like >>>

Re: can I overload operators like "=>", "->" or something like that?

2012-04-19 Thread Karl Knechtel
On Thu, Apr 19, 2012 at 3:28 PM, dmitrey wrote: > hi all, > can I somehow overload operators like "=>", "->" or something like > that? (I'm searching for appropriate overload for logical implication > "if a then b") > Thank you in advance, D. > -- > http://mail.python.org/mailman/listinfo/python-l

Fwd: Python one-liner?

2012-04-16 Thread Karl Knechtel
On Sat, Apr 14, 2012 at 7:26 AM, Tim Chase wrote: > > On 04/13/12 22:54, Chris Angelico wrote: >> >> Yes, that would be the right method to use. I'd not bother with the >> function and map() though, and simply iterate: >> >> d = {} >> for val in l: >>  d.setdefault(f(val), []).append(val) > > > Or

Re: File traversing

2012-04-16 Thread Karl Knechtel
On Sun, Apr 15, 2012 at 5:51 AM, Chris Angelico wrote: > > (You may also want to consider using the 'with' statement to guarantee > a timely closing of the file. Outside the scope of this mail though.) > > I think this list is just to collect unique entries, yes? If so, a set > may be more to you

Re: is this foolish?

2012-04-12 Thread Karl Knechtel
On Thu, Apr 12, 2012 at 7:15 AM, Tim Golden wrote: > On 12/04/2012 10:35, Cameron Simpson wrote: > > I've found myself using a Python gotcha as a feature. > > Have a look at Peter Inglesby's lightning talk from a > recent London Python Dojo: > > http://inglesp.github.com/2012/03/24/mutable-defau

[Windows] drag-and-drop onto .py file in modern versions?

2012-04-11 Thread Karl Knechtel
Hello all, Back when I had 2.6.x installed, I used to be able to drag a file onto a .py file in order to open it with that script (rather, pass the name of the file as `sys.argv[1]`). I did nothing special to make this work, as far as I can recall; it was something that the installer set up automa

Re: newbie question

2011-04-01 Thread Karl
Ah, all right. Thank you very much, eryksun! On 2011-04-01 22:48:44 +0200, eryksun () said: Regarding the format of your post, please use plain text only. On Friday, April 1, 2011 3:52:24 PM UTC-4, Karl wrote: aList = [0, 1, 2, 3, 4] bList = [2*i for i in aList] sum = 0 for j in bList: sum

newbie question

2011-04-01 Thread Karl
th 0, 1, 2, 3, ... Thanks! Karl-- http://mail.python.org/mailman/listinfo/python-list

Re: installation in mac os x

2009-06-24 Thread Karl Jansson
What happens if you work on the commandline (Terminal)? Python2.6 should be available from (out of my head) /Library/Frameworks/Python.framework/Versions/2.6/bin/python If that's working, it is successfully installed. Diez -- http://mail.python.org/mailman/listinfo/python-list If I work o

timeit and __future__

2009-06-19 Thread Karl Chen
I wanted to time something that uses with_statement, in python2.5. Importing __future__ in the statement or the setup doesn't work since it's not the beginning of the code being compiled. Other than using a separate module, I could only come up with this: timeit.template = 'from __future__ i

installation in mac os x

2009-06-10 Thread Karl Jansson
Hi, I was doing the tutorial at http://www.python.org/doc/current/ tutorial/, and I came across some code that did not work, and I got the following error: AttributeError: 'str' object has no attribute 'format'. So I downloaded a .dmg of python 2.6.2 and then I installed it. But it's

socket.getaddrinfo: flags |= AI_ADDRCONFIG

2008-11-05 Thread Karl Chen
MAPPED isn't as important since it only applies if you explicitly choose AF_INET6, a conscious decision.) Karl -- http://mail.python.org/mailman/listinfo/python-list

deleting an object

2008-09-25 Thread Karl Kobata
Please help. Questions based on snippet of code below. 1) when myTestCase is deleted, is just the pointer deleted or the entire instance with all of its data and data structure deleted? 2) What is the practice for deleted the object and recovering the memory it occupies? 3) If

fwd: member functions in a class

2008-09-18 Thread Karl Kobata
from *. Thanks karl -- http://mail.python.org/mailman/listinfo/python-list

member functions in a class

2008-09-17 Thread Karl Kobata
I am new to python and am wondering. When I create a class, with 'def' functions and if this class is instantiated say 50 times. Does this mean that all the 'def' functions code within the class is duplicated for each instance? Can someone give me a short and simple answer as to what happens in

Re: ka-ping yee tokenizer.py

2008-09-17 Thread Karl Kobata
Aaran, Thanks for your input. Your examples gave me other alternatives for what I wanted to do and it seems to work. Thanks all for your help. On Sep 16, 2:48 pm, "Karl Kobata" http://mail.python.org/mailman/listinfo/python-list> > wrote: > Hi Fredrik, > > Th

RE: ka-ping yee tokenizer.py

2008-09-16 Thread Karl Kobata
( modifyLine( myFileHandle ) ): Print token Anxiously looking forward to your thoughts. karl -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fredrik Lundh Sent: Monday, September 15, 2008 2:04 PM To: python-list@python.org Subject: Re: ka-ping yee

Re: manipulating class attributes from a decorator while the class is being defined

2008-04-19 Thread Karl-Heinz Ruskowski
> How can I reach the class attribute `regexps' from within a decorator? Now, the first way that comes to my mind is simply overloading the class and set your regexps variable in your new class. The other way is to create an object and set it more manually (obj.regexps = ['.*']). Which for me i

Re: Issue with inspect module

2008-04-19 Thread Karl-Heinz Ruskowski
> Why does the inspect module cause the output > to be printed twice? I also tested it, no problem here either. -- http://mail.python.org/mailman/listinfo/python-list

Re: Another MySQL Images Question

2008-04-18 Thread Karl-Heinz Ruskowski
Hi, > cursor.execute('update products set pic1="%s" where id="%s", ;', > (pic1, id)) Shouldn't it be something like cursor.execute('update products set pic1="%s" where id="%s", ;' % (pic1, id)) -- GPG key: 0x04B3BB96 pgpiL4LACYHv7.pgp Description: PGP signature -- http://mail.python.

Re: python setup.py install on Vista?

2008-04-18 Thread Karl-Heinz Ruskowski
hi > well using windows vista, where the h*** am i supposed to type this? you have to include the path to the python interpreter like this c:\programs\python\python.exe pythonfile.py (replace this with your path) or you set an alias called python - i don't know how to that under windows, especi

[Help]UnicodeDecodeError

2007-03-18 Thread Karl
error msg: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136,

Re: why I don't like range/xrange

2007-02-16 Thread Samuel Karl Peterson
Roel Schroeven <[EMAIL PROTECTED]> on Sat, 17 Feb 2007 01:31:13 GMT didst step forth and proclaim thus: ... > So, the point is that in C you can influence the loop's behavior by > modifying the loop variable, while you cannot do that in Python (at > least not in a for-loop). What's wrong with...

Re: string.replace non-ascii characters

2007-02-11 Thread Samuel Karl Peterson
Steven Bethard <[EMAIL PROTECTED]> on Sun, 11 Feb 2007 22:23:59 -0700 didst step forth and proclaim thus: > Samuel Karl Peterson wrote: > > Greetings Pythonistas. I have recently discovered a strange anomoly > > with string.replace. It seemingly, randomly does not deal w

Re: searching a list of lists as a two-dimensional array?

2007-02-11 Thread Samuel Karl Peterson
James Stroud <[EMAIL PROTECTED]> on Sun, 11 Feb 2007 16:53:16 -0800 didst step forth and proclaim thus: > agent-s wrote: > > Basically I'm programming a board game and I have to use a list of > > lists to represent the board (a list of 8 lists with 8 elements each). > > I have to search the adjace

Re: About getattr()

2007-02-11 Thread Samuel Karl Peterson
"Jm lists" <[EMAIL PROTECTED]> on Mon, 12 Feb 2007 12:36:10 +0800 didst step forth and proclaim thus: > Hello, > > Since I can write the statement like: > > >>> print os.path.isdir.__doc__ > Test whether a path is a directory > > Why do I still need the getattr() func as below? > > >>> print g

string.replace non-ascii characters

2007-02-11 Thread Samuel Karl Peterson
Greetings Pythonistas. I have recently discovered a strange anomoly with string.replace. It seemingly, randomly does not deal with characters of ordinal value > 127. I ran into this problem while downloading auction web pages from ebay and trying to replace the "\xa0" (dec 160, nbsp char in iso-

Re: No module named pyExcelerator Error

2007-02-11 Thread Samuel Karl Peterson
"susan" <[EMAIL PROTECTED]> on 11 Feb 2007 16:55:35 -0800 didst step forth and proclaim thus: > Hi, > I'm new of Python, and this problem stucked me whole day but can't be > solved. [snip] > anybody can tell me where's wrong please? Thanks in advance! What are the contents of sys.path from an i

Re: How to find all the same words in a text?

2007-02-11 Thread Samuel Karl Peterson
[EMAIL PROTECTED] on 11 Feb 2007 08:16:11 -0800 didst step forth and proclaim thus: > More concisely: > > import re > > pattern = re.compile(r'\b324\b') > indices = [ match.start() for match in > pattern.finditer(target_string) ] > print "Indices", indices > print "Count: ", len(indices) > Tha

Re: How to find all the same words in a text?

2007-02-11 Thread Samuel Karl Peterson
"Johny" <[EMAIL PROTECTED]> on 10 Feb 2007 05:29:23 -0800 didst step forth and proclaim thus: > I need to find all the same words in a text . > What would be the best idea to do that? I make no claims of this being the best approach: def findOccurances(a_string, word):

Re: Parsing HTML

2007-02-11 Thread Samuel Karl Peterson
"mtuller" <[EMAIL PROTECTED]> on 10 Feb 2007 15:03:36 -0800 didst step forth and proclaim thus: > Alright. I have tried everything I can find, but am not getting > anywhere. I have a web page that has data like this: [snip] > What is show is only a small section. > > I want to extract the 33,69

Re: PyThreadState_SetAsyncExc (nThreadId ??????, exc);

2006-12-14 Thread Karl H.
Func returning such a parameter. > Use the "thread_id" member of the PyThreadState object: PyThreadState *tstate; PyThreadState_SetAsyncExc(tstate->thread_id,exc); -Karl -- http://mail.python.org/mailman/listinfo/python-list

Re: What are python closures realy like?

2006-12-02 Thread Karl Kofnarson
> Karl, > > Usually when using this idiom, fun_basket would return a tuple of all of the > defined functions, rather than one vs. the other. So in place of: >>if f == 1: >>return f1 >>if f == 2: >>return f2 > Just do >>ret

What are python closures realy like?

2006-12-01 Thread Karl Kofnarson
Hi, while writing my last program I came upon the problem of accessing a common local variable by a bunch of functions. I wanted to have a function which would, depending on some argument, return other functions all having access to the same variable. An OO approach would do but why not try out cl

Backup Mailman?

2006-10-30 Thread Karl Groves
Does anyone out there know of a utility that will allow you to backup Mailman (including the subscribers and all messages)? TIA -- Karl Groves www.karlcore.com -- http://mail.python.org/mailman/listinfo/python-list

__delitem__ affecting performance

2006-10-19 Thread Karl H.
ng the code to run slower? It is not being called, so I don't see why it would affect performance. Overriding other sequence operators like __delslice__ does not exhibit this behavior. The speed difference doesn't really bother me, but I am curious. I used Python 2.4 for this test. -Karl -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling GPL code from a Python application

2006-01-04 Thread Karl A. Krueger
a "backup *nudge nudge wink wink*". An analogous provision exists in U.S. law, indeed in the same chapter cited above. It also covers copies made in the course of repairing a computer. -- Karl A. Krueger <[EMAIL PROTECTED]> { s/example/whoi/ } -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling GPL code from a Python application

2006-01-03 Thread Karl A. Krueger
tute *exempting* the running of software (and the making of backups) from copyright protection. That is, copyright does *not* grant the holder the right to restrain users from executing a copy of software that they have legally obtained. http://www.copyright.gov/title17/92chap1.html#117 -- Kar

Re: Software licenses and releasing Python programs for review

2005-06-02 Thread Karl A. Krueger
alone. Of course, if your customer is a proprietary software firm looking to own and sell the software restrictively, then they don't want those terms. But if they're just looking to use it privately and internally, I'm curious how the GPL would get in the way of that.

Re: 2D vector graphics Problem

2005-05-29 Thread Karl Max
"Scott David Daniels" <[EMAIL PROTECTED]> ha scritto nel messaggio news:[EMAIL PROTECTED] >> x = x * cos - y * sin - xRel * cos + yRel * sin + xRel >> y = x * sin + y * cos - xRel * sin - yRel * cos + yRel >> self.coords = (x,y) > > Your equation for y uses the new x, not the old x. De hi hi

2D vector graphics Problem

2005-05-29 Thread Karl Max
Hi all, I'm new here. Name's Max from tuscany, and I don't speak english very well :-) I am not veteran at coding, I am most like an "artisan coder" since commodore 64 times. Now the problem: I would like to have a little 2d engine to calculate and trace segments and poly's and their collision

Re: Regular Expressions - Python vs Perl

2005-04-21 Thread Karl A. Krueger
on, there do exist at least some Perl-compatible regex libraries in other non-Perl languages, which don't use libpcre. An example is CL-PPCRE (http://www.weitz.de/cl-ppcre/), which claims to be "more compatible with the regex semantics of Perl 5.8.0 than, say, Perl 5.6.1 is." --

Re: lambda closure question

2005-02-22 Thread Karl Anderson
ansition_tests.keys(): test_name = "test" + ig_name + tt_name test_fun = (lambda self, ig_name=ig_name, tt_name=tt_name: self.doTestItemStateTrans(ig_name, tt_name)) setattr(klass, test_name, test_fun) -- Karl Anderson [EMAIL PROTECTED] http://monkey.org/~kra/ -- http://mail.python.org/mailman/listinfo/python-list