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

2012-04-12 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

Re: is this foolish?

2012-04-12 Thread Karl Knechtel
On Thu, Apr 12, 2012 at 7:15 AM, Tim Golden m...@timgolden.me.uk 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:

Re: File traversing

2012-04-16 Thread Karl Knechtel
On Sun, Apr 15, 2012 at 5:51 AM, Chris Angelico ros...@gmail.com 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

Fwd: Python one-liner?

2012-04-16 Thread Karl Knechtel
On Sat, Apr 14, 2012 at 7:26 AM, Tim Chase python.l...@tim.thechases.com 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),

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 dmitre...@gmail.com 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. --

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 ros...@gmail.com wrote: On Fri, Apr 20, 2012 at 2:38 PM, alex23 wuwe...@gmail.com wrote: On Apr 20, 5:54 am, Jacob MacDonald jaccar...@gmail.com wrote: On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote: can I somehow overload

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 zahl...@gmail.com Date: Sat, May 12, 2012 at 8:25 AM Subject: Re: Newbie naive question ... int() throws ValueError To: Devin Jeanpierre jeanpierr

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 jeandaniel.bro...@gmail.com 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? --

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 andreas.t...@ubisoft.com 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

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 et...@stoneleaf.us 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

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 jeandaniel.bro...@gmail.com 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

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 jmweb...@gmail.com 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

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 nibi...@gmail.com wrote: Hello, I have the following code, which

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.append(5)` the first time

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,