Re: Odd behavior of object equality/identity in the context of relative vs fully qualified imports

2011-12-15 Thread Peter Otten
Nathan Rice wrote: > I just ran into this yesterday, and I am curious if there is a > rational behind it... > > I have a class that uses a dictionary to dispatch from other classes > (k) to functions for those classes (v). I recently ran into a bug > where the dictionary would report that a clas

Re: Odd behavior of object equality/identity in the context of relative vs fully qualified imports

2011-12-15 Thread Ian Kelly
On Thu, Dec 15, 2011 at 7:34 AM, Nathan Rice wrote: > I just ran into this yesterday, and I am curious if there is a > rational behind it... > > I have a class that uses a dictionary to dispatch from other classes > (k) to functions for those classes (v).  I recently ran into a bug > where the dic

Re: Odd behavior of object equality/identity in the context of relative vs fully qualified imports

2011-12-15 Thread Nathan Rice
It would be more work than I want to go into to provide full context (unless it is to file a bug report, if it actually is a bug). I verified that there are no cyclical dependency issues using snakefood, and I doublechecked that just changing the import from full to partial name is sufficient to r

Re: Odd behavior of object equality/identity in the context of relative vs fully qualified imports

2011-12-15 Thread Dave Angel
On 12/15/2011 09:34 AM, Nathan Rice wrote: I just ran into this yesterday, and I am curious if there is a rational behind it... I have a class that uses a dictionary to dispatch from other classes (k) to functions for those classes (v). I recently ran into a bug where the dictionary would repor

Re: Odd behavior with imp.reload and logging

2011-09-23 Thread Andrew Berg
On 2011.09.22 03:12 AM, Chris Angelico wrote: > In theory, this should mean that you load it fresh every time - I > think. If not, manually deleting entries from sys.modules might help, > either with or without the list of modules. I've played around with sys.modules, and it seems there are issues

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Andrew Berg
On 2011.09.22 03:25 AM, Steven D'Aprano wrote: > Objects left lying around from before the reload will keep references > open to the way things were before the reload. This often leads to > confusion when modules are edited, then reloaded. (Been there, done that.) I'll keep that in mind. My modul

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Steven D'Aprano
On Wed, 21 Sep 2011 23:47:55 -0500, Andrew Berg wrote: > On 2011.09.21 11:22 PM, Steven D'Aprano wrote: >> You could >> try something like this (untested): > That works. Thanks! > This makes me wonder what else stays around after a reload Practically everything. A reload doesn't delete anything,

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Chris Angelico
On Thu, Sep 22, 2011 at 5:59 PM, Andrew Berg wrote: > That's quite unappealing for a few reasons. First, that would likely > require writing an entirely new bot (I'm not even that familiar with the > current one; I've only been writing a module for it). Ah, then yeah, it's probably not a good ide

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Andrew Berg
On 2011.09.22 01:46 AM, Chris Angelico wrote: > I think Pike may be a good choice for you. That's quite unappealing for a few reasons. First, that would likely require writing an entirely new bot (I'm not even that familiar with the current one; I've only been writing a module for it). Also, I don'

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Chris Angelico
On Thu, Sep 22, 2011 at 3:54 PM, Andrew Berg wrote: > The main program is an IRC bot, which could potentially be in use by > many people in several channels on a network. As it is, the bot can only > connect to one server, but it could probably be set up to connect to any > number of networks. Mak

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Andrew Berg
On 2011.09.22 12:09 AM, Chris Angelico wrote: > On-the-fly reloading of modules isn't really one of Python's > strengths. Everyone who asks about it seems to be doing rapid > development/debugging and wanting to save on startup time (as opposed > to, say, running a server and updating code in it wh

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Chris Angelico
On Thu, Sep 22, 2011 at 2:47 PM, Andrew Berg wrote: > This makes me wonder what else stays around after a reload and what side > effects there are, though. I would really like to purge everything from > the previous import. The main program has no dependence on the module > whatsoever. > On-the-f

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Andrew Berg
On 2011.09.21 11:22 PM, Steven D'Aprano wrote: > You could > try something like this (untested): That works. Thanks! This makes me wonder what else stays around after a reload and what side effects there are, though. I would really like to purge everything from the previous import. The main progra

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Steven D'Aprano
On Wed, 21 Sep 2011 20:53:04 -0500, Andrew Berg wrote: > When using a logger in a module and then using imp.reload to reload the > module, logger messages are repeated in direct proportion to the number > of times the modules was loaded. That is, on the first import, the > message is written once,

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Chris Angelico
On Thu, Sep 22, 2011 at 12:44 PM, Andrew Berg wrote: > The reload isn't controlled by the module, but I have no problem > clearing out any loggers at the beginning. I'm thinking more along the lines of closing them in the old module before firing imp.reload() - maybe have a function in the module

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Andrew Berg
On 2011.09.21 08:57 PM, Chris Angelico wrote: > Unfortunately, Python doesn't really like modules to be reloaded. Are > you able to explicitly close the logger before reloading? The reload isn't controlled by the module, but I have no problem clearing out any loggers at the beginning. I'm looking t

Re: Odd behavior with imp.reload and logging

2011-09-21 Thread Chris Angelico
On Thu, Sep 22, 2011 at 11:53 AM, Andrew Berg wrote: > What causes this, and how can I fix it (or at least work around it)? Due > to the nature of the program, it's much more convenient to reload a > module than to restart the entire program (especially when testing). > Unfortunately, Python does

Re: Odd behavior regarding a list

2009-03-26 Thread Rhodri James
On Thu, 26 Mar 2009 17:01:40 -, Edd Barrett wrote: On Mar 26, 4:21 pm, Steven D'Aprano wrote: A few more comments, based on your code. >    def __classdef_integer(self): Double-underscore name mangling is often more trouble than it is worth. Unless you really need it, not just think you

Re: Odd behavior regarding a list

2009-03-26 Thread Edd Barrett
Hi there, First of all, thanks to everyone for replying. This has been a great help. On Mar 26, 4:21 pm, Steven D'Aprano wrote: > On Thu, 26 Mar 2009 08:36:49 -0700, Edd Barrett wrote: > > My question is: why has 'parent_struct_sig' changed? I was under the > > impression the assignment operator

Re: Odd behavior regarding a list

2009-03-26 Thread Steven D'Aprano
On Thu, 26 Mar 2009 08:36:49 -0700, Edd Barrett wrote: > Hi there, > > My first post here, so hello :) Hello and welcome. Let me comment on a few things out of order. > My question is: why has 'parent_struct_sig' changed? I was under the > impression the assignment operator copies, not referen

