본문 바로가기

syntax5.3

Python 파이썬에서는 멀티라인 람다 함수를 지원하지 않는 이유는 무엇인가요?, No Multiline Lambda in Python: Why not? 질문 I've heard it said that multiline lambdas can't be added in Python because they would clash syntactically with the other syntax constructs in Python. I was thinking about this on the bus today and realized I couldn't think of a single Python construct that multiline lambdas clash with. Given that I know the language pretty well, this surprised me. Now, I'm sure Guido had a reason for not incl.. 2023. 10. 26.
Python 로그 축 그래프, Plot logarithmic axes 질문 matplotlib를 사용하여 로그축 하나를 가진 그래프를 그리고 싶습니다. 문서를 읽어보았지만 구문을 이해하지 못했습니다. 아마도 플롯 인수에 'scale=linear'와 같은 간단한 것일 것 같지만 제대로 작동하지 않습니다. 샘플 프로그램: import pylab import matplotlib.pyplot as plt a = [pow(10, i) for i in range(10)] fig = plt.figure() ax = fig.add_subplot(2, 1, 1) line, = ax.plot(a, color='blue', lw=2) pylab.show() 답변 다음은 Axes.set_yscale 메서드를 사용할 수 있습니다. 이를 통해 Axes 객체가 생성된 후에도 스케일을 변경할 수 있습.. 2023. 9. 18.
Python 빈 집합 리터럴?, Empty set literal? 질문 [] = 빈 리스트 () = 빈 튜플 {} = 빈 딕셔너리 빈 세트에 대한 유사한 표기법이 있나요? 아니면 set()을 작성해야 하나요? 답변 아니요, 빈 집합에 대한 구문은 없습니다. set()를 작성해야 합니다. 2023. 9. 14.