본문 바로가기

Python

(6)
Poetry로 파이썬 의존성 관리하기 Poetry? 파이썬에서 사용하는 의존성 관리자는 몇 가지가 있습니다. 파이썬의 공식 의존성 관리자인 pip, 그리고 pip와 virtualenv를 같이 사용할 수 있는 Pipenv가 있고, 이번에 소개할 Poetry가 있습니다. 현재 회사에서 pip와 venv를 사용하여 프로젝트를 진행하고 있는데, 생각보다 번거롭기도 하고, 의존성 관리가기가 영 쉽지 않아서 Pipenv나 Poetry를 고려하고 있습니다. 여기서는 Poetry를 직접 설치하고 간단하게 써보도록 하겠습니다. pip가 불편한 이유 저는 회사에서 pip를 쓰면서 불편했던 경험이 있습니다. 처음부터 관리를 잘 한 프로젝트의 경우엔 큰 문제가 없었지만, 오래된 프로젝트나 여러 번 패키지 업데이트를 거치면서 여러 사람의 손을 탄 경우가 문제였습니..
LeetCode 0819. Most Common Word(Python) 문제 Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique. The words in paragraph are case-insensitive and the answer should be returned in lowercase. Example 1: Input: paragraph = "Bob hit a ball, the hit BALL flew far after it was hit...
LeetCode 0344. Reverse String(Python) 문제 Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. You may assume all the characters consist of printable ascii characters. Example 1: Input: ["h","e","l","l","o"] Output: ["o","l","l","e","h"] Example 2: Input: ["H","a..
LeetCode 0002. Add Two Numbers(Python) 문제 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example 1: Input: l1 = [2,4,3], l2 = [5,6,4] Output: [7,0,8] Explanation: 34..
LeetCode 0001. Two Sum 문제 Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use thesameelement twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. Exampl..
Pyenv로 파이썬 버전 관리하기 어떤 언어든 그렇겠지만 사용하다 보면 여러 버전을 동시에 사용해야 할 때가 있습니다. 이직한 회사에서 파이썬을 사용하고 있는데요. 여기도 어떤 프로젝트는 3.6.4를 사용하고 있고, 또 어떤 프로젝트는 3.7.6을 사용하고 있더라고요. 그래서 여러 버전을 동시에 사용하고 싶어 졌습니다. 마침 회사에서 pyenv라는 걸 사용하고 있어서 저도 사용해봤습니다. Pyenv는 무얼 할 수 있나요? 사용자별로 글로벌 파이썬 버전을 설정할 수 있어요. (Let you change the global Python version on a per-user basis.) 프로젝트별로 파이썬 버전을 설정할 수 있어요. (Provide support for per-project Python versions.) 환경변수로 파이썬..