OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread R.Wieser
Hello all, I've created a class from which I can iterate all its instanciated objects (using an "instances" list).The problem is that I now cannot seem to delete an object anymore, AFAIK as a copy of its "self" is still inside the "instances" list. Object in question: - - - - - - - - - - -

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread R.Wieser
Chris, > Have a method to explicitly purge the instance. I was thinking of that too but decided against it, as it would mean that my objects would need to be handled specially - which is not quite what I'm looking for. To be honest, I was thinking of/hoping that there would be a method which

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread R.Wieser
Dennis, > In __init__() you are adding "self" to a classwide list. So in > your __del__() you need to remove the instance from the > same list. Something :-) Thats the problem: __del__ only gets called when the object is destroyed - which will never happen when the "instances" list still contain

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread R.Wieser
Rhodri, > Use weak references. A WeakSet > (https://docs.python.org/3/library/weakref.html#weakref.WeakSet) is > probably what you want. Most likely!As a fresh freshling in regard to python I was not even aware that a "copy object, but do not increment the reference count" existed.Th

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-04 Thread R.Wieser
Rhodri, > Yes, it can. That's why you want to create a finalizer to tidy up. AFAIKS in my case there is nothing to cleanup. As far as I understood the WeakSet will automagically purge the reference whe the object it references is destroyed. I could also try to do it in in the __del__ method

OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Hello all, The whole question: How should I handle failed initialisation code inside the __init__ of an object ? I've seen an example doing a plain "return" (of the value "none""), but have no idea if that is all it takes. Also, I wonder what happens to the object itself. Does it still exist

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Rob, > Returning None will specifically NOT accomplish the thing you want; > nothing ever checks the return value of __init__. I thought to have read that when you return a none from it the object itself would return a placeholder singleton. > Raise an exception. Yeah, that was what I was thi

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Luciano, > """A failed __init__ should raise an appropriate exception. A bare > return or returning None is what any __init__ is expected to do in the > normal case, so it signals success.""" Ah, that settles it than. Somehow I thought that a return (of "none") there indicated an error result,

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Rob, > That's why if you for instance, open a serial port in an __init__ routine, > and something fails, you want to catch the exception there in __init__, > explicitly close that serial port, and reraise the exception. Otherwise > that port still has an object open against it until Python gets

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Luciano, > In this context, what I mean by that quote is to say that Python > never forces you to wrap anything in try/except blocks. True. But /not/ doing it means that the casted exeption in the __init__ block will just abort the whole program - in a user unfriendly way. And thats normally

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread R.Wieser
Chris, > "Control flow" is anything that changes the order that your code runs. My apologies, I should have said "a control flow mechanism" /in this context/ (though I assumed that as implicite, as I quoted the text from the OP). Case in point, the __init__ code (of a class object) can result

psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Hello all, I was doing a "lets print some time-related data", and also diaplayed the result of "psutil.boot_time()". Somewhere while doing that I saw that my clock was off, so I used the "date" command to rectify it. The thing is, after that the result of "psutil.boot_time()" was changed - and t

Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Maxime, > You may want to read PEP 418 which nicely summaries the > different clock available on each platform and their limitations. You mean the CLOCK_REALTIME and CLOCK_MONOTONIC ones ? Yeah, that was what I was looking at :-) > It looks like CLOCK_BOOTTIME is what you want but it is only >

Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Dennis, > Depends upon the OS... My apologies, its Linux (as on a Raspberry Pi). > You can easily look at the code used by psutil :-) I somehow assumed that those where build-in into the language itself. I'll have to take a peek at what else is available there too. > I read somewhere that the

Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Chris > That's possibly because you're looking at psutil, which is a third > party package. Here's its documentation: My info came frome here: https://www.programcreek.com/python/example/53873/psutil.boot_time Looking at example 1 it looks the be the same. > But I don't know what its definition

Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Chris, > I don't think boot time would be affected by a DST switch, though. > It should be recorded in UTC. The point is, it /isn't/ a recorded constant (at least not on my machine). Its just dragged around with the clocks current time (as in: current time minus uptime). And as such I could e

Re: psutil.boot_time() ... doesn't ?

2019-11-07 Thread R.Wieser
Dennis, > Which is probably... last file system modification time Nope. Its from a file it saves at shutdown, and which gets updated once an hour (I also thought of that one, but the once-an-hour update threw a wrench into it). > There is no way for a freshly booted system to differentiate be

Re: psutil.boot_time() ... doesn't ?

