Re: Best way to check if there is internet?

2022-02-22 Thread Avi Gross via Python-list
. -Original Message- From: Abdur-Rahmaan Janhangeer To: Python Sent: Tue, Feb 22, 2022 12:32 pm Subject: Re: Best way to check if there is internet? Well, nice perspective. It's a valid consideration, sound theory but poor practicality according to me. It you view it like this then betwee

Re: One-liner to merge lists?

2022-02-22 Thread Avi Gross via Python-list
quot;])} d.values() dict_values([['aaa', 'bbb', 'ccc'], [['fff', ['ggg']]], 666, {'e', 'u', 'a', 'o', 'i'}]) flatten2list(d.values()) ['aaa', 'bbb', 'ccc', 'fff&#x

Re: Long running process - how to speed up?

2022-02-23 Thread Robert Latest via Python-list
Shaozhong SHI wrote: > Can it be divided into several processes? I'd do it like this: from time import sleep from threading import Thread t = Thread(target=lambda: sleep(1)) t.run() # do your work here t.wait() -- https://mail.python.org/mailman/listinfo/python-list

Coding help

2022-02-23 Thread Richard Pullin via Python-list
I know next to nothing about computer coding nor Python. However, I am working on a mathematical challenge in which coding is required to calculate and generate different potential solutions. Can anyone help? If so, please private message me and we can discuss in more detail. Many thanks

Re: Best way to check if there is internet?

2022-02-23 Thread Robert Latest via Python-list
run or enter key on the terminal, > our Python interpreter might get deleted. Yeah, but by your logic you'd have to check the existence of /usr/bin/python each time before you run it. > Though it's nice to go in and catch exceptions, > if you have a long operation upcoming it

Re: Best way to check if there is internet?

2022-02-23 Thread Robert Latest via Python-list
tion. > So it detected that there is or there is no internet ... Your application obviously needs to make a certain network connection. Why don't you just check if the connection can be made? Why would you care if it's via cable or Wifi? -- https://mail.python.org/mailman/listinfo/python-list

Threading question .. am I doing this right?

2022-02-24 Thread Robert Latest via Python-list
ache.append() because _update() can ever only run in one thread at a time. But maybe I'm overlooking something. -- https://mail.python.org/mailman/listinfo/python-list

Re: Threading question .. am I doing this right?

2022-02-25 Thread Robert Latest via Python-list
se, so that some screens displayed error messages for a minute or two. Nobody cares but my pride was piqued and the error logs filled up. I've had my proposed solution running for a few days now without errors. For me that's enough but I wanted to ask you guys if I made some logical mistakes. -- https://mail.python.org/mailman/listinfo/python-list

Re: Threading question .. am I doing this right?

2022-02-25 Thread Robert Latest via Python-list
a future update. I don't think that's a problem. If it turns out to be one I'll create a copy of the data while I hold the lock and pass that back. > -- https://mail.python.org/mailman/listinfo/python-list

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
C. It may well be optimized in some places but there are constraints that may well make it hard to optimize compared to some other implementation without those constraints. In particular, it interfaces with standard Python data structures at times such as when initializing from a Python List,

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
wasted effort but as a tradeoff, they can do many things in a dynamic way that compiled programs may not do easily or at all. Another argument I find is unfair, is some comparisons with what I consider "mixed" effort. If you have a program that calls various numpy routines using native

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
it in the base python, perhaps as a second executable with a name like pythonn to signify that it is more numeric. So if you run that, you know you do not need to add an assortment of modules. I keep seeing programs that just automatically add numpy and pandas and various graphic modules and

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
implementation makes a huge change. Take interpreted languages including Python and R that specify all kinds of functions that may be written within the language at first. Someone may implement a function like sum() (just an example) that looks like the sum of a long list of items is the first item added

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
problems. -Original Message- From: Chris Angelico To: [email protected] Sent: Fri, Feb 25, 2022 11:16 pm Subject: Re: C is it always faster than nump? On Sat, 26 Feb 2022 at 14:35, Avi Gross via Python-list wrote: > But with numpy and more available anyway, it may not be necessary

Re: Best way to check if there is internet?

2022-02-26 Thread Robert Latest via Python-list
Chris Angelico wrote: > Every language learns from every other. Except Visual Basic, which didn't learn anything from anywhere, and all that can be learned from it is how not to do it. Ugh. -- https://mail.python.org/mailman/listinfo/python-list

Getting Syslog working on OSX Monterey

2022-02-27 Thread Philip Bloom via Python-list
m to be running correctly either. I'm on Python 3.6.8 (though we're about to start an upgrade to the latest stable, if that in theory may have changes to syslog handling). I'm mostly ending up here since I'm finding such differences in response between python modules I'd expect

