Changeset 896 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jun 19, 2016, 2:01:30 PM (8 years ago)
Author:
lfita
Message:

Adding `str_list': Function to obtain a list from a string givin a split character

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r894 r896  
    4040# significant_decomposition: Function to decompose a given number by its signifcant potencies
    4141# singleline_printing_class: Function to print all the values of a given class in a single line to be parseavel
     42# str_list: Function to obtain a list from a string givin a split character
    4243# subbasin_point: Function to provide sub-basins given a grid point following a matrix of trips
    4344# unitsdsDate: Function to know how many units of time are from a given pair of dates
     
    78147815    return hexcol
    78157816
     7817def str_list(string, cdiv):
     7818    """ Function to obtain a list from a string givin a split character
     7819      string= Strring from which to obtain a list
     7820      cdiv= character to use to split the string
     7821    >>> str_list('1:@#:$:56', ':')
     7822    ['1', '@#', '$', '56']
     7823    >>> str_list('1@#$56', ':')
     7824    ['1@#$56']
     7825    """
     7826    fname = 'str_list'
     7827
     7828    if string.find(cdiv) != -1:
     7829        listv = string.split(cdiv)
     7830    else:
     7831        listv = [string]
     7832
     7833    return listv
     7834
    78167835#quit()
    78177836
Note: See TracChangeset for help on using the changeset viewer.