Given a list of strings, format them with commas and spaces, but
    with 'and' at the end.

    >>> join_and(['apples', 'oranges', 'pears'])
    "apples, oranges, and pears"

    There is surely a better home for this
519609
def join_and(value):
    
    # convert numbers to strings
    value = [str(item) for item in value]

    if len(value) == 1:
        return value[0]
    if len(value) == 2:
        return "%s and %s" % (value[0], value[1])

    # join all but the last element
    all_but_last = ", ".join(value[:-1])
    return "%s and %s" % (all_but_last, value[-1])
163953
function commaSeparated (fn, inp, cb) {
    var all = [], res;
    while (1) {
      res = fn(inp);
      if ((res && !cb) || (res && cb(res, inp))) {
        all.push(res);
        if (inp.skipWs().takeAPeek(",")) {
          inp.skipWs();
        } else break;
      } else break;
    }
    return all;
  }
698172
def join(self, formatted_texts):
        """"""
        formatted_texts = list(formatted_texts)  # so that after the first iteration elements are not lost if generator
        for formatted_text in formatted_texts:
            assert self._is_compatible(formatted_text), "Cannot join text with different modes"
        self.text = self.text.join((formatted_text.text for formatted_text in formatted_texts))
        return self
103958
def commajoin_as_strings(iterable):
    
    return _(u',').join((six.text_type(i) for i in iterable))
129361
def join(mapping, bind, values):
    
    return [' '.join([six.text_type(v) for v in values if v is not None])]
163975
function indent(str, prefix) {
  prefix = prefix || '   ';
  var lines = str.split("\n");
  lines.forEach(function(line, i) {
    lines[i] = prefix + line;
  });
  return lines.join("\n");
}
702264
def format_lists(lists)
      lists.inject([nil]) do |buf, (_, val)|
        opts = Kat::Search.send(val[:select])
        buf << val[:select].to_s.capitalize
        buf << nil unless opts.values.first.is_a? Array
        width = opts.keys.sort { |a, b| b.size <=> a.size }.first.size
        opts.each do |k, v|
          buf += if v.is_a? Array
                   [nil, "%#{ width }s => #{ v.shift }" % k] +
                     v.map { |e| ' ' * (width + 4) + e }
                 else
                   ["%-#{ width }s => #{ v }" % k]
                 end
        end
        buf << nil
      end
    end
364940
def format_list(data):
    
    if isinstance(data, (list, tuple)):
        to_clean = ['[', ']', '(', ')', "'"]
        for item in to_clean:
            data = str(data).replace("u\"", "\"").replace("u\'", "\'")
            data = str(data).replace(item, '')
    return data
108843
function format(str, args) {
        var keys = Object.keys(args), i;
        for (i=0; i<keys.length; i++) {
            str = str.replace(new RegExp("\\{" + keys[i] + "\\}", "gi"), args[keys[i]]);
        }
        return str;
    }
424112
def complete_opt_format(self, text, *_):
        
        return [t + " " for t in FORMATTERS if t.startswith(text)]
1276195
def abbreviate_list(items, max_items=10, item_max_len=40, joiner=", ", indicator="..."):
  
  if not items:
    return items
  else:
    shortened = [abbreviate_str("%s" % item, max_len=item_max_len) for item in items[0:max_items]]
    if len(items) > max_items:
      shortened.append(indicator)
    return joiner.join(shortened)
1298457
def comma_join(fields, oxford=True):
    

    def fmt(field):
        return "'%s'" % field

    if not fields:
        return "nothing"
    elif len(fields) == 1:
        return fmt(fields[0])
    elif len(fields) == 2:
        return " and ".join([fmt(f) for f in fields])
    else:
        result = ", ".join([fmt(f) for f in fields[:-1]])
        if oxford:
            result += ","
        result += " and %s" % fmt(fields[-1])
        return result
557265
def join(self, name, args, arg_separator=None):
        """"""
        if None is arg_separator:
            arg_separator = ', '
        args = [_f for _f in args if _f]

        if not args:
            args_str = ' '
        elif len(args) == 1:
            args_str = ' ' + args[0] + ' '
        else:
            args_str = ' ' + arg_separator.join(args) + ' '

        return ''.join([name, self.__begin, args_str, self.__end])
259812
def and_(cls, obj, **kwargs):
        
        return cls.__eval_seqexp(obj, operator.and_, **kwargs)
1043157
def indentjoin(strlist, indent='\n    ', suffix=''):
    
    """
    indent_ = indent
    strlist = list(strlist)
    if len(strlist) == 0:
        return ''
    return indent_ + indent_.join([six.text_type(str_) + suffix
                                   for str_ in strlist])
494050
def join_cols(cols):
    """"""
    return ", ".join([i for i in cols]) if isinstance(cols, (list, tuple, set)) else cols
1071959
def p_expression_And(self, p):
        ''
        p[0] = And(p[1], p[3], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))