りんご210061 views
数学講師2887325 views
高校化学2924801 views
ヒストリア290763 views
雑学1473646 views
いろは3011538 views
中学英語811794 views
MathPython497548 views
世界の国564626 views
高校日本史190590 views
Help
Tools
NewsSpreadsheetCalendarBookkeepingMarkdown TablesLanguage Model NewsSlidesTier ListPen ToolIllustrationCrayonWatercolorPixel ArtASCII ArtPerspectiveEndless StairsGraphMind MapER DiagramFamily TreeMemeCurved TextImage EditorMosaicRetro FilterPencil SketchSwirl EffectLine ArtOCR/HighlighterMakeup EditorFaviconVideo TrimmerScrolling VideoVideo TitleColor PickerColor ExtractorBonfireFireworksCherry BlossomWater RippleWater SplashBreaking GlassGlass TextureFabric TextureWood GrainMarble TextureBrick Wall TextureMetal TextureWashi Paper TextureCardboard TextureCSS ButtonIcon MakerBar ChartGrouped Bar ChartStacked Bar ChartPie ChartLine ChartArea ChartStacked Area ChartScatter Plot3D Bar Chart3D Pie ChartBar Chart RaceBubble ChartPopulation PyramidPictogramEarningsCandlestick ChartInvestment RiskMortgage SimulatorCalculatorMatrix CalculatorFunction GraphPolynomial ExpansionVenn DiagramField VisualizerRubik's Cube Group TheoryTraveling SalesmanVoronoi and DelaunayFractalColumn ArithmeticDraw Math FiguresArithmetic AnimationArithmetic Word ProblemsCounting with Tree DiagramsCube NetsRolling DiceCross SectionsMotion PathMechanicsWavesElectromagnetic WavesCapacitorsLight and LensesThermodynamicsHow Semiconductors WorkMolecular StructuresAtomic OrbitalsElectrochemical CellsChemical EquilibriumCrystal LatticesBuffer pHOrganic Reaction MapPeriodic TableComplex IonsDNA Double HelixCell DivisionMembrane ChannelsNerve ImpulseMuscle ContractionHormones and HomeostasisRock ClassificationWeatherConstellationsSolar and Lunar Eclipses3D ModelingFloor PlanSeismic StructuresIntersection TurnMaglevCooking AnimationOrigamiLive Viewer CountGeoJSON MapRailway MapPopulation MapCrime MapLand Price MapSchool MapShrine and Castle MapHouse of Representatives MapWord MapSolitaireReversiHakoiri MusumeChessHamburgerRippleSlide Puzzle MakerNeon PinballNovel MakerJapanese Typing PracticePiano Score EditorMusic TheoryShogi StrategyPiano Rhythm Game

English

Import/export of modules in Pi/Pie

This article is a draft of import/export system in Pi/Pie. As Python programmer, I think from/import is better than import/from. The latter form, which is used in JS, goes backward for the perspective of path order.

If file X, Y is in A directory, the paths of X and Y contain that of A. Let the path of file X be described as X now and let us think the paths and directory/file names of A/X.

X = A + X
Y = A + Y

This naturally makes the below:

from A import X, Y

Or

import A.X
import A.Y

A.X could be printed A/X in the file system or URL. The from/import fits the OS and internet. The only problem is the redundancy of English prepositions and verbs. I prefer the symbol so Pi/Pie imports omit the two English words.

+ A.X, Y

It is easy to imagine we can use X, Y and those are in A. The plus symbol means “to add” and importing X is equal to adding X to the module sources used in a file. The comma in the import line means X and Y are in the same directory (library).

Some people could see this as the pair of A.X and Y, that is we import A.X and Y. But this must be incorrect. If we must import one library in one import sentence, in other words, we are forbidden to import multiple libraries in one import sentence, importing A.X and Y is invalid so we easily see the dot symbol separate A and X.

Bad: (A.X, Y)
OK: (A, (X, Y))

Next is the export grammar. I think the best rule is the Python style; the function whose name starts with at least one underscore is private. The “export” word should be omitted. But should a function like __add__ be private? Or should we strictly one and two underscores?

My philosophy is:

If one-underscore means private, two-underscore also means private. “Two” includes “one” and all the states in “one” must be included in “two”. So the __add__ should be private if _add is private.