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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #183 · 23 ное.

Python + bash Если вам часто требуется запускать shell команды из Python-кода, какой способ вы используете? Самый низкоуровневый это функция os.system(), либо os.popen(). Рекомендованный способ это subprocess.call(). Но это всё еще достаточно неудобно. Советую обратить своё внимание на очень крутую библиотеку sh. Что она умеет? 🔸 удобный синтаксис вызова команд как функций # os import os os.system("tar cvf demo.tar ~/") # subprocess import subprocess subprocess.call(['tar', 'cvf', 'demo.tar', '~/']) # sh import sh sh.tar('cvf', 'demo.tar', "~/") 🔸 простое создание функции-алиаса для длинной команды fn = sh.lsof.bake('-i', '-P', '-n') output = sh.grep(fn(), 'LISTEN') в этом примере также задействован пайпинг 🔸 удобный вызов команд от sudo with sh.contrib.sudo: print(ls("/root")) Такой запрос спросит пароль. Чтобы это работало нужно соответствующим способом настроить юзера. А вот вариант с вводом пароля через код. password = "secret" sudo = sh.sudo.bake("-S", _in=password+"\n") print(sudo.ls("/root")) Это не все фишки. Больше интересных примеров смотрите в документации. Специально для Windows💀 юзеров #libs#linux

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Следна