Show More
@@ -154,48 +154,6 b' class Tee(object):' | |||||
154 | self.close() |
|
154 | self.close() | |
155 |
|
155 | |||
156 |
|
156 | |||
157 | def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'): |
|
|||
158 | """Take multiple lines of input. |
|
|||
159 |
|
||||
160 | A list with each line of input as a separate element is returned when a |
|
|||
161 | termination string is entered (defaults to a single '.'). Input can also |
|
|||
162 | terminate via EOF (^D in Unix, ^Z-RET in Windows). |
|
|||
163 |
|
||||
164 | Lines of input which end in \\ are joined into single entries (and a |
|
|||
165 | secondary continuation prompt is issued as long as the user terminates |
|
|||
166 | lines with \\). This allows entering very long strings which are still |
|
|||
167 | meant to be treated as single entities. |
|
|||
168 | """ |
|
|||
169 |
|
||||
170 | try: |
|
|||
171 | if header: |
|
|||
172 | header += '\n' |
|
|||
173 | lines = [raw_input(header + ps1)] |
|
|||
174 | except EOFError: |
|
|||
175 | return [] |
|
|||
176 | terminate = [terminate_str] |
|
|||
177 | try: |
|
|||
178 | while lines[-1:] != terminate: |
|
|||
179 | new_line = raw_input(ps1) |
|
|||
180 | while new_line.endswith('\\'): |
|
|||
181 | new_line = new_line[:-1] + raw_input(ps2) |
|
|||
182 | lines.append(new_line) |
|
|||
183 |
|
||||
184 | return lines[:-1] # don't return the termination command |
|
|||
185 | except EOFError: |
|
|||
186 | print() |
|
|||
187 | return lines |
|
|||
188 |
|
||||
189 |
|
||||
190 | def raw_input_ext(prompt='', ps2='... '): |
|
|||
191 | """Similar to raw_input(), but accepts extended lines if input ends with \\.""" |
|
|||
192 |
|
||||
193 | line = raw_input(prompt) |
|
|||
194 | while line.endswith('\\'): |
|
|||
195 | line = line[:-1] + raw_input(ps2) |
|
|||
196 | return line |
|
|||
197 |
|
||||
198 |
|
||||
199 | def ask_yes_no(prompt,default=None): |
|
157 | def ask_yes_no(prompt,default=None): | |
200 | """Asks a question and returns a boolean (y/n) answer. |
|
158 | """Asks a question and returns a boolean (y/n) answer. | |
201 |
|
159 |
General Comments 0
You need to be logged in to leave comments.
Login now