C
Carl Banks
I'm talking about castironpi. I find his posts a waste of my time
"His" posts?
Carl Banks
I'm talking about castironpi. I find his posts a waste of my time
And white to play. What does exec( open( 'modA.py' ).read() ) do?
"His" posts?
Sounds like you need better filtering.
A decent news filter should be able not only kill a poster, but also
all followups to that poster recursively.
Whatever. I'm too old to worry about searching for politically correct,
gender neutral pronouns.
Actually, I am reading this as a mailing list and since I run Unix and
procmail I am sure that I could set something up if it really starts to
be annoying. So far the simple filters deal with all but a smattering
of problem postings so I don't need to expend the time.
I'm pretty sure even the most PC people wouldn't suggest using a
masculine pronoun for an inanimate objects.
(Ok, some probably would.)
Carl Banks
What is a class that is not a module?
A class is a bag of stuff and a namespace
J.
A more appropriate formulation of the 'question behind the words'
would have been, 'are there any weird corner cases in which it doesn't
import modA? I recognize it doesn't on .pyc and .pyd files, but you
could say exec( open( 'modA.py' ).read() ) ==> import modA, even if
import modA =!=> exec( open( 'modA.py' ).read() ) all the time.
However, a way of asking that's more direct would have been, "Wait...
can't you create multiple module instances like that?", but since
we've already seen successful loadings of at least the builtins,
that's been treated.
Maybe you even hear the right thing if I say,
"Does exec( open( 'modA.py' ).read() ) do the things of import modA?"
Yes, I can read the docs, but no, I can't check every possible
combination of modules.
The idea behind a singleton is to ensure something. You want non-
primary instances impossible to create. However, if (wording got
tangled here) for singleton A, if class B does the same thing, just
has different allocations-- it's own-- then A is still a singleton.
The writer of B hasn't defeated or contradicted the letter or spirit
of A.
OP's question might have come from a variety of perspectives. In some
ways yes, in others no. That is, if you try to reinstantiate modA,
you get the same instance. But if you try really hard, you get a new
one. Are you looking for an extension to import modA that won't
return an instance that is old?
So far, I know this: modules and classes are both namespaces. Are
those singletons?
A more appropriate formulation of the 'question behind the words'
would have been, 'are there any weird corner cases in which it doesn't
import modA? I recognize it doesn't on .pyc and .pyd files, but you
could say exec( open( 'modA.py' ).read() ) ==> import modA, even if
import modA =!=> exec( open( 'modA.py' ).read() ) all the time.
However, a way of asking that's more direct would have been, "Wait...
can't you create multiple module instances like that?", but since
we've already seen successful loadings of at least the builtins,
that's been treated.
Maybe you even hear the right thing if I say,
"Does exec( open( 'modA.py' ).read() ) do the things of import modA?"
Yes, I can read the docs, but no, I can't check every possible
combination of modules.
The idea behind a singleton is to ensure something. You want non-
primary instances impossible to create. However, if (wording got
tangled here) for singleton A, if class B does the same thing, just
has different allocations-- it's own-- then A is still a singleton.
The writer of B hasn't defeated or contradicted the letter or spirit
of A.
OP's question might have come from a variety of perspectives. In some
ways yes, in others no. That is, if you try to reinstantiate modA,
you get the same instance. But if you try really hard, you get a new
one. Are you looking for an extension to import modA that won't
return an instance that is old?
So far, I know this: modules and classes are both namespaces. Are
those singletons?
you
could say exec( open( 'modA.py' ).read() ) ==> import modA
Yes, you could say that, but you'd be wrong. Please test your code before
making such claims in the future.
Aye aye. -1 response not phrased in the form of a question.
Is it correct that exec( open( 'modA.py' ).read() ) -and- from modA
import * create "effectively" same results,
such as in the remaning
program not checking __module__ attributes?
Is there a slight modification of both sides that does cover a non-
trivial volume of programs, such as maybe, exec( open( 'modA.py'
).read(), locals= dict( __module__= 'modA' ) ) - and- from modA import
*, or something?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.