Is this pythonic?

I

ipytest

x.validate_output(x.find_text(x.match_filename
(x.determine_filename_pattern(datetime.datetime.now()))))

Is it even good programming form?
 
B

Bruno Desthuilliers

(e-mail address removed) a écrit :
x.validate_output(x.find_text(x.match_filename
(x.determine_filename_pattern(datetime.datetime.now()))))

Is it even good programming form?

functional programming addicts might say yes. But as far as I'm
concerned, I find it a bit too nested...
 
L

Laszlo Nagy

x.validate_output(x.find_text(x.match_filename
(x.determine_filename_pattern(datetime.datetime.now()))))

Is it even good programming form?
You should try LISP. :)
 
P

pruebauno

x.validate_output(x.find_text(x.match_filename
(x.determine_filename_pattern(datetime.datetime.now()))))

Is it even good programming form?

Lisp and Scheme programmers love that style. You can tell by the
number of parentheses :). In Python people usually use an
intermediate variable to break things up a bit but the amount of
acceptable nesting is a matter of personal style.
 
J

Jason Scheirer

Lisp and Scheme programmers love that style. You can tell by the
number of parentheses :). In Python people usually use an
intermediate variable to break things up a bit but the amount of
acceptable nesting is a matter of personal style.

I'd say it's fine but breaking up the statement once or twice is a
good idea just because if one of the function calls in this nested
thing throws an exception, a smaller statement with fewer calls makes
for a far more readable traceback. And I hope that this whole
statement all lives inside of a method in the same x class, or is a
higher-level class that makes use of this behavior? If not, you may
want to consider doing so.

class X(object):
@property
def todays_filepattern(self):
return self.match_filename(
self.determine_filename_pattern(
datetime.datetime.now()))
def validate_todays_files(self):
return self.validate_output(self.find_text
(self.todays_filepattern))
 
R

Russ P.

x.validate_output(x.find_text(x.match_filename
(x.determine_filename_pattern(datetime.datetime.now()))))

Is it even good programming form?

I hope you're kidding.
 
H

Hendrik van Rooyen

Bruno Desthuilliers said:
(e-mail address removed) a écrit :

functional programming addicts might say yes. But as far as I'm
concerned, I find it a bit too nested...
+1

I would call it onionskin programming.

There is of course nothing technically wrong with it,
and you can do the same kind of thing in C, but
every time I see something like it, my reaction is
WTF.

- Hendrik
 
B

Baby Coder

I'd say it's fine but breaking up the statement once or twice is a
good idea just because if one of the function calls in this nested
thing throws an exception, a smaller statement with fewer calls makes
for a far more readable traceback. And I hope that this whole
statement all lives inside of a method in the same x class, or is a
higher-level class that makes use of this behavior? If not, you may
want to consider doing so.

class X(object):
  @property
  def todays_filepattern(self):
      return self.match_filename(
              self.determine_filename_pattern(
                   datetime.datetime.now()))
  def validate_todays_files(self):
     return self.validate_output(self.find_text
(self.todays_filepattern))

Thanks for this lesson in application design. Just what I was looking
for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,297
Messages
2,571,538
Members
48,284
Latest member
alphabetsalphabets

Latest Threads

Top