In article <888b5e8f-1be5-4040-bc7a-45c2e1695...@d9g2000prh.googlegroups.com>,
AK Eric wrote:
>>
>> 2/ in Python, "global" really means "module-level" - there's nothing
>> like a "true" global namespace.
>
>Isn't that __main__?
>
>import __main__
>__main__.foo = "asdfasdf"
>
>print foo
># asdfasd
On Fri, Oct 30, 2009 at 9:01 AM, AK Eric wrote:
> Should we start talking about how you can add stuff to __builtin__ and
> then it really is exposed to everything? (right, unless I'm missing
> some other Python idiom?) Again, *not advocating* in standard
> practice, but I think it's important to
> > It isn't a neat trick anymore once you realize the name '__main__'
> > isn't special.
>
> > Replace __main__ with foo, or config, or whatever, and you get the
> > same results. Ok, there is a catch: a file with that name must exist,
> > at least an empty one...
True. I do feel a bit less spec
Gabriel Genellina wrote:
En Fri,
30 Oct 2009 00:29:27 -0300, Steven D'Aprano
escribió:
On Thu, 29 Oct 2009 10:31:03 -0700, AK Eric wrote:
2/ in Python, "global" really means "module-level" - there's nothing
like a "true" global namespace.
It isn't a neat trick anymore once you realize the
Bruno Desthuilliers a écrit :
AK Eric a écrit :
2/ in Python, "global" really means "module-level" - there's nothing
like a "true" global namespace.
Isn't that __main__?
Nope
import __main__
__main__.foo = "asdfasdf"
print foo
# asdfasdf
Not advocating, but it does serve the purpose.
AK Eric a écrit :
2/ in Python, "global" really means "module-level" - there's nothing
like a "true" global namespace.
Isn't that __main__?
Nope
import __main__
__main__.foo = "asdfasdf"
print foo
# asdfasdf
Not advocating, but it does serve the purpose.
This won't make 'foo' available
En Fri, 30 Oct 2009 00:29:27 -0300, Steven D'Aprano
escribió:
On Thu, 29 Oct 2009 10:31:03 -0700, AK Eric wrote:
2/ in Python, "global" really means "module-level" - there's nothing
like a "true" global namespace.
Isn't that __main__?
Well there you go, I just learned something new.
I w
On Thu, 29 Oct 2009 10:31:03 -0700, AK Eric wrote:
>> 2/ in Python, "global" really means "module-level" - there's nothing
>> like a "true" global namespace.
>
> Isn't that __main__?
Well there you go, I just learned something new.
I was going to say "No, every module has its own __main__", and
On Thu, Oct 29, 2009 at 7:11 PM, AK Eric wrote:
>> Good that you're not advocating it, because IMHO it's bad practice to
>> have circular import dependencies. By using the __main__ alias, you
>> avoid the worst problems, but that just means the others are more subtle.
>
> I figured I'd get that k
> Good that you're not advocating it, because IMHO it's bad practice to
> have circular import dependencies. By using the __main__ alias, you
> avoid the worst problems, but that just means the others are more subtle.
I figured I'd get that kind of response, not that it's incorrect ;)
Great power
AK Eric wrote:
2/ in Python, "global" really means "module-level" - there's nothing
like a "true" global namespace.
Isn't that __main__?
import __main__
__main__.foo = "asdfasdf"
print foo
# asdfasdf
Not advocating, but it does serve the purpose.
Good that you're not advocating it,
> 2/ in Python, "global" really means "module-level" - there's nothing
> like a "true" global namespace.
Isn't that __main__?
import __main__
__main__.foo = "asdfasdf"
print foo
# asdfasdf
Not advocating, but it does serve the purpose.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Oct 29, 2009 at 3:25 AM, VYAS ASHISH M-NTB837
wrote:
>
> Dear all
>
> How do I write a code that gets executed 'every x' minutes?
>
>
>
> I know how to do it 'after x' minutes, I do the following:
>
> def doAtTimerFire():
> """ The things I want to do 'after x' minutes go here. """
Dear all
How do I write a code that gets executed 'every x' minutes?
I know how to do it 'after x' minutes, I do the following:
def doAtTimerFire():
""" The things I want to do 'after x' minutes go here. """
And then from main code, I do this:
tmr = threading.Timer(timeInSeconds,
Ronn Ross a écrit :
(please don't top-post - fixed)
On Oct 28, 2009, at 20:50, mattofak wrote:
Hi All;
I'm new to Python and moving from C, which is probably a big source of
my confusion. I'm struggling with something right now though and I
hope you all can help.
I have a global configuratio
On Wed, Oct 28, 2009 at 8:50 PM, mattofak wrote:
> Hi All;
>
> I'm new to Python and moving from C, which is probably a big source of
> my confusion. I'm struggling with something right now though and I
> hope you all can help.
>
> I have a global configuration that I would like all my classes and
> On Oct 28, 2009, at 20:50, mattofak wrote:
>> Hi All;
>>
>> I'm new to Python and moving from C, which is probably a big source of
>> my confusion. I'm struggling with something right now though and I
>> hope you all can help.
>>
>> I have a global configuration that I would like all my classes
Inside the method that you want to use the var prefix the first
instance with global. For example: global my_var. Then you can use the
var like normal in the method. Good luck
On Oct 28, 2009, at 20:50, mattofak wrote:
Hi All;
I'm new to Python and moving from C, which is probably a big
18 matches
Mail list logo