Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Extensions

Extensions is a common feature in Swift language. It enables to extend a class or a type to add it methods or attributes.

This lab aims to add this feature to Python, using a CPython trick, making possible to extends even built-in types such as strings, int or lists !

Example

from Extensions import Extension

# Add a "length" property to strings
@Extension
class str:
	@property
	def length(self):
		return len(self)
		
print ('Hello, World!'.length)
# Output: 13