tagged [python]

Converting string to tuple without splitting characters

Converting string to tuple without splitting characters I am striving to convert a string to a tuple without splitting the characters of the string in the process. Can somebody suggest an easy method ...

How to print like printf in Python3?

How to print like printf in Python3? In Python 2 I used: I've tried:

2 Aug at 20:0

How to read numbers from file in Python?

How to read numbers from file in Python? I'd like to read numbers from file into two dimensional array. File contents: - - For example:

21 Sep at 19:15

Python: OSError: [Errno 2] No such file or directory: ''

Python: OSError: [Errno 2] No such file or directory: '' I have a 100 lines, 3 years old python scraper that now bug. Starting lines are: When run, I recei

31 Mar at 01:14

How do I get a decimal value when using the division operator in Python?

How do I get a decimal value when using the division operator in Python? For example, the standard division symbol '/' rounds to zero: However, I want it to return 0.04. What do I use?

How to run multiple functions at the same time?

How to run multiple functions at the same time? I'm trying to run 2 functions at the same time. Does anyone know how to do this?

Correct way to try/except using Python requests module?

Correct way to try/except using Python requests module? Is this correct? Is there a better way to structure this? Will this cover all my bases?

How do I make function decorators and chain them together?

How do I make function decorators and chain them together? How do I make two decorators in Python that would do the following? Calling `say()` should return:

Command line input in Python

Command line input in Python Is it possible to run first the program then wait for the input of the user in command line. e.g.

Extracting text from a PDF file using PDFMiner in python?

Extracting text from a PDF file using PDFMiner in python? I am looking for documentation examples on how to extract text from a PDF file using PDFMiner with Python. It looks like PDFMiner updated thei...

How can I check for a new line in string in Python 3.x?

How can I check for a new line in string in Python 3.x? How to check for a new line in a string? Does python3.x have anything similar to java's regular operation where direct `if (x=='*\n')` would hav...

4 Mar at 12:59

How to send a "multipart/form-data" with requests in python?

How to send a "multipart/form-data" with requests in python? How to send a `multipart/form-data` with `requests` in python? How to send a file, I understand, but how to send the form data by this meth...

How to convert string to binary?

How to convert string to binary? I am in need of a way to get the binary representation of a string in python. e.g. Is there a module of some neat way of doing this?

3 Oct at 21:5

How to crop an image using PIL?

How to crop an image using PIL? I want to crop image in the way by removing first 30 rows and last 30 rows from the given image. I have searched but did not get the exact solution. Does somebody have ...

22 May at 09:13

How to get method parameter names?

How to get method parameter names? Given that a function `a_method` has been defined like Starting from `a_method` itself, how can I get the argument names - for example, as a tuple of strings, like `...

Any way to clear python's IDLE window?

Any way to clear python's IDLE window? I know there's a similar topic about python console, but I do not know if they are the same. I tried system("clear") and it didn't work here. How do I clear pyth...

19 Apr at 00:42

What is sys.maxint in Python 3?

What is sys.maxint in Python 3? I've been trying to find out how to represent a maximum integer, and I've read to use `"sys.maxint"`. However, in Python 3 when I call it I get:

18 Apr at 20:6

Upgrade to python 3.8 using conda

Upgrade to python 3.8 using conda Python 3.8.0 is out, but I haven't been able to find any post on how to update to python 3.8 using conda - maybe they will wait for the official release? Any suggesti...

26 Oct at 04:55

Converting dictionary to JSON

Converting dictionary to JSON I am not able to access my data in the JSON. What am I doing wrong?

28 May at 17:15

requests: how to disable / bypass proxy

requests: how to disable / bypass proxy I am getting an url with: As I can see in the 'access.log' of "myserver.com", the client's system proxy is used. But I want to disable using proxies at all with...

24 Aug at 15:22

How to get the domain name of my site within a Django template?

How to get the domain name of my site within a Django template? How do I get the domain name of my current site from within a Django template? I've tried looking in the tag and filters but nothing the...

Generate a random letter in Python

Generate a random letter in Python Is there a way to generate random letters in Python (like random.randint but for letters)? The range functionality of random.randint would be nice but having a gener...

17 Jun at 13:39

Why should we NOT use sys.setdefaultencoding("utf-8") in a py script?

Why should we NOT use sys.setdefaultencoding("utf-8") in a py script? I have seen few py scripts which use this at the top of the script. In what cases one should use it?

15 Nov at 22:3

`from ... import` vs `import .`

`from ... import` vs `import .` I'm wondering if there's any difference between the code fragment and the fragment or if they are interchangeable. If they are interchangeable, which is the "standard"/...

Is there a ceiling equivalent of // operator in Python?

Is there a ceiling equivalent of // operator in Python? I found out about the `//` operator in Python which in Python 3 does division with floor. Is there an operator which divides with ceil instead? ...

2 Jul at 12:59