Re: Odd behavior regarding a list

2009-03-26 Thread Dave Angel
But you didn't do an assignment, you did an append. Append modifies the object, which is referenced by both parent_struct_sig and this_cdata["struct-sig"] If you're sure you want a *copy* of the list before the modifications, you might do something like parent_struct_sig = \

Re: Odd behavior regarding a list

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 08:36 -0700, Edd Barrett wrote: > Hi there, > > My first post here, so hello :) > > Just a little background, I am writing my dissertation, which is a JIT > compiler based upon LLVM and it's python bindings, along with the > aperiot LL(1) parser. > > I have some code here,

Re: Odd behavior of python module listing

2008-06-09 Thread Benjamin Kaplan
On Mon, Jun 9, 2008 at 4:58 PM, Lie <[EMAIL PROTECTED]> wrote: > Yesterday I installed compiz-icon in my Ubuntu. Today, when I go to > the python interpreter, I happen to do this: > > ### START OF PYTHON SESSION ### > Python 2.5.2 (r252:60911, Apr 21 2008, 11:17:30) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubu

Re: Odd behavior in Python/Tkinter?

2007-12-22 Thread Lie
On Dec 22, 7:35 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Lie wrote: > > But an expression (e.g. string) is NOT a variable. > > in this case, it is.  I don't know if it's worth spending more time on > this, since you're not listening, but let's make one more attempt. Sure I'm listening (well,

Re: Odd behavior in Python/Tkinter?

2007-12-22 Thread Fredrik Lundh
Lie wrote: > But an expression (e.g. string) is NOT a variable. in this case, it is. I don't know if it's worth spending more time on this, since you're not listening, but let's make one more attempt. for the Entry widget, the "textvariable" argument, if given, identifies an *internal* Tkint

Re: Odd behavior in Python/Tkinter?

2007-12-22 Thread Lie
> But an expression (e.g. string) is NOT a variable. It's fine if the > value mirrored when I set the textvariable conf to the same variable, > but in this case I'm setting them to the same expression (e.g. string). On the other hand, the oddness multiplied since the value replication doesn't happ

Re: Odd behavior in Python/Tkinter?

