Re: gedit 'External Tools' plugin hashlib weirdness

2010-10-01 Thread Joel Hedlund
I apparently replied to soon. Removing /usr/lib/python2.4 from PYTHONPATH did not solve the problem. I think I may have had a launcher-started gedit running somewhere in the background while testing. Any subsequent terminal-launches would then just create new windows for the existing (non-bugged)

Re: gedit 'External Tools' plugin hashlib weirdness

2010-09-30 Thread Joel Hedlund
On Sep 30, 3:40 pm, Peter Otten <__pete...@web.de> wrote: > I'm surprised that /usr/lib/python2.4 doesn't appear in the traceback. That certainly would have been useful, wouldn't it? -- http://mail.python.org/mailman/listinfo/python-list

Re: gedit 'External Tools' plugin hashlib weirdness

2010-09-30 Thread Joel Hedlund
I guess the moral of the story is don't always dist-upgrade. Reformat once in a while to remove old forgotten garbage. Clear the blood clots from your systems, so to say. -- http://mail.python.org/mailman/listinfo/python-list

Re: gedit 'External Tools' plugin hashlib weirdness

2010-09-30 Thread Joel Hedlund
FOUND IT! I added the line print >> f, '\n'.join(sorted(sys.path)) and diff:ed the files produced from terminal/launcher. When using the launcher, changes to PYTHONPATH done in ~/.bashrc are not picked up, and I apparently had an old reference to /usr/lib/ python2.4 sitting in there. Removed it

Re: gedit 'External Tools' plugin hashlib weirdness

2010-09-30 Thread Joel Hedlund
How do I catch output to stdout/stderr when launching from a launcher? I added this to /usr/lib/gedit-2/plugins/externaltools/__init__.py: import sys f = open('/tmp/eraseme.txt', 'w') print >> f, "The executable is %r." % sys.executable f.close() In both cases (launcher/termial) the contents of

Re: gedit 'External Tools' plugin hashlib weirdness

2010-09-30 Thread Joel Hedlund
bah, I meant to say I'm running "a fully updated ubuntu lucid lynx (10.4)". -- http://mail.python.org/mailman/listinfo/python-list

gedit 'External Tools' plugin hashlib weirdness

2010-09-30 Thread Joel Hedlund
I'm having a weird problem with the 'External Tools' plugin for gedit, that seems to get weirder the more I dig into it. When I start gedit by clicking a launcher (from the Ubuntu menu, panel or desktop) everything is dandy and the 'External Tools' plugin works as expected. When gedit is launched f

Re: safe eval of moderately simple math expressions

2009-04-11 Thread Joel Hedlund
Peter Otten wrote: Joel Hedlund wrote: Peter Otten wrote: def is_it_safe(source): return "_" not in source and r'\' not in source "".join(map(chr, [95, 95, 110, 111, 95, 95])) '__no__' But you don't have access to neither map or chr? /

Re: safe eval of moderately simple math expressions

2009-04-11 Thread Joel Hedlund
Peter Otten wrote: def is_it_safe(source): return "_" not in source and r'\' not in source "".join(map(chr, [95, 95, 110, 111, 95, 95])) '__no__' But you don't have access to neither map or chr? /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: safe eval of moderately simple math expressions

2009-04-11 Thread Joel Hedlund
Peter Otten wrote: But what you're planning to do seems more like def is_it_safe(source): ... return "_" not in source ... source = "getattr(42, '\\x5f\\x5fclass\\x5f\\x5f')" if is_it_safe(source): ... print eval(source) ... Bah. You are completely right of course. Just as a thou

Re: safe eval of moderately simple math expressions

2009-04-11 Thread Joel Hedlund
Matt Nordhoff wrote: '\x5f' '_' getattr(42, '\x5f\x5fclass\x5f\x5f') # __class__ Is that enough to show you the error of your ways? No, because >>> print '_' in '\x5f\x5fclass\x5f\x5f' True :-D Cuz seriously, it's a bad idea. Yes probably, but that's not why. :-) (BTW: What if a use

Re: safe eval of moderately simple math expressions

2009-04-11 Thread Joel Hedlund
Matt Nordhoff wrote: '\x5f' '_' getattr(42, '\x5f\x5fclass\x5f\x5f') # __class__ Is that enough to show you the error of your ways? No, because >>> print '_' in '\x5f\x5fclass\x5f\x5f' True :-D Cuz seriously, it's a bad idea. Yes probably, but that's not why. :-) (BTW: What if a use

