SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
replacing
import with
accio in
CPython
>>> import sys!
>>> accio sys!
SyntaxError
>>> import sys!
>>> accio sys!
SyntaxError
>>> import sys!
>>> accio sys!
SyntaxError
>>> accio sys!
>>> import sys!
SyntaxError
>>> accio sys!
>>> import sys!
SyntaxError
>>> accio sys!
>>> import sys!
SyntaxError
why?
we’ll learn:!
what is a
statement
we’ll learn:!
what is a
SyntaxError
we’ll learn:!
how does
Python know
the difference?
we’ll learn:!
bootstrapping
!
replacing
import with
accio
import is a
statement
statements
are defined in
the Grammar!
file
import_stmt: !
import_name | !
import_from
import_name: !
‘import’ !
dotted_as_names
first attempt
import_name: !
‘accio’ !
dotted_as_names
$ make
import sys!
^!
SyntaxError:
invalid syntax
oops
second
attempt
$ sed ’s/
import/accio’
$ make
accio sys!
^!
SyntaxError:
invalid syntax
bootstrapping
!
third attempt
import_name: !
‘import’ !
dotted_as_names!
| ‘accio’ !
dotted_as_names
$ make
$PATH
import_name: !
‘accio’ !
dotted_as_names
$ sed ’s/
import/accio’
$ make
>>> accio sys!
>>> import sys!
SyntaxError
>>> accio sys!
>>> import sys!
SyntaxError
>>> accio sys!
>>> import sys!
SyntaxError!
links
• Grammar - https://docs.python.org/2/reference/
grammar.html
• EBNF - http://en.wikipedia.org/wiki/
Extended_Backus%E2%80%93Naur_Form
• Adding a statement - http://
eli.thegreenplace.net/2010/06/30/python-
internals-adding-a-new-statement-to-python/
@amygdalama!
mathamy.com

Mais conteúdo relacionado

Destaque

Practice guidelines for postanesthetic care 2013
Practice guidelines for postanesthetic care 2013Practice guidelines for postanesthetic care 2013
Practice guidelines for postanesthetic care 2013
Ann Sodders
 
Codechamps offering 26_mar14
Codechamps offering 26_mar14Codechamps offering 26_mar14
Codechamps offering 26_mar14
Robert Eckart
 

Destaque (15)

Report1
Report1Report1
Report1
 
Cloudezz - Platform-as-Infrastructure via Turnkey Private Cloud
Cloudezz - Platform-as-Infrastructure via Turnkey Private CloudCloudezz - Platform-as-Infrastructure via Turnkey Private Cloud
Cloudezz - Platform-as-Infrastructure via Turnkey Private Cloud
 
Skoleprojekt - e-konceptudvikling - Redesign af 4yourbody
Skoleprojekt - e-konceptudvikling - Redesign af 4yourbodySkoleprojekt - e-konceptudvikling - Redesign af 4yourbody
Skoleprojekt - e-konceptudvikling - Redesign af 4yourbody
 
C9 booklet
C9 bookletC9 booklet
C9 booklet
 
Skoleprojekt - e-konceptudvikling- Kvindemuseet
Skoleprojekt - e-konceptudvikling- KvindemuseetSkoleprojekt - e-konceptudvikling- Kvindemuseet
Skoleprojekt - e-konceptudvikling- Kvindemuseet
 
Practice guidelines for postanesthetic care 2013
Practice guidelines for postanesthetic care 2013Practice guidelines for postanesthetic care 2013
Practice guidelines for postanesthetic care 2013
 
Print
PrintPrint
Print
 
Altarix review
Altarix reviewAltarix review
Altarix review
 
Codechamps offering 26_mar14
Codechamps offering 26_mar14Codechamps offering 26_mar14
Codechamps offering 26_mar14
 
Ajeet_GE(1)
Ajeet_GE(1)Ajeet_GE(1)
Ajeet_GE(1)
 
Экспертные системы: лекция №4
Экспертные системы: лекция №4Экспертные системы: лекция №4
Экспертные системы: лекция №4
 
Vietnam Where to go
Vietnam Where to goVietnam Where to go
Vietnam Where to go
 
σύντομο βιογραφικό μαρίας πολυδούρη
σύντομο βιογραφικό μαρίας πολυδούρησύντομο βιογραφικό μαρίας πολυδούρη
σύντομο βιογραφικό μαρίας πολυδούρη
 
Cec slides
Cec slidesCec slides
Cec slides
 
The Search Challenge - Sagittarius 24/7 Multichannel Travel Cosumer Masterclass
The Search Challenge - Sagittarius 24/7 Multichannel Travel Cosumer MasterclassThe Search Challenge - Sagittarius 24/7 Multichannel Travel Cosumer Masterclass
The Search Challenge - Sagittarius 24/7 Multichannel Travel Cosumer Masterclass
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

Replacing `import` with `accio` in cpython