Found 34484 Articles for Programming

List of Keywords in Python Programming

Anvi Jain
Updated on 11-Aug-2022 11:37:47

1K+ Views

Keywords in Python are reserved words. You cannot use them as variable name, function name, class name, etc. Following are the Keywords in Python − Keywords in Python FALSE await else import pass None break except in raise TRUE class finally is return and continue for lambda try as def from nonlocal while assert del global not with async ... Read More

Convert between binary and ASCII using Python (binascii)

Smita Kapse
Updated on 30-Jul-2019 22:30:25

797 Views

The binascii module enables conversion between binary and various ASCII encoded binary representations. The binascii module contains low-level functions written in C for greater speed. They are used by the higher-level modules such as uu, base64 or binhex modules.The binascii module defines the following functions. These function are named as a2b_* or b2a_*binascii.a2b_uu(string): Convert a single line of uuencoded data back to binary and return the binary data. Lines normally contain 45 (binary) bytes, except for the last line. Line data may be followed by white space.binascii.b2a_uu(data): Convert binary data to a line of ASCII characters, the return value is the converted ... Read More

Encode and decode binhex4 files using Python (binhex)

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

399 Views

The binhex module encodes and decodes files in binhex4 format. This format is used in the representation of Macintosh files in ASCII. Only the data fork is handled.The binhex module defines the following functions −binhex.binhex(input, output): Convert a binary file with filename input to binhex file output. The output parameter can either be a filename or a file-like object (any object supporting a write() and close() method).binhex.hexbin(input, output): Decode a binhex file input. input may be a filename or a file-like object supporting read() and close() methods. The resulting file is written to a file named output unless the argument is None ... Read More

Python Context Variables

Smita Kapse
Updated on 30-Jul-2019 22:30:25

1K+ Views

Context variable can have different values depending on its context. Unlike Thread-Local Storage where each execution thread may have a different value for a variable, a context variable may be several contexts in one execution thread. This is useful in keeping track of variables in concurrent asynchronous tasks.The ContextVar class is used to declare and work with Context Variables.import contextvars name = contextvars.ContextVar("name", default = 'Hello')The optional default parameter is returned by ContextVar.get() when no value for the variable is found in the current context.name: The name of the variable. This is a read-only property.Following methods are defined in ContextVar ... Read More

Python Interfaces to Unix databases (dbm)

Anvi Jain
Updated on 30-Jul-2019 22:30:25

182 Views

The dbm package in Python's built-in library provides a dictionary like an interface DBM style databases. The dbm library is a simple database engine, written by Ken Thompson. DBM stands for DataBase Manager, used by UNIX operating system, the library stores arbitrary data by use of a single key (a primary key) in fixed-size buckets and uses hashing techniques to enable fast retrieval of the data by key.There are following modules in dbm package −The dbm.ndbm module provides an interface to the Unix “(n)dbm” library. Dbm objects behave like dictionaries, with keys and values should be stored as bytes. The ... Read More

Generate and parse Mac OS X .plist files using Python (plistlib)

Smita Kapse
Updated on 30-Jul-2019 22:30:25

2K+ Views

Files with '.plist' the extension is used by Mac OS X applications to store application properties. The plislib module provides an interface to read/write operations of these property list files.The plist file format serializes basic object types, like dictionaries, lists, numbers, and strings. Usually, the top level object is a dictionary. To write out and to parse a plist file, use the dump() and load() functions. Serialized byte strings are handled by use dumps() and loads() functions. Values can be strings, integers, floats, booleans, tuples, lists, dictionaries (but only with string keys).This module defines the following functions −load()Read a plist ... Read More

JavaTuples addAtX() method for Septet class

Samual Sam
Updated on 30-Jul-2019 22:30:25

60 Views

The addAtX() method is used to add value to the Septet Tuple. The index can be set here with the X i.e. the place where the value gets added.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example ... Read More

JavaTuples setAt0() method for Septet class

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

58 Views

The setAt0() method is used to set the Septet value in JavaTuples and a copy with new value at the specified index i.e. index 0 here.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; import ... Read More

Create Septet Tuple from Array in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

84 Views

Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; public class Demo { public static void main(String[] args) { String[] myArr = { ... Read More

Create Septet Tuple from List in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

69 Views

The fromCollection() method is used in JavaTuples to create Septet Tuple from List collection.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; import java.util.*; public class Demo { public static void main(String[] ... Read More

Advertisements