Paul Rubin schrieb:
>
> Name mangling is a poor substitute for private variables. If you want
> to be able to share private variables with other classes under certain
> circumstances, it's better to use something like C++'s "friend"
> declaration, where you can export the variables to a specific
Paul Rubin schrieb:
> Gregor Horvath <[EMAIL PROTECTED]> writes:
>
>>>to be able to share private variables with other classes under certain
>>>circumstances, it's better to use something like C++'s "friend"
>>>declaration, where you ca
Paul Rubin schrieb:
> allowed to do that--that's why the variable is private. Is he
> supposed to get your permission every time he wants to change how the
> private variables in his class work?
>
No, but the assumption here is that the maintainer / designer of a class
alaways knows everything
Paul Rubin schrieb:
>
> Huh? If my car has a "feature" that lets someone blow it to
> smithereens from hundreds of miles away without even intending to,
> that's somehow an advantage?
I would not accept a car that does constraint my driving directions. I
want to drive for myself, because its f
Paul Rubin schrieb:
>
> If you don't want the compiler to make sure your private instance
> variables stay private, then don't declare them that way. You're the
> one asking for less flexibility.
I want to declare them as privat, but want to give the flexibilty to
access them at the users own
Paul Rubin schrieb:
>
> You could have a "friend" declaration like in C++, if you want to let
> some class see the private instance variables of another class.
Everything is said on this topic. There are two ligitimate solutions to
the problem of private instance variables. Its a matter of tas
Paul Rubin schrieb:
> Bill Mill <[EMAIL PROTECTED]> writes:
>
>>Python is for consenting adults.
>
> Python might be for consenting adults, but multi-person software
> projects are supposed to be done in the workplace, not the bedroom.
Are the numerous working python open source projects not mul
Paul Rubin schrieb:
>
> I don't know of a single program that's actually relying on the
> non-enforcement. I've asked for examples but have only gotten
> theoretical ones. As far as I can tell, the feature is useless.
Real open source live example from yesterdays mailinglists:
quick question:
Paul Rubin schrieb:
> Gregor Horvath <[EMAIL PROTECTED]> writes:
>
>>Real open source live example from yesterdays mailinglists:
>
>
> I don't see any use of name mangling in that example.
Someone has a problem and tweaks a private variable as a workaround.
Paul Rubin wrote:
> Gregor Horvath <[EMAIL PROTECTED]> writes:
>>Someone has a problem and tweaks a private variable as a workaround.
>
> They should have patched the source instead.
>
I think they are going to do that. In the meantime our friend has a
working sol
El Pitonero schrieb:
>
> The fact that you can override Python's "list()" function can be either
> viewed as pro or con. The fact that you can override member variables
> can also be viewed as pro or con.
>
If there is a tool like pyChecker, which can detect such pitfalls and
warns but not forb
Hi,
I have just written a python module to program the M232 measurement unit
from elv.
It has 8 digital I/O and 6 analog ports (0-5V). Works fine, although it
is a little bit slow (0,2 s to measure)
Furthermore the digital ports do not have enough power to switch a relay
directly, I had to do it
Hi,
I googled for a possibilty to create a html table where the user can
input data.
I just found this site:
http://www.codeproject.com/aspnet/I3HTree2.asp
That is what I am looking for.
Is there an existing solution for python?
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
Before I reinvent the wheel I`d like to ask if someone has done this
before since I did not find an advice at Google.
The goal is to create a dynamic Tree View in HTML.
Say I have a data strucure like this:
structList =
{'Sun':{'Sun.1':['Sun1.1','Sun1.2'],'Sun.2':['Sun2.1','Sun2.2']},'Kupa':
Hi,
given the dynamic nature of python I assume that there is an elegant
solution for my problem, but I did not manage to find it.
I have a file that contains for example on line:
['147', '148', '146']
when I read the file
f = file("I050901.ids").readlines()
I have a string
f[0] == "['147
John Machin wrote:
>> f = file("I050901.ids").readlines()
>
> Y3K bug alert :-)
but then there is Python 3000 and Hurd, which solves all problems of
this universe :-)
> Something like this:
>
> >>> def munch(astrg):
> ...return [x[1:-1] for x in astrg.rstrip("\n")[1:-1].split(", ")]
T
Hi,
>>>type(['1'])
>>>type(('1'))
I wonder why ('1') is no tuple
Because I have to treat this "special" case differently in my code.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
thanks are given to all
"problem" solved...
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
James wrote:
You will probably find migrating to VB.NET easier than to Python if you
have to do WYSIWYG data bound form design.
VB.NET is quite a nice language (I personally prefer C#). Much nicer
than VB6. Python is better but it may not meet YOUR needs
infrastructure wise.
This is more a strategi
Hello,
class A(self):
def A1():
pass
class B(self):
def B1():
#
#*** How can I access A1 here ***
#
self.A1() # doesnet work because self references to B
self.self.A
Hello Nick,
thank you, your answer really helped me..
--
Greg
Nick Coghlan wrote:
Gregor Horvath wrote:
Hello,
class A(self):
def A1():
pass
class B(self):
def B1():
#
#*** How can I access A1 here
Hi,
Adam DePrince wrote:
computers of the day. This was in a misguided effort to make computers
understandable to their target audience. The goal of the day was to
build a system that a manager would want to buy; it was believed that
[..]
BASIC = Beginners all purpose symbolic instruction code
A
Peter Otten wrote:
May you could give us an idea of the current state of basic affairs then by
translating the following example snippet:
yes you can do it in VB6, but pythons lists and dictionarys are superior
to those built in in VB and I think to those in most other languages.
It's me wrote:
It's me wrote:
Absolutely *ugly*!
But still, your point is well taken. Thank you for pointing this out.
Adam was right:
"Don't do it, unless your goal is simply to embarrass and insult
programmers".
OK. Then please schow me, how you can create a complex form with grids,
explorer like trees etc.
Daniel T. wrote:
[EMAIL PROTECTED] wrote:
A paper finding that OOP can lead to more buggy software is at
http://www.leshatton.org/IEEE_Soft_98a.html
Sure, OOP *can* lead to more buggy software, that doesn't mean it always
does.
I think that costs(=time) to develop and maintain software depends
Thomas Bartkus wrote:
> On what basis do you think the mechanics of producing a working
> language are easier because the language is interpreted.
Because:
Type code
Run code.
VB6 goes a step further:
Run Code
Type Code
That means that you can set a breakpoint. While the debugger sto
Adam DePrince wrote:
On Fri, 2004-12-17 at 09:25, Steve Holden wrote:
Or make any given standard python object accessible from MS Excel in 2
minutes.
What you describe is a political, not technical, challenge.
What I describe is a daily costumer demand.
Like or not, the world uses Excel and co
Andrew Dalke wrote:
Huh? I'm talking about my views of myself. I said that
BASIC was a programming language I could learn without access
to anyone else, on a microcomputer circa 1982. All I had was
the book that came with the computer, and after a while a
book on BASIC games.
The machine I had w
chris wrote:
I'm creating an excel document dynamically from scratch using Python
and the win32com module. All is well, but now I need to add a macro to
the spreadsheet and run it (to enable some sorting features in the
spreadsheet). I think I know how to run a macro once it's installed
(using th
RM wrote:
What you say is true. However, I didn't think the target audience of
this book was newbies. Python newbies yes, but not programming
newbies. For programming newbies I would recommend the "Learning
Python" book instead.
The availability argument, however, is a good point.
I was/am a pyt
Hi,
Is there a possibility to format a log message to give the function name
where the log appears?
Example
import logging
def aTestFunction():
logger.debug("This is a message")
The log should read:
aTestFunction This is a message.
There is a possibilty to format the module namewith %(m
Hi,
[EMAIL PROTECTED] schrieb:
> I am reading a log file, and wondering what is the best way to read and
> analize this.
Look at:
http://pyparsing.wikispaces.com/
There is also an example for parsing an apache log.
--
Servus, Gregor
http://www.gregor-horvath.com
--
http://mail.python.or
Paolo Pantaleo schrieb:
> How can I write a pareser for a certain gramamr? I found PyPy that
> does it, is thare any other tool? Maybe something built-in the python
> interpreter?
>
http://pyparsing.wikispaces.com/
--
Servus, Gregor
http://www.gregor-horvath.com
--
http://mail.python.org/
[EMAIL PROTECTED] schrieb:
> a previous thread
>
> http://mail.python.org/pipermail/python-list/2002-June/107616.html
>
> discussed this issue, and Dave Moor kindly pointed to his solution.
> However this is no longer a current link, does anyone know if there is
> a currently available solution?
Jack schrieb:
> I'd like to set up a wiki system for a project I'm working on.
> Since I'm not good at databases, and there's really not much
> stuff to put into the wiki, I hope it is text file-based.
> I used DokuWiki before, which is very nice but it's written
> in PHP. Is there a similar system
James Stroud schrieb:
> project or package. How do people manage this? Do you run a script to
> find files with the .pyc extension and delete those before every commit,
> or is there a more elegant way? It seems like a lot of wasted bandwidth
> an memory on the server side to constantly be dealing
Sir Psycho schrieb:
>
> Im looking at making a site in Python, however, Im lost as to what ISPs
> actually support. Some ISPs say they support Python so does that mean
> if I wanted to use TurboGears It would just work anyway?
http://docs.turbogears.org/1.0/Hosting?highlight=%28hosting%29
--
neoedmund schrieb:
> python use multiple inheritance.
> but "inheritance" means you must inherite all methods from super type.
> now i just need "some" methods from one type and "some" methods from
> other types,
> to build the new type.
> Do you think this way is more flexible than tranditional in
Hi,
this:
class base(object):
@adecorator(xy)
def edit(self):
print "edit"
class child(base):
xy = 3
obviously fails because "xy" is not bound at class creation time of the
base object.
One solution could be delegation:
class base(object):
@classmethod
def edit(se
Gregor Horvath schrieb:
>
> Is there any other solution, probably with metaclasses ?
>
I've found this one:
class mymeta(type):
def __new__(meta, class_name, bases, new_attrs):
new_attrs["edit"] = adecorator(new_attrs['xy'])(bases[0].edit)
Hi,
As I am no expert web programmer I thought I'd better ask the experts if
there is a simpler or better solution to my problem than the one I am
thinking of. (using TurboGears)
The problem
---
I have a form. Ok. you can submit, validate it etc.
Now I have a link on that form to another
Bruno Desthuilliers schrieb:
> yes : replace the link with another submit button, then in your
> controller check which submit has been successful and take appropriate
> action.
Thanks !
--
Servus, Gregor
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] schrieb:
> Would you normally write methods to retrive and set your class
> variables or just refrence them directly?
>
you start by referencing them directly and ONLY if you need you can add
getters and setters later on without breaking any client code.
see the property functi
Fulvio schrieb:
>
> Is there some trick to apply the best search in wise use of resources while
> using the above said methods?
>
measure it:
http://docs.python.org/lib/module-timeit.html
Regarding your debugger question in the seperate thread I don't know
since I am not using a debugger at a
Hi,
in a windows server python application I receive once a week suddenly
and not reproducible the following error. UnhandledException.rpt file:
//===
Exception code: C090 FLT_INVALID_OPER
Hi,
I have a testservice.py (see below). I installed the Windows-Service
successfully. (via commandlineoption install)
The problem is that it runs only when it is in c:\windows\system32 or in
the python path.
I added the desired path (Y:\) to the PYTHONPATH environment variable
for the system acco
Larry Bates schrieb:
> I believe that your problem is that services run under Local
> System account. Normally Local System account would not have
> a drive mapping Y:\. You can change the account that a service
You are absolutly correct.
I moved the script to a local drive instead of a mapped
walterbyrd schrieb:
>
> What other "gotchas" would I look for?
>
Maybe this is helpfull for you:
http://docs.turbogears.org/1.0/Hosting
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Lad schrieb:
> On my website I allow users to upload files. I would like a user to see
> how much time is left before a file is uploaded. So, I would like to
> have a progress bar during a file uploading. Can Python help me with
> that?Or how can be a progress bar made?
> Thank you for ideas.
> L
Hi,
I searched the web and docs but cannot figure out whats wrong with this
code:
#!/usr/bin/python
import Tkinter as Tk
class testtk(Tk.Frame):
def __init__(self):
self.root = Tk.Tk()
Tk.Frame.__init__(self,self.root)
self.frame = Tk.Frame(self.root)
self.var = Tk.Stri
Gregor Horvath schrieb:
> if __name__ == "__main__":
> t = testtk()
> t.var.set("TEST")
>
> Result:
>
> _tkinter.TclError: can't set "PY_VAR0": invalid command name
> "-1210125972check"
>
>
> Any ideas, wh
kimiraikkonen schrieb:
> My another aim is: Can i develop graphical applications (like in
> Windows) which contain menus, interactive dialog boxes etc. using
> Ptyhon?
>
> I got it quite but not sure. I don't know Ptyhon's capability skills
> for creating interactive softwares like in Windows's c
Kay Schluehr schrieb:
> That's what I love most about the Python community. Whenever there is
> just a non-standard, platform-dependent or crappy implementation of a
> feature you get told that you don't need it. When printf was good for
> little David print is good enough for me.
>
That's a pro
Kay Schluehr schrieb:
> The problem is simply that the Python community has failed in this
> respect. There are many platform dependent and ideology driven ways to
> do deal with code editing / debugging but not actually a recommend or
> "pythonic" way. Other than Smalltalk, Python has not created
dmitrey schrieb:
> howto check is object Arg1
> - a func, lambda-func
> - something else?
>
> I tried callable(Arg1), but callable(lambda-func) returnes False
I don't understand your problem:
>>> callable(lambda:0)
True
Please post your relevant code.
Greg
--
http://mail.python.org/mailman
René Fleschenberg schrieb:
>
> We all know what the PEP is about (we can read). The point is: If we do
> not *need* non-English/ASCII identifiers, we do not need the PEP. If the
> PEP does not solve an actual *problem* and still introduces some
> potential for *new* problems, it should be rejected
Ross Ridge schrieb:
> non-ASCII identifiers. While it's easy to find code where comments use
> non-ASCII characters, I was never able to find a non-made up example
> that used them in identifiers.
If comments are allowed to be none English, then why are identifier not?
This is inconsistent becau
René Fleschenberg schrieb:
> today, to the best of my knowledge. And "in some form or another"
> basically means that the PEP would create more possibilities for things
> to go wrong. That things can already go wrong today does not mean that
> it does not matter if we create more occasions were th
René Fleschenberg schrieb:
>> I love Python because it does not dictate how to do things.
>> I do not need a ASCII-Dictator, I can judge myself when to use this
>> feature and when to avoid it, like any other feature.
>
> *That* logic can be used to justify the introduction of *any* feature.
>
[EMAIL PROTECTED] schrieb:
> code on the (GUI-less) production servers over a terminal link. They
> have to use all kinds of environments where they can't install the
> latest and greatest fonts. Promoting code that becomes very hard to
> read and debug in real situations seems like a sound nega
Hendrik van Rooyen schrieb:
> It is not so much for technical reasons as for aesthetic
> ones - I find reading a mix of languages horrible, and I am
> kind of surprised by the strength of my own reaction.
This is a matter of taste.
In some programs I use German identifiers (not unicode). I and o
Eric Brunel schrieb:
> Highly improbable in the general context. If I stumble on a source code
> in Chinese, Russian or Hebrew, I wouldn't be able to figure out a single
> sound.
If you get source code in a programming language that you don't know you
can't figure out a single sound too.
How i
Eric Brunel schrieb:
>
> The point is that today, I have a reasonable chance of being able to
> read, understand and edit any Python code. With PEP 3131, it will no
> more be true. That's what bugs me.
That's just not true. I and others in this thread have stated that they
use German or other
Istvan Albert schrieb:
> Here is something that just happened and relates to this subject: I
> had to help a student run some python code on her laptop, she had
> Windows XP that hid the extensions. I wanted to set it up such that
> the extension is shown. I don't have XP in front of me but when I
[EMAIL PROTECTED] schrieb:
>> 2) Create a way to internationalize the standard library (and possibly
>> the language keywords, too). Ideally, create a general standardized way
>> to internationalize code, possibly similiar to how people
>> internationalize strings today.
>
> Why? Or more acurate
[EMAIL PROTECTED] schrieb:
> On May 16, 12:54 pm, Gregor Horvath <[EMAIL PROTECTED]> wrote:
>> Istvan Albert schrieb:
>>
>> So the solution is to forbid Chinese XP ?
>>
>
> It's one solution, depending on your support needs.
>
That would be
Hendrik van Rooyen schrieb:
> I can sympathise a little bit with a customer who tries to read code.
> Why that should be necessary, I cannot understand - does the stuff
> not work to the extent that the customer feels he has to help you?
> You do not talk as if you are incompetent, so I see no rea
placid schrieb:
> Just wondering if there is any way of sending a JavaScript array to a
> Python cgi script? A quick Google search didn't turn up anything
> useful.
http://mochikit.com/doc/html/MochiKit/Base.html#json-serialization
http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.3/docs/i
HMS Surprise schrieb:
>
> #~~
> createdIncidentId = 0
> .
> .
> .
> #attempt to change varialbe
> createdIncidentID = 1
> .
> .
> .
> if createdIncidentId == 1:
>...
>
test.py is your code above
$ pychecker -v test.py
Processing test...
Warnings...
test.py:7: Variable
Martin v. Löwis schrieb:
> I've reported this before, but happily do it again: I have lived many
> years without knowing what a "hub" is, and what "to pass" means if
> it's not the opposite of "to fail". Yet, I have used their technical
> meanings correctly all these years.
That's not only true f
Istvan Albert schrieb:
>
> After the first time that your programmer friends need fix a trivial
> bug in a piece of code that does not display correctly in the terminal
> I can assure you that their mellow acceptance will turn to something
> entirely different.
>
Is there any difference for you
[EMAIL PROTECTED] schrieb:
> With the second one, all my standard tools would work fine. My user's
> setups will work with it. And there's a much higher chance that all
> the intervening systems will work with it.
>
Please fix your setup.
This is the 21st Century. Unicode is the default in Pyt
Hendrik van Rooyen schrieb:
> I suppose that this "one language track" - mindedness of mine
> is why I find the mix of keywords and German or Afrikaans so
> abhorrent - I cannot really help it, it feels as if I am eating a
> sandwich, and that I bite on a stone in the bread. - It just jars.
Ple
Istvan Albert schrieb:
> On May 17, 2:30 pm, Gregor Horvath <[EMAIL PROTECTED]> wrote:
>
>> Is there any difference for you in debugging this code snippets?
>
>> class Türstock(object):
>
> Of course there is, how do I type the ü ? (I can copy/paste for
&
Paul Boddie schrieb:
> Perhaps, but the treatment by your mail/news software plus the
> delightful Google Groups of the original text (which seemed intact in
> the original, although I don't have the fonts for the content) would
> suggest that not just social or cultural issues would be involved.
[EMAIL PROTECTED] schrieb:
> opposed. But dismissing the fact that Outlook and other quite common
> tools may have severe problems with code seems naive (or disingenuous,
> but I don't think that's the case here).
Of course there is broken software out there. There are even editors
that mix tab
Jack schrieb:
> I didn't call del explicitly. I'm expecting Python to call it when
> the program exits. I put a logging line in __del__() but I never
> see that line printed. It seems that __del__() is not being called
> even when the program exits. Any idea why?
>
>
http://effbot.org/pyfaq/my-
walterbyrd schrieb:
> Don't get me wrong: I am not saying that PHP is better than Python for
> web-development. But, I sometimes think that Python could learn a few
> things from PHP.
Yes, indeed we can learn that popularity is not superiority. ;-)
Gregor
--
http://mail.python.org/mailman/listi
Gerardo Herzig schrieb:
>
> @is_logued_in
> def change_pass():
>bla
>bla
>
> And so on for all the other functions who needs that the user is still
> loged in.
>
> where obviosly the is_logued_in() function will determine if the dude is
> still loged in, and THEN execute change_pass().
Alexander Eisenhuth schrieb:
>
> I'm wodering how the information hiding in python is ment. As I
> understand there doesn't exist public / protected / private mechanism,
> but a '_' and '__' naming convention.
>
> As I figured out there is only public and private possible as speakin in
> "C+
Alex Martelli schrieb:
>
> Why, thanks for the pointer -- I'm particularly proud of having written
> """
> The only really workable way to develop large software projects, just as
> the only really workable way to run a large business, is a state of
> controlled chaos.
> """
Yes, indeed a good sa
[EMAIL PROTECTED] schrieb:
> I agree with Steve. I have yet to see an IDE for Python (or anything
> else) that unindents statements. Even IDLE, the Official IDE for
> Python, doesn't do that.
emacs in python-mode
Just hit TAB and it unindents "else" in the given example.
Hit TAB again and it cy
madzientist schrieb:
>
> Is Python a bad choice for the blind programmer, as a result of a
> tight linkage between visual aspects of the code and its function ? I
> wish the site blindprogramming.com weren't so lifeless...
There was a thread regarding blind people and python indentation shortly:
George Sakkis schrieb:
> I'd like to gather advice and links to any existing solutions (e.g.
> libraries, frameworks, design patterns) on general ways of writing
> complex web forms, as opposed to the typical {name:value} flat model.
> A particular case of what I mean by complex is hierarchical for
Edward Elliott schrieb:
> On top of that, the expressive power of nested comments seems greater
> than an endless string of ^#s. Sometimes it's just easier to see what's
> going on.
not if you are using grep
--
Gregor
http://www.gregor-horvath.com
--
http://mail.python.org/mailman/listinfo/py
[EMAIL PROTECTED] schrieb:
>
> Does Python have a mechanism for events/event-driven programming?
>
Probably this is something for you:
http://twistedmatrix.com/trac/
--
Servus, Gregor
http://www.gregor-horvath.com
--
http://mail.python.org/mailman/listinfo/python-list
Chris schrieb:
> How do I find and print to screen the IP address of the computer my
> python program is working on?
>
IP adresses are bound to network interfaces not to computers.
One Computer can have multiple network interfaces.
--
Servus, Gregor
http://www.gregor-horvath.com
--
http://
[EMAIL PROTECTED] schrieb:
>
> Is there a standard way to document protocols in Python? Of should I
> come up with something tailored to my needs.
>
Write unittests or doctest strings.
--
Servus, Gregor
http://www.gregor-horvath.com
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
My application is a client/server in a LAN. I want to keep my programs
.py files on a central File Server serving all clients. The clients
should load those over the LAN every time they start the program since I
expect that they are rapidly changing and I dont want to update each
client sepera
Serge Orlov schrieb:
> I believe it's better to keep *everything* on the file server. Suppose
Certainly!
> your OS is windows and suppose you want to keep everything in s:/tools.
> The actions are:
> 3. Create little dispatcher s:/tools/win32/client.py:
> #!s:/tools/python24-win32/python.exe
> i
Hi,
>>> None <= 0
True
Why?
Is there a logical reason?
Gregor
--
http://mail.python.org/mailman/listinfo/python-list
D'Arcy J.M. Cain schrieb:
On Fri, 25 Apr 2008 20:27:15 +0200
Gregor Horvath <[EMAIL PROTECTED]> wrote:
>>> None <= 0
True
Why?
Why not?
Because, from http://www.python.org/dev/peps/pep-0020/ :
Errors should never pass silently.
In the face of ambiguity, refuse
Hi,
class A(object):
test = "test"
class B(object):
a = A()
In [36]: B.a.test
Out[36]: 'test'
In [37]: getattr(B, "a.test")
---
Traceback (most recent call last)
/ in ()
: type object 'B' has no attribut
Peter Otten schrieb:
make your own function that loops over the attributes, or spell it
reduce(getattr, "a.test".split("."), B)
'test'
Thank's, but this does not work for this case:
class A(object):
test = "test"
class B(object):
a = [A(),]
In [70]: reduce(getattr, "a[0].test".s
Hi,
why is this code failing?
class B(object):
pass
B.testattr = property(lambda s:"hallo")
b = B()
b.testattr = "test"
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
/tmp/python-14202ViU.py in ()
14 B.testattr = property(lambda s:"hallo")
15 b = B()
---> 16 b.testattr = "tes
Gregor Horvath schrieb:
why is this code failing?
OK I answer myself :-)
Because there is not fset function definied in the property.
I have to del the attr before rebinding the attributename to another object.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I do not understand why __del__ does not get executed in the following
example.
test.py:
#!/usr/bin/python
class A(object):
def __init__(self):
print "init"
def __del__(self):
print "del"
test1.py
#!/usr/bin/python
import test
class B(object):
a = test.A()
Running te
Felipe Almeida Lessa schrieb:
del B
# We'll to tell him to collect the garbage here, but
>
> ... # usually it should not be necessary.
Thanks. If I do
del B
then the __del__ of A gets called.
That surprises me. I thought that B gets del'd by python when it goes
out of scope?
Do I
Duncan Booth schrieb:
> What is less obvious is that new style classes always include circular
> references, so a class is never detroyed until the garbage collector runs.
Thanks. I tried the same example with old style classes and A.__del__
gets correctly called.
> Of course, if your __del__
Duncan Booth schrieb:
> First off, never depend on __del__ to do anything critical. The only
Thanks to all of you!
Everything's clear now!
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 118 matches
Mail list logo