Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Big O runtime nested for loop and append
Post: RE: Big O runtime nested for loop and append
The code you posted has a runtime of O(1) because it is a SyntaxError at compile-time, so there is no runtime behaviour **biggrin**
list.append has amortised O(1) behaviour. Which means that if you ... |
|
stevendaprano |
General Coding Help |
4 |
1,396 |
Dec-31-2022, 11:50 PM |
|
|
Thread: Killed
Post: RE: Killed
How are you running the program? Where is the output "Killed" shown?
What operating system and version of Python are you using?
Just reading the file as bytes doesn't care that the RAR is password p... |
|
stevendaprano |
General Coding Help |
1 |
787 |
Dec-31-2022, 11:36 PM |
|
|
Thread: Illegal instruction (core dumped) when import pandas.
Post: RE: Illegal instruction (core dumped) when import ...
Quote:I installed pandas and pyarrow with "pip3 install" command
It looks like it was already installed:
Quote:Requirement already satisfied: pandas in ./.local/lib/python3.10/site-packages (1.5.2)
... |
|
stevendaprano |
General Coding Help |
1 |
2,117 |
Dec-31-2022, 11:31 PM |
|
|
Thread: How do I add comments from a text-file to an array of folders?
Post: RE: How do I add comments from a text-file to an a...
What happens when you run the code showed? Does it work? Do you get an error?
What's in the metadata file? Is that the file holding the comments? Are they also one per line? |
|
stevendaprano |
General Coding Help |
2 |
1,801 |
Dec-31-2022, 11:23 PM |
|
|
Thread: How to print variables in function?
Post: RE: How to print variables in function?
(Dec-31-2022, 11:54 AM)samuelbachorik Wrote: I got it now, thank you for help
Is the solution a secret? For the benefit of other people reading this question, you should give the answer so everyone ... |
|
stevendaprano |
General Coding Help |
3 |
918 |
Dec-31-2022, 11:12 PM |
|
|
Thread: Opinion: how should my scripts cache web download files?
Post: Opinion: how should my scripts cache web download ...
I have a script that downloads files from the web. To be a good web citizen, I want to keep a local cache and only re-fetch from the internet if the cache is too old.
I cannot rely on there being a l... |
|
stevendaprano |
General Coding Help |
0 |
736 |
Dec-17-2022, 12:19 AM |
|
|
Thread: Review my code: convert a HTTP date header to a datetime object
Post: Review my code: convert a HTTP date header to a da...
Please review my code. Is this the right thing to do?
I get a HTTP date stamp from a web response, and convert it into a datetime object:
import datetime
from urllib import request
URL = "https://w... |
|
stevendaprano |
General Coding Help |
1 |
2,013 |
Dec-17-2022, 12:03 AM |
|
|
Thread: When is stdin not connected to a tty, but can still be used interactively?
Post: When is stdin not connected to a tty, but can stil...
I'm looking at some code which is intended to be used interactively, and I don't quite understand it.
Simplified, the code looks like this:
import sys
def example():
try:
import tty
... |
|
stevendaprano |
General Coding Help |
1 |
1,019 |
Sep-24-2022, 12:25 PM |
|
|
Thread: Reminder that pip runs arbitrary code
Post: Reminder that pip runs arbitrary code
This is just a reminder that not only pip install but also pip dryrun will run arbitrary code and can install files in your home directory. Or any other place you have write permission.
Further discu... |
|
stevendaprano |
News and Discussions |
0 |
799 |
Sep-18-2022, 03:49 AM |
|
|
Thread: Can Python be used as a macro language for excel, Word, etc.?
Post: RE: Can Python be used as a macro language for exc...
You can also use Python as a scripting language for LibreOffice and OpenOffice. |
|
stevendaprano |
News and Discussions |
8 |
3,109 |
Sep-17-2022, 08:12 AM |
|
|
Thread: Sort of a general "best practices" question
Post: RE: Sort of a general "best practices" question
Your question isn't really a Python question, you are probably better off asking on developer forums for email (say, Thunderbird) and security forums.
Anything which is not physically part of the ema... |
|
stevendaprano |
News and Discussions |
2 |
1,330 |
Sep-17-2022, 08:03 AM |
|
|
Thread: Breaking Change for Python 3.7 - 3.12
Post: RE: Breaking Change for Python 3.7 - 3.12
There is a long (nearly 200 posts) thread discussing this breaking change on Discuss.
Alas, the moderators have shut the discussion down. I feel, perhaps a bit unfairly, that the security team were r... |
|
stevendaprano |
News and Discussions |
9 |
4,343 |
Sep-17-2022, 07:40 AM |
|
|
Thread: PEP 671 Syntax for late bound function default values
Post: PEP 671 Syntax for late bound function default val...
PEP 671 proposes to introduce syntax to solve the "early binding gotcha" when mutable objects are used as default arguments. Instead of writing
def func(arg=None):
if arg is None:
arg = [... |
|
stevendaprano |
News and Discussions |
2 |
1,080 |
Jun-21-2022, 10:53 AM |
|
|
Thread: math.log versus math.log10
Post: RE: math.log versus math.log10
Ah, apart from you accidentally counting the case where they are equal as "greater", that's a good experimental test which answers my question.
I re-did the test with the correct test, and found that... |
|
stevendaprano |
General Coding Help |
10 |
2,427 |
May-23-2022, 02:35 PM |
|
|
Thread: Mixed types of numeric data in the statistics module
Post: RE: Mixed types of numeric data in the statistics ...
Thanks for the feedback, and sorry for the delay in responding.
(May-16-2022, 07:45 AM)Gribouillis Wrote: The «result is not guaranteed» part worries me. It means that the occasional user has a cer... |
|
stevendaprano |
News and Discussions |
2 |
1,310 |
May-23-2022, 02:15 AM |
|
|
Thread: math.log versus math.log10
Post: RE: math.log versus math.log10
Thanks but that doesn't answer my question. My question is whether log(num, 10) is always less than or equal to log10(num)? Or could it sometimes be greater than log10? |
|
stevendaprano |
General Coding Help |
10 |
2,427 |
May-23-2022, 01:51 AM |
|
|
Thread: math.log versus math.log10
Post: math.log versus math.log10
math.log(num, 10) is usually, but not always, equal to math.log10(num). In my random testing, when they are different, log(num, 10) is always smaller than log10(num).
(The difference appears to be 1 ... |
|
stevendaprano |
General Coding Help |
10 |
2,427 |
May-22-2022, 11:44 AM |
|
|
Thread: Have I implemented this function correctly?
Post: RE: Have I implemented this function correctly?
(May-19-2022, 06:52 PM)amusinR Wrote: it gives me an "KeyError: 1". What can be the reason?
Dunno. What's the full error traceback you get? How confident are you that the "pcy" (what's a pcy?) is co... |
|
stevendaprano |
General Coding Help |
4 |
2,357 |
May-22-2022, 02:52 AM |
|
|
Thread: do you have an idea for optimizing this code?
Post: RE: do you have an idea for optimizing this code?
What are you trying to optimize for?
memory use
readability
startup time
run time speed
network access
something else?
The answer will depend on what you are trying to optimize for, and why yo... |
|
stevendaprano |
General Coding Help |
3 |
1,374 |
May-22-2022, 02:45 AM |
|
|
Thread: Should Python support i suffix for complex numbers as well as j ?
Post: RE: Should Python support i suffix for complex num...
No, I've never tried it.
You should publish it on PyPI to make it easier for people to find. |
|
stevendaprano |
News and Discussions |
3 |
1,429 |
May-21-2022, 08:37 AM |