Re: safe eval of moderately simple math expressions

2009-04-11 Thread Joel Hedlund
Aaron Brady wrote: Would you be willing to examine a syntax tree to determine if there are any class accesses? Sure? How do I do that? I've never done that type of thing before so I can't really say if it would work or not. /Joel -- http://mail.python.org/mailman/listinfo/python-list

safe eval of moderately simple math expressions

2009-04-09 Thread Joel Hedlund
42).__class__.__base__.__subclasses__() if t.__name__ == 'file').next()" from messing things up. I assume there's lots of nasty and absolutely lethal stuff that I've missed, and I kindly request you show me the error of my ways. Thank you for your time! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: weird dict problem, how can this even happen?

2008-12-19 Thread Joel Hedlund
Joel Hedlund wrote: First off, please note that I consider my problem to be solved, many thanks to c.l.p and especially Duncan Booth. But of course continued discussion on this topic can be both enlightening and entertaining as long as people are interested. So here goes: heh, nothing like a

Re: weird dict problem, how can this even happen?

2008-12-17 Thread Joel Hedlund
Steven D'Aprano wrote: On Tue, 16 Dec 2008 14:32:39 +0100, Joel Hedlund wrote: Duncan Booth wrote: Alternatively give up on defining hash and __eq__ for FragmentInfo and rely on object identity instead. Object identity wouldn't work so well for caching. Objects would always be dra

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Joel Hedlund
Scott David Daniels wrote: Perhaps your hash function could be something like: I'm not sure I understand what you're suggesting. /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Joel Hedlund
Duncan Booth wrote: I think you probably are correct. The only thing I can think that might help is if you can catch all the situations where changes to the dependent values might change the hash and wrap them up: before changing the hash pop the item out of the dict, then reinsert it after the

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Joel Hedlund
Duncan Booth wrote: It could happen quite easily if the hash value of the object has changed since it was put in the dictionary. what does the definition of your core.gui.FragmentInfo object look like? Dunno if it'll help much, but: class FragmentInfo(object): def __init__(self, renderer,

weird dict problem, how can this even happen?

2008-12-15 Thread Joel Hedlund
hat I'm aware of. I can't even understand how this could happen. How do I even debug this? Please help, I feel like I've taken crazy pills here! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do_size_allocate properly in a gtk.Viewport subclass

2008-10-23 Thread Joel Hedlund
Joel Hedlund wrote: And another relevant question: am I overcomplicating this? Yes. :-) The proper way of doing this is to pack the widget in a container, and then add the container (with viewport) to a scrolledwindow. For example, for a centered widget choose a 1x1 gtk.Table and attach

Re: How to do_size_allocate properly in a gtk.Viewport subclass

2008-10-22 Thread Joel Hedlund
Hrvoje Niksic wrote: Note that there's a mailing list dedicated to PyGTK, <[EMAIL PROTECTED]>, so you might also want to ask your question there. Thanks. I'll try that and hope people won't take offense from cross-posting. I'll be wathching this thread for answers too though. In my experience

How to do_size_allocate properly in a gtk.Viewport subclass

2008-10-22 Thread Joel Hedlund
Hi! I've raised this issue on #pygtk and #gtk+ but with no luck. I haven't been able to solve this even with aid of google, the pygtk reference and the gtk C source, so pretty please help? I'm making an application that you can think of as an image viewer. I want to display a widget in a gtk

gtk.gdk.Pixbuf.scale() unexpected behavior when offset != 0

2008-06-17 Thread Joel Hedlund
interpolation methods. * This behavior is identical in gtk.gdk.Pixbuf.compose(). This can't possibly be how this is supposed to work! Have I misunderstood something, or is this a bug? Cheers! /Joel Hedlund <>-- http://mail.python.org/mailman/listinfo/python-list

Re: Test-driven development and code size

2007-09-26 Thread Joel Hedlund
> test-driven development merely means that you take that test case and > *keep it* in your unit test. Then, once you're assured that you will > find the bug again any time it reappears, go ahead and fix it. My presumption has been that in order to do proper test-driven development I would have t

