Questions tagged as 'python'

1
answer

Broken Pipe with sockets in python

I'm having the following error whenever I try to send a message from the server to the client using sockets in Python: server:importsockets=socket.socket(socket.AF_INET,socket.SOCK_STREAM)host='localhost'port=5008s.bind((host,port))s.listen(...
asked by 19.11.2016 / 20:09
3
answers

Error installing Scrapy package in Python

I'm trying to install Scrapy through pip, but I've been getting errors like:    running build_ext       buildig 'lxml.etree' extension       error: Microsoft Visual C ++ 10.0 is required (Unable to find   vcvarsall.bat). I already have...
asked by 18.11.2016 / 18:44
1
answer

Is there any way to override a specific line of a text file using Python?

I would like to edit a specific line in a file, but file.write () does not allow this type of manipulation. Being the Text: 1 "Ola" 2 "Como vai?" 3 "Tudo bem?" I would like to edit only line 2: 1 "Ola" 2 "Boa tarde" 3 "Tudo bem?"...
asked by 22.11.2017 / 04:57
3
answers

Extract numbers from a list using Regex

I have the following list <type 'list'>: [u'1',u'2'',u'3',u'4',u'7'] The result I hope is: 1 2 3 4 7 I tried to use re.findall(r'\d+', variavel) But it does not work, note that I also need     
asked by 17.09.2016 / 16:21
1
answer

python (on / off switch) [closed]

Hello. I'm learning to program in python3, it's been some time. I am Ubuntu user. I've been creating a script for some time, now I want to improve it, I've looked for some modules and some examples but I did not find anything. I need a scr...
asked by 01.02.2017 / 19:41
1
answer

How to extract the icon of an .exe file using python?

I simply had the need to have a .ico image file extracted from an .exe file and I do not even know how to start it. How can I do this?     
asked by 14.04.2017 / 21:59
2
answers

Python accumulator list

I'm developing a function that takes 3 parameters fctn (function, list, element) and you have to return a list with the intermediate states of the accumulator, as in the example below: >>> fctn(lambda acc, x: acc + x, [1, 2, 3, 4], 0)...
asked by 09.04.2017 / 17:42
2
answers

Iterate a list within switch

I would like to know how I can iterate a list in switch in python , type I have a list with ten values lista = [1,2,3,4,5,6,7,8,9,11] now I want to access this list value by value and create a loop conditional for each value h...
asked by 06.05.2016 / 00:27
1
answer

In python, how can I simulate a read-only property in classes?

I'd like to know how I can simulate a read-only property in Python . For example, I have the following code: class IPInfo(object): def __init__(self, ip): self.ip = ip; ip = IPInfo(object) ip.ip = 'aqui é possível edi...
asked by 20.07.2016 / 18:09
1
answer

Delete list item if directory does not exist

I have a list containing the path of some directories, I want to check if each directory exists, for that I use os.path.exists() , if a directory does not exist, I use the remove() method to remove it from the list, looping for...
asked by 26.07.2016 / 16:11