Hi, I'm writing a gdesklets control, that dynamicly uses __import__ and
getattr to get the right classes based on userinput. The problem is, that
my control is somehow being run from somewhere unknown. This means that
__import__ can't find the modules. I tried putting an
os.chdir("~/.gdesklets/Cont
Is it possible for an imported module to find its own location?
--
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks of
Europe's Dark Ages; they are the only ones with the training and insight
to
Den Thu, 05 Jan 2006 14:53:40 +0800. skrev limodou:
> 2006/1/5, Thomas Dybdahl Ahle <[EMAIL PROTECTED]>:
>> Is it possible for an imported module to find its own location?
>
> you can access __file__(missing for built-in modules) or __path__(used
> for a package) attr
Hi, I'm writing a program, using popen4(gnuchess),
The problem is, that gnuchess keeps running after program exit.
I know about the atexit module, but in java, you could make a process a
daemon process, and it would only run as long as the real processes ran. I
think this is a better way to stop g
nly run when the parrentprocess is still running.
I know this is called a daemon thread in java.
> 2006/8/26, Thomas Dybdahl Ahle <[EMAIL PROTECTED]>:
>> Hi, I'm writing a program, using popen4(gnuchess),
>> The problem is, that gnuchess keeps running after program exit.
Hi, When I do a small program like
from subprocess import Popen
popen = Popen(["ping", "google.com"])
from time import sleep
sleep(100)
start it and kill it, the ping process lives on.
Is there a way to ensure that the ping process is always killed when the
python process is?
I can't use atexit,
Den Tue, 05 Jun 2007 14:07:44 +0200 skrev Stefan Sonnenberg-Carstens:
> Thomas Dybdahl Ahle schrieb:
>> Hi, When I do a small program like
>>
>> from subprocess import Popen
>> popen = Popen(["ping", "google.com"]) from time import sleep
>> sl
Den Tue, 05 Jun 2007 07:06:15 -0700 skrev Rob Wolfe:
> Thomas Dybdahl Ahle wrote:
>
>> Problem is - I can't do that when I get killed. Isn't it possible to
>> open processes in such a way like terminals? If I kill the terminal,
>> everything open in it will d
When I close my (gtk) program, I get errors like the below.
It seams that when the interpreter shuts down, it sets every variable to
None, but continues running the threads, (seems only in cases where
they've just been asleep)
I don't think this would be intended behavior?
Exception in thread Th
Den Tue, 05 Jun 2007 22:01:44 +0200 skrev Rob Wolfe:
> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes:
>
>> But you can't ever catch sigkill.
>
> There is no protection against sigkill.
>
>> Isn't there a way to make sure the os kills the childpr
Den Tue, 05 Jun 2007 15:46:39 -0500 skrev Michael Bentley:
> But actually *that* is an orphan process. When a parent process dies
> and the child continues to run, the child becomes an orphan and is
> adopted by init. Orphan processes can be cleaned up on most Unices with
> 'init q' (or somethin
Den Tue, 05 Jun 2007 17:41:47 -0500 skrev Michael Bentley:
> On Jun 5, 2007, at 5:13 PM, Michael Bentley wrote:
>
>
>> On Jun 5, 2007, at 4:17 PM, Thomas Dybdahl Ahle wrote:
>>
>>> Den Tue, 05 Jun 2007 15:46:39 -0500 skrev Michael Bentley:
>>>
>&g
Den Thu, 07 Jun 2007 07:00:53 + skrev reed:
> On Jun 5, 7:58 am, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
>> Hi, When I do a small program like
>>
>> from subprocess import Popen
>> popen = Popen(["ping", "google.com"]) from time
I have a sort function in a python chess program.
Currently it looks like this:
def sortMoves (board, table, ply, moves):
f = lambda move: getMoveValue (board, table, ply, move)
moves.sort(key=f, reverse=True)
return moves
However I'd really like not to use the lambda, as it slows dow
Den Fri, 02 Mar 2007 21:13:02 +0100 skrev Bjoern Schliessmann:
> Thomas Dybdahl Ahle wrote:
>
>> However I'd really like not to use the lambda, as it slows down the
>> code.
>
> Did you check how much the slowdown is?
Yes, the lambda adds 50%
--
http://mail.pytho
Den Fri, 02 Mar 2007 11:44:27 -0800 skrev Paul Rubin:
> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes:
>> Do you have any ideas how I can sort these moves the fastest?
>
> One idea: if you're using alpha-beta pruning, maybe you can use
> something like heapq inste
Den Fri, 02 Mar 2007 20:33:45 +0100 skrev Diez B. Roggisch:
> Thomas Dybdahl Ahle schrieb:
>> I have a sort function in a python chess program. Currently it looks
>> like this:
>>
>> def sortMoves (board, table, ply, moves):
>> f = lambda move: getM
Den Fri, 02 Mar 2007 15:20:33 -0800 skrev MonkeeSage:
> On Mar 2, 5:11 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
>> Wouldn't that be just as slow?
>
> Well, I'm not sure about speed, but with the lambda you're creating a
> new callable for f eve
Den Fri, 02 Mar 2007 19:26:08 -0300 skrev Silver Rock:
> Friends,
>
> I don´t see why using classes.. functions does everything already. I
> read the Rossum tutotial and two other already.
>
> Maybe this is because I am only writing small scripts, or some more
> serious misunderstandings of the
Den Fri, 02 Mar 2007 15:32:58 -0800 skrev [EMAIL PROTECTED]:
> I'm trying to extract some data from an XHTML Transitional web page.
> xml.dom.minidom.parseString("text of web page") gives errors about it
> not being well formed XML.
> Do I just need to add something like or what?
As many HTML Tr
Den Fri, 02 Mar 2007 16:27:47 -0800 skrev MonkeeSage:
> On Mar 2, 5:51 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
>> I guess the thing is that I'd have to create a new callable no matter
>> how, as it is the only way to bring the extra variables into the
>&g
Den Fri, 02 Mar 2007 16:46:05 -0800 skrev Paul Rubin:
> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes:
>> Do you mean that I add my moves something like this?
>>
>> from heapq import heappush, heappop
>> heap = []
>> for move in genAll():
>> hea
Den Sat, 03 Mar 2007 11:26:08 +0100 skrev Diez B. Roggisch:
>> Well, you'd have to define the function inside the sortMoves function,
>> as it is where the variables exists.
>>
>> def sortMoves(board, table, ply, moves):
>> def sortKey(move):
>> return getMoveValue(board, table, ply,
Hi, I have a function, which looks like the following:
connecting = False
def func ():
global connecting
connecting = True
try:
# Do lot of network stuff
except Exception, e:
connecting = False
raise e
This works quite good, but it is a hell to debug. Instea
Den Fri, 23 Mar 2007 07:38:47 -0700 skrev Alex Martelli:
> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
>> This works quite good, but it is a hell to debug. Instead of getting a
>> log message to the line which originally raised the exception.
> As you see, the traceb
Hi, I've writing a python application in which I'd like to have a small
"ping label", to always tell the current ping time to the server.
It seems however that I have to be root to send those imcp packages, but
I guess there must be a workaround since I can easily use the "ping"
command as ordi
Den Mon, 26 Mar 2007 11:24:34 +0200 skrev Michal 'vorner' Vaner:
> On Mon, Mar 26, 2007 at 08:30:16AM +0200, Thomas Dybdahl Ahle wrote:
>> Do anybody know how to do this in python?
> You need root for that and the ping command is allowed to have them by
> suid bit.
Den Mon, 26 Mar 2007 06:30:04 -0500 skrev Nick Craig-Wood:
> Michael Bentley <[EMAIL PROTECTED]> wrote:
>> On Mar 26, 2007, at 1:30 AM, Thomas Dybdahl Ahle wrote:
>> > It seems however that I have to be root to send those imcp packages,
>> > but I guess there
Hi, I'm writing an application that connects to the internet.
Something like this:
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
self.sock = socket.socket(af, socktype, proto)
Now if the user press the cancel button
Hi, I'm writing a program with a large data stream to which modules can
connect using regular expressions.
Now I'd like to not have to test all expressions every time I get a line,
as most of the time, one of them having a match means none of the others
can have so.
But ofcource there are also
Den Mon, 16 Apr 2007 11:50:40 +0200 skrev Thomas Dybdahl Ahle:
> Hi, I'm writing a program with a large data stream to which modules can
> connect using regular expressions.
>
> Now I'd like to not have to test all expressions every time I get a
> line, as most of the t
Den Tue, 17 Apr 2007 11:59:15 -0700 skrev Paddy:
> On Apr 17, 9:17 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>> Paddy schrieb:
>> > you could OR all the individual RE's test them all at once then find
>> > out which matched.
>>
>> > big_re = "|".join( r"(?P<__match_%i__>%s)" % (i, r)
>> >
Den Tue, 17 Apr 2007 11:07:38 -0700 skrev kyosohma:
> On Apr 17, 12:41 pm, Chi Yin Cheung <[EMAIL PROTECTED]> wrote:
>> Hi,
>> Is there a way in python to output binary files? I need to python to
>> write out a stream of 5 million floating point numbers, separated by
>> some separator, but it seem
Hey
I have this pythonapp I'm trying to pack, and I've read in the Gnome
specifications that I should run "update-icon-cache" after install, in
order to get the menus and stuff correctly updated.
Is there a way to specify a (list of) commands to be run after
installation?
--
http://mail.python
Den Sun, 23 Sep 2007 17:28:38 +0200 skrev stef mientki:
> yadin wrote:
>
>> if i were up to make a GUI chich are the advantages of choosing python
>> over matlab or java?
>>
> The best is Delphi,
> second is VB,
That sounds mostly like a personal preference :)
I would certainly suggest Python ver
Hi, I have an application for which I want users to be able to make
themes.
I've planed a rather advanced model (in xml), which gives themes the
option to redefine various drawing methods.
Now I don't want those themes to be able to take over the current user,
but I'd still like the scripts to b
Hi, I've got some DES encrypted data, for which I know the password.
The problem is that I have to generate an 8byte key from the password.
I use python-crypto-2.0.1.
I also know, that the C# way to do the decryption is:
PasswordDeriveBytes bytes1 = new
PasswordDeriveBytes("passwordString", null);
Den Mon, 15 May 2006 11:32:47 -0700. skrev Paul Rubin:
> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes:
>> byte[] array2 = bytes1.CryptDeriveKey("DES", "MD5", 0, array1);
>> > Anybody know how to do this in python?
>
> I'm not aware of a
Hi, I'm writing an app in python, and I'm storing some a lot of data in
bitmaps.
I need a way to find the first or latest set bit in a 64bit number, and
for that I've implemented a small routine.
Thing is that this routine is not as fast as I'd wish. I know most
processors implement BSF an
On Sun, 2008-02-03 at 15:18 +, [EMAIL PROTECTED] wrote:
> what would be the best python GUI toolkit, it must be cross platform.
>
> i have tried gtk, but it interface are real bad and its coding was
difficult
> so i dropped it,
I came from Sving to Gtk, so for me also it was a real brainbreak
On Sat, 2008-02-02 at 18:03 -0800, [EMAIL PROTECTED] wrote:
> for _ in xrange (1,n):
>some code
I'd always use i for loop variables I don't know what to call. It stands
for iterator or something. In a nested loop the next variable would
simply be called j and so on.
I also tend to use _, but
On Sun, 2008-02-03 at 10:17 -0800, [EMAIL PROTECTED] wrote:
> I'm considering writing a little interpreter for a python-like
> language and I'm looking for name suggestions. :-)
>
> Basically, I don't want to change a whole lot about Python. In fact,
> I see myself starting with the compiler mod
On Sat, 2008-02-09 at 14:56 +0100, Martin P. Hellwig wrote:
> > Propagate, travel, what's the difference?
> >
> Unfortunately, I didn't study any of this but I sure do remember the
> answer one drunk physic said to me in a bar when I ask him the question:
> "Does light travel or propagate?"
> H
I tend to make a lot of mistakes of misspelled variable names.
Is it possible to make python warn me about those at "compile time"?
Very few times I use dynamic variable initialization. I can live with
getting a warning for those as well.
--
Best Regards,
Med Venlig Hilsen,
Thomas
--
http://m
On Wed, 2008-03-26 at 23:04 +0100, Michał Bentkowski wrote:
> Why does python create a reference here, not just copy the variable?
Python, like most other oo languages, will always make references for =,
unless you work on native types (numbers and strings).
Instead use one of:
k = j[:]
or
k = [
On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote:
> The built-in function round( ) will always "round up", that is 1.5 is
> rounded to 2.0 and 2.5 is rounded to 3.0.
>
> If I want to round to the nearest even, that is
>
> my_round(1.5) = 2# As expected
> my_round(2.5) = 2# Not 3,
On Sat, 2008-05-03 at 21:37 +, Ivan Illarionov wrote:
> On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvát wrote:
>
> > Arnaud Delobelle wrote:
> >>
> >> sum() works for any sequence of objects with an __add__ method, not
> >> just floats! Your algorithm is specific to floats.
> >
> > Thi
47 matches
Mail list logo