non-gobject based dbus library?

2014-10-17 Thread Tycho Andersen
Hi all, An application I maintain recently moved away from the gobject event loop to the tulip/trollius/asyncio event loop. However, we were using python-dbus, which internally uses the gobject event loop, as our main event loop. This worked nicely when we were gobject based, but now that we're

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Tycho Andersen
On Fri, Oct 26, 2012 at 09:49:50AM +0200, Ulrich Eckhardt wrote: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Tycho Andersen
On Fri, Oct 26, 2012 at 05:36:50PM -0400, Dave Angel wrote: On 10/26/2012 05:26 PM, Tycho Andersen wrote: Assuming it's the length of the list that's the problem, not the length of the strings in the list... args = ['foo', 'bar', 'baz'] args[-1] = args[-1] + '\n' line = ' '.join(args

Re: Python Gotcha's?

2012-04-05 Thread Tycho Andersen
On Thu, Apr 05, 2012 at 08:32:10AM -0400, Roy Smith wrote: One of the hardest things about writing parsers is generating helpful error messages when things don't parse. But, it's only of value to do that when you're parsing something you expect to be written by a human, and thus a human

Re: No os.copy()? Why not?

2012-04-03 Thread Tycho Andersen
On Tue, Apr 03, 2012 at 03:46:31PM -0400, D'Arcy Cain wrote: On 03/28/12 16:12, John Ladasky wrote: I'm looking for a Python (2.7) equivalent to the Unix cp command. Since the equivalents of rm and mkdir are in the os module, I figured I look there. I haven't found anything in the

Generating a pkg config file with distutils

2012-03-27 Thread Tycho Andersen
Hi all, I'm distributing a package which for various legacy reasons needs to generate a pkgconfig file from a template (adding version numbers, prefixes, etc.) and install the file in the right place ($PREFIX/lib/pkgconfig/foo.pc in most cases). Currently, I have a rather nasty hack to implement

Re: Best way to disconnect from ldap?

2012-03-22 Thread Tycho Andersen
On Wed, Mar 21, 2012 at 04:49:54PM -0500, Tim Chase wrote: On 03/21/12 15:54, Chris Kaynor wrote: As Chris Rebert pointed out, there is no guarantee as to when the __del__ method is called. CPython will generally call it immediately, however if there are reference cycles it may never call it

Re: Best way to disconnect from ldap?

2012-03-22 Thread Tycho Andersen
On Thu, Mar 22, 2012 at 06:27:45AM -0700, Chris Rebert wrote: On Thu, Mar 22, 2012 at 6:14 AM, Tycho Andersen ty...@tycho.ws wrote: On Wed, Mar 21, 2012 at 04:49:54PM -0500, Tim Chase wrote: On 03/21/12 15:54, Chris Kaynor wrote: As Chris Rebert pointed out, there is no guarantee as to when

Re: Best way to disconnect from ldap?

2012-03-22 Thread Tycho Andersen
On Thu, Mar 22, 2012 at 05:26:11PM +, Steven D'Aprano wrote: On Thu, 22 Mar 2012 08:14:47 -0500, Tycho Andersen wrote: I've had similar experiences. In fact, in light of all this - why does __del__ exist at all? Novice python users may (reasonably) assume it behaves similarly to a C

Re: Generating a .pc file using distutils

2012-02-12 Thread Tycho Andersen
Just re-bumping this - I am fiddling with this code again and it's gross, so any input would be greatly appreciated :-) \t On Mon, Jan 23, 2012 at 05:31:20PM -0600, Tycho Andersen wrote: Is there some standard way to generate a .pc file (given a .pc.in or similar) using distutils

[issue13051] Infinite recursion in curses.textpad.Textbox

2012-01-25 Thread Tycho Andersen
Tycho Andersen ty...@tycho.ws added the comment: Hi, any movement on this? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13051 ___ ___ Python

Generating a .pc file using distutils

2012-01-23 Thread Tycho Andersen
Is there some standard way to generate a .pc file (given a .pc.in or similar) using distutils? If there's not, is there a good way to access whatever the user passes in as --prefix (besides parsing sys.argv yourself)? Thanks, \t -- http://mail.python.org/mailman/listinfo/python-list

[issue13051] Infinite recursion in curses.textpad.Textbox

2011-12-20 Thread Tycho Andersen
Tycho Andersen ty...@tycho.ws added the comment: Attached is a patch which contains a testcase as well. A few notes about this testcase: 1. I couldn't figure out how to get it to run correctly after all the other tests had run, so I had to run it first. This seems lame. One possible fix

Getting a patch accepted

2011-12-19 Thread Tycho Andersen
Hi all, A couple months ago I found a bug in a corner of the curses library (http://bugs.python.org/issue13051) and filed it. Unfortunately, there was nobody listed to cc on the noisy list, so it probably got lost in the shuffle. (There is even previous mention of this bug elsewhere on the

Re: unit-profiling, similar to unit-testing

2011-11-17 Thread Tycho Andersen
On Wed, Nov 16, 2011 at 09:36:40AM -0500, Roy Smith wrote: In article 95bcp8-bft@satorlaser.homedns.org, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Hi! I'm currently trying to establish a few tests here that evaluate certain performance characteristics of our

[issue13051] Infinite recursion in curses.textpad.Textbox

2011-09-27 Thread Tycho Andersen
New submission from Tycho Andersen ty...@tycho.ws: The attached patch fixes two bugs which manifest as infinite recursion in _insert_printable_char() of Textbox. First, the previous implementation of _insert_printable_char() used recursion to move characters when inserting a character. Thus

Re: Interpreting Left to right?

2011-06-24 Thread Tycho Andersen
On Fri, Jun 24, 2011 at 12:14:27AM -0700, Ethan Furman wrote: The example given to me when I had this question: -- x = x['huh'] = {} -- x {'huh': {...}} As you can see, the creation of the dictionary is evaluated, and bound to the name 'x'; then the key 'huh' is set to the same

Re: Interpreting Left to right?

2011-06-24 Thread Tycho Andersen
On Fri, Jun 24, 2011 at 01:13:08PM -0700, Ethan Furman wrote: Tycho Andersen wrote: On Fri, Jun 24, 2011 at 12:14:27AM -0700, Ethan Furman wrote: The example given to me when I had this question: -- x = x['huh'] = {} -- x {'huh': {...}} As you can see, the creation of the dictionary

Re: Interpreting Left to right?

2011-06-24 Thread Tycho Andersen
On Fri, Jun 24, 2011 at 01:24:24PM -0700, Ned Deily wrote: In article 20110624200618.gk6...@point.cs.wisc.edu, Tycho Andersen ty...@tycho.ws wrote: Yes, I understand that, but I guess I don't understand *why* things are done that way. What is the evaluation order principle at work here? I

Re: Interpreting Left to right?

2011-06-24 Thread Tycho Andersen
On Fri, Jun 24, 2011 at 05:02:00PM -0400, Terry Reedy wrote: On 6/24/2011 4:06 PM, Tycho Andersen wrote: tmp = {} x['huh'] = tmp # NameEror! That is, the right hand sides of assignments are evaluated before the left hand sides. That is (somehow?) not the case here. You are parsing

Re: split long string in two code lines

2011-06-13 Thread Tycho Andersen
On Mon, Jun 13, 2011 at 11:31:29PM +0200, Tracubik wrote: Hi all, newbie question here how can i write code like this: 1 def foo(): 2for index in ... 3for plsdoit in ... 4print this is a very long string that i'm going to write 5 here, it'll be for sure longer

Re: Proper way to handle errors in a module

2011-05-12 Thread Tycho Andersen
On Thu, May 12, 2011 at 03:12:39PM -0500, Andrew Berg wrote: On 2011.05.12 02:25 PM, MRAB wrote: You can raise an exception wherever you like! :-) If I raise an exception that isn't a built-in exception, I get something like NameError: name 'HelloError' is not defined. I don't know how to

re documentation bug?

2011-03-07 Thread Tycho Andersen
Consider the following session: Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type help, copyright, credits or license for more information. import re p = re.compile(foo) re.sub(p, bar, foobaz, flags=re.IGNORECASE) Traceback (most recent call last): File stdin, line

Re: Importing libs on Windows?

2010-08-12 Thread Tycho Andersen
On Thu, Aug 12, 2010 at 04:09:10PM -0700, Brian Salter wrote: I've seen a number of tutorials that describe how to bring in a dll in python, but does anybody know of a tutorial for how to bring in a lib? Is it even possible? I don't know if it's possible, but why do you want to do it? .lib

Re: introducing Lettuce, BDD tool for python with Django integration

2010-06-08 Thread Tycho Andersen
On Tue, Jun 8, 2010 at 9:18 PM, alex23 wuwe...@gmail.com wrote: On Jun 9, 3:29 am, Terry Reedy tjre...@udel.edu wrote: On 6/8/2010 2:26 AM, Gabriel Falcão wrote: There is not much to say, except to explain 'BDD'. If only there was some kind of way to quickly look up the meaning of

Re: Extract all words that begin with x

2010-05-10 Thread Tycho Andersen
On Mon, May 10, 2010 at 10:23 PM, Terry Reedy tjre...@udel.edu wrote: On 5/10/2010 5:35 AM, James Mills wrote: On Mon, May 10, 2010 at 6:50 PM, Xavier Hocont...@xavierho.com  wrote: Have I missed something, or wouldn't this work just as well: list_of_strings = ['2', 'awes', '3465sdg',

Re: Kindly show me a better way to do it

2010-05-08 Thread Tycho Andersen
On Sat, May 8, 2010 at 3:41 PM, Oltmans rolf.oltm...@gmail.com wrote: Hi, I've a list that looks like following a = [ [1,2,3,4], [5,6,7,8] ] Currently, I'm iterating through it like for i in [k for k in a]:        for a in i:                print a but I was wondering if there is a

Re: Kindly show me a better way to do it

2010-05-08 Thread Tycho Andersen
On Sat, May 8, 2010 at 4:09 PM, Günther Dietrich gd.use...@spamfence.net wrote: [snip] Too simple? No, not at all. I really only intended to point the OP to itertools, because it does lots of useful things exactly like this one. \t -- http://mail.python.org/mailman/listinfo/python-list

Re: list vs tuple for a dict key- why aren't both hashable?

2009-11-08 Thread Tycho Andersen
On Sun, 8 Nov 2009, Wells wrote: I'm not quite understanding why a tuple is hashable but a list is not. Any pointers? Thanks! The keys of a dict have to be immutable. Lists are mutable, tuples are not. \t -- http://mail.python.org/mailman/listinfo/python-list

Re: Less APIs or more encapsulation?

2009-09-09 Thread Tycho Andersen
On Wed, Sep 9, 2009 at 10:08 AM, 一首诗newpt...@gmail.com wrote: But when C has many many methods to expose to outer user, 2nd choice seems to be more reasonable I In the first design, B.newMethod did nothing really useful. Is there any reason you can't do something like the following? class

Re: Splitting on '^' ?

2009-08-14 Thread Tycho Andersen
On Fri, Aug 14, 2009 at 3:23 PM, kjno.em...@please.post wrote: [snip] import re re.split('^', 'spam\nham\neggs\n') ['spam\nham\neggs\n'] re.split('(?m)^', 'spam\nham\neggs\n') ['spam\nham\neggs\n'] bol_re = re.compile('^', re.M) bol_re.split('spam\nham\neggs\n') ['spam\nham\neggs\n'] Am

Re: How to fetch an XML file using an HTTPS query

2009-08-04 Thread Tycho Andersen
Blah, forgot to include the list. When is python-list going to get Reply-To? \t On Tue, Aug 4, 2009 at 8:38 AM, Tycho Andersenty...@tycho.ws wrote: Hi Ido, On Tue, Aug 4, 2009 at 6:25 AM, Ido Levyi...@il.ibm.com wrote: [snip] I got the following result in both cases:         ?xml

Re: Help understanding the decisions *behind* python?

2009-07-20 Thread Tycho Andersen
On Mon, Jul 20, 2009 at 11:27 AM, Phillip B Oldhamphillip.old...@gmail.com wrote: snip We often find we need to do manipulations like the above without changing the order of the original list, and languages like JS allow this. We can't work out how to do this in python though, other than

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Tycho Andersen
On Sat, Jul 18, 2009 at 4:43 PM, Irmen de Jongirmen.nos...@xs4all.nl wrote: twgray wrote: I am attempting to send a jpeg image file created on an embedded device over a wifi socket to a Python client running on a Linux pc (Ubuntu).  All works well, except I don't know, on the pc client side,

Re: import module unbelieveable behaviour

2009-07-15 Thread Tycho Andersen
On Wed, Jul 15, 2009 at 8:12 AM, Peter Fodrekpeter.fod...@stuba.sk wrote: Would anyone be helpful for me to get more information about this problem because  pydb does not show anything usable for me,please? What is the directory structure for the HeeksCNC module? Although I'm no expert, I