Subject:
|
Re: TMTOWTDI (was: Re: NQC in Boston University Linux :))
|
Newsgroups:
|
lugnet.off-topic.geek
|
Date:
|
Sat, 8 Apr 2000 01:00:44 GMT
|
Reply-To:
|
MATTDM@MATTDM.stopspammersORG
|
Highlighted:
|
(details)
|
Viewed:
|
251 times
|
| |
| |
Todd Lehman <lehman@javanet.com> wrote:
> ref $foo or die "blah"; # assertion that $foo should be a reference
> !ref $foo and die "blah"; # assertion that $foo should not be a scalar
> if (!ref $foo) { die "blah"; } # dies for some $foo; emphasis on test
> unless (ref $foo) { die "blah"; } # dies for most $foo; emphasis on test
> die "blah" if !ref $foo; # dies for some $foo; emphasis on die
> die "blah" unless ref $foo; # dies for most $foo; emphasis on die
Well, in python, that's very easy, since all variables are references.
But, for example, to test if 'foo' is a callable object (a function, class,
method, etc...), this is the Way:
if not callable(foo):
sys.exit(1)
As I understand it, any other syntax is Wrong. (Well, actually, it's
probably more correct to handle the error more gracefully. But that's a
separate issue.)
> I feel crippled in a langage which forces me to write all of the above a
> single way -- and not just for quick-hack code.
This may be a good clue that python is not for you. :)
--
Matthew Miller ---> mattdm@mattdm.org
Quotes 'R' Us ---> http://quotes-r-us.org/
|
|
Message is in Reply To:
18 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|