Questions tagged as 'python'

1
answer

What is the difference between a package and a module in Python?

Is there a difference between a package and a module in Python? If there is a difference, can you give examples of packages and modules?     
asked by 25.05.2017 / 02:00
1
answer

How can I make sure the word does not break in the middle? And leave a maximum of 40 characters per line?

valor = '''In the beginning God created the heavens and the earth. Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters. And God said, "Let there be light," and ther...
asked by 10.10.2018 / 15:49
1
answer

What is the purpose of __slots__?

What is this __slots__ property for? in the documentation something about "wasted space", but at the end of the accounts I did not quite understand the purpose of using __slots__ . What is it for and when should I use it?...
asked by 11.01.2017 / 15:54
2
answers

How can I compare the keys of a hash with a user input?

File: 101;Johnny 'wave-boy' Jones;USA;8.32;Fish;21 102;Juan Martino;Spain;9.01;Gun;36 103;Joseph 'smitty' Smyth;USA;8.85;Cruizer;18 104;Stacey O'Neill;Ireland;8.91;Malibu;22 105;Aideen 'board babe' Wu;Japan;8.65;Fish;24 106;Zack 'bonnie-lad' M...
asked by 28.01.2017 / 03:41
1
answer

How to save a video captured by webcam without showing it using OpenCV in python?

I'm starting to learn Computer Vision. I'm using the OpenCV module for Python 3. Reading tutorials, I discovered the following script: import cv2 cap = cv2.VideoCapture(0) fourcc = cv2.VideoWriter_fourcc(*'DIVX') out = cv2.VideoWriter('outpu...
asked by 15.01.2017 / 17:24
2
answers

How to make a "LIKE" in a DJANGO ORM query?

To make a query to get the data exactly in Django, I use filter , like this: usuarios = Usuarios.objects.filter(nome='Jonh') This will generate a SQL similar to: SELECT * FROM usuarios wHERE nome = 'Jonh' Since I've been using Dj...
asked by 15.02.2018 / 14:03
2
answers

How can I optimize my access to the Python dictionary?

I have a dictionary of the following form: dicionario = {'1':'Banana','7':'Maçã','3':'Pera','2':'Melancia'} If I check the '2' key in the dictionary: if '2' in dicionario: . My programmer's intuition tells me that the c...
asked by 24.01.2018 / 18:17
1
answer

Check if all items in a string are different?

How can I check if all items in a string are different? For example: x:"abcdefga" = False y:"abcdefg" = True Since x[0] == x[7] , then it would be False . But in this case I would use this condition in if . Is th...
asked by 02.05.2017 / 01:37
1
answer

Data structure that represents a deck of cards

I'm developing a project in Python where I have to play a card game. I am doubtful as to what the best data structure to use, according to the description provided: Each letter must be represented by a pair (,), in which both elements are str...
asked by 07.12.2017 / 14:05
3
answers

How to construct time series with frequencies different from the original?

I have a dataframe with daily precipitation data, with dates from 01/01/1900 until 12/31/2010, example: # Data Est_1 Est_2 Est_3 # 17/12/2010 NA 0 0 # 18/12/2010 NA 0...
asked by 15.09.2015 / 02:08