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)
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
bah, I meant to say I'm running a fully updated ubuntu lucid lynx
(10.4).
--
http://mail.python.org/mailman/listinfo/python-list
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
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,
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
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
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
Matt Nordhoff wrote:
'\x5f'
'_'
getattr(42, '\x5f\x5fclass\x5f\x5f') # __class__
type 'int'
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
Matt Nordhoff wrote:
'\x5f'
'_'
getattr(42, '\x5f\x5fclass\x5f\x5f') # __class__
type 'int'
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
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)
...
type 'int'
Bah. You are completely right of course.
Just as
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:
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?
/Joel
'5f5f7374696c6c5f6e6f745f736166655f5f'.decode
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
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 drawn
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,
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
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
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
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
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,
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
inline: hasselhoff.jpeg--
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 to
:
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
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
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
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
--
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
--
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
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
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 learn
nicely?
Does this seem like a humongous project?
Thanks for taking the time!
/Joel Hedlund
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
, 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
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 bothered me for a while, and
since this newsgroup
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!
The question of type checking
And while we're at it : please avoid top-posting.
Yes, that was sloppy. Sorry.
/Joel
--
http://mail.python.org/mailman/listinfo/python-list
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 obvious
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 about
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
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
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_script.py.
Cheers!
/Joel Hedlund
--
http
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
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.
Pros:
Pinpointed tracebacks with very exact error messages.
Cons
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
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
? 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 thanks for your time.
Cheers!
/Joel Hedlund
Background
##
(feel free to skip this if you are in a hurry)
I'm writing
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
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
illegal, because repr is not supposed to be used
this way.
Joel Hedlund wrote:
Hi!
There's one thing about dictionaries and __hash__() methods that puzzle me. I
have a class with several data members, one of which is 'name' (a str). I
would
like to store several of these objects in a dict
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
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 advice.
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! :-) Thanks
for taking the time to read it.
So what are your thoughts about this, then?
Cheers!
/Joel Hedlund
--
http://mail.python.org/mailman
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 in this thread. Read up
approach would be unpythonic.
Right.
Chill!
/Joel Hedlund
/F
--
http://mail.python.org/mailman/listinfo/python-list
[*] I discovered a neat feature I didn't know my editor had: grepping for
[c:python-keywordis
Neat indeed. Which editor is that?
Thanks for a quick and comprehensive answer, btw.
Cheers!
/Joel
--
http://mail.python.org/mailman/listinfo/python-list
,
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
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 point. Anything that helps guarding against
stealthed errors is a good thing by my standards.
Cheers!
/Joel Hedlund
--
http://mail.python.org/mailman
, 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
away from speed microoptimisations as much as possible since it
generally results in less readable code, which in turn often results in an
overall speed loss because code maintenance will be harder.
Cheers!
/Joel Hedlund
--
http://mail.python.org/mailman/listinfo/python-list
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
is is like id(obj1) == id(obj2)
snip
(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 include
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
/Joel Hedlund
--
http://mail.python.org/mailman/listinfo/python-list
http://www.doxdesk.com/img/software/py/icons.png
Neat!
/Joel Hedlund
--
http://mail.python.org/mailman/listinfo/python-list
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/mailman/listinfo/python-list
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):
File pyshell#30, line 1, in -toplevel-
[a for a in b for b in c]
NameError
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*.
I think he's
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
with 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
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 place, that guide above worked flawlessly.
Cheers!
/Joel Hedlund
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
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 my post.
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 help.
/Joel Hedlund
--
http
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
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
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[i + 1]
print
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
Hope it helps
/Joel Hedlund
--
http
:
#!/usr/bin/python
import re
regexp = re.compile(r(tag1)(.*)/\1)
line = tag1sometext/tag1
match = regexp.search(line)
if match:
variable = match.group(2)
Good luck!
/Joel Hedlund
[EMAIL PROTECTED
I'd go for
regexp = re.compile(r(tag1)(.*?)/\1)
Indeed. I second that.
/Joel
--
http://mail.python.org/mailman/listinfo/python-list
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 helper updates.
Cheers!
/Joel Hedlund
--
http
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
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 size
, 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:
source
import signal, os, sys
from terminal_info import
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?.
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 EOF?
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:
source
import signal, os, sys
from terminal_info import get_terminal_size
terminal_size = get_terminal_size()
_bTerminalSizeChanged
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... I
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
(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): TABULATION FUNCTIONS
try
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
99 matches
Mail list logo