converting from perl: variable sized unpack

phil hunt philh at comuno.freeserve.co.uk
Sat Jul 21 16:29:38 EDT 2001


On 21 Jul 2001 01:49:19 GMT, Quinn Dunkan <quinn at yak.ugcs.caltech.edu> wrote:
>On Thu, 19 Jul 2001 12:36:49 +0100, phil hunt <philh at comuno.freeserve.co.uk>
>wrote:
>>On 18 Jul 2001 21:19:54 GMT, Quinn Dunkan <quinn at yak.ugcs.caltech.edu> wrote:
>>>It's not just you, but I don't agree, and it's not just me either.
>>>NameErrors, KeyErrors, and IndexErrors have saved me many times.  One of the
>>>things I didn't like about perl is how it magically created values on
>>>reference, and then I had to go hunt down the bad reference that created it.
>>>And I often store None in dicts and lists.  It would be weird if d.has_key(x)
>>>could be true or false while d[x] always evaluated to None.  That means that
>>>d[x] is implicitly creating a None when d.has_key(x) is false,
>>
>>It doesn't, it's just returning a value.
>
>But where is that value coming from?  It wasn't stored in the dict!

Consider the expression 2+3. Where is the 5 coming from; it wasn't
stored anywhere previously.

>And keep in mind that looking up global names and looking up object attributes
>are conceptually dictionary lookups (in globals() and obj.__dict__,
>respectively).

I'd be happy for a reference to a non-existant variable to create
it with a default value (e.g. None). Awk does this, and I find it
a good feature ofd not having to manually cross the t's and dot the i's.

>
>This is the kind of automatic creation and coercion that many people love
>about perl.  Many other people, however, don't :)

One of the few things Perl does right, then. Personally I find Perl
almost impossible to code in as I cannot make head or tail of it
as far as lexical analysis goes.

-- 
#===== Philip Hunt == philh at comuno.freeserve.co.uk ======#
    Herbivore: effort-free public key encryption. See:
<http://www.vision25.demon.co.uk/oss/herbivore/intro.html>
        ** First software release coming soon! **






More information about the Python-list mailing list