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)
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
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
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
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
bah, I meant to say I'm running "a fully updated ubuntu lucid lynx
(10.4)".
--
http://mail.python.org/mailman/listinfo/python-list
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
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?
/
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
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
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
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
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
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
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
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
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
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
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,
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
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
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
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
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
> 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
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
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
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
> 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/
> 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
> 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
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
> 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
> 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
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
> 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
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
> 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
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
> 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
> 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
> 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
> 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
> And while we're at it : please avoid top-posting.
Yes, that was sloppy. Sorry.
/Joel
--
http://mail.python.org/mailman/listinfo/python-list
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!
&
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
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.
> 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
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
> 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
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
> 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
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
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
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
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
>>>>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
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
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
> [*] 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
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
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
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!
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
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
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
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
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
> "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
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
__ c_c_c_C/ \C_c_c_c____
/Joel Hedlund
--
http://mail.python.org/mailman/listinfo/python-list
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
> http://www.doxdesk.com/img/software/py/icons.png
Neat!
/Joel Hedlund
--
http://mail.python.org/mailman/listinfo/python-list
> 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
>>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*."
>
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)
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
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
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
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
> 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
> 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
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[
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
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
---
> I'd go for
> regexp = re.compile(r"<(tag1)>(.*?)")
Indeed. I second that.
/Joel
--
http://mail.python.org/mailman/listinfo/python-list
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)
-----
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
> 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
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
> 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?".
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
> 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
> 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
> 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..
> 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
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
> 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
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
99 matches
Mail list logo