- Trending Categories
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 34494 Articles for Programming
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
2K+ Views
When using file operations and directory structures, working with file paths is a typical task in Python programming. You may occasionally need to strip off particular parts of a file path, such a directory name, in order to analyze or alter it independently. Python offers a number of methods to carry out this work quickly and effectively. This extensive article will examine various techniques for extracting a directory in Python from a file path. We will walk you through the procedure with step-by-step explanations and code samples. You may divide a file path into several parts, get the parent directory, ... Read More
![Sai Subramanyam](https://www.tutorialspoint.com/assets/profiles/13512/profile/60_68191-1512710774.jpg)
125 Views
Whenever, you want to pass different number of arguments each time you call a method you should use vararg methods. This example creates sumvarargs() method which takes variable no of int numbers as an argument and returns the sum of these arguments as an output. Example Live Demo public class Main { static int sumvarargs(int... intArrays) { int sum, i; sum = 0; for(i = 0; i< intArrays.length; i++) { ... Read More
![Alekhya Nagulavancha](https://www.tutorialspoint.com/assets/profiles/535884/profile/60_4128029-1665726265.jpg)
9K+ Views
Iterating over files in a given directory can be helpful for doing things like finding files that match a certain criterion, or counting the number of files in a directory. Python provides the following five ways to walk through all the existing files in a directory os.listdir() method os.walk() method os.scandir() method Using pathlib module glob.iglob() method Let us look at these methods in detail. Using os.listdir() Method The os.listdir() method is used to list all the files present in a directory. It accepts the path of the directory as an argument and all the entries, apart from ... Read More
![Lakshmi Srinivas](https://www.tutorialspoint.com/assets/profiles/13528/profile/60_91717-1512651120.jpg)
163 Views
In Java methods, parameters accept arguments with three dots. These are known as variable arguments.sample(int args …){}If they are used you can pass a different number of arguments each time you call these methods.Examplepublic class Sample { void demoMethod(String... args) { for (String arg: args) { System.out.println(arg); } } public static void main(String args[] ) { new Sample().demoMethod("ram", "rahim", "robert"); new Sample().demoMethod("krishna", "kasyap") } }Outputram rahim robert krishna kasyap
![Monica Mona](https://www.tutorialspoint.com/assets/profiles/13520/profile/60_87298-1512650151.jpg)
777 Views
Methods which uses variable arguments (varargs, arguments with three dots) are known as variadic functions.ExampleLive Demopublic class Sample { void demoMethod(String... args) { for (String arg: args) { System.out.println(arg); } } public static void main(String args[] ){ new Sample().demoMethod("ram", "rahim", "robert"); new Sample().demoMethod("krishna", "kasyap"); } }Outputram rahim robert krishna kasyap
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
5K+ Views
While working with file systems and directories in Python, understanding the directories’ structure and their contents is essential for efficient file management and organization. Python makes available various methods and libraries that allow you to list the directory tree structure, including all subdirectories and files, in a comprehensive and exhaustive manner. Whether you're organizing files, analyzing directory structures, or performing data processing tasks, knowing how to list the directory tree structure in Python will significantly enhance your file handling capabilities. In this extensive article, we will explore different methods to list the directory tree structure in Python. We will also ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
519 Views
Annotations are a tag (metadata) which provides info about a program. Annotations in Java Start with the symbol ‘@’. They are used by the compiler to detect errors. Software tools to generate code. They are used to show attributes of an element: e.g. @Deprecated, @Override. Annotation are used to describe the purpose of an element of the framework, e.g. @Entity, @TestCase, @WebService Annotations describe the behaviour of an element: @Statefull, @Transaction. Example Live Demo class Sample{ public void display(){ System.out.println(" "); } } public ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
3K+ Views
When dealing with and handling file systems and directory structures in Python, it's important to find if a given directory contains any other directories. This data becomes invaluable in various situations, such as organizing files, managing hierarchical data, or implementing conditional logic based on the presence of subdirectories. Python has provision for several methods and techniques to efficiently check for the existence of directories within a given directory. In this informative article, we will explore different methods to check if a given directory contains any other directories in Python. We will also provide step−by−step explanations and code examples to help ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
9K+ Views
When working with directories in Python, it's often necessary to obtain a list of files and subdirectories within a given directory. Moreover, sorting this directory listing by their names can be beneficial for better organization and readability. Python provides several methods and techniques to achieve this goal efficiently. Sorting the directory listing alphabetically can help you quickly locate specific files or directories and facilitate various file management tasks. In this comprehensive article, we will explore different methods to get a directory listing sorted by name in Python. We will provide step−by−step explanations and code examples to guide you through the ... Read More