Re: What is a good way of having several versions of a python module installed in parallell?

2007-09-25 Thread Joel Hedlund
First of all, thanks for all the input - it's appreciated. > Otherwise, three words: > > test driven development Do you also do this for all the little stuff, the small hacks you just whip together to get a particular task done? My impression is that doing proper unittests adds a lot of time

Re: What is a good way of having several versions of a python module installed in parallell?

2007-09-25 Thread Joel Hedlund
First of all, thanks for all the input - it's appreciated. > Otherwise, three words: > > test driven development Do you also do this for all the little stuff, the small hacks you just whip together to get a particular task done? My impression is that doing proper unittests adds a lot of time

What is a good way of having several versions of a python module installed in parallell?

2007-09-25 Thread Joel Hedlund
ose version after import: import mymodule mymodule.require_version("1.1.3") Is this a good way of thinking about it? What would be an efficient way of implementing it? Cheers! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Slightly OT: Why all the spam?

2007-05-23 Thread Joel Hedlund
> Then they aren't expired. If they were expired, you wouldn't > see them. Alright, so the solution is not to browse c.l.p articles newer than a week while the boss is behind your back then. :-) Thanks for educating a usenet white belt though! /Joel -- http://mail.python.org/mailman/listinfo/

Re: Slightly OT: Why all the spam?

2007-05-23 Thread Joel Hedlund
> Expired articles are removed on the server by the server. > ... > maybe Thunderbird is doing something weird (caching headers?). I can see the spam headers and also read the actual articles, and there are lots of them for the last 5 days. Nothing much before that, though. /Joel -- http://m

Re: Slightly OT: Why all the spam?

2007-05-23 Thread Joel Hedlund
> Thus you may want to consider reading c.l.p via nntp when at work. I'm doing that using Thunderbird 1.5.0, and I still get the spam. Googling for a bit shows me that people have been having issues with Thunderbird not removing expired articles all the way since 2003. Does anyone have a sugges

Slightly OT: Why all the spam?

2007-05-21 Thread Joel Hedlund
Does anyone know why we get so much spam to this group? It's starting to get embarrasing to read at work and that's just not how it should be. Cheers! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: Need startup suggestions for writing a MSA viewer GUI in python

2007-01-11 Thread Joel Hedlund
> UI design requires a different skillset than programming. It can be a > very frustrating and thankless task as well. It is incomparably easier > to see the flaws in existing interfaces than correcting them (or even > creating the said interface). Make sure to start with something simple, > and le

Re: Need startup suggestions for writing a MSA viewer GUI in python

2007-01-11 Thread Joel Hedlund
> This will probably be a major, but not humongous project. wxPython, > pyGTk, and pyQt all have the architecture and basics you'll need, it > will probably be about the same amount of work to create in all of > them. Pick the one that best suites your licensing and platform needs. Thanks for the

Need startup suggestions for writing a MSA viewer GUI in python

2007-01-10 Thread Joel Hedlund
PyGTK? Would they still allow me to render the MSA nicely? Does this seem like a humongous project? Thanks for taking the time! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: import parser does not import parser.py in same dir on win

2006-11-11 Thread Joel Hedlund
> the table of built-in modules are checked before searching the path. I figured as much. But why is the behavior different on linux/win? Is this documented somewhere? /Joel -- http://mail.python.org/mailman/listinfo/python-list

import parser does not import parser.py in same dir on win

2006-11-11 Thread Joel Hedlund
quot;? In both cases the script dir is first on sys.path, and I'm using the plain old terminal/cmd window. Thanks for your time. Cheers! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Slightly OT: Is pyhelp.cgi documentation search broken?

2006-10-27 Thread Joel Hedlund
> It works now again. You are now officially my hero. > Note that you can also download the module and use it locally. Cool. I'll do that! Thanks! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Slightly OT: Is pyhelp.cgi documentation search broken?

