Skip to content

Tag: python

PyCharm: Unreachable Code?

PyCharm is showing me that some code is unreachable within a method before the return statement is reached. I cannot help but wonder how is that even remotely possible? self.fail simply calls self.response.write(things). Update: Yeah, when I surround it with a try/catch clause, the issue is resolved… St…

Python ‘is’ vs JavaScript ===

The Python use of ‘is’ seems to be similar to JavaScript ‘===’ but not quite. Here they talk about exact instances: http://www.learnpython.org/en/Conditions here (for JS) they talk about “equal AND the same type.” http://www.w3schools.com/js/js_comparisons.asp SO can you ha…

Getting started with cython on mac os

I wrote a simple program in python: Then I execute this: It was generated a file: main.c And then I tried this: And I have an error: How to compile python to c ? How to get started with cython with xcode on mac ? Answer You have to tell the gcc compiler where is the pyconfig.h file on your

Max function in python returning wrong results

I am trying to find the Max and Min in a set of numbers from a CSV file. My code keeps returning the wrong number for Max function for some rows. Here is my code: An example of my output: I am not sure what I have done wrong. Some advice would be appreciated. Answer Your list elements are strings.