Defining constant strings

Tal Einat tal.no.no.spam at gmail.com
Sun Aug 27 12:28:46 EDT 2006


Hans wrote:
> Hi,
>
> I want to define a couple of constant strings, like in C:
> #define mystring "This is my string"
> or using a const char construction.
>
> Is this really not possible in Python?
>
> Hans

One last note:

If you truly insist on having constant variables, you could write a
class which implements such behavior. You can write a simple class
which answers your specific needs quite easily.

Or you could go for a more generic approach, such as this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59878

- Tal




More information about the Python-list mailing list