Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85858

What behavior would you expect?

Date 2015-02-18 21:44 -0700
Subject What behavior would you expect?
From Jason Friedman <jsf80238@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.18856.1424321059.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

I have need to search a directory and return the name of the most recent
file matching a given pattern.  Given a directory with these files and
timestamps,

q.pattern1.abc Feb 13
r.pattern1.cdf  Feb 12
s.pattern1.efg  Feb 10
t.pattern2.abc Feb 13
u.pattern2.xyz  Feb 14
v.pattern2.efg  Feb 10

calling my_function("/path/to/dir", "pattern1") will return q.pattern1.abc
and calling my_function("/path/to/dir", "pattern2") will return
u.pattern2.xyz.

My question is, what would be a reasonable behavior/result/return value if:
1. "/path/to/dir" does not exist or is not readable
2. no files match the given pattern

Also, what would be a reasonable name for such a function?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

What behavior would you expect? Jason Friedman <jsf80238@gmail.com> - 2015-02-18 21:44 -0700
  Re: What behavior would you expect? Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-19 14:16 +0000
    Re: What behavior would you expect? Chris Angelico <rosuav@gmail.com> - 2015-02-20 02:08 +1100
      Re: What behavior would you expect? Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-19 20:03 +0000
        Re: What behavior would you expect? Chris Angelico <rosuav@gmail.com> - 2015-02-20 07:11 +1100
          Re: What behavior would you expect? Dan Sommers <dan@tombstonezero.net> - 2015-02-20 04:54 +0000
            Re: What behavior would you expect? Chris Angelico <rosuav@gmail.com> - 2015-02-20 16:16 +1100
              Re: What behavior would you expect? Dan Sommers <dan@tombstonezero.net> - 2015-02-20 05:40 +0000
                Re: What behavior would you expect? Jason Friedman <jsf80238@gmail.com> - 2015-02-19 22:49 -0700
                Re: What behavior would you expect? Paul Rubin <no.email@nospam.invalid> - 2015-02-19 22:18 -0800
                Re: What behavior would you expect? Chris Angelico <rosuav@gmail.com> - 2015-02-20 17:21 +1100
                Re: What behavior would you expect? Paul Rubin <no.email@nospam.invalid> - 2015-02-19 23:18 -0800

csiph-web