Be gentle with me....

William Tanksley wtanksle at hawking.armored.net
Tue Dec 7 22:59:18 EST 1999


On Tue, 07 Dec 1999 13:21:39 GMT, ajmayo at my-deja.com wrote:
>  wtanksle at hawking.armored.net (William Tanksley) wrote:
>> On Mon, 06 Dec 1999 10:49:25 GMT, ajmayo at my-deja.com wrote:
>> >  ajmayo at my-deja.com wrote:

>[snip]
>> >In fact, I don't necessarily *want* to make that
>> >client-side code easy to read - code obfuscation is actually a
>> >feature
>> >when you're trying to protect your intellectual property from the
>> >browser's View Source feature.

>> I don't buy this.  You're not getting enough value from this trivial
>> bit of obfusication, and you're losing a LOT.

>er, I meant obfuscating the *client-side* code, not the server-side
>code. But let's not get too excited about that. IE5, for instance,
>supports client-side code encryption which is probably a better idea
>than relying on obfuscation. I just meant really that there didn't seem
>to be any way in Python of abbreviating the code so that (in pseudocode)

>begin
>   if something then
>       begin
>           more code with more nested blocks...
>       end
>   end if
>end

>could be output as a 'one liner' when producing dynamic client-side
>code from the server. It looks to me like you have to (a) include the
>line separators (b) use n spaces at the start of each block at level n.

There's a few ways of abbreviating it, actually.  (And by the way, "1" is
a perfectly acceptable value for n.)  As I posted, one-liners can be
crammed into one line by means of semicolons, so

if x:
  do()
  dah()

looks like this:

if x: do();dah()

>This is just plain wasteful of communication line bandwidth, as well as
>being a bit of a pain when you are writing the code.

Negative on both counts.  It's a pleasure when you're writing the code,
and it's not "plain wasteful" if the language does what you need it to.

Perl spends a lot of time being bandwidth efficient, but it winds up
taking MORE room for many things (for example, compare the classical Perl
"munitions export" cryptography .signature with ESR's Python equivalent --
the Python one is shorter).

>[snip]
>> >Secondly, I am afraid I gasped when I read that variables don't
>> >require
>> >declaration. This is a useful feature for tiny 'throw-away' programs
>> >but please, please tell me there's the equivalent of Visual Basic's
>> >Option Explicit or perl's Use Strict.

>> You're telling us that you use obfusication but don't like the idea of
>> variables not requiring declaration?

>> Anyhow, Perl's use strict mode has essentially the same effect as
>> Python's normal operation (modulo a few minor behaviors).

>As I said, I don't want to obfuscate the *server-side* code. No, I want
>it to be a marvel of clarity and wit for the generations of programmers
>who will maintain it. The server-side code doesn't go out to the
>client, remember. I must admit I kinda feel mandatory variable
>declaration has proven to be a *good* feature of modern programming
>languages though I accept Javascript could do with the equivalent
>of 'use strict' too.

I like variable declaration as well.  Use it all the time.  Just not in
Python :-).  I like the fact that Python lets me skip it, although I
wouldn't complain if it became optional.

>So I guess you're telling me that you can't mandate variable
>declaration in Python. Ah well, as long as I know, I guess.

Nope, not possible.  You have to find other ways.

>re Zope - yup, I will certainly be checking it out. Thanks again for
>all your help.

Good luck!

-- 
-William "Billy" Tanksley, in hoc signo hack



More information about the Python-list mailing list