2007-12-22 Thread Lie
On Dec 22, 1:42 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Lie wrote: > >>> Inspect the following code: > > >>> --- start of code --- > >>> import Tkinter as Tk > >>> from Tkconstants import * > >>> root = Tk.Tk() > >>> e1 = Tk.Entry(root, text = 'Hello World') > >>> e2 = Tk.Entry(root, text =

Re: Odd behavior in Python/Tkinter?

2007-12-21 Thread Fredrik Lundh
Lie wrote: >>> Inspect the following code: >>> >>> --- start of code --- >>> import Tkinter as Tk >>> from Tkconstants import * >>> root = Tk.Tk() >>> e1 = Tk.Entry(root, text = 'Hello World') >>> e2 = Tk.Entry(root, text = 'Hello World') >> >> the "text" (or "textvariable") option to the Entry

Re: Odd behavior in Python/Tkinter?

2007-12-21 Thread Lie
On Dec 22, 4:05 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Lie wrote: > > Inspect the following code: > > > --- start of code --- > > import Tkinter as Tk > > from Tkconstants import * > > > root = Tk.Tk() > > > e1 = Tk.Entry(root, text = 'Hello World') > > e2 = Tk.Entry(root, text = 'Hello Wor

Re: Odd behavior in Python/Tkinter?

2007-12-21 Thread Simon Forman
On Dec 21, 12:30 pm, Lie <[EMAIL PROTECTED]> wrote: > Inspect the following code: > > --- start of code --- > import Tkinter as Tk > from Tkconstants import * > > root = Tk.Tk() > > e1 = Tk.Entry(root, text = 'Hello World') > e2 = Tk.Entry(root, text = 'Hello World') > > e1.grid(row = 1, column = 1

Re: Odd behavior in Python/Tkinter?

2007-12-21 Thread Fredrik Lundh
Lie wrote: > Inspect the following code: > > --- start of code --- > import Tkinter as Tk > from Tkconstants import * > > root = Tk.Tk() > > e1 = Tk.Entry(root, text = 'Hello World') > e2 = Tk.Entry(root, text = 'Hello World') the "text" (or "textvariable") option to the Entry widget is the na

Re: Odd behavior with staticmethods

2006-07-04 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: please stop top-posting, it's getting very annoying > ya know, I've searched for these "new classes" at least five times. Then go and buy yourself a pair of glasses. It's one of the entrie in the "documentation" menu of python.org. -- bruno desthuilliers python -c "pri

Re: Odd behavior with staticmethods

2006-07-02 Thread [EMAIL PROTECTED]
THANK YOU! Now I can actually worry about the advantages/disadvantages! -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd behavior with staticmethods

2006-07-01 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > ya know, I've searched for these "new classes" at least five times. > I've heard all the wonderful things about how they make your life into > a piece of chocolate with rainbows sprinkled in it. Never once have I > found a site that explains what syntax to use to make th

Re: Odd behavior with staticmethods

2006-07-01 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > ya know, I've searched for these "new classes" at least five times. > I've heard all the wonderful things about how they make your life into > a piece of chocolate with rainbows sprinkled in it. Never once have I > found a site that explains what syntax to use to make

Re: Odd behavior with staticmethods

2006-07-01 Thread [EMAIL PROTECTED]
ya know, I've searched for these "new classes" at least five times. I've heard all the wonderful things about how they make your life into a piece of chocolate with rainbows sprinkled in it. Never once have I found a site that explains what syntax to use to make these new classes. Anyone have a U

Re: Odd behavior with staticmethods

2006-07-01 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > I'm getting rather inconsistent behavior with staticmethod. Not really. class A: > def orig(): > print "hi" > st = staticmethod(orig) > st2 = st > wrapped = [ orig ] > wrapped2 = [ st ] ... A.wrapped[0]() # ODD - wra

Re: odd behavior

2005-11-11 Thread Steven D'Aprano
On Fri, 11 Nov 2005 11:34:47 -0800, Greg wrote: > Forgive me, and be kind, as I am just a newby learning this language > out of M.L. Hetland's book. The following behavior of 2.4.1 seems very > strange x = ['aardvark', 'abalone', 'acme', 'add', 'aerate'] x.sort(key=len) x > ['add'

Re: odd behavior

2005-11-11 Thread Lee Harr
On 2005-11-11, Kristian Zoerhoff <[EMAIL PROTECTED]> wrote: > On 11 Nov 2005 11:34:47 -0800, Greg <[EMAIL PROTECTED]> wrote: >> Forgive me, and be kind, as I am just a newby learning this language >> out of M.L. Hetland's book. The following behavior of 2.4.1 seems very >> strange >> >>> x = ['aar

Re: odd behavior

2005-11-11 Thread Kristian Zoerhoff
On 11 Nov 2005 11:34:47 -0800, Greg <[EMAIL PROTECTED]> wrote: > Forgive me, and be kind, as I am just a newby learning this language > out of M.L. Hetland's book. The following behavior of 2.4.1 seems very > strange > >>> x = ['aardvark', 'abalone', 'acme', 'add', > 'aerate'] > >>> x.sort(ke

Re: Odd behavior with os.fork and time.sleep

2005-09-16 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Yin" <[EMAIL PROTECTED]> wrote: > I am writing a script that monitors a child process. If the child > process dies on its own, then the parent continues on. If the child > process is still alive after a timeout period, the parent will kill the > child process. E