Argument of an Exception in Python

Mohd Mohtashim
Updated on 30-Jan-2020 06:59:44

5K+ Views

An exception can have an argument, which is a value that gives additional information about the problem. The contents of the argument vary by exception. You capture an exception's argument by supplying a variable in the except clause as follows −try:    You do your operations here;    ...................... except ExceptionType, Argument:    You can print value of Argument here...If you write the code to handle a single exception, you can have a variable follow the name of the exception in the except statement. If you are trapping multiple exceptions, you can have a variable follow the tuple of the exception.This ... Read More

How MySQL Handles Out-of-Range Numeric Values

usharani
Updated on 30-Jan-2020 06:59:14

770 Views

Handling of MySQL numeric value that is out of allowed range of column data type depends upon the SQL mode in following ways −(A) Enabled SQL strict mode - When strict SQL mode is enabled, MySQL returns the error on entering the put-of-range value. In this case, the insertion of some or all the values got failed.For example, we have created a table with two columns having TINYINT and UNSIGNED TINYINT as their data types on columns.mysql> Create table counting(Range1 Tinyint, Range2 Tinyint Unsigned); Query OK, 0 rows affected (0.14 sec)Now with the help of the following command, we enabled the ... Read More

The try-finally Clause in Python

Mohd Mohtashim
Updated on 30-Jan-2020 06:58:31

2K+ Views

You can use a finally: block along with a try: block. The finally block is a place to put any code that must execute, whether the try-block raised an exception or not. The syntax of the try-finally statement is this −try:    You do your operations here;    ......................    Due to any exception, this may be skipped. finally:    This would always be executed.    ......................You cannot use else clause as well along with a finally clause.Example Live Demo#!/usr/bin/python try:    fh = open("testfile", "w")    fh.write("This is my test file for exception handling!!") finally:    print "Error: can\'t find file or read ... Read More

Remove FileList Item from Multiple Input File in HTML5

V Jyothi
Updated on 30-Jan-2020 06:58:16

2K+ Views

When there is a situation where we need to remove items from DOM’s through JavaScript, we cannot do so directly from FileList object. We need to assign the following to an array:$('input:file#upload')[1].filesAfter that remove items from this array using splice or method of our choice and use that array.Another way is to upload files with the help of HTML file uploader and then delete corresponding objects by using JavaScript.

Assertions in Python

Mohd Mohtashim
Updated on 30-Jan-2020 06:53:51

329 Views

An assertion is a sanity-check that you can turn on or turn off when you are done with your testing of the program.The easiest way to think of an assertion is to liken it to a raise-if statement (or to be more accurate, a raise-if-not statement). An expression is tested, and if the result comes up false, an exception is raised.Assertions are carried out by the assert statement, the newest keyword to Python, introduced in version 1.5.Programmers often place assertions at the start of a function to check for valid input, and after a function call to check for valid ... Read More

Prevent Color Buffer from Being Cleared in WebGL

Samual Sam
Updated on 30-Jan-2020 06:53:31

200 Views

Even if removing the color by code:mycanvas.clearColor(d[1],d[2],d[3],2.0); mycanvas.clear(can.COLOR_BUFFER_BIT );The screen gets cleared at beginning of next draw cycle.To create WebGLRenderingContext, previous drawing buffer can be preserved.gl = someCanvas.getContext("webgl", { preserveDrawingBuffer: true }); The default is preserveDrawingBuffer: false by making this property true, previous drawing can be easily preserved

HTML5 Using src with Raw Binary Data

Govinda Sai
Updated on 30-Jan-2020 06:52:52

1K+ Views

If an audio file is stored in database and then we want to use this file as a blob or binary in an application where audio source is according to session then binary data is returned through ${sessionScope.user.music}. To load the audio file in an audio tag, data:audio/mp3;base64 works well.As for the image, image tag is used as follows:

HTML5 Drag and Drop Not Dropping Issue

Vrundesha Joshi
Updated on 30-Jan-2020 06:52:23

558 Views

It is because there is no dragover event handler; however, default event handler of dragover event is used. After that, no drop event is triggered.e.preventdefault is needed for dragover event before drop event.If you want to allow a drop, then default handler is prevented for canceling the event. This can be done either by returning false from an attribute-defined event listener or by calling events event.prevent default method. False is returned when the division has dragover as property.The default is prevented.

MySQL CHAR_LENGTH Function with NULL Input

Sai Nath
Updated on 30-Jan-2020 06:51:33

340 Views

In this case, the output of CHAR_LENGTH() function depends on the condition that whether we are providing NULL as a string or we are providing simply NULL to it. Following example will demonstrate the difference −mysql> Select CHAR_LENGTH(NULL); +-------------------+ | CHAR_LENGTH(NULL) | +-------------------+ | NULL              | +-------------------+ 1 row in set (0.00 sec) mysql> Select CHAR_LENGTH('NULL'); +---------------------+ | CHAR_LENGTH('NULL') | +---------------------+ | 4                   | +---------------------+ 1 row in set (0.00 sec)As we can observe from the above result set that when we will provide ... Read More

MySQL ASCII Function Return for NULL

Ayyan
Updated on 30-Jan-2020 06:41:55

147 Views

In this case, the output of ASCII() function depends on the condition that whether we are providing NULL as a string or we are providing simply NULL to it. Following example will demonstrate the difference −mysql> SELECT ASCII(null); +-------------+ | ASCII(null) | +-------------+ | NULL        | +-------------+ 1 row in set (0.00 sec) mysql> SELECT ASCII('null'); +---------------+ | ASCII('null') | +---------------+ | 110           | +---------------+ 1 row in set (0.00 sec) mysql> Select ASCII(NULL); +-------------+ | ASCII(NULL) | +-------------+ | NULL        | +-------------+ 1 row in set ... Read More

Advertisements