2006-10-26 Thread Joel Hedlund
bother for me, since I rely heavily on it for my work. Is it broken? If so, is anybody trying to get it back up again, and what's the time scale in that case? Is there an alternative available somewhere? Cheers! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
> Oh, I was just addressing your bit about not knowing unit tests. > Doctests can be quicker to put together and have only a small learning > curve. OK, I see what you mean. And you're right. I'm struggling mightily right now with trying to come up with sane unit tests for a bunch of generalized

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
> You might try doctests, they can be easier to write and fit into the > unit test framework if needed. While I firmly believe in keeping docs up to date, I don't think that doctests alone can solve the problem of maintaining data integrity in projects with more comlex interfaces (which is what

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
> I still wait for a > proof that it leads to more robust programs - FWIW, MVHO is that it > usually leads to more complex - hence potentially less robust - code. MVHO? I assume you are not talking about Miami Valley Housing Opportunities here, but bloat probably leads to bugs, yes. > Talking ab

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
> I'm not sure that trying to fight against the language is a sound > approach, whatever the language. That's the very reason I posted in the first place. I feel like I'm fighting the language, and since python at least to me seems to be so well thought out in all other aspects, the most obviou

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
> And while we're at it : please avoid top-posting. Yes, that was sloppy. Sorry. /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
said to Robert Kern in this thread, this does not really seem resolve the problem of setting an approprate level of validation. How do you do it? Please reply to the group if you can find the time. Cheers! /Joel Hedlund Bruno Desthuilliers wrote: > Joel Hedlund a écrit : >> Hi! &

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
s solution makes for extremely clean code, but the thought of potential silent data corruption makes me more than a little queasy. What level do you go for? Thanks! /Joel Robert Kern wrote: > Joel Hedlund wrote: >> Hi! >> >> The question of type checking/enforcing has b

Python style: to check or not to check args and data members

