walrus with a twist :+= or ...

2021-10-27 Thread Avi Gross via Python-list
I realized that the person seeking completeness in Python may next ask why the Walrus operator, :=, is not properly extended to include a whole assortment of allowed assignment operators I mean in normal python programs you are allowed to abbreviate x = x + 5 with x += 5 Similar

RE: walrus with a twist :+= or ...

2021-10-27 Thread Avi Gross via Python-list
I just realized I left out **= so my apologies. Are there other such abbreviations and does anyone use them? -Original Message- From: Python-list On Behalf Of Avi Gross via Python-list Sent: Wednesday, October 27, 2021 8:57 PM To: [email protected] Subject: walrus with a twist

RE: walrus with a twist :+= or ...

2021-10-27 Thread Avi Gross via Python-list
Wednesday, October 27, 2021 9:11 PM To: Python Subject: Re: walrus with a twist :+= or ... On Thu, Oct 28, 2021 at 11:58 AM Avi Gross via Python-list wrote: > On a serious note, if it was ever considered a good idea, what would > be an acceptable sequence of symbols that might not b

RE: walrus with a twist :+= or ...

2021-10-27 Thread Avi Gross via Python-list
we got along fine before a walrus came along, ... or did we? -Original Message- From: Python-list On Behalf Of MRAB Sent: Wednesday, October 27, 2021 9:21 PM To: [email protected] Subject: Re: walrus with a twist :+= or ... On 2021-10-28 02:06, Avi Gross via Python-list wrote: >

Re: New assignmens ...

2021-10-28 Thread Jon Ribbens via Python-list
On 2021-10-28, Paul Rubin wrote: > Chris Angelico writes: >> But it all depends on the exact process being done, which is why I've >> been asking for real examples. > > My most frequent use case for walrus is so common that I have sometimes > implemented a special class for it: > >if g := re.

RE: Re: The task is to invent names for things

2021-10-28 Thread Avi Gross via Python-list
Names can be taken too far as the same variable may have different connotations in one place than another. Say I am counting how many of something and incrementing variable HowMany as I go along and initialized to zero. Then I want to test if I have any and instead of: if (HowMany > 0) I

RE: New assignmens ...

2021-10-28 Thread Avi Gross via Python-list
Antoon, You keep beating a dead horse. NOBODY denies there are benefits to suggestions like the one we are describing. It is a logical fallacy to keep arguing this way. And nobody (meaning me) suggests costs are a dominant factor in decisions no matter the benefits. The realistic suggest

RE: walrus with a twist :+= or ...

2021-10-28 Thread Avi Gross via Python-list
ything like I am describing (or something much better) is being looked at? -Original Message- From: Python-list On Behalf Of Peter J. Holzer Sent: Thursday, October 28, 2021 5:08 AM To: [email protected] Subject: Re: walrus with a twist :+= or ... On 2021-10-27 22:15:09 -0400, Avi

RE: The task is to invent names for things

2021-10-28 Thread Avi Gross via Python-list
Stefan, I choose not to get involved in a discussion about arbitrary naming rules as many languages and programmers have their own ideas and preferences and rules. My examples were EXAMPLES and the actual names are irrelevant. Feel free not to use them and I assure you I have no plans to either

RE: walrus with a twist :+= or ...

2021-10-28 Thread Avi Gross via Python-list
, that should do even on standard keyboards. ∴ -Original Message- From: Python-list On Behalf Of Chris Angelico Sent: Thursday, October 28, 2021 3:24 PM To: Python Subject: Re: walrus with a twist :+= or ... On Fri, Oct 29, 2021 at 5:53 AM Avi Gross via Python-list wrote: > Is ther

Re: Get a Joke in Python

2021-10-28 Thread Jon Ribbens via Python-list
On 2021-10-28, Greg Ewing wrote: > On 29/10/21 11:34 am, Chris Angelico wrote: >> On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse >> wrote: >>> QA engineer walks into a bar. Orders a beer. Orders 0 beers. >>> Orders 9 beers. Orders a lizard. Orders -1 beers. >>> Orders a sfdeljknesv.

RE: New assignmens ...

2021-10-29 Thread Avi Gross via Python-list
29, 2021 10:04 AM To: [email protected] Subject: Re: New assignmens ... Op 28/10/2021 om 19:36 schreef Avi Gross via Python-list: > Now for a dumb question. Many languages allow a form of setting a variable to > a value like: > > > > assign(var, 5+sin(x))

