C macros in Python.
Grant Griffin
not.this at seebelow.org
Wed Oct 18 13:32:00 EDT 2000
More information about the Python-list mailing list
Wed Oct 18 13:32:00 EDT 2000
- Previous message (by thread): C macros in Python.
- Next message (by thread): C macros in Python.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <slrn8updfp.ero.quinn at zloty.ugcs.caltech.edu>, quinn at zloty.ugcs.caltech.edu says... > >On Tue, 17 Oct 2000 11:30:35 +0100, Burkhard Kloss <bk at xk7.com> wrote: >>> On a different, but related, topic...I sometimes miss C's #define >>> macro. There doesn't seem to be any similar thing in Python capable of >>> creating identifiers which are 1) constant, that is, "read only", and 2) >>> truly global in scope. >>How about defining a function that returns the value? that would make it >>nicely read-only. >> >>define pi(): return 3.14.... > >pi = 3 > >will defeat that nicely. (BTW, here's a "Python Moment" if ever there was one: I realized awhile back that tuples are essentially read-only lists.) >If you want something to be constant in python, don't reassign it. Not that >hard, now is it? :) And if you want something "truly global" you could shove >it into __builtins__, which is great not only for confusing other people but >also increasing job security. And that's why you want globals in the first >place, right? :) In my own case, I just would like to have the global constants: True = 1 False = 0 >Or, you could just run all your python scripts through cpp. 1 (meaning: "True" <wink>), but that sounds like more trouble than it's worth. those-who-would-like-"True"-and-"False"-get-"None"-ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com
- Previous message (by thread): C macros in Python.
- Next message (by thread): C macros in Python.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list