Re: Getting Syslog working on OSX Monterey

2022-02-27 Thread Philip Bloom via Python-list
eed to check your platform and use the appropriate address (you may need to do this check at runtime if your application needs to run on several platforms) Aiming for this to be being picked up on the same computer I'm running the test script (Python -> Logging -> SyslogHandler -> Mac

Re: Threading question .. am I doing this right?

2022-02-28 Thread Robert Latest via Python-list
- https://mail.python.org/mailman/listinfo/python-list

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Robert Latest via Python-list
o JSON or String. I've done exactly this. Since my data was strictly ASCII I decided to go for JSON. But in the end you're the only one who can decide this because only you know the data. That's why you won't find any hard and fast rule for this. -- https://mail.python.org/mailman/listinfo/python-list

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-01 Thread Robert Latest via Python-list
acters in utf8mb4 character set. -- https://mail.python.org/mailman/listinfo/python-list

Re: All permutations from 2 lists

2022-03-01 Thread Rob Cliffe via Python-list
t;us-east-2"), ("Windows", "us-east-1"), "Windows", "us-east-2')] The lists can be different lengths or can be 0 length. Tried a few different things with itertools but have not got just what I need. TIA! -- https://mail.python.org/mailman/listinfo/python-list

Re: All permutations from 2 lists

