본문 바로가기
반응형

파이썬171

Python ==과 is의 차이 Python에서 ==과 is은 비슷해보이지만 다른 의미를 가지고 있습니다. 결론부터 이야기하면 ==은 객체가 가지고 있는 값 비교이고 is은 객체가 같은지를 비교하는 것입니다. 예를 들어보겠습니다. str1 = 'test' str2 = 'test' print(str1 == str2) # true print(str1 is str2) # true str1,str2은 둘다 'test'라는 값을 가지고 있는 str를 참조하고 있고 어쨌던 간에 ==은 값을 비교한다고 했으니 str1 == str2은 true가 맞습니다. 그럼 str1 is str2은 왜 true일까요? 그건 str1와 str2이 값만 같은게 아니라 아예 동일한 str 객체이기 때문입니다. 내장함수 id()를 이용해 주소를 확인해보겠습니다. str.. 2020. 2. 12.
[Pycharm] Method *** may be 'static' 메세지 해결 Pycharm으로 개발하다보면 class안에 선언한 메소드에 대해 Method *** may be 'static' 이라는 메세지가 뜨는 경우가 있다. 정확히는 메소드명에 밑줄이 생기고 마우스를 올려보면 뜨는 메세지인데, 저 메세지가 뜨는 이유는 메소드 내부에서 self(객체의 인스턴스)에 접근하는 로직이 없어서 Pycharm이 우리가 만든 메소드를 보고 애가 지금 인스턴스가 필요하지 않은 static 메소드를 만드려고 하는건가?? 싶어서 띄우는 메세지입니다. static 메소드로 만들거면 @staticmethod를 붙여주고 static 메소드가 아닌데 self에 접근할 일이 없었다면 Pycham에게 이 사실을 알려주기 위해 # noinspection PyMethodMayBeStatic를 붙여주면 밑줄이 .. 2020. 2. 2.
Relative imports in Python 3 https://stackoverflow.com/questions/16981921/relative-imports-in-python-3 Relative imports in Python 3 I want to import a function from another file in the same directory. Sometimes it works for me with from .mymodule import myfunction but sometimes I get a: SystemError: Parent module '' not loaded, stackoverflow.com 2020. 2. 2.
Pymongo.errors.OperationFailure: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string. pymongo.errors.OperationFailure: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string. 에러 발생시 연결부에 retryWrites = "false" 설정 connection = pymongo.MongoClient('dsXXXXXX.mlab.com:XXXXX', retryWrites = "false") 2020. 1. 30.
Multiprocessing vs. Threading in Python: What Every Data Scientist Needs to Know https://blog.floydhub.com/multiprocessing-vs-threading-in-python-what-every-data-scientist-needs-to-know/ Multiprocessing vs. Threading in Python: What Every Data Scientist Needs to Know This deep dive on Python parallelization libraries - multiprocessing and threading - will explain which to use when for different data scientist problem sets. blog.floydhub.com 나중에 번역해봐야겠다. 2020. 1. 30.
반응형