Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Python type way of comparison     - Linux mention the right notes (Linux)

- Solaris 11 forget the root password (Linux)

- Django 1.8 TEMPLATE_DIRS configuration and STATICFILES_DIRS (Server)

- installation process of Matlab 2012a under Ubuntu 14.04 (Linux)

- Recycle Bin function realization in Linux (Linux)

- Learning and Practice (Linux)

- Basic Java JNI (Programming)

- Guide: Trickle restrict application bandwidth usage (Linux)

- Linux environment variable settings methods and differences (Linux)

- Ora-1092: OPI colleague K aborting process --- killed by OO Well killer (Database)

- Git remote repository Explanation (Linux)

- Linux script to copy the folder to all folders with the same name (Linux)

- MySQL server after an unexpected power outage can not start (Database)

- Ubuntu font settings: Using Windows Font (Linux)

- Install Ruby on Rails in Ubuntu 15.04 in (Linux)

- Android 4.2 compilation notes (Programming)

- Android Touch message passing mechanism analysis (Programming)

- Spring Data MongoDB combat (Database)

- 10 Best Swift Tutorial examples (Programming)

- About Linux iptables firewall interview questions and answers (Linux)

 
         
  Python type way of comparison
     
  Add Date : 2017-08-31      
         
         
         
  By class member types module to determine, in fact, all in python types are instances of this type of module types.
import types
type (x) is types.IntType # determines whether an int
type (x) is types.StringType # whether string type
type (x) is types.InstanceType # whether it is a custom instance object, isinstance function does not support this comparison

By known type comparison, since all of the same types of objects in python type they cited are the same, it is possible by way of the following comparison:
type (x) == types (1) # int type to determine whether
type (x) == type ( 'a') # whether the string type
type (x) is types (1) # int type to determine whether
type (x) is type ( 'a') # whether the string type

Use the built-in function isinstance:
Python can get the type of an object using the type function:
>>> Lst = [1, 2, 3]
>>> Type (lst)
< Type 'list'>
Isinstance function can also use, to determine whether an object is of a known type. Its first parameter is an object, the second is a list of type names or type name. Returns a Boolean value. If the same type and parameter type II object returns True. If the two parameters of a tuple, then if the object type and one tuple type the same name that is returned True.
>>> Isinstance (lst, list)
True
>>> Isinstance (lst, (int, str, list))
True
     
         
         
         
  More:      
 
- To_explore Linux system boot process (Linux)
- Linux scp remote file copy (Linux)
- shell script: LVS start simple script (Server)
- Linux System Getting Started Tutorial: Installing Git on Linux (Linux)
- Json Applications of FastJson (Programming)
- How to create an alternative Android / iOS connected wireless hotspot AP in Ubuntu 15.04 (Linux)
- Linux SSH remote connection service slow Solutions (Linux)
- To install Redis under Linux (Database)
- Samhain: Powerful intrusion detection system under Linux (Linux)
- Android recyclerview cardview (Programming)
- Why HBase need to build SQL engine layer (Database)
- Git Tutorial Comments (Linux)
- MongoDB collection data migration to MySQL database (Database)
- Advanced permissions Linux file system settings (Linux)
- Nginx + uWSGI + Django + Python Application Architecture Deployment (Server)
- Android imageView in the Src and Background (Programming)
- How to configure AWStats in Ubuntu Server (Server)
- Summary Linux operating system some tips to prevent attacks (Linux)
- To build PHP environment (Nginx + MariaDB + PHP7) under CentOS 6.5 (Server)
- Linux Mint brightness adjustment --xrandr command learning (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.