Questions tagged as 'python-2.7'

1
answer

What is Yield for?

For some time now I have written some basic scripts with Python, in some tutorials sometimes I get the yield , which usually appears in repetition structures commonly while . What is it for? And how to use?     
asked by 17.10.2015 / 01:11
3
answers

In Python, what are the consequences of using 'is' instead of '=='

The two forms below return True , but what are the consequences of this in a more complex code? >>> a = '2' >>> a is '2' >>> True >>> a == '2' >>> True     
asked by 24.10.2014 / 23:44
3
answers

Is there a more efficient way to dynamically create an array from another array by filtering the contents of the array first?

I have an array of values that can include several numpy.nan: import numpy as np a = np.array ( [1, 2, np.nan, 4] ) And I want to iterate over your items to create a new array without np.nan. The way I know to create arrays dynamically...
asked by 15.12.2013 / 17:48
1
answer

Name conventions for variables and functions in Python?

In R , there is a lot of freedom and variety in function names between packages. Names with dot ( get.this ), names with camelCase ( getThis ), names with underline ( get_this ). This has its pros and cons: but the fact i...
asked by 09.03.2014 / 02:54
3
answers

What does% = mean?

I have a code that contains the situation below: id %= 1000 But I do not know the function of this operator.     
asked by 19.11.2015 / 13:48
1
answer

Differences between Python versions 3.x and 2.7

I'm going to start a project in the faculty related to search engines and I want to take the opportunity to also learn Python. I do not know much about language, and my biggest question is which version, between 3.x and 2.7, has better suppor...
asked by 19.02.2016 / 03:08
1
answer

Problems with pip installation (python package manager)

I use Mac OS and use HomeBrew as the package manager. I installed python 2.7.10 . Along with this installation was to have occurred with pip . However the following problem occurs: ==> /usr/local/Cellar/python/2.7.10/bin/...
asked by 06.06.2015 / 15:44
2
answers

Differences between Python versions?

Hello! I recently decided to start studying the Python language, however, when researching the language, I noticed that there are differences between version 2 and 3. Are these differences really significant?     
asked by 11.12.2015 / 09:57
1
answer

How to calculate the shannon entropy based on the HTTP header

The Shannon entropy is given by the formula: WhereTiwillbethedataextractedfrommynetworkdump(dump.pcap).TheendofanHTTPheaderonaregularconnectionismarkedby\r\n\r\n: ExampleofanincompleteHTTPheader(couldbeadenialofserviceattack): Mygoalistocalc...
asked by 01.09.2017 / 20:51
4
answers

Count occurrences in a list according to prefixes

Let's imagine that I have a list ['rato', 'roeu', 'rolha', 'rainha', 'rei', 'russia'] and another list with prefixes ['ro', 'ra', 'r'] How do I count how many times each prefix is within the first list?     
asked by 07.04.2015 / 23:10