How to exit from Python without traceback?

0 votes
I would like to know how to I exit from Python without having a traceback dump on the output.

I still want to be able to return an error code but I do not want to display the traceback log.

I want to be able to exit using exit (number) without trace but in case of an Exception (not an exit) I want the trace.
May 10, 2018 in Python by aryya
• 7,370 points
186 views

1 answer to this question.

0 votes

shutil has many methods you can use. One of which is:

from shutil import copyfile

copyfile(src, dst)

Copy the contents of the file named src to a file named dst. The destination location must be writable; otherwise, an IOError exception will be raised. If dst already exists, it will be replaced. Special files such as character or block devices and pipes cannot be copied with this function. srcand dst are path names given as strings.

answered May 10, 2018 by charlie_brown
• 7,770 points

Related Questions In Python

0 votes
1 answer

How to exit from Python without traceback?

Perhaps you're trying to catch all exceptions ...READ MORE

answered Jul 31, 2018 in Python by Priyaj
• 57,530 points
2,145 views
0 votes
1 answer

How to exit from Python without traceback?

You are presumably encountering an exception and ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 13,250 points
254 views
+2 votes
11 answers
0 votes
1 answer

How to get text label from SAP using pywinauto[python]

Hi. Can you please tell me what ...READ MORE

answered Jun 28, 2018 in Python by Nietzsche's daemon
• 4,260 points
745 views
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 69,040 points

edited Aug 8, 2018 by Omkar 3,672 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

answered Sep 12, 2018 in Python by Priyaj
• 57,530 points
135 views
0 votes
1 answer

how to exit a python script in an if statement

This works fine for me: while True: ...READ MORE

answered Sep 19, 2018 in Python by bug_seeker
• 15,390 points
20,313 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

answered Sep 24, 2018 in Python by Priyaj
• 57,530 points
124 views
0 votes
1 answer

How can I write code to find a palindrome in python without using string functions?

In Logic 1, try if i<int(length/2): instead of if i<int((length/2+1)): In ...READ MORE

answered Jan 16, 2019 in Python by charlie_brown
• 7,770 points
6,906 views
+2 votes
2 answers

How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,770 points
2,479 views