Questions tagged as 'python'

1
answer

Create python executable: PyOS_InputHook is not available for interactive use of PyGTK

I just finished my first program with python and would like to create an executable for distribution. However, I'm having a hard time doing this. I've tried using py2exe , pyinstaller and cx_freeze to no avail. After reading many opinions a...
asked by 21.12.2015 / 02:20
3
answers

What is the purpose of declaring a function within a function?

In Python it is possible to declare a function inside another function, as shown in the following code. def foo(palavra=None): print(palavra) def bar(outra_palavra=None): print(outra_palavra) if __name__ == '__main__': fo...
asked by 05.11.2017 / 07:54
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
5
answers

How to generate 200,000 primes as fast as possible in Python?

   Attention: I'm not looking for pieces of code ready. I just want someone to help me think of some way to generate these 200,000 primes as efficiently as possible in Python. I'm solving the # 61 CodeAbbey issue, but I can not think of...
asked by 23.08.2017 / 19:15
2
answers

What is the name of this structure in Python?

In the following code: first_part = 46 last_part = 57 guess = f'{first_part}{last_part}'.encode() print(guess) print(type(guess)) But I did not understand the code snippet: guess = f'{first_part}{last_part}'.encode() I need an explana...
asked by 27.09.2018 / 15:20
1
answer

What is Python Egg?

Reading a book about Python, the author shows a command in which you can create an Egg and upload of your package at PyPi (official python package repository). Basically using the command below: python setup.py bdist_egg upload --identity...
asked by 29.03.2017 / 17:59
2
answers

How to develop programs for Android through Python?

To develop programs for Android in Python is it necessary to build a framework in such a way that the application is executable on Android phones? I'm new to Android programmer, I'm studying and I knew Python has great portability. How can I...
asked by 29.06.2014 / 00:19
1
answer

What is Ellipsis in Python?

In Python's list of native constants , you can find Ellipsis . print(Ellipsis, type(Ellipsis)) #-> (Ellipsis, <type 'ellipsis'>) In Python 3, there is still the syntactic sugar ... representing Ellipsis . pr...
asked by 01.11.2017 / 12:24
2
answers

Difference from #! in the first line of a Python script

For a Python script to be run on a Linux / Unix-based operating system, it should start with the designated shebang ( #! ): #! /usr/bin/env python But followed by the same I've seen two different instructions used: #! /usr/bin/env...
asked by 09.04.2015 / 21:15