TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #197 · 4 јан.

Подразумеваемые неймспейсы или неявные пакеты. Этот функционал добавлен в Python 3.3 Что он означает? Ранее, до 3.3 пакетами считались лишь директории, в которых есть файл __init__.py. Этот файл одновременно являлся свидетельством того, что директория это Python-пакет, и служил "телом" этого пакета. То есть местом, где можно написать код, как это делается внутри модуля. Этот код исполняется в момент импорта пакета, так что его принято называть "код инициализации пакета". Начиная с версии 3.3 Любая директория считается пакетом и Python будет пытаться использовать любую директорию для импорта. Конечно, не любую в файловой системе, а только те что находятся в sys.path. Это значит, что теперь __init__.py нужно делать только если: 🔸 вам требуется создать код инициализации пакета 🔸 нужна совместимость со старыми версиями Python На мой взгляд это немного упрощает разработку, делает её чище, но с другой стороны убивает некоторую однозначность происходящего. Например, я создал репозиторий со своей библиотекой и рядом положил код примеров или тестов. repo_name/ my_library/ __init__.py main.py examples/ exam1.py exam2.py В этом репозитории пакетом является только my_library, остальные директории это не пакеты, это просто дополнительный код в файлах. Директория examples не добавлена в sys.path, в ней нет рабочих модулей. Но если она лежит рядом с my_library, то Python вполне сможет импортнуть из неё модули, так как посчитает что examples это валидный пакет. Конечно, пример несколько надуманный. Никто не будет добавлять корень репозитория в sys.path. Но, я думаю, суть ясна. Иногда директория это просто директория а не пакет! #basic#pep

Hashtags

Резултати

Пронајдени 1 слични објави

Пребарај: #approaching

当前筛选 #approaching清除筛选
English Speakers

@English_Speakers · Post #3541 · 10.08.2018 г., 03:32

Important Five: Common Errors in the use of Prepositions 1) For #Days#, we use 'On', For Dates, we use 'On', For months we use, 'In', For seasons we use 'In', For a particular time, we use 'At'. For morning and evening, we use 'In'. For night, we use# 'At'.# #At:# at 7 o'clock; at midday; at dinner; at Christmas #In:# in the evening; in Easter week; in September; in (the) winter; in 1864; in the 20th century #On:# on Friday; on April 1st; on Christmas Day #Incorrect:# My brother completed the project in a month’s time. #Correct:# My brother completed the project in a month. #Incorrect:# We love to visit the nearest market on Sunday. #Correct:# We love to visit the nearest market on #Sundays.# 2)The verbs lack, approach and enter are directly followed by objects without prepositions. Other verbs that do not normally take prepositions are: discuss, marry and resemble. #Incorrect:# Although my sister is intelligent, she lacks of confidence. #Correct:# Although my sister is intelligent, she# lacks confidence.# #Incorrect:# The train is now approaching to my city. #Correct:# The train is now #approaching my city.# #Incorrect:# The boys were not allowed to enter into the house. #Correct:# The boys were not allowed to #enter the house.# 3) The prepositions #in# and #on# are used to show position. To say where things are going, we use #into# and #onto.# #Incorrect: #The ball rolled slowly in the goal. #Correct:# The ball rolled slowly# into# the goal. #Incorrect:# She ran in the room crying. #Correct:# She ran #into# the room crying. 4) We use #in# to say how soon something will happen. #Within# means ‘inside’ or ‘not beyond’. #Incorrect:# The train will arrive #within# six minutes. #Correct:# The train will arrive# in# six minutes. #Incorrect#: You need to complete this book in a month. #Correct:# You need to complete this book within a month. #Incorrect:# If you don’t live by your income, you will have to pay huge debts. #Correct:# If you don’t live# within# your income, you will have to pay huge debts. 5) #Through# is used for movement in a three-dimensional space. #Incorrect:# The ball went #to# the window and fell on the ground. #Correct#: The ball went #through# the window and fell on the ground.