On 2010-05-19 07:34:37 -0700, Steven D'Aprano said:
# Untested.
def verbose_print(arg, level, verbosity=1):
if level <= verbosity:
print arg
def my_function(arg):
my_print(arg, level=2)
return arg.upper()
if __name__ == '__main__':
if '--verbose' in sys.argv:
On Wed, 19 May 2010 00:16:56 -0700, TomF wrote:
> Let's say you have a bunch of globals, one of which is a verbose flag.
> If I understand the difference, using a module gbls.py:
>
> # in gbls.py
> verbose = False
> # elsewhere:
> import gbls
> gbls.verbose = True
>
> Using a class:
>
> # In th
On 2010-05-16 12:27:21 -0700, christian schulze said:
On 16 Mai, 20:20, James Mills wrote:
On Mon, May 17, 2010 at 4:00 AM, Krister Svanlund
wrote:
On Sun, May 16, 2010 at 7:50 PM, AON LAZIO wrote:
How can I set up global variables for the entire python applications?
Like I can call an
Steven D'Aprano wrote:
> I think it is an abuse of the term constant to allow you to talk about a
> mutable object being "constant", since it can vary. Generally, you don't
> care about identity, only equality. Making up a syntax on the spot:
>
> constant pi = [3.1415]
> assert pi = 3.1415
> p
On Mon, 17 May 2010 23:54:38 +0100, Rhodri James wrote:
> On Mon, 17 May 2010 05:29:20 +0100, Steven D'Aprano
> wrote:
>
>> On Sun, 16 May 2010 18:57:15 -0700, John Nagle wrote:
>>
>>> James Mills wrote:
The only place global variables are considered somewhat "acceptable"
are as consta
2010/5/16 Chris Rebert :
> On Sun, May 16, 2010 at 10:50 AM, AON LAZIO wrote:
>> Hi,
>>How can I set up global variables for the entire python applications?
>> Like I can call and set this variables in any .py files.
>>Think of it as a global variable in a single .py file but this is for t
On Mon, 17 May 2010 05:29:20 +0100, Steven D'Aprano
wrote:
On Sun, 16 May 2010 18:57:15 -0700, John Nagle wrote:
James Mills wrote:
The only place global variables are considered somewhat "acceptable"
are as constants in a module shared as a static value.
Python really ought to have
On Mon, 17 May 2010 19:56:15 +1200, Gregory Ewing wrote:
> John Nagle wrote:
>> Also, more compile-time arithmetic becomes possible.
>
> But only if their values can be computed at compile time.
John said "more", not "everything imaginable can be calculated at compile
time" :)
Python already d
John Nagle wrote:
Also, more compile-time arithmetic becomes possible.
But only if their values can be computed at compile time. This
leads to a huge can of worms if you want to be able to import
named constants from other modules. A large part of what
currently happens only at run time would h
On Mon, May 17, 2010 at 2:24 PM, Steven D'Aprano
wrote:
> In what way are they constant? Can you not modify them and rebind them?
It's just style/convention :)
Much like _ to denote private variables and methods!
--james
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 16 May 2010 18:57:15 -0700, John Nagle wrote:
> James Mills wrote:
>> The only place global variables are considered somewhat "acceptable"
>> are as constants in a module shared as a static value.
>
> Python really ought to have named constants.
+1
Unfortunately, it will most likely
On Mon, 17 May 2010 13:34:57 +1000, James Mills wrote:
> On Mon, May 17, 2010 at 11:57 AM, John Nagle wrote:
>> For one thing, it's fine to share constants across threads, while
>> sharing globals is generally undesirable. Also, more compile-time
>> arithmetic becomes possible.
>>
>> Python
On Mon, May 17, 2010 at 11:57 AM, John Nagle wrote:
> For one thing, it's fine to share constants across threads, while
> sharing globals is generally undesirable. Also, more compile-time
> arithmetic becomes possible.
>
> Python does have a few built-in named unassignable constants:
> "True"
James Mills wrote:
The only place global variables are considered somewhat "acceptable"
are as constants in a module shared as a static value.
Python really ought to have named constants.
For one thing, it's fine to share constants across threads, while
sharing globals is generally undes
On 16 Mai, 20:20, James Mills wrote:
> On Mon, May 17, 2010 at 4:00 AM, Krister Svanlund
>
> wrote:
> > On Sun, May 16, 2010 at 7:50 PM, AON LAZIO wrote:
> >> How can I set up global variables for the entire python applications?
> >> Like I can call and set this variables in any .py files.
>
On Mon, May 17, 2010 at 4:00 AM, Krister Svanlund
wrote:
> On Sun, May 16, 2010 at 7:50 PM, AON LAZIO wrote:
>> How can I set up global variables for the entire python applications?
>> Like I can call and set this variables in any .py files.
>> Think of it as a global variable in a single .
On Sun, May 16, 2010 at 10:50 AM, AON LAZIO wrote:
> Hi,
> How can I set up global variables for the entire python applications?
> Like I can call and set this variables in any .py files.
> Think of it as a global variable in a single .py file but this is for the
> entire application.
Thank
On Sun, May 16, 2010 at 7:50 PM, AON LAZIO wrote:
> Hi,
> How can I set up global variables for the entire python applications?
> Like I can call and set this variables in any .py files.
> Think of it as a global variable in a single .py file but this is for the
> entire application.
> Th
On Mon, May 17, 2010 at 3:50 AM, AON LAZIO wrote:
> Hi,
> How can I set up global variables for the entire python applications?
> Like I can call and set this variables in any .py files.
> Think of it as a global variable in a single .py file but this is for the
> entire application.
If you
Hi,
How can I set up global variables for the entire python applications?
Like I can call and set this variables in any .py files.
Think of it as a global variable in a single .py file but this is for the
entire application.
Thanks
--
Aonlazio
'Peace is always the way.' NW
--
http://mai
20 matches
Mail list logo