Questions tagged as 'python'

1
answer

Is there any pythonic way to slice an array?

In JavaScript there is Array.prototype.slice : var input = [ 'laranja', 'limão', 'melancia', 'mamão' ]; var aparada = input.slice(1, -1); console.log( aparada ); And in PHP array_slice : $input = arr...
asked by 24.12.2017 / 20:00
2
answers

How to import an xls file into Python?

I'm starting my studies in Python and would like to import a database that is in .xls to Python. Could someone help me? NOTE: Python version 3.4.3.     
asked by 08.04.2015 / 00:06
0
answers

Reload form.custom.inpval after save form

I'm developing a web2py system and I have the following question: I made a custom form that has a field that sends a preview image. The code looks like this: {{=data['form'].custom.begin}} {{dsp = data['form'].custom.dspval}} {{inp...
asked by 06.06.2014 / 05:45
1
answer

How to list the class synopsis?

I started to venture into python and am doing program that lists the properties of the classes. I use the obj dic , the help (obj), and the dir (obj). Does anyone know if there is a command that lists the synopses of the methods, something like...
asked by 13.12.2016 / 06:54
2
answers

How to create an executable for a python program that installs the used libraries?

Hello, I have a code that I did in python and uses some libraries. I would like to know if it is possible to make an executable for this program and the user who uses it does not need to have python or these libraries installed.     
asked by 16.04.2017 / 00:32
2
answers

How do I repeat a string in Python?

The question is simple: How do I repeat a string in Python? I'm used to PHP. When I want to repeat a string in PHP, I do so: var $str = 'StackOverflow'; str_repeat($str, 5); // Imprime: StackOverflowStackOverflowStackOverflowStac...
asked by 13.08.2015 / 13:56
3
answers

What does it mean to put the 'as' command after the 'import' command in the code below?

The 'as' is in the send_to_twitter (msg) function import urllib.request import time def send_to_twitter(msg): import twitter as t: CONSUMER_KEY = '1wrnsF5lB8fEWVzRdvlIqdTle' CONSUMER_SECRET = 'eTiylDUHLJgGnTCcxzzCtzHXG4OlHrbY6wLvu...
asked by 06.01.2017 / 22:15
5
answers

Function equivalent to trim (function to remove extra spaces at the beginning and end) in python?

In PHP and javascript, we have the trim function that serves to trim string , removing extra spaces at the beginning and at the end. So: $str = ' meu nome é wallace '; var_dump(trim($str)); // string('meu nome é wallace')...
asked by 12.01.2016 / 12:04
3
answers

When to use blank lines in a Python program?

Is skipping one of the aspects that make a program well-indented? If yes, what is the criteria used to skip lines?     
asked by 25.10.2017 / 21:01
2
answers

Is a module the same as a class in Python?

Is a module the same as a class? If not what are the differences? I ask this because according to The Zen of Python , modules should be used instead of if s. The problem is that after searching I looked the same.     
asked by 05.03.2015 / 02:08