2022-03-02 Thread Avi Gross via Python-list
or other variants. You pointed out, validly, that if either of the original lists is empty, it fails. True. But that opens the question of what happens when any random thing is thrown there such as "hello" which Python happily treats as ['h', 'e', 'l', &

Re: Getting Syslog working on OSX Monterey

2022-03-02 Thread Philip Bloom via Python-list
ld expect as the default if you are using the C > API. > > What you do not see used in the SyslogHandler() is the import syslog > and hence its nor using openlog() etc from syslog API. > > Barry > > > > >hp > > > > -- > > _ | Peter J. Holz

Re: All permutations from 2 lists

2022-03-03 Thread Rob Cliffe via Python-list
On 03/03/2022 14:07, Larry Martell wrote: On Wed, Mar 2, 2022 at 9:42 PM Avi Gross via Python-list wrote: Larry, i waited patiently to see what others will write and perhaps see if you explain better what you need. You seem to gleefully swat down anything offered. So I am not tempted to

Re: All permutations from 2 lists

2022-03-03 Thread Avi Gross via Python-list
not about you asking how to solve a very reasonable problem in Python. It was about the process and what was disclosed and then the expectation that we should have known about things not shared. Certainly sharing too much is a problem too. Your title alone was very concrete asking about 2 lists.

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
is such a thing in Python? I have used it maybe once. My issue with this construct is that calling the second block `else` doesn't make sense; a much more sensible name would be `then`. Now, imagine a parallel universe, where the for-else construct would have a different behavior:

Re: Timezone jokes (was: All permutations from 2 lists)

2022-03-03 Thread Avi Gross via Python-list
: Chris Angelico To: [email protected] Sent: Thu, Mar 3, 2022 12:40 pm Subject: Re: Timezone jokes (was: All permutations from 2 lists) On Fri, 4 Mar 2022 at 03:29, Tim Chase wrote: > > On 2022-03-03 06:27, Grant Edwards wrote: > > On 2022-03-03, Chris Angelico wrote: > > &

Re: Getting Syslog working on OSX Monterey

2022-03-03 Thread Philip Bloom via Python-list
Grabbing latest python that does work. Good we're about to get out of the stone ages a bit here. So findings: Syslog - works in 3.10, broken against monterey in 3.6. Logging.Handlers.Sysloghandler - is broken in both against Monterey. Will bug it for the tracker. Thanks for the fee

Re: Behavior of the for-else construct

2022-03-03 Thread Jon Ribbens via Python-list
#x27; needs vary. I can't even remember the last time I've needed something as you suggest above - certainly far less often than I need 'for...else' as it is now. > What are your thoughts? Do you agree? I don't agree. But it doesn't really matter if anyone agrees or not,

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
age must be added to sparingly and with so many requests, perhaps only a few non bug-fixes can seriously be considered. -Original Message- From: Akkana Peck To: [email protected] Sent: Thu, Mar 3, 2022 5:33 pm Subject: Re: Behavior of the for-else construct computermaster360 writes

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
Cliffe On 03/03/2022 23:07, Avi Gross via Python-list wrote: The drumbeat I keep hearing is that some people hear/see the same word as implying something else. ELSE is ambiguous in the context it is used. And naturally, since nobody desperately wants to use non-reserved keywords, nobody seems

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
l programs are limited to [{( and maybe < and their counterparts. This leads to odd Python behavior (other languages too) where symbols are re-used ad nauseam. { can mean set or dictionary or simply some other way to group code. So I would love to see some key that allows you to do something li

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
g a function as `[`(args) instead of [args] and rewriting it. Python plays lots of similar games, such as the decorators you like to use. In many places, Python makes it easier for me to do things. There really are more like three kinds of Programmers. Some see the world one way and some another w

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
On 04/03/2022 00:34, Chris Angelico wrote: On Fri, 4 Mar 2022 at 10:09, Avi Gross via Python-list wrote: The drumbeat I keep hearing is that some people hear/see the same word as implying something else. ELSE is ambiguous in the context it is used. What I'm hearing is that ther

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
On 04/03/2022 00:38, Avi Gross via Python-list wrote: Rob, I regularly code with lots of comments like the one you describe, or mark the end of a region that started on an earlier screen such as a deeply nested construct. So do I (and not just in Python).  It's good practice. I hav

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
On 04/03/2022 00:43, Chris Angelico wrote: On Fri, 4 Mar 2022 at 11:14, Rob Cliffe via Python-list wrote: I find it so hard to remember what `for ... else` means that on the very few occasions I have used it, I ALWAYS put a comment alongside/below the `else` to remind myself (and anyone

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
On 04/03/2022 01:44, Ethan Furman wrote: On 3/3/22 5:32 PM, Rob Cliffe via Python-list wrote: > There are three types of programmer: those that can count, and those that can't. Actually, there are 10 types of programmer:  those that can count in binary, and those that can't.

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
#x27;if a break occurred', then at least only one debtor is killed, as an example to the others, and no Exception will occur in the unlikely event of "debtors" being empty. Happy fund-raising! Rob Cliffe There's something in this. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
to hold objects holding a set and not confuse the notations for sets and dictionaries as Python ended up doing. (Yes, I know it is NOT confusing in some ways as one holds key:value pairs and the other just value, but making an empty set now requires the notation of set() while an empty dictionary i

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
an ELSE dangling. -Original Message- From: Jach Feng To: [email protected] Sent: Thu, Mar 3, 2022 9:22 pm Subject: Re: Behavior of the for-else construct I never feel confused by "else" because I always think it in "break...else", not "for...else".

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
as discussed, you could do an IF statement to check if closet is empty but for iterators, it gets ... -Original Message- From: Dieter Maurer To: Rob Cliffe Cc: [email protected] Sent: Fri, Mar 4, 2022 2:12 am Subject: Re: Behavior of the for-else construct Rob Cliffe wrote at 2022-3

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
s were not allowed to have embedded spaces, it made sense to treat them like tokens that could be broken up at whitespace. As mentioned, languages (or other programs) would often parse a command line and create something like this for the main program in C with suitable version in Python and other

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
s useful because it is more direct or other reasons. in the case we are discussing, what are the scope issues in: eye = 1 for eye in ... : pass else: eye = None It looks like all references to eye refer to the same object. Some other methods we have touched on (or others may bring up) may

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
erwise need keywords. Anything between braces can be an extension of the language in a context where users do not put their own variable names. But again, any language defined can be set up to do things their own way. In Python, I believe the contents of a loop are not examined at all if skipped

Re: Behavior of the for-else construct

2022-03-04 Thread Rob Cliffe via Python-list
On 04/03/2022 20:52, Avi Gross via Python-list wrote: I have an observation about exception handling in general. Some people use exceptions, including ones they create and throw, for a similar idea. You might for example try to use an exception if your first attempt fails that specifies

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
situations where almost all programs are found in the first component of PATH, perhaps the exception approach is not horrible. It may even at times be done with less coding effort than other alternatives. Not my preferred way, of course. -Original Message- From: Rob Cliffe via Python-list

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
last name in German notation as a variable in Python now: Groß = 144 Groß / 12 12.0 But even if I was German (and despite living in Austria for a year, I am not) I might want to write some things in French which might not be on that Keyboard, unless it includes everything in ISO 8859-1, albeit

Re: Behavior of the for-else construct

2022-03-05 Thread Rob Cliffe via Python-list
On 05/03/2022 01:15, Cameron Simpson wrote: I sort of wish it had both "used break" and "did not use break" branches, a bit like try/except/else. And "zero iterations". Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
ng. I hope the idea comes across, even if you disagree with my indenting or exact method. Constructs like the above do in theory allow some really complex matching and often in a way easier to understand than having endless clauses added below the for group. But as repeatedly stated, P

Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
I am not sure how we end up conversing about PASCAL on a Python forum. But it is worth considering how people educated in aspects of Computer Science often come from somewhat different background and how it flavors what they do now. I paid no attention to where PASCAL was being used other than

Help: Unable to find IDLE folder inside the Python Lib folder

2022-03-05 Thread Deji Olofinboba via Python-list
Dear Python officer, Please I am new to programming. I have justinstalled the python 3.10.2. After the installation, I was able to locate thePython Shell but unable to locate IDLE despite checking it before downloading in the python installation folder. I also reinstalled Python and checked

Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
and other languages to undergrads ;-) -Original Message- From: Dennis Lee Bieber To: [email protected] Sent: Sat, Mar 5, 2022 7:00 pm Subject: Re: Behavior of the for-else construct On Sat, 5 Mar 2022 21:40:08 + (UTC), Avi Gross declaimed the following: >I am not sure how we end

Re: Behavior of the for-else construct

2022-03-06 Thread Avi Gross via Python-list
rly interested in proofreading, the result tends to be that I simply get annoyed and the one pointing it out is taken as wandering off topic even more than I do. Python is named after a snake right? So is it upper case or lower case or mixed case? No, wait, it is named after Monty Python. But what mad

C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-06 Thread Jen Kris via Python-list
I am using the C API in Python 3.8 with the nltk library, and I have a problem with the return from a library call implemented with PyObject_CallFunctionObjArgs.  This is the relevant Python code: import nltk from nltk.corpus import gutenberg fileids = gutenberg.fileids() sentences

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
the same way as ‘’.join, and if not then (2) how can I strip characters from a string object in the C API?  Thanks. Mar 6, 2022, 17:42 by [email protected]: > On 2022-03-07 00:32, Jen Kris via Python-list wrote: > >> I am using the C API in Python 3.8 with the nltk

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
The PyObject str_sentence is a string representation of a list.  I need to convert the list to a string like "".join because that's what the library call takes.  Mar 7, 2022, 09:09 by [email protected]: > On Tue, 8 Mar 2022 at 04:06, Jen Kris via Python-list > wrote: &g

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
string representations are not the same – or at least the   >> PyUnicode_AsEncodedString is not the same, as each item is surrounded by >> single quotes. >> >> Assuming that the conversion to bytes object for the REPR is an accurate >> representation of str_sentenc

Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
of a dictionary object and a string.  The relevant part of the Python code is: half_slice = int(len(dictdata) * 0.5) subdata_a = dictdata[half_slice:] subdata_b = dictdata[:half_slice] This is what I’ve done so far with the C API: int64_t Calc_Slices(PyObject* pDictdata, int64_t records_count

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
s.com: > On 2022-03-12 21:24, Jen Kris via Python-list wrote: > >> I have a C API project where I have to slice a list into two parts.   >> Unfortunately the documentation on the slice objects is not clear enough for >> me to understand how to do this, and I haven’t found e

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
pDictData, despite the name, is a list of 2-tuples where each 2-tuple is a dictionary object and a string.  Mar 12, 2022, 13:41 by [email protected]: > On Sun, 13 Mar 2022 at 08:25, Jen Kris via Python-list > wrote: > >> PyObject* slice = PySlice_New(PyLong_FromLong(0)

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
;s a borked one, kaboom). > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
Thanks for PySequence_InPlaceConcat, so when I need to extend I'll know what to use.  But my previous email was based on incorrect information from several SO posts that claimed only the extend method will work to add tuples to a list.  I found that's wrong -- even my own Python cod

Re: for convenience

2022-03-21 Thread Avi Gross via Python-list
, use a macro preprocessor, to parse the code once to make various textual changes without any real understanding of thelanguage and produce output ready for a compiler or interpreter phase. Python has nothing really like that albeit I can think of some things as well asgimmicks and tricks that can

convenience

2022-03-22 Thread Avi Gross via Python-list
ve in a language like R, you can add the namespace to the environment and use it in read-only mode but writing to a resulting variable like "col1" makes a new local variable and does not make any change to the underlying filed in a data.frame. I mean (again this is not Python code) that: mydat

Re: for convenience

2022-03-22 Thread Avi Gross via Python-list
I sent George a private reply as discussing other languages gets rapidly off-topic. I want to add a small addendum here about the technique he used and a Dave Neal and others are trying, a way to imagine things that is more compatible with how a language like Python works so it meets expectation

Re: convenience

2022-03-22 Thread Avi Gross via Python-list
Greg, Yes, what I describe may not be common and some code goes to serious lengths precisely to make direct connections to internals on an object hard to access. But Python indeed allows and perhaps encourages you to use what you consider side effects but perhaps more. There are many dunder

Pyto Implementation - GROWING TREND

2022-03-24 Thread Steeve Kerou via Python-list
Hi, We develop Pyto - the first python class with an animated character that helps you learn the basics concepts of Python Language like you're playing video game - and we'd like it to be implemented.  Potential is limitless and can reach unlimited number of new users who will the

Re: for convenience

2022-03-24 Thread Avi Gross via Python-list
other choices. Python made lots of choices early on and then tried to graft on ever more features, sometimes well and sometimes not optimally. The same is true for so many other languages. A carefully designed new language built now might analyze and make changes. I would even argue that a new

Re: for convenience

2022-03-24 Thread Avi Gross via Python-list
Chris: > No, I would say that a preprocessor of that sort isn't necessary to a > Python-like language. If you really want one, it's honestly not that > hard to do; remember, "preprocessor" means that it processes the > source code before the main language sees it

Re: for convenience

2022-03-24 Thread Avi Gross via Python-list
s like [~* and so on with no real relationship to the language being employed. You can often write code using an identical regular expression and use it with functions in Python, Perl, R, C++ and lots of other languages. Similarly, the printf() family has a guiding string that uses symbols like

Re: for convenience

2022-03-24 Thread Avi Gross via Python-list
Yes, Chris, you can do all kinds of useful things in Python and I can not make much of a case for requiring a pre-processor. The main reason would be to make code that interprets faster or produces a smaller file of Python commands. All I was saying was that there might be a scenario where a

Re: How to detect an undefined method?

2022-03-27 Thread Kirill Ratkin via Python-list
Hi You can get all methods of your object and check the method you want to call is there or not. |methods = [method for method in dir() if callable(getattr(, method))] if 'method_you_need' in methods: . // BR | 27.03.2022 12:24, Manfred Lotz пишет: Let's say I have a Pyth

Re: How to detect an undefined method?

2022-03-27 Thread Kirill Ratkin via Python-list
And neither 'mypy --strict' or 'pyre' can find such error. I guess there  is not warranty to detect such sitations in huge codebase. It's python dynamic nature. May be dynamic checkers can help in such situations ... 27.03.2022 20:07, Manfred Lotz пишет: On 3/27/22 18:

Re: How to detect an undefined method?

2022-03-27 Thread Avi Gross via Python-list
The question seems to be how or whether you can check Python code in advance for any instances of a method for an object being called that is not instantiated. Right? As Kirill points out, Python can be quite dynamic. I can think of oodles of ways checking would not work well in a static

Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-28 Thread Cecil Westerhof via Python-list
ntu for servers is that Ubuntu wants to be up to date. So Ubuntu starts very close to Debian security wise, but will shift rapidly. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list

Re: calling a function asynchronously

2022-03-30 Thread Kirill Ratkin via Python-list
; > asyncio.run(long()) > print('after asyncio.run') > > The final print does not come out until after long() completes. > > Is there any way to do this? > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: calling a function asynchronously

2022-03-30 Thread Kirill Ratkin via Python-list
19:10, Larry Martell пишет: import asyncio import time async def long(): for i in range(100): time.sleep(10) asyncio.run(long()) print('after asyncio.run') -- https://mail.python.org/mailman/listinfo/python-list

Re: calling a function asynchronously

2022-03-30 Thread Kirill Ratkin via Python-list
Hi 30.03.2022 21:44, Larry Martell пишет: On Wed, Mar 30, 2022 at 2:40 PM Kirill Ratkin via Python-list wrote: Hi again, I changed a bit your example and it works as you expected I hope. import asyncio async def long(): for i in range(100): await asyncio.sleep(10

Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-31 Thread Cecil Westerhof via Python-list
"Peter J. Holzer" writes: > On 2022-03-28 15:35:07 +0200, Cecil Westerhof via Python-list wrote: >> "Loris Bennett" writes: >> > Ubuntu is presumably relying on the Debian security team as well as >> > other volunteers and at least one compan

Temporally disabling buffering

2022-03-31 Thread Cecil Westerhof via Python-list
In Python when the output of a script is going to a pipe stdout is buffered. When sending output to tee that is very inconvenient. We can set PYTHONUNBUFFERED, but then stdout is always unbuffered. On Linux we can do: PYTHONUNBUFFERED=T script.py | tee script.log Now the output is only

Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-31 Thread Cecil Westerhof via Python-list
rd policy (there are exceptions) on most distros is to stay with > the same version of any package for the entire lifetime. So for example, > Ubuntu 20.04 was released with Apache 2.4.41 and Python 3.8.10 and > Debian 11 was released with Apache 2.4.53 and Python 3.9.2 and they are > still o

Re: dict.get_deep()

2022-04-03 Thread Kirill Ratkin via Python-list
ething like this instead? data.get_deep("users", 0, "address", "street") and also, instead of this try: result = data["users"][0]["address"]["street"] except KeyError, IndexError: result = "second star" write this: data.get_deep("users", 0, "address", "street", default="second star") ? -- https://mail.python.org/mailman/listinfo/python-list

Re: dict.get_deep()

2022-04-03 Thread Kirill Ratkin via Python-list
and also, instead of this try: result = data["users"][0]["address"]["street"] except KeyError, IndexError: result = "second star" write this: data.get_deep("users", 0, "address", "street", default="second star") ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Sharing part of a function

2022-04-03 Thread Cecil Westerhof via Python-list
Betty Hollinshead writes: > "Memoising" is the answer -- see "Python Algorithms" by Magnus Lie Hetland. > In the mean time, here a simplified version of "memoising" using a dict. > This version handles pretty large fibonacci numbers! > > # fibonac

Re: dict.get_deep()

2022-04-03 Thread Avi Gross via Python-list
ult)and a value passed back up the chain. For any errors alongthe way, the default would be returned. Is this closer to the spirit of the request? I view this versionof nested dictionaries as a sort of tree structure with variablebranches along the way. So an approach like this could makesense

Re: dict.get_deep()

2022-04-04 Thread Kirill Ratkin via Python-list
Hello, Yes, I misunderstood as well because started to think about pattern matching which is good but this is not subject the question was about. Sorry for my mistake. Because question was about 'builtin' function which means stdlib function implemented in python itself or

Re: dict.get_deep()

2022-04-04 Thread Avi Gross via Python-list
ns offered. -Original Message- From: Kirill Ratkin via Python-list To: [email protected] Sent: Mon, Apr 4, 2022 3:40 am Subject: Re: dict.get_deep() Hello, Yes, I misunderstood as well because started to think about pattern matching which is good but this is not subject the question

Re: Sharing part of a function

2022-04-07 Thread Cecil Westerhof via Python-list
cursive': return rec(n) raise ValueError(f'Got a wrong function implementation type: {type}') -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list

Making a Python program into an executable file

2022-04-11 Thread Brian Wagstaff via Python-list
Dear Python team, I am trying to find out how to make my Python programs into executable files (.exe, I presume) using Pyinstaller. I searched on line for how to do this (the document I came across is headed Data to Fish), and it seemed that Step 1 was to download the most recent version of

Functionality like local static in C

2022-04-14 Thread Cecil Westerhof via Python-list
the variable does not have the default value, but the value it had when the function returned. Does python has something like that? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-14 Thread Jon Ribbens via Python-list
'day' it means '86400 seconds'. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-14 Thread Jon Ribbens via Python-list
On 2022-04-14, MRAB wrote: > On 2022-04-14 16:22, Jon Ribbens via Python-list wrote: >> On 2022-04-14, Paul Bryan wrote: >>> I think because minutes and hours can easily be composed by multiplying >>> seconds. days is separate because you cannot compose days from se

Re: Functionality like local static in C

2022-04-15 Thread Cecil Westerhof via Python-list
r example to 43), > the next time the function is called the variable does not have the > default value, but the value it had when the function returned. > Does python has something like that? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof --

Re: code confusion

2022-04-15 Thread Avi Gross via Python-list
sed something like howMany and verified the number was an integer larger than 0. As for getting the second largest number, there is nothing wrong with determining it the hard way. Of course for some people, it is more intuitive to sort the uniqued data and simply choose the 2nd entry from the e

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Peter J. Holzer wrote: > On 2022-04-14 15:22:29 -, Jon Ribbens via Python-list wrote: >> On 2022-04-14, Paul Bryan wrote: >> > I think because minutes and hours can easily be composed by multiplying >> > seconds. days is separate because you canno

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Jon Ribbens wrote: > On 2022-04-16, Peter J. Holzer wrote: >> Python missed the switch to DST here, the timezone is wrong. > > Because you didn't let it use any timezone information. You need to > either use the third-party 'pytz' module, or in Py

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Peter J. Holzer wrote: > On 2022-04-16 13:47:32 -, Jon Ribbens via Python-list wrote: >> That's impossible unless you redefine 'timedelta' from being, as it is >> now, a fixed-length period of time, to instead being the difference >> bet

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-16 Thread Jon Ribbens via Python-list
On 2022-04-16, Peter J. Holzer wrote: > On 2022-04-16 14:22:04 -, Jon Ribbens via Python-list wrote: >> On 2022-04-16, Jon Ribbens wrote: >> > On 2022-04-16, Peter J. Holzer wrote: >> >> Python missed the switch to DST here, the timezone is wrong. >> >

Re: How do I make a video animation with transparent background?

2016-08-09 Thread Dale Marvin via Python-list
Python world is Vapoursynth: <https://github.com/vapoursynth/vapoursynth> <http://www.vapoursynth.com/doc/index.html> I runs with Cython and generally pipes to something like ffmpeg which creates the final video file so it may be a more complex than you want but it is capable of th

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread Larry Hudson via Python-list
tonk style piano, Ira Ironstrings (don't know real name) played banjo.] -- -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list

<    35   36   37   38   39   40   41   42   43   44   >