![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 27104 Articles for Server Side Programming
![Sarika Singh](https://www.tutorialspoint.com/assets/profiles/502778/profile/60_2211036-1660719373.jpg)
18K+ Views
When an object is deleted or destroyed, a destructor is invoked. Before terminating an object, cleanup tasks like closing database connections or filehandles are completed using the destructor. The garbage collector in Python manages memory automatically. for instance, when an object is no longer relevant, it clears the memory. In Python, the destructor is entirely automatic and never called manually. In the following two scenarios, the destructor is called − When an object is no longer relevant or it goes out of scope The object's reference counter reaches zero. Using the __del__() method In Python, a destructor is ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
521 Views
A class attribute is an attribute of the class rather than an attribute of an instance of the class.In the code below class_var is a class attribute, and i_var is an instance attribute: All instances of the class have access to class_var, which can also be accessed as a property of the class itself −Exampleclass MyClass (object): class_var = 2 def __init__(self, i_var): self.i_var = i_var foo = MyClass(3) baz = MyClass(4) print (foo.class_var, foo.i_var) print (baz.class_var, baz.i_var)OutputThis gives the output(2, 3) (2, 4)
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
4K+ Views
Having entered following command from linux terminal −$ g++ helloworld.cppThe a.out file should be created in the current working directory if the compilation is successful. Check if a.out is created.To execute enter following from command line −$ ./a.outIn most cases, output of your source program is displayed. However, as in your case, error message indicating a.out is not executable is appearing. See the properties of a.out and make it executable (if not already) by following command −$ chmod +x a.outYou may require sudo privilege for this. In all probability this should work. all the bestRead More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/7345/profile/60_93814-1511173378.jpg)
169 Views
Python tuple is an immutable object. Hence any operation that tries to modify it (like append/insert) is not allowed. However, following workaround can be used.First, convert tuple to list by built-in function list(). You can always append as well as insert an item to list object. Then use another built-in function tuple() to convert this list object back to tuple.>>> T1=(10,50,20,9,40,25,60,30,1,56) >>> L1=list(T1) >>> L1 [10, 50, 20, 9, 40, 25, 60, 30, 1, 56] >>> L1.append(100) >>> L1.insert(4,45) >>> T1=tuple(L1) >>> T1 (10, 50, 20, 9, 45, 40, 25, 60, 30, 1, 56, 100)
![Sarika Singh](https://www.tutorialspoint.com/assets/profiles/502778/profile/60_2211036-1660719373.jpg)
120K+ Views
Tuples in Python are immutable, meaning that once they are created, their contents cannot be changed. However, there are situations when we want to change the existing tuple, in which case we must make a new tuple using only the changed elements from the original tuple. Following is the example of the tuple − s = (4, 5, 6) print(s) print(type(s)) Following is the output of the above code − (4, 5, 6) Tuple is immutable, although you can use the + operator to concatenate several tuples. The old object is still present at this point, and ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/7345/profile/60_93814-1511173378.jpg)
299 Views
Slicing operator can be used with any sequence data type, including Tuple. Slicing means separating a part of a sequence, here a tuple. The symbol used for slicing is ‘:’. The operator requires two operands. First operand is the index of starting element of slice, and second is index of last element in slice+1. Resultant slice is also a tuple.>>> T1=(10,50,20,9,40,25,60,30,1,56) >>> T1[2:4] (20, 9)Both operands are optional. If first operand is missing, slice starts from beginning. If second operand is missing, slice goes upto end.>>> T1=(10,50,20,9,40,25,60,30,1,56) >>> T1[6:] (60, 30, 1, 56) >>> T1[:4] (10, 50, 20, 9)
![Pythonic](https://www.tutorialspoint.com/assets/profiles/15007/profile/60_156531-1514381552.jpg)
3K+ Views
By definition, tuple object is immutable. Hence it is not possible to remove element from it. However, a workaround would be convert tuple to a list, remove desired element from list and convert it back to a tuple.>>> T1=(1,2,3,4) >>> L1=list(T1) >>> L1.pop(0) 1 >>> L1 [2, 3, 4] >>> T1=tuple(L1) >>> T1 (2, 3, 4)
![Pythonic](https://www.tutorialspoint.com/assets/profiles/15007/profile/60_156531-1514381552.jpg)
137 Views
The built-in functions repr() and str() respectively call object.__repr__(self) and object.__str__(self) methods. First function computes official representation of the object, while second returns informal representation of the object. Result of both functions is same for integer object. >>> x = 1 >>> repr(x) '1' >>> str(x) '1' However, it is not the case for string object. >>> x = "Hello" >>> repr(x) "'Hello'" >>> str(x) 'Hello' Return value of repr() of a string object can be evaluated by eval() function and results in valid string object. However, result of str() can not be evaluated. ... Read More
![Pythonic](https://www.tutorialspoint.com/assets/profiles/15007/profile/60_156531-1514381552.jpg)
517 Views
Presence of a certain file in the computer can be verified by two ways using Python code. One way is using isfile() function of os.path module. The function returns true if file at specified path exists, otherwise it returns false. >>> import os >>> os.path.isfile("d:\Package1\package1\fibo.py") True >>> os.path.isfile("d:/Package1/package1/fibo.py") True >>> os.path.isfile("d:onexisting.txt") Note that to use backslash in path, two backslashes have to be used to escape out of Python string. Other way is to catch IOError exception that is raised when open() function has string argument corresponding to non-existing file. try: fo = open("d:onexisting.txt", ... Read More
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
2K+ Views
In this article, we will show you how to remove the index list elements from the original list using python. Now we see 2 methods to accomplish this task − Using pop() method Using del keyword Assume we have taken a list containing some elements. We will remove the index list elements from the main list using different methods as specified above. Note We must sort the indices list in descending order because removing elements from the beginning will change the indices of other elements, and removing another element will result in an incorrect result due to misplaced ... Read More