Sideway
output.to from Sideway
Draft for Information Only

Content

Python Built-in Class Functions
memoryview()
  Parameters
  Remarks
object()
  Parameters
  Remarks
property()
  Parameters
  Remarks
range()
  Parameters
  Remarks
slice()
  Parameters
  Remarks
type()
  Parameters
  Remarks
 Source and Reference

Python Built-in Class Functions

The Python interpreter has some built-in class functions.

memoryview()

class memoryview(obj)

Parameters

memoryview()to return a memory view object. objto specify the object to be returned from

Remarks

  • obj must support the buffer protocol. Built-in objects that support the buffer protocol include bytes and bytearray
  • A memoryview has the notion of an element, which is the atomic memory unit handled by the originating object obj.

object()

class object

Parameters

objectto return a new featureless object.

Remarks

  • object is a base for all classes
  • It has the methods that are common to all instances of Python classes.
  • object does not accept any arguments.
  • object does not have a __dict__, so no arbitrary attributes can be assigned to an instance of the object class.

property()

class property(fget=None, fset=None, fdel=None, doc=None)

Parameters

property()to return a property attribute. fget=Noneto specify a function for getting an attribute value. fset=Noneto specify a function for setting an attribute value. fdel=Noneto specify a function for deleting an attribute value. doc=Noneto create a docstring for the attribute.

Remarks

  • If doc is given, doc will be the docstring of the property attribute. Otherwise the property will copy fget's docstring, if it exists. This makes it possible to create read-only properties easily using property() as a decorator.
  • A property object has getter, setter, and deleter methods usable as decorators that create a copy of the property with the corresponding accessor function set to the decorated function.
  • The returned property object also has the attributes fget, fset, and fdel corresponding to the constructor arguments.

range()

class range(stop)
class range(start, stop[, step])

Parameters

range()to return an immutable sequence range type. stopto specify the stop of the range. startto specify the start of the range. [step]optional, to specify the step of the range.

Remarks

  • The arguments start, stop, and step must be integers, either built-in int or any object that implements the __index__ special method.
  • if the step argument is omitted, it defaults to 1.
  • if the start argument is omitted, it defaults to 0
  • if the step argument is zero, ValueError is raised
  • For a positive step, the contents of a range 𝑟 are determined by the formula 𝑟[𝑖]=start+step*𝑖 where 𝑖>=0 and 𝑟[𝑖]<stop.
  • For a negative step, the contents of the range are still determined by the formula 𝑟[𝑖]=start+step*𝑖, but the constraints are 𝑖>=0 and 𝑟[𝑖]>stop.
  • A range object will be empty if 𝑟[0] does not meet the value constraint.
  • Ranges do support negative indices, but these are interpreted as indexing from the end of the sequence determined by the positive indices.
  • Ranges containing absolute values larger than sys.maxsize are permitted but some features, such as len(), may raise OverflowError.

slice()

class slice(stop)
class slice(start, stop[, step])

Parameters

slice()to return a slice object. stopto specify the stop of slice startto specify the start of slice stepoptional, to specify the step of slice

Remarks

  • The start and step arguments default to None.
  • Slice objects have read-only data attributes start, stop, and step which merely return the argument values (or their default).
  • Slice objects have no other explicit functionality.

type()

class type(object)
class type(name, bases, dict)

Parameters

type()to return the type of an object. objectto specify the object to be returned from nameto specify the class name basesto specify the bases tuples itemizes the base classes dictto specify the dict dictionary

Remarks

  • With one argument, return the type of an object.
  • The return value is a type object and generally the same object as returned by object.__class__.
  • With three arguments, return a new type object. This is essentially a dynamic form of the class statement.
  • The name string is the class name and becomes the __name__ attribute
  • The base tuple becomes the __bases__ attribute
  • The dict dictionary is the namespace containing definitions for class body and s copied to a standard dictionary to become the __dict__ attribute.

Source and Reference


©sideway

ID: 200602102 Last Updated: 6/21/2020 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019