Tag: ‘object’
Object Oriented Approach to Display a sequence of numbers without any For-Loop or Recursion
Suppose we have to display a sequence of numbers like from 10 to 20 i.e. 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 Advertisements without using any for-loop and recursion. Solution: Frequently Asked: Object Oriented Approach to Display a sequence of numbers without any For-Loop or Recursion We will use two concepts …
Object Oriented Approach to Display a sequence of numbers without any For-Loop or RecursionRead More
Python : How to convert a timestamp string to a datetime object using datetime.strptime()
In this article we will discuss how to convert timestamp in different string formats to a datetime class object in Python. String to datetime object using datetime.strptime() Python’s datetime module provides a datetime class, which has a method to convert string to a datetime object i.e. Advertisements datetime.strptime(date_string, format) If accepts a string containing the …
Python : How to convert a timestamp string to a datetime object using datetime.strptime()Read More
Python : How to convert datetime object to string using datetime.strftime()
In this article we will discuss how to convert a datetime class object to different string formats using datetime.strftime() function. datetime.strftime() Python’s datetime class provides a member function strftime() to create string representation of data in the object i.e. Advertisements datetime.strftime(Format_String) It accepts a format string as argument and converts the data in object to …
Python : How to convert datetime object to string using datetime.strftime()Read More
Solved- TypeError: dict_values object does not support indexing
In this article, we will discuss about the reasons of getting error ‘TypeError: ‘dict_values’ object does not support indexing’ and how to resolve this error. A little background, In Python, the dictionary class provides functions keys(), values() and items() to fetch keys, values or all items (key-value pairs). But all these functions returns view objects, …
Solved- TypeError: dict_values object does not support indexingRead More
Solved- TypeError: dict_keys object does not support indexing
In this article, we will discuss about the reasons of getting error ‘TypeError: ‘dict_keys’ object does not support indexing’ and how to resolve this error. A little background, In Python, the dictionary class provides functions keys(), values() and items() to fetch keys, values or all items (key-value pairs). But all these functions return view objects, …
Solved- TypeError: dict_keys object does not support indexingRead More
Create timezone aware datetime object in Python
In this article, we will discuss how to create a timezone-aware datetime object in Python. It means the tzinfo attribute in the datetime object should not be empty and contain the specified timezone info. In Python’s datetime module, the datetime class has an attribute tzinfo, which contains the timezone information. If you create a naive …
Javascript: Check if key exists in Object (4 ways)
While working in javascript, there is often a requirement to determine if a key exists in a particular object. This article demonstrates easy ways to check if a key exists in a javascript object using different methods and example illustrations. Table of Contents: Check if key exists in javascript Object using in operator Check if …
Javascript : Check if an object is array
While working in javascript arrays, we sometimes encounter a requirement to check if an object is an array. This article demonstrates easy ways to check if a javascript object is an array using different methods and example illustrations. Table of Contents: Check if an object is an array using Array.isArray() Check if an object is …
Loop Through an Object in Javascript (6 ways)
Very common requirement many people encounter while working with javascript objects is to loop through an object to process its key or value or both. This article demonstrates easy ways to loop through an object in javascript using various example illustrations. Table of Contents: Loop Through an Object in Javascript using for in Loop Through …
Get a Subset of Javascript’s Object Properties (4 ways)
While working with javascript objects, often, there is a requirement to get a subset of the properties of a javascript object. This article will discuss different ways to get a subset of properties of one object into a new object using various example illustrations. Table of Contents: Get a Subset of Javascript Object using Object …
Get a Subset of Javascript’s Object Properties (4 ways)Read More