Python "with"

J. Cliff Dyer jcd at sdf.lonestar.org
Mon Sep 17 06:30:46 EDT 2007


Ivan Voras wrote:
> Laurent Pointal wrote:
>
>> The ugly part is the 'tmp' name, try to choose a name with a proper
>> meaning about what it is really, and it become clean and readable:
>>
>> filerefs = some.big.structure.or.nested.object.with.file.references
>> filerefs.encoding = "utf-8"
>> filerefs.name = "MyFileName.txt"
>> filerefs.use_quotes = True
>>
>> Isn't it ?
>
> Well, no, but this might be due to personal tastes. At least, I don't
> think it's better then some other alternatives. For example, in C99
> you can do:
>
> static struct option_s foo_option = {
>     .name = "foo",
>     .type = O_STRING,
>     .def_value = "default"
> };
>
> At least to me, this looks even better than the Pascal's syntax.
>
>
So basically, what you're saying is you don't like namespace prefixes at
all? 

Keeping your namespaces separate will help the clarity of your code
immensely, unless, arguably, you're doing heavy numerical processing,
goes the argument in a recent thread.  Probably what will help you the
most is not a fancy trick for getting rid of the namespace, but getting
over your aversion to them.  That will make you a better programmer, in
the long run.  Debugging will be easier, people will enjoy working with
your code more.  Clarity is beautiful.  Objectively so.  Not just some
lame "in the eye of the beholder" kind of beautiful.

Cheers,
Cliff



More information about the Python-list mailing list