코딩
-
Pyton/프로그램의 종료, exit() & quit()코딩/Python 2024. 4. 17. 03:46
quit()이 영향을 끼치는 범위 quit()은 quit()이 포함된 함수에서 중단되는 것이 아닌 전체 프로세스 수준에서 중단된다. 아래의 예제에서 프로그램은 test_quit1()에서 중단되고 동시에 test_quit2()와 test_quit3()도 함께 중단된다. def test_quit1(a): if a == '': quit() else: print(a) def test_quit2(a): test_quit1(a) print('2') def test_quit3(a): test_quit2(a) print('3') a = '' test_quit3(a) exit()와 quit()의 차이 exit()와 quit() 함수는 모두 현재 실행 중인 Python 인터프리터를 종료하는 함수이다. 하지만 이 두 함수는..
-
Python/프로젝트 패키징코딩/Python 2024. 3. 15. 19:00
Source: https://packaging.python.org/en/latest/tutorials/packaging-projects/ Packaging Python Projects This tutorial walks you through how to package a simple Python project. It will show you how to add the necessary files and structure to create the package, how to build the package, and how to upload it to the Python Package Index (PyPI). 이 튜토리얼에서는 간단한 Python 프로젝트를 패키징하는 방법을 안내한다. 패키지를 생성하는 데 ..
-
Python/Reference/어휘분석코딩/Python 2024. 3. 15. 14:47
파이썬을 사용하면서 파이썬 매뉴얼을 참고해야 할 경우가 있다. 이럴 경우 매뉴얼의 구성과 용어에 대해 알고 접근하는 것이 도움이 된다. 그래서 매뉴얼을 설명하는 챕터 1과 2를 번역해 올린다. 원문은 아래 링크 참조 2. Lexical analysis A Python program is read by a parser. Input to the parser is a stream of tokens, generated by the lexical analyzer. This chapter describes how the lexical analyzer breaks a file into tokens. Python reads program text as Unicode code points; the encoding of ..
-
Python/Reference/소개코딩/Python 2024. 3. 15. 14:35
파이썬을 사용하면서 파이썬 매뉴얼을 참고해야 할 경우가 있다. 이럴 경우 매뉴얼의 구성과 용어에 대해 알고 접근하는 것이 도움이 된다. 그래서 매뉴얼을 설명하는 챕터 1과 2를 번역해 올린다. 원문은 아래 링크 참조 1. Introduction This reference manual describes the Python programming language. It is not intended as a tutorial. While I am trying to be as precise as possible, I chose to use English rather than formal specifications for everything except syntax and lexical analysis. This s..
-
Python/PEP 8 – Style Guide for Python Code코딩/Python 2024. 3. 10. 02:47
파이썬 프로그래밍 가이드입니다. 원본은 링크를 참조하세요. PEP 8 – Style Guide for Python Code Author: Guido van Rossum , Barry Warsaw , Alyssa Coghlan Status: Active Type: Process Created: 05-Jul-2001 Post-History: 05-Jul-2001, 01-Aug-2013 Introduction This document gives coding conventions for the Python code comprising the standard library in the main Python distribution. Please see the companion informational PEP des..
-
Python/영문 국문 번역 자료 병합, 마크다운, HTML 태그 추가코딩/Python 2024. 3. 8. 23:51
영문과 번역문을 병합하고 MD 태그, HTML 태그 추가하는 프로그램 프로그래밍을 공부하다 보면 이리 저리 자료를 찾아야 할 일이 많다. 대부분 영어로 된 문서를 읽게 되는데 그리 어렵진 않지만 국문자료보다는 시간이 더 걸리는 게 사실이다. 그래서 영문 자료를 번역해서 빠르게 읽는데 대부분의 경우는 괜찮지만 부분부분 해석이 난해해서 원문을 찾아 읽게 된다. 그래서 영문과 번역본을 한 눈에 보면서 비교할 수 있도록 자료를 만들었다. 하지만 수동으로 하기에는 시간이 너무 걸리므로 파이썬을 이용해서 대부분을 자동화시켰다. 이 작업으로 생성된 html 결과물이 아래 글이다. https://summertrees.tistory.com/576 Python/정규식 HOWTO 이 문서는 아래 문서를 번역한 것입니다. 원..
-
Python/람다식의 다른 적용: if문 대체코딩/Python 2024. 3. 8. 16:56
람다식의 확장 함수 여기 세 함수가 있다. 입력값에 100,200,300을 더하는 함수다. def p100(n): re = n + 100 return re def p200(n): re = n + 200 return re def p300(n): re = n + 300 return re if문 만일 이 함수들을 케이스로 사용한다면 if..elif..else를 쓸 것이다. q = 1 if q == 1: ans = p100(q) elif q == 2: ans = p200(q) elif q == 3: ans = p300(q) else: print('No answer') 여기까지는 일반적인 방법이다. 람다식 이제 람다식과 리스트를 결합해서 케이스를 대체한다. cmd_l = [lambda n: p100(n), lam..
-
Python/정규식 HOWTO코딩/Python 2024. 3. 4. 10:24
아래 내용은 Python reference를 번역한 것이다. 원본 내용은 제목의 링크를 참조한다. Regular Expression HOWTO Author: A.M. Kuchling Abstract This document is an introductory tutorial to using regular expressions in Python with the re module. It provides a gentler introduction than the corresponding section in the Library Reference. 이 문서는 re 모듈과 함께 Python에서 정규식을 사용하는 방법에 대한 입문 튜토리얼이다. Library Reference의 해당 섹션보다 덜 딱딱한 소개를 제공한다..