Posts: 4,646
Threads: 1,493
Joined: Sep 2016
how can i reference a method of a class from a different method in the same class?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
what if the method to reference from is
__getattribute__()
?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
Jul-02-2020, 01:33 AM
(This post was last modified: Jul-02-2020, 01:41 AM by Skaperen.)
because i need to substitute all attribute gets with the like named attribute of the actual open file object. that means __getattr__ won't be called because __getattribute__ found the attribute. attribute "close" is the special case where i need to substitute the method in my class (so it can do os.rename() after the file is closed).
yes, i can see it is tricky. and i also have the issue of needing to store a few variables in this object instance, (1 and 2) the file names to rename,(3) the open file object that needs to be referenced and closed. that makes a lot of attributes to juggle (most reference the open file and a few not).
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
this is all in my effort to create
topen() a function that emulates
open() as close as it can while opening files being created using a temporary name and doing a rename of the temporary name to the original name when the file is closed. a future function named
ztopen() will also perform compression or decompression using the compress library open() emulations functions, based on the name of the file.
one thing i did, with success, was create a way to access the self name space without using attributes. the trick i used was to base the class from the dict type. then i can do dictionary style references to self. this avoided much complication in
__getattribute__() [though most of these could probably be done less complex in
__getattr__()].
topen() is now working for the basic test i am doing. i have other tests to do, including having many files concurrently open (to be sure things never get mixed up).
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.