2019-11-07 Thread R.Wieser
Chris, > Yes, but even if it's not recorded as a timestamp but as an > uptime counter, that counter can be referenced against the > current time in UTC. Absolutily. Though the keyword here is "can". My "could easily imagine" considers the other possibility. I guess I should sit down sometime

Re: psutil.boot_time() ... doesn't ?

2019-11-08 Thread R.Wieser
Dennis, > Well... If it is the last file written during shutdown, it would be > the "last file system modification time" Yep ... up until the next hours cronjob overwriting it ... Currently I've got a (very) small init.d shellscript which copies the contents of that file into another one - whi

Re: psutil.boot_time() ... doesn't ?

2019-11-08 Thread R.Wieser
Dennis, > However -- manually changing date/time is not going to illustrate this. > ANY change made to date/time will reflect a change in UTC time. It turns out that the get_uptime() does /not/ calculate the boottime from the current clock minus the uptime. Its a seconds-since-epoch (absolute!)

How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
Hello all, I'm writing some code to toggle a pin on a Raspberry Pi, and would like to have that happen at (multiples of) 300 uSec increments. I tried time.sleep(), but that one disregards the time after the last one ends and the new one is started. In other words, all the time spend in code (

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
Skip, > Take a look at threading.Timer. Thanks. It seems to solve the problem by calling it at the start of the executed code (instead of the end), but costs thread usage ... Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
David, > timeInterval = 0.0003 > time.sleep(timeInterval - (time.perf_counter() % timeInterval)) Possibly: any reason for the performance counter modulo the interval ? Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
Dennis, > So... you need to adjust for the time spent in processing between > calls to sleep(). That was my first thought too, but any code calculating that adjustment before ultimatily calling sleep itself can also be interrupted.With that in mind I was aiming/hoping for something with a /

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
Rob, > 300us is getting on towards realtime. Not really. Translated to a frequency (toggeling the pin) it would be just 1.6 KHz. Thats rather slow for an ARM machine running on 1.4 Ghz (about a million times as fast). > I've never tried it that fast. I've already got it running it using th

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
David, > The general simplified idea was run it whenever the time is 0 modulo > your interval. So you ask how long until that next time. Ah, using the perf_counter() as its own reference (no "last time fired" storage needed). Thanks for the explanation. Regards, Rudy Wieser -- https://mail.

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
Dietmar, > Actually, with such requirements you're usually better off with a > microcontroller. Probably, yes. /Anything/ is better than a multi process mini 'puter for tasks like these. Doesn't mean I'm not going to try though. But honestly, generating a "modulated" 1.6 KHz square-wave sign

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread R.Wieser
Luciano, > Mr. Wieser, I haven't seen you mention which library you're using > to write to GPIO with Python. To be honest, I took a "blink.py" example as a base, and just went with it. So, I had to look it up. Its the first one you mentioned, RPi.GPIO. Thanks for telling me about WiringPi's be

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dietmar, > It *is* real-time... > Real-time is not about speed, but about guaranteed timing. What I tried to indicate is that the Pi has 500,000 cycles to work with between two of those time events. I consider that to be quite a few. > at least not on a multitasking non-realtime system. Yep

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > Avoiding drift still comes down to computing the time (in some unit) > at which the interval is to expire, and then delaying for the difference > between that time and current time. Yep. And although that can be done with Python, I had hoped to be able to shift all that to lower-leve

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > Let's see if I can remember how to use my BK Precision > 2542 scope... :-) You didn't have to do that. I was already planning to put my TDS 210 (tektronics) scope to work today, if only to see what the effect of drift-compensated sleeps would be (inserting some print commands here a

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > You know... I never finished my thought there... :-) I already got the feeling I missed something there. > ... 1.6kHz appears to just be viable (there may still be a context > switch but it wasn't visible on my o'scope) Thats ... slow.And a limitation I definitily have to remember

nonlocal fails ?