RE: How to apply a self defined function in Pandas

2021-10-31 Thread Avi Gross via Python-list
When people post multiple comments and partial answers and the reply every time is to ask for more; there may be a disconnect. Some assume that the person is just stuck but generally can go forward with a little hint. But when you keep being asked for more, maybe it means they want you to do it

Problem with concatenating two dataframes

2021-11-06 Thread Mahmood Naderan via Python-list
In the following code, I am trying to create some key-value pairs in a dictionary where the first element is a name and the second element is a dataframe. # Creating a dictionary data = {'Value':[0,0,0]} kernel_df = pd.DataFrame(data, index=['M1','M2','M3']) dict = {'dummy':kernel_df} # dummy  -

Re: Problem with concatenating two dataframes

2021-11-06 Thread Mahmood Naderan via Python-list
>Try this instead: > > >    dict[name] = pd.concat([dict[name], values]) OK. That fixed the problem, however, I see that they are concatenated vertically. How can I change that to horizontal? The printed dictionary in the end looks like {'dummy': Value M1  0 M2  0 M3  0, 'K1':

Re: Problem with concatenating two dataframes

2021-11-06 Thread Mahmood Naderan via Python-list
>The second argument of pd.concat is 'axis', which defaults to 0. Try >using 1 instead of 0. Unfortunately, that doesn't help... dict[name] = pd.concat( [dict[name],values], axis=1 ) {'dummy': Value M1  0 M2  0 M3  0, 'K1':Value  Value 0   10.0NaN 15.0NaN 2  

Breaking new relic format on a new line character in FileHandler appender

2021-11-10 Thread Vijay Karavadra via Python-list
Hello Team, I'm trying to add logs in the new relic platform from a python application. For that, I've to add logs in a local file in a specific format which is '{"log.level":"%(levelname)s", "log.entity.name":"my-service-name", "message":"%(message)s"}' This works fine in normal scenario and g

Re: Avoid nested SIGINT handling

2021-11-10 Thread Jon Ribbens via Python-list
On 2021-11-10, Paulo da Silva wrote: > Hi! > > How do I handle a SIGINT (or any other signal) avoid nesting? I don't think you need to. Python will only call signal handlers in the main thread, so a handler can't be executed while another handler is running anyway. -- https://mail.python.org/mai

Re: Avoid nested SIGINT handling

2021-11-13 Thread Mladen Gogala via Python-list
On Thu, 11 Nov 2021 17:22:15 +1100, Chris Angelico wrote: > Threads aren't the point here - signals happen immediately. Actually, signals are not delivered immediately. Signals are delivered the next time the process gets its turn on CPU. The process scheduler will make process runnable and the

Returning the index of a row in dataframe

2021-11-14 Thread Mahmood Naderan via Python-list
Hi In the following dataframe, I want to get the index string by specifying the row number which is the same as value column. Value     global loads   0     global stores  1     local loads    2 For example, `df.iloc[1].index.name` should return "global store

Re: Returning the index of a row in dataframe

2021-11-14 Thread Mahmood Naderan via Python-list
>>> df.iloc[1].name Correct I also see that 'df.index[1]' works fine. Thanks. Regards, Mahmood -- https://mail.python.org/mailman/listinfo/python-list

Using astype(int) for strings with thousand separator

2021-11-14 Thread Mahmood Naderan via Python-list
Hi While reading a csv file, some cells have values like '1,024' which I mean they contains thousand separator ','. Therefore, when I want to process them with   row = df.iloc[0].astype(int) I get the following error   ValueError: invalid literal for int() with base 10: '1,024' How can I fi

Re: Using astype(int) for strings with thousand separator

2021-11-15 Thread Mahmood Naderan via Python-list
> (see > https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html) Got it. Thanks. Regards, Mahmood -- https://mail.python.org/mailman/listinfo/python-list

Re: Proliferation of Python packaging formats

2021-11-17 Thread Jon Ribbens via Python-list
On 2021-11-17, Skip Montanaro wrote: > Is the proliferation of packaging formats in Python as nutzo as this author > believes? > > https://drewdevault.com/2021/11/16/Python-stop-screwing-distros-over.html > > Asking because I've never been in the business of releasing "retail" Python > application

get_axes not present?

2021-11-18 Thread Mahmood Naderan via Python-list
Hi I am using the following versions >>> import matplotlib >>> print(matplotlib. __version__) 3.3.4 >>> import pandas as pd >>> print(pd.__version__) 1.2.3 >>> import sys >>> sys.version_info sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0) In my code, I use axes in

