[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pyton & perl



"Michael P. Soulier" wrote:
> 
> On Sun, Apr 01, 2001 at 05:57:50PM -0700, Robert Cymbala wrote:
> >
> > Can't just split lines in Python?  Splitting lines where it's logical
> > to do so is possible.  Here's a sample, created with CPython mode in
> > Emacs.  The entire script is at:
> > http://www.lafn.org/~cymbala/photospy.html
> >
> >  131            # Create an "alias" down to the sent layer.
> >  132            self.info['data'][
> >  133                self.info['roll_number_max']][
> >  134                'sent'] = {}
> >  135            sent = self.info['data'][
> >  136                self.info['roll_number_max']][
> >  137                'sent']
> 
>     I didn't say you couldn't split lines. I said you couldn't do it
> necessarily where it's logical to do so. I do not find the above code splits
> lines at logical points. It is making use of the open parens to split lines,
> when personally, I would never split across an open paren like that. I find it
> difficult to read.
> 
>     Typical perl for me
> 
>     my @files = sort
>                 map { $dir . "/$_" }
>                 grep { !/^\./ }
>                 readdir DIR;
> 
>     I find this far more readable, but that's me.

  consider having all the indends the same (just think about it)

  something along these lines:

my @files = sort
  map { $dir . "/$_" }
  grep { !/^\./ }
  readdir DIR;

  because when you have code like this:

my @files = sort
  map { $dir . "/$_" }
  grep { !/^\./ }
  readdir DIR;

my($firstValue, $secondOne, $andSomethingElse) = function(
  $firstParam,
  $secondParam,
  $thirdParam
);

$andHereWeGoAgain = yetAnotherFunctionWithLongNameAndLotsaParameters(
  $firstParam,
  $secondParam,
  $thirdParam
);

  it's a lot more readable then if each one would have it's own
different indent... IMO. While I hate the idea of indentation being
enforced like it is in python I think that being consistentin rules and
visuals (how it looks) is very important for readability of programs.

	erik



Reply to: