Tutorialspoint

Interpreter base classes in Python

Rishi Raj
Answered 8h 47m ago

Python's interactive mode works on the principle of REPL (Read - Evaluate - Print - Loop). The code module in Python's standard library provides classes nd convenience functions to set up REPL environment from within Python script.Following two classes are defined in code module:InteractiveInterpreter: This class deals with parsing and ... Read More

Package extension utility in Python

Vikyath Ram
Answered 8h 50m ago

When you want to add to the module search path for a specific package and work with resources included in a package, you need to use pkgutil module from Python library. It includes functions for changing the import rules for Python packages. It is also possible to load non-code resources ... Read More

POP3 protocol client in Python

Rishi Raj
Answered 8h 54m ago

The poolib module from Python's standard library defines POP3 and POP3_SSL classes. POP3 class encapsulates a connection to a POP3 server and implements the protocol as defined in RFC 1939. POP3_SSL classsupports POP3 servers that use SSL as an underlying protocol layer.POP3 protocolis obsolescent as its implementation quality of POP3 ... Read More

FTP protocol client in Python

Vikyath Ram
Answered 9h 0m ago

The all important The FTP class in ftplib module implements the client side of the FTP protocol.To establish connection with a FTP server, obtain FTP object.con=FTP(hostname)The FTP class supports following methods −connect()Connect to the given host and port. The default port number is 21, as specified by the FTP protocol ... Read More

Common string operations in Python

Arushi
Answered 9h 24m ago

The string module in Python’s standard library provides following useful constants, classes and a helper function called capwords()Constantsascii_lettersThe concatenation of lowercase and uppercase constants.ascii_lowercaseThe lowercase letters 'abcdefghijklmnopqrstuvwxyz'ascii_uppercaseThe uppercase letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'digitsThe string '0123456789'.hexdigitsThe string '0123456789abcdefABCDEF'.octdigitsThe string '01234567'.punctuationString of ASCII characters which are considered punctuation characters.printableString of ASCII characters digits, ascii_letters, punctuation, ... Read More

zipapp - Manage executable Python zip archives

Arushi
Answered 9h 31m ago

The zipapp module has been introduced in Python's standard library since ver 3.5. This module is used to manage the creation of zip files containing Python code, which can be executed directly by the Python interpreter. The module provides both a Command-Line Interface and a programming interface.To use zipapp module ... Read More

Access to the underlying platform’s identifying data in Python

Arushi
Answered 10h 2m ago

Functions in the platform module help us probe the underlying platform’s hardware, operating system, and interpreter version information.architecture()This function queries the given executable (defaults to the Python interpreter executable) for various architecture information.>>> import platform >>> platform.architecture() ('64bit', '')machine()This function returns the machine type, e.g. 'i386'. An empty string is ... Read More

C-style parser for command line options in Python

Rishi Raj
Answered 10h 11m ago

Python’s sys module provides access to any command-line arguments via the sys.argv. sys.argv is the list of command-line arguments and sys.argv[0] is the program ie. the script name.Save following code as args.pyimport sys print ('argument list', sys.argv)Execute above script from command line as follows:C:\python37>python args.py 11 22 argument list ['args.py', ... Read More

Draw a border around an undecorated JFrame in Java

Samual Sam
Answered 10h 32m ago

At first, set an undecorated frame −setUndecorated(true);Now draw a border −getRootPane().setBorder (.createMatteBorder(3, 3, 3, 3, Color.ORANGE));The following is an example to draw a border around an undecorated JFrame −Exampleimport java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo extends JFrame {    JLabel label = ... Read More

How to create modeless and model JDialog in Java?

karthikeya Boyini
Answered 10h 38m ago

MODELESS TypeThe following is an example to set JDialog with Modality type MODELESS −Exampleimport java.awt.Cursor; import java.awt.Dialog.ModalityType; import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();     ... Read More

How to set default button for JFrame in Java?

Samual Sam
Answered 10h 42m ago

To set default button for JFrame, use the setDefaultButton() method −JFrame frame = new JFrame(); frame.getRootPane().setDefaultButton(button);The following is an example to set default button for JFrame −Exampleimport java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String args[]) {       ... Read More

How to set minimum size limit for a JFrame in Java

karthikeya Boyini
Answered 10h 44m ago

Use the setMinimumSize() method to set the minimum size limit for a JFrame −JFrame frame = new JFrame(); frame.setMinimumSize(new Dimension(500, 300));The following is an example to set minimum size limit for a JFrame −Exampleimport java.awt.Color; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] ... Read More

Get JFrame window size information in Java

Samual Sam
Answered 10h 46m ago

To get JFrame window size information, you can use the following −environment.getMaximumWindowBounds();For Screen Size −config.getBounds()For Frame Size −frame.getSize());The following is an example to get JFrame window size information −Exampleimport java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {   ... Read More

How can we clear all selections in Java Swing JList?

karthikeya Boyini
Answered 10h 47m ago

To clear all selections, use the List clearSelection() method in Java −JList list = new JList(sports); list.clearSelection();Above, the elements in Sports array is a String array −String sports[]= { "Cricket", "Football", "Hockey", "Rugby"};The following is an example to clear all selection in JList −Examplepackage my; import java.awt.event.*; import java.awt.*; import ... Read More

How to select the second index in Java JList?

Samual Sam
Answered 10h 49m ago

To select the second index, use the setSelectedIndex() method −JList new JList(sports); list.setSelectedIndex(2);The following is an example to select the second index in Java JList −Examplepackage my; import java.awt.event.*; import java.awt.*; import javax.swing.*; class SwingDemo extends JFrame {    static JFrame frame;    static JList list;    public static void ... Read More

1 2 3 4 5 6 7 ... 1346 Next
Advertisements
Loading...
Unanswered Questions View All

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.