Re: get_axes not present?

2021-11-18 Thread Mahmood Naderan via Python-list
>It's not saying get_axes doesn't exist because of version skew, it's >saying that the object returned by the call to the left of it >(get_figure()) returned None, and None doesn't have methods > >Something isn't set up right, but you'll have to trace that through. Do you think the following

Re: get_axes not present?

2021-11-19 Thread Mahmood Naderan via Python-list
>And what is the result of plot()?  Is it a valid object, or is it None? Well the error happens on the plot() line. I tried to print some information like this:     print("axes=", axes)     print("axes[0]=", axes[0])     print("cnt=", cnt)     print("row=", row)     ax1 = row.plot( fontsize=fon

RE: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Avi Gross via Python-list
This discussion gets tiresome for some. Mathematics is a pristine world that is NOT the real world. It handles near-infinities fairly gracefully but many things in the real world break down because our reality is not infinitely divisible and some parts are neither contiguous nor fixed but in some

RE: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Avi Gross via Python-list
g Subject: Re: Unexpected behaviour of math.floor, round and int functions (rounding) On Sun, Nov 21, 2021 at 8:32 AM Avi Gross via Python-list wrote: > > This discussion gets tiresome for some. > > Mathematics is a pristine world that is NOT the real world. It handles > near-infinit

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Rob Cliffe via Python-list
On 20/11/2021 22:59, Avi Gross via Python-list wrote: there are grey lines along the way where some mathematical proofs do weird things like IGNORE parts of a calculation by suggesting they are going to zero much faster than other parts and then wave a mathematical wand about what happens when

RE: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Avi Gross via Python-list
Can I suggest a way to look at it, Grant? In base 10, we represent all numbers as the (possibly infinite) sum of ten raised to some integral power. 123 is 3 times 1 (ten to the zero power) plus 2 times 10 (ten to the one power) plus 1 times 100 (ten to the two power) 123.456 just extends this wi

RE: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Avi Gross via Python-list
not expected to apply for a non-abelian case. -Original Message- From: Python-list On Behalf Of Rob Cliffe via Python-list Sent: Saturday, November 20, 2021 6:19 PM To: Subject: Re: Unexpected behaviour of math.floor, round and int functions (rounding) On 20/11/2021 22:59, Avi Gross

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Rob Cliffe via Python-list
On 21/11/2021 01:02, Chris Angelico wrote: If you have a number with a finite binary representation, you can guarantee that it can be represented finitely in decimal too. Infinitely repeating expansions come from denominators that are coprime with the numeric base. Not quite, e.g. 1/14 is

RE: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Avi Gross via Python-list
om: Python-list On Behalf Of Chris Angelico Sent: Saturday, November 20, 2021 6:23 PM To: [email protected] Subject: Re: Unexpected behaviour of math.floor, round and int functions (rounding) On Sun, Nov 21, 2021 at 10:01 AM Avi Gross via Python-list wrote: > Computers generally

RE: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Avi Gross via Python-list
- From: Python-list On Behalf Of Chris Angelico Sent: Saturday, November 20, 2021 8:03 PM To: [email protected] Subject: Re: Unexpected behaviour of math.floor, round and int functions (rounding) On Sun, Nov 21, 2021 at 11:39 AM Avi Gross via Python-list wrote: > > Can I suggest a

Re: get_axes not present?

2021-11-21 Thread Mahmood Naderan via Python-list
>The best way to get >assistance here on the list is to create a minimal, self-contained, >run-able, example program that you can post in its entirety here that >demonstrates the issue. I created a sample code with input. Since the code processes a csv file to group input rows, I also included t

Re: get_axes not present?

2021-11-21 Thread Mahmood Naderan via Python-list
>I installed the latest pandas, although on Python 3.10, and the script >worked without a problem. Yes as I wrote it works with 1.3.3 but mine is 1.2.3. I am trying to keep the current version because of the possible future consequences. In the end maybe I have to upgrade the pandas. Regards,

Re: get_axes not present?

2021-11-21 Thread Mahmood Naderan via Python-list
>Your example isn't minimal enough for me to be able to pin it down any >better than that, though. Chris, I was able to simply it even further. Please look at this: $ cat test.batch.csv Value,Value 10,2 5,2 10,2 $ cat test.py import pandas as pd import csv,sys import matplotlib import matplot

About get_axes() in Pandas 1.2.3

2021-11-22 Thread Mahmood Naderan via Python-list
Hi I asked a question some days ago, but due to the lack of minimal producing code, the topic got a bit messy. So, I have decided to ask it in a new topic with a clear minimum code. With Pandas 1.2.3 and Matplotlib 3.3.4, the following plot() functions returns error and I don't know what is wr

Re: copy.copy

2021-11-22 Thread Jon Ribbens via Python-list
On 2021-11-22, ast wrote: > Hi, > > >>> a = 6 > >>> b = 6 > >>> a is b > True > > ok, we all know that Python creates a sole instance > with small integers, but: > > >>> import copy > >>> b = copy.copy(a) > >>> a is b > True > > I was expecting False Why did you expect False? For immutable types

Re: About get_axes() in Pandas 1.2.3

2021-11-22 Thread Mahmood Naderan via Python-list
>I can help you narrow it down a bit. The problem actually occurs inside >this function call somehow. You can verify this by doing this: > > >fig,axes = plt.subplots(2,1, figsize=(20, 15)) > >print ("axes[0].get_figure()=",axes[0].get_figure()) > >You'll find that get_figure() is returning None, wh

RE: pyinstaller wrong classified as Windows virus

2021-11-25 Thread Avi Gross via Python-list
I am not sure what your real problem is, Ulli, but many antivirus programs can be TEMPORARILY shut off. Not highly recommended, of course, but if you properly disable it on a newly rebooted system running little, and it still happens, then something else may be going on. If one recognizes your cod

Re: Negative subscripts

2021-11-26 Thread Rob Cliffe via Python-list
You could evaluate y separately: yval = for item in x[:-yval] if yval else x:     [do stuff] or you could do it using the walrus operator: for item in x[:-yval] if (yval := ) else x:     [do stuff] or, perhaps simplest, you could do for item in x[:-y or None]: # a value of None for a slice a

Re: pyinstaller wrong classified as Windows virus

2021-11-28 Thread Tony Flury via Python-list
Have you tried using Nuitka - rather than pyInstalller - it means you distribute a single executable and the Python run time library (which they probably have already), and it has the advantage that it is a bit quicker than standard python. Rather than bundle the source code and interpreter in

Python child process in while True loop blocks parent

2021-11-29 Thread Jen Kris via Python-list
I have a C program that forks to create a child process and uses execv to call a Python program.  The Python program communicates with the parent process (in C) through a FIFO pipe monitored with epoll().  The Python child process is in a while True loop, which is intended to keep it running w

Re: Python child process in while True loop blocks parent

2021-11-29 Thread Jen Kris via Python-list
hat's nonblocking by default.  The child will become more complex, but not in a way that affects polling.  And thanks for the tip about the c-string termination.  Nov 29, 2021, 14:12 by [email protected]: > > >> On 29 Nov 2021, at 20:36, Jen Kris via Python-list >&

Re: Python child process in while True loop blocks parent

2021-12-01 Thread Jen Kris via Python-list
useful to understand in detail what is behind os.open(). > > Barry > > > > >> >> >> Nov 29, 2021, 14:12 by >> [email protected]>> : >> >>> >>> >>>> On 29 Nov 2021, at 20:36, Jen Kris via Python-list <>>&g

Re: A decade or so of Python programming, and I've never thought to "for-elif"

2021-12-01 Thread Rob Cliffe via Python-list
If for ... else was spelt more intelligibly, e.g. for ... nobreak, there would be no temptation to use anything like `elif'. `nobreakif' wouldn't be a keyword. Rob Cliffe On 30/11/2021 06:24, Chris Angelico wrote: for ns in namespaces: if name in ns: print("Found!") brea

ANN: A new library for encryption and signing has been released.

2021-12-05 Thread Vinay Sajip via Python-list
A new library called pagesign (Python-age-sign) has been released on PyPI [1]. It covers similar functionality to python-gnupg, but uses the modern encryption tool age [2] and the modern signing tool minisign [3]. The initial release allows you to: * Create and manage identities (which are conta

Re: Python child process in while True loop blocks parent

2021-12-05 Thread Jen Kris via Python-list
e opened as rdwr in Python because that's >>>> nonblocking by default.  The child will become more complex, but not in a >>>> way that affects polling.  And thanks for the tip about the c-string >>>> termination.  >>>> >>>> >&g

Re: Python child process in while True loop blocks parent

2021-12-05 Thread Jen Kris via Python-list
gt;> >>> Barry >>> >>> >>> >>>> >>>> >>>> >>>> Nov 30, 2021, 11:42 by >>>> [email protected]>>>> : >>>> >>>>> >>>>> >>>>> >>>>>> On 29 Nov 202

python list files and folder using tkinter

2021-12-05 Thread Pascal B via Python-list
Hello, I have already posted a message some time ago for this app. Since then, I didn't code in python or made any changes. I think before getting further with functionnalities a few things or the whole thing need to be changed. For exemple, it would need a button to pick folders and maybe ask if

Re: Python child process in while True loop blocks parent

2021-12-06 Thread Jen Kris via Python-list
t;).  You may be confused by the fact that threads are called light-weight processes.  Or maybe I'm confused :) If you have other information, please let me know.  Thanks.  Jen Dec 5, 2021, 18:08 by [email protected]: > On 2021-12-06 00:51:13 +0100, Jen Kris via Python-list wrote: >

Re: Python child process in while True loop blocks parent

2021-12-06 Thread Jen Kris via Python-list
@barrys-emacs.org: > > >> On 6 Dec 2021, at 17:09, Jen Kris via Python-list >> wrote: >> >> I can't find any support for your comment that "Fork creates a new >> process and therefore also a new thread." From the Linux man pages >> htt

Re: Return

2021-12-07 Thread Roland Mueller via Python-list
Hello ti 7. jouluk. 2021 klo 19.47 vani arul ([email protected]) kirjoitti: > Hey There, > Can someone help to understand how a python function can return value with > using return in the code? > It is not not about explicit or implicit function call. > > Not sure whether I understood your que

Re: HTML extraction

2021-12-07 Thread Roland Mueller via Python-list
Hello, ti 7. jouluk. 2021 klo 20.08 Chris Angelico ([email protected]) kirjoitti: > On Wed, Dec 8, 2021 at 4:55 AM Julius Hamilton > wrote: > > > > Hey, > > > > Could anyone please comment on the purest way simply to strip HTML tags > > from the internal text they surround? > > > > I know Beautif

Re: Python child process in while True loop blocks parent

2021-12-08 Thread Jen Kris via Python-list
I started this post on November 29, and there have been helpful comments since then from Barry Scott, Cameron Simpson, Peter Holzer and Chris Angelico.  Thanks to all of you.  I've found a solution that works for my purpose, and I said earlier that I would post the solution I found. If anyone

ANN: distlib 0.3.4 released on PyPI

2021-12-08 Thread Vinay Sajip via Python-list
I've recently released version 0.3.4 of distlib on PyPI [1]. For newcomers, distlib is a library of packaging functionality which is intended to be usable as the basis for third-party packaging tools. The main changes in this release are as follows: * Fixed #153: Raise warnings in get_distributio

Re: Short, perfect program to read sentences of webpage

2021-12-08 Thread Jon Ribbens via Python-list
On 2021-12-08, Julius Hamilton wrote: > 1. The HTML extraction is not perfect. It doesn’t produce as clean text as > I would like. Sometimes random links or tags get left in there. And the > sentences are sometimes randomly broken by newlines. Oh. Leaving tags in suggests you are doing this very

Re: Return

2021-12-09 Thread Roland Müller via Python-list
Hello, On 12/8/21 11:29, vani arul wrote: Thanks for your help. I am not good at programming.My code works perfectly.But I am bit confused about the return values. Binary Search Program /def Binarysearch(a,key):     l=0     r=len(a)-1     while l<=r:     med = (l+r)//2     if key==a

Isn't TypeError built in?

2021-12-12 Thread Mike Dewhirst via Python-list
Obviously something is wrong elsewhere but I'm not sure where to look. Ubuntu 20.04 with plenty of RAM.     def __del__(self):     try:     for context_obj in self._context_refs:     try:     delattr(context_obj, self._attr_name)     except Att

Re: Isn't TypeError built in?

2021-12-13 Thread Mike Dewhirst via Python-list
On 13/12/2021 12:42 pm, Chris Angelico wrote: On Mon, Dec 13, 2021 at 12:31 PM Mike Dewhirst via Python-list wrote: Obviously something is wrong elsewhere but I'm not sure where to look. Ubuntu 20.04 with plenty of RAM. def __del__(self): try: for context_o

Re: Advanced ways to get object information from within python

2021-12-23 Thread Robert Latest via Python-list
Julius Hamilton wrote: > dir(scrapy) shows this: > > ['Field', 'FormRequest', 'Item', 'Request', 'Selector', 'Spider', > '__all__', '__builtins__', '__cached__', '__doc__', '__file__', > '__loader__', '__name__', '__package__', '__path__', '__spec__', > '__version__', '_txv', 'exceptions', 'http',

Re: Isn't TypeError built in?

2021-12-25 Thread Mike Dewhirst via Python-list
Isn't TypeError built in? On 2021-12-13 12:22:28 +1100, Mike Dewhirst via Python-list wrote:> Obviously something is wrong elsewhere but I'm not sure where to look.> Ubuntu 20.04 with plenty of RAM.[...]> [Mon Dec 13 01:15:49.885659 2021] [mpm_event:notice] [pid 1033:tid> 140

RE: recover pickled data: pickle data was truncated

2021-12-29 Thread Avi Gross via Python-list
I am not an expert on the topic but my first reaction is it depends on how the data is corrupted and we do not know that. So I am addressing a more general concept here. Some algorithms break if a single byte or even bit changes and nothing beyond that point makes sense. Many encryption techniques

RE: builtins.TypeError: catching classes that do not inherit from BaseException is not allowed

2021-12-30 Thread Avi Gross via Python-list
Beauty of Recursion? Well, there is what I call Mathematical Beauty, and then there is reality. It is fantastic to prove neat theorems that something is possible by methods like mathematical induction that in some sense use recursion as in if something is true for some base value and it can be sh

RE: builtins.TypeError: catching classes that do not inherit from BaseException is not allowed

2021-12-31 Thread Avi Gross via Python-list
I am sure some people have a sense of humor, but anyone on this forum who actually does not have some idea of what various "tree" data structures are in computer science, probably won't get any replies from me when asking such questions. But indeed there are things closer to classical trees that a

Re: What to write or search on github to get the code for what is written below:

2022-01-07 Thread Avi Gross via Python-list
This entire thread seems a bit IFFY to me. It does seme like HW to me but also a bit peripheral. The fact that the data is in EXCEL is a detail. And unless a spreadheet is complex, it may be trivial to save the file as a .CSV and from then on read from there into Python (or anything) and when don

Extracting dataframe column with multiple conditions on row values

2022-01-07 Thread Mahmood Naderan via Python-list
Hi I have a csv file like this V0,V1,V2,V3 4,1,1,1 6,4,5,2 2,3,6,7 And I want to search two rows for a match and find the column. For example, I want to search row[0] for 1 and row[1] for 5. The corresponding column is V2 (which is the third column). Then I

Re: Extracting dataframe column with multiple conditions on row values

2022-01-08 Thread Avi Gross via Python-list
on row values Il giorno sabato 8 gennaio 2022 alle 02:21:40 UTC+1 dn ha scritto: > Salaam Mahmood, > On 08/01/2022 12.07, Mahmood Naderan via Python-list wrote: > > I have a csv file like this > > V0,V1,V2,V3 > > 4,1,1,1 > > 6,4,5,2 > > 2,3,6,7 > > >

Re: What to write or search on github to get the code for what is written below:

2022-01-09 Thread Avi Gross via Python-list
Is this thread even close to being on track? It is not really relevant to argue yet on whether to use EXCEL directly or a data.base. Many ways can be used to solve a problem and if the EXCEL sheet will never be updated manually or by some other program, it is sort of moot as you can ONE TIME tra

Re: What to write or search on github to get the code for what is written below:

2022-01-13 Thread Avi Gross via Python-list
I am not replying to anything below so I have removed it. So I need to remind people of the topic and how it has wandered. Someone has data in a not particularly great format in an EXCEL spreadsheet. They want to somehow use an external language like Python to manipulate the contents from outsid

Re: keep getting a syntax error on the very first program I am running

2022-01-14 Thread Jon Ribbens via Python-list
On 2022-01-15, Bob Griffin wrote: >I am running this program and keep getting this error. Is this normal? > >Invalid syntax. Perhaps you forgot a comma? > >Also the t in tags is highlighted. > >I even tried different versions of Python also. > >Python 3.10.1 (tags/v3.10.1:2cd

Writing a string with comma in one column of CSV file

2022-01-15 Thread Mahmood Naderan via Python-list
Hi, I use the following line to write some information to a CSV file which is comma delimited. f = open(output_file, 'w', newline='') wr = csv.writer(f) ... f.write(str(n) + "," + str(key) + "\n" ) Problem is that key is a string which may contain ',' and this causes the final CSV file to have

Re: What to write or search on github to get the code for what is written below:

2022-01-15 Thread Avi Gross via Python-list
To: [email protected] Sent: Sat, Jan 15, 2022 3:05 pm Subject: Re: What to write or search on github to get the code for what is written below: On 1/13/22 16:08, Avi Gross via Python-list wrote: > > I am not replying to anything below so I have removed it. > Instead, someone sug

Re: Writing a string with comma in one column of CSV file

2022-01-15 Thread Mahmood Naderan via Python-list
Right. I was also able to put all columns in a string and then use writerow(). Thanks. Regards, Mahmood On Saturday, January 15, 2022, 10:33:08 PM GMT+1, alister via Python-list wrote: On Sat, 15 Jan 2022 20:56:22 + (UTC), Mahmood Naderan wrote: > Hi, > I use the fol

Re: Writing a string with comma in one column of CSV file

2022-01-15 Thread Avi Gross via Python-list
st a thought. If you like your way, fine, I see another reply suggesting how to hide the commas but that can be a problem if humans read and edit the results in the external file and do not follow through. -Original Message- From: Mahmood Naderan via Python-list To: DL Neil via Python-

Re: What to write or search on github to get the code for what is written below:

2022-01-17 Thread Avi Gross via Python-list
I can appreciate people under time pressure wanting the job DONE first and maybe learning more after. So, yes, it makes perfect sense to delegate the task to others with expertise or ask for advice. This forum may mean many things to many people but for me, it is a place to offer guidance and s

Trouble downloading Python

2022-01-18 Thread Renda Saptoe via Python-list
Good day, I am experiencing issues trying to download Python. I would please need some assistance to help download the progam to my laptop. Kind regards Renda -- https://mail.python.org/mailman/listinfo/python-list

Re: What to write or search on github to get the code for what is written below:

2022-01-18 Thread Avi Gross via Python-list
I do not manage any python lists or have any say in how they run so I have no idea why I am being asked by name below, as Dennis pointed out. So I won't reply on whatever I am being asked, but want to point out that many forums may be asked questions and some people on the forum will not respond

Puzzling behaviour of Py_IncRef

2022-01-19 Thread Tony Flury via Python-list
I am writing a C extension module for an AVL tree, and I am trying to ensure reference counting is done correctly. I was having a problem with the reference counting so I worked up this little POC of the problem, and I hope someone can explain this. Extension function : static PyObject *_N

Re: Puzzling behaviour of Py_IncRef

2022-01-19 Thread Tony Flury via Python-list
On 19/01/2022 11:09, Chris Angelico wrote: On Wed, Jan 19, 2022 at 10:00 PM Tony Flury via Python-list wrote: Extension function : static PyObject *_Node_test_ref_count(PyObject *self) { printf("\nIncrementing ref count for self - just for the hell of

"undefined symbol" in C extension module

2022-01-22 Thread Robert Latest via Python-list
Hi guys, I've written some CPython extension modules in the past without problems. Now after moving to a new Archlinux box with Python3.10 installed, I can't build them any more. Or rather, I can build them but not use them due to "undefined symbols" during linking. Here's ldd's output when used o

Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Avi Gross via Python-list
I keep wondering about the questions asked by NArshad here. His message can be read below mine, for context. This is a place focused on using the Python language. The web page being in HTML is beyond irrelevant and in particular, web pages generally are in HTML even if only as a way to call oth

Re: "undefined symbol" in C extension module

2022-01-23 Thread Robert Latest via Python-list
Dan Stromberg wrote: > Perhaps try: > https://stromberg.dnsalias.org/svn/find-sym/trunk > > It tries to find symbols in C libraries. > > In this case, I believe you'll find it in -lpythonx.ym Thanks! Found out that ldd produces many errors also with working python libraries. Turns out I tried to r

Re: Pandas or Numpy

2022-01-23 Thread Avi Gross via Python-list
Definitely it sounds like you may use both. Quite a bit of what people do using DataFrame objects includes working on copies of individual columns, which often are numpy Series or the like and in the other direction, can be used to create or amend a pandas DataFrame. Plus, many operations used t

Re: Puzzling behaviour of Py_IncRef

2022-01-25 Thread Tony Flury via Python-list
On 20/01/2022 23:12, Chris Angelico wrote: On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote: On 20/01/22 12:09 am, Chris Angelico wrote: At this point, the refcount has indeed been increased. return self; } And then you say "my return value is this object". So you're incre

Re: Puzzling behaviour of Py_IncRef

2022-01-25 Thread Tony Flury via Python-list
On 25/01/2022 22:28, Barry wrote: On 25 Jan 2022, at 14:50, Tony Flury via Python-list wrote:  On 20/01/2022 23:12, Chris Angelico wrote: On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote: On 20/01/22 12:09 am, Chris Angelico wrote: At this point, the refcount has indeed been increased

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Tony Flury via Python-list
On 26/01/2022 01:29, MRAB wrote: On 2022-01-25 23:50, Tony Flury via Python-list wrote: On 25/01/2022 22:28, Barry wrote: On 25 Jan 2022, at 14:50, Tony Flury via Python-list  wrote:  On 20/01/2022 23:12, Chris Angelico wrote: On Fri, 21 Jan 2022 at 10:10, Greg Ewing  wrote: On 20/01

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Tony Flury via Python-list
On 26/01/2022 08:20, Chris Angelico wrote: On Wed, 26 Jan 2022 at 19:04, Tony Flury via Python-list wrote: So according to that I should increment twice if and only if the calling code is using the result - which you can't tell in the C code - which is very odd behaviour. No, the r

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Tony Flury via Python-list
On 26/01/2022 22:41, Barry wrote: Run python and your code under a debugger and check the ref count of the object as you step through the code. Don’t just step through your code but also step through the C python code. That will allow you to see how this works at a low level. Setting a watc

Re: Starting using Python

2022-01-27 Thread Tony Flury via Python-list
On 03/01/2022 12:45, Joao Marques wrote: Good morning: I have a very simple question: I want to start writing programs in Python so I went to the Microsoft Store and installed Python3.9. No problem so far. I would prefer to have a gui interface, an interface that I can use file-->Open and File-

Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-01 Thread Jen Kris via Python-list
I am using multiprocesssing.shared_memory to pass data between NASM and Python.  The shared memory is created in NASM before Python is called.  Python connects to the shm:  shm_00 = shared_memory.SharedMemory(name='shm_object_00',create=False).  I have used shared memory at other points in thi

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-01 Thread Jen Kris via Python-list
ig endian.  However, if anyone on this list knows how to pass data from a non-Python language to Python in multiprocessing.shared_memory please let me (and the list) know.  Thanks.  Feb 1, 2022, 14:20 by [email protected]: > > >> On 1 Feb 2022, at 20:26, Jen Kris via Pyth

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-02 Thread Avi Gross via Python-list
I applaud trying to find the right solution but wonder if a more trivial solution is even being considered. It ignores big and little endians and just converts your data into another form and back. If all you want to do is send an integer that fit in 32 bits or 64 bits, why not convert it to a

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-02 Thread Jen Kris via Python-list
It's not clear to me from the struct module whether it can actually auto-detect endianness.  I think it must be specified, just as I had to do with int.from_bytes().  In my case endianness was dictated by how the four bytes were populated, starting with the zero bytes on the left.  Feb 1, 202

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-02 Thread Jen Kris via Python-list
An ASCII string will not work.  If you convert 32894 to an ascii string you will have five bytes, but you need four.  In my original post I showed the C program I used to convert any 32-bit number to 4 bytes.  Feb 2, 2022, 10:16 by [email protected]: > I applaud trying to find the right

Waht do you think about my repeated_timer class

2022-02-02 Thread Cecil Westerhof via Python-list
I need (sometimes) to repeatedly execute a function. For this I wrote the below class. What do you think about it? from threading import Timer class repeated_timer(object): def __init__(self, fn, interval, start = False): if not callable(fn): raise Ty

Re: Waht do you think about my repeated_timer class

2022-02-02 Thread Cecil Westerhof via Python-list
Chris Angelico writes: > On Thu, 3 Feb 2022 at 09:33, Barry wrote: > (Side point: The OP's code is quite inefficient, as it creates a new > thread for each reiteration, but there's nothing wrong with that if > you're looking for something simple.) It is just something I wrote fast. How could I

Re: Waht do you think about my repeated_timer class

2022-02-02 Thread Cecil Westerhof via Python-list
Cecil Westerhof writes: >> (regardless of your OS). The same could be done with this timer; an >> __exit__ method would make a lot of sense here, and would allow the >> timer to be used in a with block to govern its execution. (It also >> isn't really necessary, but if you want a good Pythonic wa

<    25   26   27   28   29   30   31   32   33   34   >