2019-11-14 Thread R.Wieser
Hello all, I've just tried to use a "nonlocal MyVar" statement in a procedure defenition, but it throws an error saying "Syntax error: no binding for nonlocal 'MyVar' found. According to platform.python_version() I'm running version 3.8.3 Why am I getting that error ? (already googeled ofcours

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Jan, > The nonlocal statement causes the listed identifiers to refer to > previously bound variables in the nearest **enclosing scope excluding > globals**. I read that too, but didn't get from it that the main scope is excluded (I assumed the"excluding globals" was ment at as such dec

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Rhodri, > MyVar is a global here, so nonlocal explicitly doesn't pick it up. I do not agree with you there (the variable being global). If it where than I would have been able to alter the variable inside the procedure without having to resort to a "global" override (an override which is only

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
MRAB, > 'nonlocal' is used where the function is nested in another function The problem is that that was not clear to me from the description - nor is it logical to me why it exludes the main context from its use. Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Jan, > So what you want to do is dynamic scope? No, not really.I was looking for method to let one procedure share a variable with its caller - or callers, selectable by me. And as a "by reference" argument does not seem to exist in Python ... And yes, I am a ware that procedures can ret

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Michael, > nonlocal does not share or use its *caller's* variables. Rather it > reaches into the scope of the outer function where it was defined. > That's a very different concept than what you're proposing. Oh blimy! You're right.Its an at compile-time thing, not a runtime one. Thanks

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Richard, > Assuming that one language works like another is a danger Abitrarily redefining words and using misnomers is another ... ("global" and "nonlocal" respecivily if you wonder) > First, Python doesn't really have 'Variables' like a lot of other > languages > (they don't hold a bag of b

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dave, > Can you expand on what you are trying to accomplish with this? There is a small 433 MHz rf transmitter connected to the pin, and when I send the right pattern a wireless wall-wart will respond and switch a lamp on or off. Its just ment as an example of a real-world application of P

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > Ugh -- let's try Google Drive... I was able to download them, thanks.All but the 100uSec one seemed to be rather stable. > That is what I'd thought, but if you've looked at that simple program I > used, apparently the "run longer" was taking place between the > > t += > > and the

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > The R-Pi has never, to my knowledge, been billed as suitable > for industrial/real-time/process-control... I have not read those specs to be honest. But for some reason I assumed that a 1.4 GHz machine should easily be able to generate a 1.6 KHz signal, even using Python. I was wr

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Michael, > I note that you didn't answer the question, what are you trying > to accomplish? I think I did - though implicitily. What do normal people use "by reference" arguments for ? Yep, that is what I wanted too. > It looks to me like you're trying to write a program in a different > la

Re: How to delay until a next increment of time occurs ?

2019-11-15 Thread R.Wieser
Dave, > OK I'm old enough cancer to know what X10 is. :-) Ah, so that is the name I forgot. :-) > I wouldn't think this is too difficult to do as you're only sending. You're right, codewise it isn't. > For this application IMO there is too much going on inside python that can > interrupt the

Re: How to delay until a next increment of time occurs ?

2019-11-15 Thread R.Wieser
Rob, > On an actually practical note; ever since they started baking the > quasi-realtime stuff into the Linux kernel, you've been able to use the > whole sched_setscheduler(2) family of calls (from C) to set a process's > real-time priority. Its something worth to look into. Thanks. Regards

Re: nonlocal fails ?

2019-11-15 Thread R.Wieser
Chris, > That doesn't really answer the question. The problem is that you want to solve /this/ problem, while I'm looking for replies that are applicable to similar ones too. To be blunt about it: I consider solutions that only solve a single problem most always as a waste of my time (exceptio

Re: nonlocal fails ?

2019-11-15 Thread R.Wieser
Terry, > This is discouraged for anything very complex. Complex things do not exist. If you think you have something like it you've just not yet broken it down in its components yet. :-) > This is the standard way in Python and other OO languages. By 'excluded', > do you mean 'rejected', or

Re: How to delay until a next increment of time occurs ?

2019-11-15 Thread R.Wieser
Dennis, > No, that addition is a fixed increment on the initial starting > time, and is NOT relative to the ending of a sleep. > No, that addition is a fixed increment Yep. > on the initial starting time Nope. If pythons sleep is worth its salt it ends exactly on the time provided in "t".

Re: nonlocal fails ?

2019-11-15 Thread R.Wieser
Michael, > Well I've only seen this done in languages where other mechanisms >for returning complex types are not present. :-) Than you have not seen to many languages I'm afraid. There are quite a number of languages where /every/ type of argument (including values) can be transfered "by refer

Re: nonlocal fails ?

2019-11-15 Thread R.Wieser
Dennis, > The first thing one needs to learn is that Python does NOT follow the > common post-office mailbox concept where > > x = y > > means the /value/ stored at location identified by "y" is /copied/ to the > location identified by "x". :-) Although that is how we humans remember the effect

Re: nonlocal fails ?

2019-11-15 Thread R.Wieser
Pieter, > Do you mean, if Proc1() is called from Func1, it uses MyVar defined >in Func1, and if it is called from Func2, it uses MyVar from Func2? Yep. > If that is what you mean, that would be dynamic scope. Thanks for pointing that out (I've learned a new definition today! :-) ). Regards, Ru

Re: How to delay until a next increment of time occurs ?

2019-11-15 Thread R.Wieser
Dietmar, > I would assume that this is not an application that needs to output a 100% > correct pulse train every time. Correct. Thats in the design of the pulses themselves (25% duticycle for one state, 75% for the other. Lots of leeway, and self synchronising) > You may just repeat the pa

Writing a CPython extension - calling another sibbling method ?

2019-11-17 Thread R.Wieser
Hello all, I'm trying to edit a binary extension to Python, and have a situation where I would like to create method which adds a single argument, and than jumps to / calls another method. Like this: static PyObject *py_proc1(PyObject *self, PyObject *args) { Py_RETURN_NONE } static Py

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-18 Thread R.Wieser
MRAB, > One possibility is to refactor the code so that py_proc1 and py_proc2 > themselves just handle their arguments and then call the function that > does the actual work. The thing is that the arguments of py_proc1 and py_proc2 are the same, but for a single argument. Which means that le

Re: How to delay until a next increment of time occurs ?

2019-11-19 Thread R.Wieser
Peter, First things first: For some reason I see your message coming in empty, but with two attachments. An "att*.txt" one with the actual message contents, and a "signature.asc". Makes it kind of hard to read ... > No. There are many reasons why sleep() might return after t Not /that/ many

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread R.Wieser
Michael > Does this have to be done in the C API? As far as I can tell, yes. What I need to do is not exposed by the extension itself, meaning that a wrapper class can't get access to it either. And its just a syntax problem. I currently simply have not enough knowledge about the CPython AP

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread R.Wieser
MRAB, > It could be something like this: [snip example code] Thank you very much. Your "Call the other method" line shows me that I've been overthinking things. :-( After that I decided to see if I could give the "py_proc1" function two arguments, which worked. That means that the prepending

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread R.Wieser
Michael, > Sure but the Python methods* themselves are exposed and accessible > and according to your previous posts, all you want to do is add an > argument to a call to the existing method. If that's true, then you > should be able to do that part from pure Python. >* class methods defined by

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-20 Thread R.Wieser
Luciano, > Now that's a novel approach to asking for free help: pretending > to be smarter than the people who are trying to help you. What makes you think I'm /pretending/ ?*Ofcourse* I'm smarter than anyone on this earth, didn't you know ? :-D But I'll let you in on a secret: I'm rather a

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-20 Thread R.Wieser
Michael, > If you mentioned RPi.GPIO before, I apologize for my mistake. No I didn't, there is nothing to apologize for. > That's very helpful to know. I have no clue to why it would be, as my question has got *zero* to do with it - its valid for /any/ extension using the CPython C API.Jus

Re: Writing a CPython extension - calling another sibbling method ?

2019-11-20 Thread R.Wieser
Dennis, > So... extract the original args, then build a new args object with your > added argument, then call your new function with that... I wanted to respond that prepending a string to an existing argument sounds quite a bit easier than what you are describing, but than I realized that I ju

Re: tab replace to space 4

2019-11-29 Thread R.Wieser
Moi, > tkinter/IDLE in py380 : completely buggy. Example code please ? (plus a description of what should happen and what happens instead if you have it) Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: tab replace to space 4

2019-11-29 Thread R.Wieser
Terry, > R.W., are you reading via c.l.p, or the python google group? The first, using nntp.aioe.org > Don't hold your breath. A similar poster I challenged on StackOverflow > was honest enough to admit that he had not touched IDLE for a decade. Its just that I've just began to touch tkinter,

Re: tab replace to space 4

2019-11-29 Thread R.Wieser
Terry, > I have been using tk/tkinter based IDLE for over a decade on Windows with > very few issues. I think they are similarly stable on linux, etc. [Snip] Thanks for that explanation. And I see that, in my question, I should have asked for the involved OS too. Regards, Rudy Wieser -- ht

Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Hello all, Using Python3 I would like to import a specific class from another file (in the same folder), and have trouble doing so. "from file import function" works, but fails when I try to do the same with a class. "import file x = file.class" works, but also executes commands that are in t

Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Chris, > Are you sure there's a difference between classes and functions here? Yes, quite sure. If not my attempt to load a class he same way as a function would have worked. Which it doesn't. > Try "from file import function" and see if it runs commands at > the root of the file. What funct

Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Python, > from the_file import ClassName > > should work. I guess that your class name is not "class" right? You guessed that right. :-) Not a good idea to pick confusing names like that, especially when you do something the first time. > Note that in all cases when you import a module (either

Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Peter, >> "from file import function" works, but fails when I try to do the same >> with a class. > > Are you sure? It should behave the same for any name in the module. I am. At least, that is what the error said: "cannot import 'classname' from 'filename' " But as it turns out the problem is

Re: Python3 - How do I import a class from another file

2019-12-08 Thread R.Wieser
Dennis, > Common practice is that the class is capitalized. Instances >are lowercase. Thanks. Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3 - How do I import a class from another file

2019-12-09 Thread R.Wieser
Terry, > Not really. The resulting global objects do not normally take enough > space to worry about on normal modern desktops. For some reason I still aim to keep my (running) programs as small as possible - even though the ammount of memory has grown more than a thousandfold since I started

Re: Python3 - How do I import a class from another file

2019-12-09 Thread R.Wieser
DL, > Some of this you will know. (Hopefully) some will be 'new': Some of it is known to me, and indeed I do hope that there will be new stuff in there too. Its why I took up Python. :-) Thanks for the explanation (including the aliassing I wasn't aware of) and the links. Regards, Rudy Wiese

Re: Python3 - How do I import a class from another file

2019-12-09 Thread R.Wieser
Greg, >>> Are you sure there's a difference between classes and functions here? >> >> Yes, quite sure. > > And we're even more sure that there isn't. :-) As it turned out "we're" are right, and I was thrown off by the error message. :-p The problem is that I had no idea why I got that (rather e

Re: Python3 - How do I import a class from another file

2019-12-09 Thread R.Wieser
Python, > Child *depends* on Parent. I'm sorry, but without any kind of underbuilding statements like that are of no value to me I'm afraid. Also: if I can just copy-and-paste the class into the file which origionally included it and have the whole program run without a problem than that depe

Re: Python3 - How do I import a class from another file

2019-12-09 Thread R.Wieser
Greg, > There's nothing stopping you from subsequently rebinding that name to some > other object, or deleting it altogether. Which is something I did not expect. But running into is what makes doing something new interesting. :-) And I just realized something else: I just assumed that the "d

Re: Python3 - How do I import a class from another file

2019-12-09 Thread R.Wieser
Dennis, > "del instance" only deletes the NAME. [snip] Yep, I already assumed that that would happen. Just wanted to keep it simple. > "instance" xyz does not shadow "class" xyz... instead, the name "xyz" > only exists in the binding to the instance. That is what I tried to say: the name-bind

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
DL, > I went through this cycle of thinking, first using if __name__... to > 'hide' testing, then adding test functions within the module, and now keep > test code quite separate from 'the real thing'. :-) The normal newbie progression, off of which I'm in phase #1. Having a working program

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Greg, > In that case, it was only working by accident. I don't think so. Or you must be thinking that the __del__ method of an instance is only called by the garbage collector - which would be rather daft (just think of a file thats created when initialising an instance, but not closes until t

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Chris, > Well, that's exactly what happens. So, only the reference count gets lowered. Yep, thats daft. ... unless you explain why it can only be done that way. > Also, when you scorn something without knowing your facts, > you tend to make yourself look like a fool :) I tend to go with logic

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Python, > which contradicts your previous statement. I don't think so. > "with" is "more stuff" it is the right way to deal with disposable > ressource in the first place. Than you have missed the point altogether. It isn't about what you think is the perfect way to deal with something, but

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Chris, > Okay. What should happen when you do this? > > x = 5 > del x > > Should the integer 5 be deleted? Yep. What do you think happens instead ? I've not seen you explain or support anything in that regard, not even now. There is a bit of a problem with the above though: It has got zero t

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Antoon, > Well yes that is why it is stupid to rely on the garbage collector to do > those things for you. That is why Greg Ewing already stated: > >> If your object has a method for explicitly making it release its >> resources, it would be better to use that rather than rely on >> the garbage co

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Michael, >> So, only the reference count gets lowered. Yep, thats daft. > > Why? Consider: You missed the point. It was-and-is not about decrementing a reference but still having it above zero, but what happens when the reference becomes zero: is the __del__ method called directly (as I find

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
MRAB, > You merely disabled the mark-and-sweep collector. Nope. Go check the docs on "gc" Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Rhodri, > the object that is the integer 5 *isn't* deleted That was not the question. And you're now referring to the object as well as the integer, which makes it confusing. You also have not explained what happens instead. In short, your above statement has ZERO value to me. > On the cont

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Dennis, > In common Python, small integers are cached internally for reuse That is what I imagined could possibly be happening, reading the specific "the integer 5" formulation in the question ("reading between the lines" and all that). And thanks for that explanation, underbuild an all. :-)

Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Chris, > Once again, you make positive assertions about things you > don't understand. And you have refused to bring any kind of help (explanation!) forward that could have shown me the erring of my ways, as well as refusing to adress my (attempting to explain) examples. You might know a thing o

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Roel, > Rudy, unless/until you know the language inside out, you'd better listen > to Chris and other people here who spend a lot of time and effort in > helping people like you. I tried. But what he said made no sense to me, and no matter how hard I tried I could not get Chris (or others fo

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Dennis, This is the first time I've seen you post FUD. :-(( > It is called when the language IMPLEMENTATION decides to call it. > That time is not specified in the language description/reference manual. I'm rather sure it neither specifies that for any of the other commands. Does that mean that

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
MRAB, > From the help: ... > Do not depend on immediate finalization of objects when they become > unreachable (so you should always close files explicitly). Do you notice there is not a single word about (the delayed action of) the __del__ method in there ? Why than do you think its talking a

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Paul, > You do understand that the reference counting garbage collector is an > implementation detail of the CPython implementation *only*, don't you? No, I don't. But do tell how that matters to me. > there can be an indefinite delay between the last reference to > a value being lost and the

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
MRAB, > You don't "del" an instance, you "del" a reference, which might be in the > form of a name in a namespace. Remember me, the newbie to the language ? Did you understand what I tried to to say ? Good. Thats al that matters. > When the instance is collected, whenever that happens to be

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Michael, > You said it by implication. > > quote: "And as I do not think the designers of the language where that > stupid I must therefore reject your claim to what you think happens." I suggest you try reading that again, and imagine it being two centences, the first ending after "stupid" and

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Michael, > It's a two-way street. It's hard to teach someone that won't be taught. Whacking a student over the head because he doesn't understand has never helped the student*. So, stop whacking and start /teaching/. Like thinking of examples that could show the student where he goes wrong

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Antoon, > There is a difference between not understanding why things are as > you are told, and assuming because you don't understand, what you > are told is wrong. The other side is you guys, expecting from me that, even though I appearantly do not understand it, just take whatever has being sa

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Greg, > In CPython, these are the same thing. As soon as the reference > count becomes zero, the __del__ method is called That is what I assumed (the logical thing to do). > *and* the object is removed from memory. Which sounds reasonable too, especially in regard to the instances variables ne

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Bev, > You acknowledge that you are new to Python, yet you claimed > to know better than Python experts. You claim you want an answer > and yet you purposefully ignored their response because it didn't match > what you wanted to hear. No, I didn't. I just pointed out that their position simply w

Re: Python3 - How do I import a class from another file

2019-12-11 Thread R.Wieser
Chris, > Yes, we know exactly how that's solved, Nice. > but you specifically said you weren't interested in learning. Try taking a few courses of "understanding what you read". That is /not/ what I said. Though it goes in par with your amadant "you're wrong" chanting, even if there is at l

tkinter treeview widget - bind doubleclick to items only ?

2020-01-20 Thread R.Wieser
Hello all, I've create a treeview, and would (ofcourse) want to register some mouse-clicking on it, and for that I've found the ".bind()" method. https://stackoverflow.com/questions/3794268/command-for-clicking-on-the-items-of-a-tkinter-treeview-widget There is a slight problem with it though:

Re: tkinter treeview widget - bind doubleclick to items only ?

2020-01-20 Thread R.Wieser
MRAB, > self.treeview.bind('', self.on_dclick) That is what I used. Doubleclicking on the heading caused the "on_dclick" code to execute, though initially the ".identify()" call in my code returns an empty ID (no row present at the location I clicked). That changes when the treeview contents

tkinter - Changing the fontsize for the window and its widgets ?

2020-01-21 Thread R.Wieser
Hello all, I've got a small tkinter based program showing (among others) a treeview. I would like to set the default font for the whole window to something larger, as its supposed to be displayed on a TV a few meters away from the user. A few problems: 1) I have not been able to find any info

  1   2   >