Questions tagged as 'python'

7
answers

Less number of movements of a horse to a given house in Chess

On a chessboard in any house I have a Horse (represented in red) and I will have only one other piece (represented in green) that the horse should go to it: Imustusethesimplestpathandtakeintoaccountthemovementofthehorse(inL)andcountthemovemen...
asked by 03.12.2016 / 01:06
2
answers

FieldError: Relation fields do not support nested lookups

I'm trying to do a query in Django with several joins , and I came across this error that I do not know what it means: Tag.objects.filter(dset__descendant__entities__entity=e)    FieldError: Relation fields do not support nested lookups...
asked by 22.01.2016 / 19:10
3
answers

Why static methods can be called through the "instance" class in Python 3?

Let's say I have the following class: class Person: @staticmethod def hello(): print('Hello!) When performing the Person().hello() operation, the method executes normally. But the hello method belongs to the Pe...
asked by 09.10.2017 / 19:08
4
answers

How to call an external function, without sending the 'self'?

I am using a class attribute to save the View that I want to test in a Django application, like this: # TESTS.PY class OrderTests(TestCase, ShopTest): _VIEW = views.order def test_gateway_answer(self): url = 'whatever url'...
asked by 31.12.2013 / 15:16
1
answer

How to use virtualenv to manage the dependencies of a Python application?

I need to manage the dependencies of a Python application I'm developing, so it's easy for other team developers to be able to work on the project using the same versions of the packages I'm using. Can I do this with virtualenv ? How?...
asked by 11.12.2013 / 17:50
2
answers

In Python, what is the difference between == and the is command? [duplicate]

I'm confused by the use of two commands, the is and the == , that as far as I understand they do the same thing that is to compare if two objects are equal. Is there any more performance?     
asked by 29.12.2016 / 01:19
1
answer

How decorators work in Python?

@Elizeu Santos asked in the Portuguese Python group of facebook the following:    "Talk to people, I'm studying python and something I'm not understanding   are the decorators. I faced them doing the flask tuition, they can   make me clear up...
asked by 06.07.2014 / 05:39
4
answers

What is the most complete way to install python in Windows?

I know this question can be interpreted as a discussion, so I did it with the word "complete" rather than "better." I'm a python user in GNU / Linux and here it comes more or less preinstalled. Still, I can use pip to install or remove new pa...
asked by 31.12.2013 / 14:32
3
answers

How can I distribute the .py program without having to install all the libraries?

I'm learning Python and need to distribute a program, read about cx_Freeze and py2exe to generate an .exe. However, I do not mind distributing the program code together, so I do not see a need to generate an .exe. How can I distribute the .py...
asked by 13.06.2015 / 02:47
3
answers

How to "round" a float in Python?

I have this sum: total = 0.1 + 0.2 print total #retorna 0.30000000000000004 How would I "round" the decimal places and return only the number of houses added? Example: totalA = 0.1 + 0.2 #retornaria 0.3 totalB = 0.32 + 0.25 #retorna...
asked by 21.12.2014 / 02:15