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

Резултати

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

Пребарај: #basics

当前筛选 #basics清除筛选
Go

@golang · Post #67 · 20.07.2018 г., 18:47

Generally I don’t like aliases but in some cases they might be helpful 😀 #development#basics https://codeburst.io/learn-how-to-create-custom-bash-commands-in-less-than-4-minutes-6d4ceadd9590

Go

@golang · Post #26 · 27.01.2018 г., 16:15

In the GoLang we use interfaces everywhere. But we also should understand the rules and idioms how GoLang interfaces works. Let’s read about them 😉; part one: #development#basics https://medium.com/golangspec/interfaces-in-go-part-i-4ae53a97479c

Go

@golang · Post #69 · 24.08.2018 г., 10:05

A good reading list with a knowledge base about Golang, based on blog posts and Golang books. Inside of the link: - 3 categories of stages: Beginner, Intermediate, Advanced; - Common questions like “Why should you learn Go?” and “How to Write Go Code” - Web, Concurrency, Code style, Testing and other GoLang related topics. #language#development#basics Add to bookmarks and enjoy the reading! https://github.com/enocom/gopher-reading-list

Go

@golang · Post #46 · 05.03.2018 г., 20:39

Simple and good for understanding tutorial about Golang’s channels. It can help beginners to meet with them and learn to use it without problems 🙂 Keys of the article: - What is a channel, goals, and functions of it; - Deadlocks and other problems; - Channel ranging and closing. When, why and how? #development#basics#language http://guzalexander.com/2013/12/06/golang-channels-tutorial.html

Go

@golang · Post #52 · 22.03.2018 г., 14:57

How to work and use field tags in GoLang? Inside of this article Michał Łowicki from Opera company explains basics and features of tagging; include examples and best practices 🙂 #development#practice#basics https://medium.com/golangspec/tags-in-golang-3e5db0b8ef3e

Go

@golang · Post #47 · 07.03.2018 г., 07:42

One of popularly questions is: How to handle errors correctly? GoLang best practices on the Medium will help with it. Of course, code examples are included 🙂 #development#practice#basics https://medium.com/@sebdah/go-best-practices-error-handling-2d15e1f0c5ee?source=linkShare-b636419a57de-1520408380

Go

@golang · Post #61 · 21.05.2018 г., 19:17

Hi 👋 there! This article is meant for those who’re new to Go and want to start learning about Go’s concurrency primitives: go routines and channels. #development#manual#basics https://medium.com/@trevor4e/learning-gos-concurrency-through-illustrations-8c4aff603b3

Go

@golang · Post #27 · 28.01.2018 г., 12:44

Everybody use dependencies and third-party packages but what is the best way to use it? GopherAcademy helps to understand best practice for the vendor folder organization. Of course, code examples and theory points are included 🙂 #development#basics#manual https://blog.gopheracademy.com/advent-2015/vendor-folder/

Go

@golang · Post #34 · 05.02.2018 г., 08:41

New post about concurrency problems and solutions. Main points with examples: - Blocking Channels; - Blocking Channels Buffer; - Wait Group (run multiple async tasks and wait for them execution); #development#basics#algorithms https://hackernoon.com/concurrency-how-it-can-help-you-and-how-you-can-use-golang-to-reach-it-easily-ae3e070b3d2c

Go

@golang · Post #49 · 11.03.2018 г., 11:39

Top GoLang features that you don’t know or don’t hear so much 🙂 If you want some main points of this article they are here: - GoDoc; - Static code analysis; - Built-in testing and profiling framework; - Race condition detection; - Learning curve; - Reflection; - Opinionatedness; - Culture. #manual#development#basics#language https://medium.freecodecamp.org/here-are-some-amazing-advantages-of-go-that-you-dont-hear-much-about-1af99de3b23a?source=linkShare-b636419a57de-1520768034

12
ПретходнаСтраница 1 од 2Следна