2006-08-31 Thread Joel Hedlund
ck with the barebone strategy, or should I go all the way? Did I miss something obvious? Should I read some docs? (Which?) Are there performance issues to consider? Thanks again for taking the time. Cheers! /Joel Hedlund """Example module without method argument type checking.

Re: sys.argv[0] doesn't always contain the full path of running script.

2006-08-31 Thread Joel Hedlund
> Running "python test.py" now prints /path/to/my_module.py, not > /path/to/my_script.py. That should have been "python my_script.py". Sorry for the slip-up. Cheers! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.argv[0] doesn't always contain the full path of running script.

2006-08-31 Thread Joel Hedlund
an imported module. Consider this: my_script.py: --- import my_module --- my_module.py: --- print __file__ --- Running "python test.py" now prints /path/to/my_module.py, not /path/to/my_scrip

Re: Has anyone used davlib by Greg Stein?

2006-07-31 Thread Joel Hedlund
> Has anyone worked with this? Is it any good? I'll take the palpable silence as a "no" then. :-) Thank's anyway! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Has anyone used davlib by Greg Stein?

2006-07-18 Thread Joel Hedlund
Hi! I want to PUT files to a authenticated https WebDAV server from within a python script. Therefore I put "python dav" into google, and the davlib module by Greg Stein (and Guido?) came up. It seems to be soild but has very little docs. Has anyone worked with this? Is it any good? Where can I

Re: logging module: add client_addr to all log records

2006-05-11 Thread Joel Hedlund
> See a very similar example which uses the new 'extra' keyword argument: Now that's brilliant! Exactly what I need. But unfortunately, it's also unavailable until 2.5 comes out. Until then I'm afraid I'm stuck with my shoddy hack... but it's always nice to know the time will come when I can fi

Re: Is this a good use of __metaclass__?

2006-05-09 Thread Joel Hedlund
Hi! Thanks for taking the time to answer. I will definitely have a look at writing dispatchers. > The problem you have with your metaclass version, is the infamous > metaclass conflict. I think I solved the problem of conflicting metaclasses in this case and I posted it as a reply to Bruno D

Is this a good use of __metaclass__?

2006-05-05 Thread Joel Hedlund
efinitions, and that gives me bad vibes. What should I do? Is there a way to fix my "Neat" solution? Is my "Ugly" solution in fact not so horrid as I think it is? Or should I rethink the whole idea? Or maybe stick with decorating manually (or in BaseAPI.__init__)? Sincere

Re: Possibly dumb question about dicts and __hash__()

2006-05-04 Thread Joel Hedlund
Hi! > Just the hash is not enough. You need to define equality, too: Thanks a million for clearing that up. Cheers! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Joel Hedlund
Beautiful! But how come my attempt didn't work? I've seen docs that explain how __hash__() methods are used to put objects in dict buckets: http://docs.python.org/ref/customization.html#l2h-195 But if it's really hash(str(o)) that's used for dict keys, what good are __hash__() methods? Or am I

Re: Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Joel Hedlund
>>>>d = {} >>>>d[a] = 1 >>>>d[b] = 50 >>>>print d > > {Delaware: 1, Hawaii: 50} > >>>>d[a] > > 1 > >>>>d[b] > > 50 > > Although this is a bit illegal, because repr is not supposed to be use

Possibly dumb question about dicts and __hash__()

2006-05-03 Thread Joel Hedlund
ash__() method? If so - what's the intended use of the __hash__() method? Is there a better way of implementing this? I realise I could just write d[o.name] = o but this problem seems to pop up every now and then and I'm curious if there's some neat syntactic trick that I could legally apply here. Thanks for your time! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Free Python IDE ?

2006-03-30 Thread Joel Hedlund
Ernesto wrote: > I'm looking for a tool that I can use to "step through" python software > (debugging environment). Is there a good FREE one (or one which is > excellent and moderately priced ) ? > Try searching this newsgroup for "python ide", "editor" and such and you'll get plenty of good ad

Re: Difference between 'is' and '=='

2006-03-29 Thread Joel Hedlund
> [*] I discovered a neat feature I didn't know my editor had: grepping for > "<[c:python-keyword>is" Neat indeed. Which editor is that? Thanks for a quick and comprehensive answer, btw. Cheers! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-29 Thread Joel Hedlund
27;re sure it's the right thing to do. don't use it when you're not > sure. > any other approach would be unpythonic. Right. Chill! /Joel Hedlund > > > > > -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-29 Thread Joel Hedlund
sorry > You compare a module.CONSTANT to the result of an expression s/an expression/a binary operation/ /joel Joel Hedlund wrote: >>If it weren't for the current CPython optimization (caching small >>integers) > > > This has already been covered elsewhere

Re: Difference between 'is' and '=='

2006-03-29 Thread Joel Hedlund
to less readable code. You should never use it, unless it leads to a *measurable* gain in performance, in which it should also be given a value equality fallback and a comment. And lastly, PEP8 should be changed to reflect this. Wow... that got a bit long and I applaud you for getting this far!

Re: Difference between 'is' and '=='

2006-03-28 Thread Joel Hedlund
t really does not apply. > (I think you should give it up... you're trying to push a rope.) I'm not pushing anything. I just don't like being misquoted. Cheers, Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-28 Thread Joel Hedlund
ot of nontrivial computations). That's where any real speed gains can be found. PEP8 tells me it's better style to write "a is None" and that's good enough for me. Otherwise I try to stay away from speed microoptimisations as much as possible since it generally results

Re: Difference between 'is' and '=='

2006-03-28 Thread Joel Hedlund
nge CONST, and "a is CONST" will *still* be True. Anyone who thinks it's a good idea to change a CONST that's not in a module that they have full control over must really know what they're doing or suffer the consequences. Most often, the consequences will be nasty bugs. Cheers! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-28 Thread Joel Hedlund
utations. > By doing an "is" instead of a "==" you *can* catch some errors. > > By > testing with "is" you test for *that* integer, the one defined on your > module and that shouldn't go out of it anyway. I totally agree with you on this poi

Re: Difference between 'is' and '=='

2006-03-28 Thread Joel Hedlund
meaning, as in the example that I cooked up in my post. More examples: os.R_OK, or more complex ones like mymodule.DEFAULT_CONNECTION_CLASS. Sorry for causing unneccessary confusion. Cheers! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-27 Thread Joel Hedlund
> "is" is like id(obj1) == id(obj2) > (Think of id as memory adresses.) Which means that "is" comparisons in general will be faster than == comparisons. According to PEP8 (python programming style guidelines) you should use 'is' when comparing to singletons like None. I take this to also includ

Re: OT: unix newbie questions

2006-03-26 Thread Joel Hedlund
s and options for commonly used programs and commands. If you type "cd " and hit tab for completions you will only see directories, since bash_completions knows that this is all cd accepts. Don't know if tcsh has anything similar. Cheers, Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Python has a new Logo

2006-03-24 Thread Joel Hedlund
__ c_c_c_C/ \C_c_c_c____ /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Become another user

2006-03-21 Thread Joel Hedlund
he admin to set things up so the server has permission to give away files to Joakim? Say, putting them in a common group or something? Just making the files world readable may not be the best option (which I believe is the only option otherwise). Cheers! /Joel Hedlund -- http://mail.python.org/m

Re: New-style Python icons

2006-03-21 Thread Joel Hedlund
> http://www.doxdesk.com/img/software/py/icons.png Neat! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting nested loop iterations

2006-03-17 Thread Joel Hedlund
> a list comprehension works exactly like an ordinary for > loop, except that the important thing (the expression) is moved to the > beginning of the statement. Right. Thanks! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-17 Thread Joel Hedlund
>>This "release" is as alpha as alpha gets. It's so alpha it >>actually loops back around to zeta -- but it's a start, and I >>think it's exactly what the Python community needs. > > > Not to pick nits, but that should actually be "... so alpha that it actually > loops back around to *OMEGA*." >

Re: Counting nested loop iterations

2006-03-17 Thread Joel Hedlund
can read up on this? Cheers, Joel Hedlund More detailed example: >>> c = [[1,4,8],[2,5,7]] >>> [a for b in c for a in b] [1, 4, 8, 2, 5, 7] >>> del a,b,c >>> c = [[1,4,8],[2,5,7]] >>> [a for a in b for b in c] Traceback (most recent call last)

Re: andmap and ormap

2006-03-14 Thread Joel Hedlund
ith the latest stable production release (2.4.2 at the time of writing I believe). Or should I start grabbing the Subversion trunk on a nightly basis? Cheers! /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IDE: great headache....

2006-03-13 Thread Joel Hedlund
act given up using Eclipse, but then I found that starter guide I linked to in my last post. It really is excellent. It's thorough and to the point, and I really recommend it to people who are interested in PyDev. Cheers, Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IDE: great headache....

2006-03-13 Thread Joel Hedlund
all I ever read and it was enough for me to get going with Eclipse + PyDev within 15 minutes on a WinXP machine. On a side note: with Ubuntulinux 5.10 it was more of a hassle, but that was just to get Eclipse running smoothly. I.e: an Eclipse/apt/Java problem. Once that was neatly in pla

Re: why use special config formats?

2006-03-10 Thread Joel Hedlund
I agree with Steve and I agree Sybren. Also: This is a Bad Idea, since you should never add more complexity than needed. Imports, computation, IO and so on are generally not needed for program configuration, so standard configfile syntax should therefore not allow it. Otherwise you may easily

Re: A bit OT: Python prompts display as nested mail quotes in Thunderbird

2006-03-10 Thread Joel Hedlund
> Do you have the Quote Colors extension? I do now. :-) > You can also disable the use of colors in the options, but that will > remove the colors for all messages. Or I can tell it to display colored '>' chars. Marvellous! Thanks for the advice! You're a real he

Re: A bit OT: Python prompts display as nested mail quotes in Thunderbird

2006-03-10 Thread Joel Hedlund
> They already ARE "plain text" (I don't know of anyone submitting > MIME/HTML enhanced content on this group). I know. > it would mean all other quoted text would not look "quoted" in your reader. I.e. they would have '>' chars at line start. That is *excatly* what I want and what I asked in m

Re: Inter-module globals

2006-03-09 Thread Joel Hedlund
cow Hope it helps! /Joel Hedlund main.py: #!/usr/bin/python import sys import graphics from common import Settings try: i = sys.argv.index('--gfx-dir') except ValueError: pass else: Settings.graphics_dir = sys.argv[

A bit OT: Python prompts display as nested mail quotes in Thunderbird

2006-03-09 Thread Joel Hedlund
else encountered/solved this problem? Should I get another newsgroup reader? In that case, which? I'm running Thunderbird 1.0.7 on Ubuntulinux 5.10. Thank you for your time, Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking function calls

2006-03-08 Thread Joel Hedlund
for argument 'cow' rose says moo! Traceback (most recent call last): File "/merlot1/yohell/eraseme/test.py", line 23, in -toplevel- make_noise('rose') File "/merlot1/yohell/eraseme/test.py", line 13, in moo raise TypeError TypeError ---

Re: help in converting perl re to python re

2006-03-03 Thread Joel Hedlund
> I'd go for > regexp = re.compile(r"<(tag1)>(.*?)") Indeed. I second that. /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: help in converting perl re to python re

2006-03-03 Thread Joel Hedlund
e there. :-) This should do it in python: #!/usr/bin/python import re regexp = re.compile(r"<(tag1)>(.*)") line = "sometext" match = regexp.search(line) if match: variable = match.group(2) -----

Re: editor for Python on Linux

2006-02-21 Thread Joel Hedlund
ditors. Another pro for IDLE is that you probably already have it installed, since it comes included in the standard python releases. If you decide to give IDLE a go you might also want to check out the latest subversion version of IDLE, since it has a bunch of really useful syntax helpe

Re: Best way of finding terminal width/height?

2006-02-15 Thread Joel Hedlund
> Sure. I was going to do that yesterday, but I realized that I > didn't know how/where to do it. I assume there's a link > somewhere at www.python.org, but I haven't had a chance to look > yet. It's already reported to the bug tracker: http://www.python.org/sf/210599 Apparently, this has been

Re: What editor shall I use?

2006-02-13 Thread Joel Hedlund
Lad wrote: > What editor shall I use if my Python script must contain utf-8 > characters? Also, don't overlook IDLE, the IDE that ships with python. I use it in my work every day. Once every three months or so I invest a day in looking for a better free python IDE/editor, and still after 3 years

Re: Replacing curses (Was: Re: Problem with curses and UTF-8)

2006-02-09 Thread Joel Hedlund
> The code for handling window resizing isn't jumping out at > me but I'll keep looking. (...jumping out, rather unexpectedly!) You might be interested in an ongoing discussion that I and Grant Edwards are holding in this newsgroup on the subject "Best way of finding terminal width/height?".

Re: Best way of finding terminal width/height?

2006-02-09 Thread Joel Hedlund
WINCH, report_terminal_size_change) Sorry about that. /Joel Joel Hedlund wrote: >> You might want to try just setting a flag in the signal handler >> to see if that prevents the I/O operations on stdin/stdout from >> being interrupted. > > > Tried this: > > > > import

Re: Best way of finding terminal width/height?

2006-02-09 Thread Joel Hedlund
> It didn't insert an EOF, it just caused read() to return > "prematurely". You should call read() again until it receives > a _real_ EOF and returns ''. Copy that. Point taken. > There appear to be a couple problems with this description: > > 1) It says that read() in blocking mode without a s

Re: Best way of finding terminal width/height?

2006-02-08 Thread Joel Hedlund
> sys.stdin.read() will return when ... the > underyling read() call is aborted by a signal. Not "return", really? Won't it just pass an exception? I thought that was what I was catching with the "except IOError" part there? I assumed that sys.stdin.read() would only return a value properly at

Re: Best way of finding terminal width/height?

2006-02-07 Thread Joel Hedlund
> You just call the failed read() or write() again. Unless > there's some way that the read/write partially succeeded and > you don't have any way to know how many bytes were > read/written, If that's the case then Python's "file" object > read and write would appear to be broken by design. Wow..

Re: Best way of finding terminal width/height?

2006-02-07 Thread Joel Hedlund
> You might want to try just setting a flag in the signal handler > to see if that prevents the I/O operations on stdin/stdout from > being interrupted. Tried this: import signal, os, sys from terminal_info import get_terminal_size terminal_size = get_terminal_size() _bTerminalSizeChanged = F

Re: Best way of finding terminal width/height?

2006-02-06 Thread Joel Hedlund
Thank you for a very quick, informative and concise response. > BTW: don't forget to attach a handler to the window-size-change > signal (SIGWINCH) so that you know when your terminal changes sizes Do you mean something like this? import signal, os # terminal_info contains the example from my fi

Re: Best way of finding terminal width/height?

2006-02-05 Thread Joel Hedlund
> Which details? We'd be happy to explain the code. Not that > you need to understand the details to use the code. OK, why '1234' in here, and what's termios.TIOCGWINSZ, and how should I have known this was the way too do it? fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234') Am I interpreting C str

Best way of finding terminal width/height?

2006-02-05 Thread Joel Hedlund
s for your time (and thanks Chuck for sharing your code!) /Joel Hedlund IFM Bioinformatics Linköping University Chuck Blake's terminal_size code snippet: (from http://pdos.csail.mit.edu/~cblake/cls/cls.py). def ioctl_GWINSZ(fd): TABU