Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa47bf4

Browse files
d3daveCarreau
authored andcommitted
Use slicing instead of condition
1 parent b8d9894 commit fa47bf4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

IPython/terminal/ptutils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def _elide_point(string:str, *, min_elide=30)->str:
4747
if file_parts[-1] == '':
4848
file_parts.pop()
4949

50-
if len(object_parts) > 3 and object_parts[1] and object_parts[-2]:
51-
return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(object_parts[0], object_parts[1][0], object_parts[-2][-1], object_parts[-1])
50+
if len(object_parts) > 3:
51+
return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(object_parts[0], object_parts[1][:1], object_parts[-2][-1:], object_parts[-1])
5252

53-
elif len(file_parts) > 3 and file_parts[1] and file_parts[-2]:
54-
return ('{}' + os.sep + '{}\N{HORIZONTAL ELLIPSIS}{}' + os.sep + '{}').format(file_parts[0], file_parts[1][0], file_parts[-2][-1], file_parts[-1])
53+
elif len(file_parts) > 3:
54+
return ('{}' + os.sep + '{}\N{HORIZONTAL ELLIPSIS}{}' + os.sep + '{}').format(file_parts[0], file_parts[1][:1], file_parts[-2][-1:], file_parts[-1])
5555

5656
return string
5757

0 commit comments

Comments
 (0)