On Jul 24, 5:20 am, Bruno Desthuilliers wrote:
> IIRC, __new__ is supposed to return the newly created object - which you
> are not doing here.
>
> class Bar(Foo):
> def __new__(cls, a, b, c, *args):
> print 'Bar.__new__', len(args)
> if not args:
> cls = Zoo
>
Ok here's the problem, I'm modifying a 3rd party library (boto) to
have more specific exceptions. I want to change S3ResponseError into
about 30 more specific errors. Preferably I want to do this by
changing as little code as possible. I also want the new exceptions to
be a subclass of the old S3Re
On Dec 21, 5:59 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>You just need to turn things around:
> >>> def foo(a, b, c):
> ... return a, b, c
> ...
> >>> args = range(2)
> >>> foo(c=2, *args)
> (0, 1, 2)
> >>>
You know, I feel like a real shmuck for not trying that...
Th
You can use 2005 to build extensions for Python 2.5. I've done this
with several extensions, both my own and others. I do not know if you
can use it for Python 2.4, so I won't advise you on that. I thought
Microsoft made its C/C++ compiler, version 7.1 (2003) freely available
as a command line tool
I've always wondered why I can't do:
def foo(a,b,c):
return a,b,c
args = range(2)
foo(*args, c = 2)
When you can do:
foo(*args, **{'c':2})
Whenever I stub my toe on this one, I always just use the second
approach, which seems less readable. As with most things in Python,
I've suspected the
It looks like you can get a fairly good apporximation for samefile on
win32. Currently I'm using the algorithm suggested by Tim Chase as it
is "good enough" for my needs.
But if one wanted to add samefile to the ntpath module, here's the
algorithm I would suggest:
If the passed files do not exist
On 12/16/06, The Night Blogger <[EMAIL PROTECTED]> wrote:
> Can someone recommend me a good API for writing a sexy looking (Rich UI like
> WinForms) shrink wrap application
> My requirement is that the application needs to look as good on Windows as
> on the Apple Mac
wxPython or something layere
On Dec 16, 8:43 pm, Jive Dadson <[EMAIL PROTECTED]> wrote:
>I bought the ebook. Searching for "pixel", all I came up with was a
> method called GetPixel in a "device context." I know there must be a
> device context buried in there somewhere, so now I need to winkle it out.
You are right that yo
On Dec 16, 8:30 pm, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Sat, 16 Dec 2006 17:02:04 -0800, Sandra-24 wrote:
> > Comparing file system paths as strings is very brittle.Why do you say that?
> > Are you thinking of something like this?
>
> /home//user/so
Comparing file system paths as strings is very brittle. Is there a
better way to test if two paths point to the same file or directory
(and that will work across platforms?)
Thanks,
-Sandra
--
http://mail.python.org/mailman/listinfo/python-list
Try the wxPython mailing list, which you can find on their site. And
the best wxPython reference is the book (also available as an e-book)
by Robin Dunn, who created wxPython. Seeing wxPython from his
perspective is well worth the money. If I recall correctly he devoted
an entire chapter to drawing
On Nov 2, 1:32 pm, robert <[EMAIL PROTECTED]> wrote:
> I'd like to use multiple CPU cores for selected time consuming Python
> computations (incl. numpy/scipy) in a frictionless manner.
>
> Interprocess communication is tedious and out of question, so I thought about
> simply using a more Python
giuseppe wrote:
> What is the better IDE software for python programming?
>
One word.
Wing.
The debugger will pay for itself within weeks. There is no better
Python debugger for most situations.
-Sandra
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
> Just curious what users of the two big commercial IDEs think of them
> compared to one another (if you've used both).
>
> Wing IDE looks a lot nicer and fuller featured in the screenshots, but a
> glance at the feature list shows that the "personal" version doesn't
> even supp
I looked at posh, and read the report on it, it's very interesting, but
it will not work for me. Posh requires that it forks the processes, but
in mod_python the processes were forked by apache and use different
interpreters.
Calvin Spealman wrote:
> Maybe what you want is something like memcache
A dictionary that can be shared across processes without being
marshaled?
Is there such a thing already for python?
If not is there one for C maybe?
I was just thinking how useful such a thing could be. It's a great way
to share things between processes. For example I use a cache that
subclasses
[EMAIL PROTECTED] wrote:
> You can do the same on Windows if you use CreateProcessEx to create the
> new processes and pass a NULL SectionHandle. I don't think this helps
> in your case, but I was correcting your impression that "you'd have to
> physically double the computer's memory for a dual c
Felipe Almeida Lessa wrote:
> 4 Sep 2006 19:19:24 -0700, Sandra-24 <[EMAIL PROTECTED]>:
> > If there was a mod_dotnet I wouldn't be using
> > CPython anymore.
>
> I guess you won't be using then: http://www.mono-project.com/Mod_mono
>
Oh I'm awa
Steve Holden wrote:
> Quite right too. You haven't even sacrificed a chicken yet ...
Hopefully we don't get to that point.
> You write as though the GIL was invented to get in the programmer's way,
> which is quite wrong. It's there to avoid deep problems with thread
> interaction. Languages tha
Hari Sekhon wrote:
> If anybody knows how to do this could they please give me a quick
> pointer and tell me what libraries I need to go read up on?
>
One word. Selenium.
-Sandra
--
http://mail.python.org/mailman/listinfo/python-list
alf wrote:
> Hi,
>
> I have a reference to certain objects. What is the most pythonic way to
> test for valid reference:
>
> if obj:
>
> if None!=obs:
>
> if obj is not None:
I like this way the most. I used timeit to benchmark this against the
first one, expecting it to be fast
> You seem to be confused about the nature of multiple-process
> programming.
>
> If you're on a modern Unix/Linux platform and you have static read-only
> data, you can just read it in before forking and it'll be shared
> between the processes..
Not familiar with *nix programming, but I'll take y
Qiangning Hong wrote:
> Do you really get that error?
Sorry, my bad. You're correct of course. I had accidentally passed an
object, by naming it the same as the function, instead of my function,
and the object had __call__ defined, and took exactly two parameters,
just like my function, but one of
How can you prevent self from being passed to a function stored as a
member variable?
class Foo(object):
def __init__(self, callback):
self.func = callback
f =Foo(lambda x: x)
f.func(1) # TypeError, func expects 1 argument, recieved 2
I thought maybe you could do this:
class Foo(object
The trouble is there are some environments where you are forced to use
threads. Apache and mod_python are an example. You can't make use of
mutliple CPUs unless you're on *nux and run with multiple processes AND
you're application doesn't store large amounts of data in memory (which
mine does) so y
damacy wrote:
> hi, there. i have a problem writing a program which can obtain ip
> addresses of machines running in the same local network.
>
> say, there are 4 machines present in the network; [a], [b], [c] and [d]
> and if i run my program on [a], it should be able to find "host names"
> and "ip
Lawrence D'Oliveiro wrote:
>
> All you want is a dictionary, then. That's basically what Python objects
> are.
Yes, that's it exactly. I made a lazy wrapper for it, and I was really
happy with what I was able to accomplish, it turned out to be very
easy.
Thanks,
-Sandra
--
http://mail.python.o
Lawrence D'Oliveiro wrote:
> In article <[EMAIL PROTECTED]>,
> "Sandra-24" <[EMAIL PROTECTED]> wrote:
>
> >Now that is a clever little trick. I never would have guessed you can
> >assign to __class__, Python always surprises me in it's
life in C code.
The technique of using the __class__.__subclasses__ also fails:
TypeError: cannot create 'B' instances
This seems more complex than I thought. Can one do this for an object
that beings it's life in C?
Thanks,
-Sandra
Peter Otten wrote:
> Sandra-24 wrote:
>
Can you create an instance of a subclass using an existing instance of
the base class?
Such things would be impossible in some languages or very difficult in
others. I wonder if this can be done in python, without copying the
base class instance, which in my case is a very expensive object.
Any i
C/C++ is used for a lot of things and not going anywhere.
I recommend you learn it not because you should create applications in
C or C++, but because it will increase your skills and value as a
programmer. I recommend you even spend a few weeks with an assembly
language, for the same reason.
How
No it's not an academic excercise, but your right, the situation is
more complex than I originally thought. I've got a minor bug in my
template code, but it'd cause more trouble to fix than to leave in for
the moment.
Thanks for your input!
-Sandra
--
http://mail.python.org/mailman/listinfo/pyth
I'm not sure how complex this is, I've been brainstorming a little, and
I've come up with:
If the previous line ended with a comma or a \ (before an optional
comment)
That's easy to cover with a regex
But that doesn't cover everything, because this is legal:
l = [
1,
2,
3
]
I can't believe I missed it in the documentation. Maybe it wasn't in
the offline version I was using, but more likely it was just one of
those things.
So the trouble seems to be that the traceback holds a reference to the
frame where the exception occurred, and as a result a local variable
that re
try:
exc_type, exc_value, exc_traceback = sys.exc_info()
# Do something
finally:
exc_traceback = None
Why the try/finally with setting exc_traceback to None? The python docs
didn't give me any clue, and I'm wondering what this person knows that
I don't.
Thanks,
-Sandra
--
http://mail.p
I was reading over some python code recently, and I saw something like
this:
contents = open(file).read()
And of course you can also do:
open(file, "w").write(obj)
Why do they no close the files? Is this sloppy programming or is the
file automatically closed when the reference is destroyed (aft
Sorry, this was my mistake, I had some unicode strings in the list
without realizing it. I deleted the topic within 10 minutes, but
apparently I wasn't fast enough. You're right join works the way it
should, I just wasn't aware I had the unicode strings in there.
-Sandra
--
http://mail.python.or
I'd love to know why calling ''.join() on a list of encoded strings
automatically results in converting to the default encoding. First of
all, it's undocumented, so If I didn't have non-ascii characters in my
utf-8 data, I'd never have known until one day I did, and then the code
would break. Secon
Hey Crutcher, thanks for the code, that would work. I'm now debating
using that, or using function arguments to get the variables into the
namespace. This would require knowing the variables in the dict ahead
of time, but I suppose I can do that because it's part of the same
system that creates the
Is there a way in python to add the items of a dictionary to the local
function scope? i.e. var_foo = dict['var_foo']. I don't know how many
items are in this dictionary, or what they are until runtime.
exec statements are difficult for debuggers to deal with, so as a
workaround I built my code in
40 matches
Mail list logo