Questions tagged as 'python-3.x'

2
answers

Python convert a string in CamelCase to separated by dashes

Hi, I'm needing to convert a string in CamelCase to separate scripts, I've been trying a bit of regular expressions but I can not get any part of it, the idea is to enter a string in CamelCase: Entry: 'HolaMundoCruel' Exit: 'hola-mundo...
asked by 08.04.2017 / 16:29
1
answer

Go through the dictionary in the template

I have the following view: from django.shortcuts import render def ini (request): dic = {"nombre" : "Mauro", "apellido" : "London", "sexo" : "M"} return render(request, "ini.html", dic ) and the ini.html: {% extends 'base.html' %...
asked by 11.10.2018 / 01:56
1
answer

(Overloading) - Overload Operators in Python

How can I overload the (+, -, *, /, ... , //) operators on an object in python. Example: a = Vector(3, 5) b = Vector(2, 7) print(a + b) # Output: <Vector (5.000000, 12.000000)> print(b - a) # Output: <Vector (-1.000000,...
asked by 12.08.2018 / 02:38
2
answers

Is there something like typeof in Python?

As the title says, is there a way to get the internal data type of a variable in Python 3? In C # I can compare it in the following way: var str = "Strings"; if (str.GetType() == typeof(string)) Debug.WriteLine("str es un string.");...
asked by 01.07.2016 / 18:19
1
answer

datetime.strptime returns 'NoneType' objects

I am trying to write a simple module to store date data from the information entered by the user: import datetime formato_dia = ("%Y%m%d","%Y/%m/%d", "%Y-%m-%d") def dia_manual(): while True: entrada_dia = input("""Escriba la fec...
asked by 06.08.2018 / 14:45
1
answer

Simplify a heavy document (1 GB)

I'm dealing with a Geoide model, specifically the EGM2008 : This file contains the Geoid undulation (in meters) with respect to the ellipsoid WGS84, with a mesh pitch of 2.5 '(minutes) Occupy 1.28 GB Example of the file | LAT...
asked by 06.10.2017 / 16:22
3
answers

How to invert individual words of a string with python?

I want to invert the string but I keep the word order and only invert the letters as for example, if I have    My dog Renzo I should get    iM orrep ozneR. But when I use [::-1] it gives me this result:    ozneR orrep iM...
asked by 07.09.2018 / 01:54
2
answers

Read certain elements in a string

Let's say that I have this string a='12345&&&4554444' as I do to read only the numbers of that string without having to do it with a cycle since the only way I know is going through the list. variable=str('') for i in a:...
asked by 17.03.2018 / 18:33
2
answers

How to return data correctly

I am new programming and I am in the challenge of making an incremental file backup. I have been based on the paradigm of object-oriented programming and I tried to work using the good practice "DRY" (Do not repeat yourself) to avoid repeatin...
asked by 02.01.2017 / 23:22
2
answers

'key' in dict vs. dict.get ('key')

What is the main difference between: >>> dic = {} >>> existe = dic['key'] if 'key' in dic else None >>> existe None Y: >>> dic = {} >>> existe = dic.get('key', None) >>> existe None...
asked by 05.04.2018 / 18:05