Re: help: pandas and 2d table

2024-04-16 Thread jak via Python-list

Stefan Ram ha scritto:

jak  wrote or quoted:

Stefan Ram ha scritto:

df = df.where( df == 'zz' ).stack().reset_index()
result ={ 'zz': list( zip( df.iloc[ :, 0 ], df.iloc[ :, 1 ]))}

Since I don't know Pandas, I will need a month at least to understand
these 2 lines of code. Thanks again.


   Here's a technique to better understand such code:

   Transform it into a program with small statements and small
   expressions with no more than one call per statement if possible.
   (After each litte change check that the output stays the same.)

import pandas as pd

# Warning! Will overwrite the file 'file_20240412201813_tmp_DML.csv'!
with open( 'file_20240412201813_tmp_DML.csv', 'w' )as out:
 print( '''obj,foo1,foo2,foo3,foo4,foo5,foo6
foo1,aa,ab,zz,ad,ae,af
foo2,ba,bb,bc,bd,zz,bf
foo3,ca,zz,cc,cd,ce,zz
foo4,da,db,dc,dd,de,df
foo5,ea,eb,ec,zz,ee,ef
foo6,fa,fb,fc,fd,fe,ff''', file=out )
# Note the "index_col=0" below, which is important here!
df = pd.read_csv( 'file_20240412201813_tmp_DML.csv', index_col=0 )

selection = df.where( df == 'zz' )
selection_stack = selection.stack()
df = selection_stack.reset_index()
df0 = df.iloc[ :, 0 ]
df1 = df.iloc[ :, 1 ]
z = zip( df0, df1 )
l = list( z )
result ={ 'zz': l }
print( result )

   I suggest to next insert print statements to print each intermediate
   value:

# Note the "index_col=0" below, which is important here!
df = pd.read_csv( 'file_20240412201813_tmp_DML.csv', index_col=0 )
print( 'df = \n', type( df ), ':\n"', df, '"\n' )

selection = df.where( df == 'zz' )
print( "result of where( df == 'zz' ) = \n", type( selection ), ':\n"',
   selection, '"\n' )

selection_stack = selection.stack()
print( 'result of stack() = \n', type( selection_stack ), ':\n"',
   selection_stack, '"\n' )

df = selection_stack.reset_index()
print( 'result of reset_index() = \n', type( df ), ':\n"', df, '"\n' )

df0 = df.iloc[ :, 0 ]
print( 'value of .iloc[ :, 0 ]= \n', type( df0 ), ':\n"', df0, '"\n' )

df1 = df.iloc[ :, 1 ]
print( 'value of .iloc[ :, 1 ] = \n', type( df1 ), ':\n"', df1, '"\n' )

z = zip( df0, df1 )
print( 'result of zip( df0, df1 )= \n', type( z ), ':\n"', z, '"\n' )

l = list( z )
print( 'result of list( z )= \n', type( l ), ':\n"', l, '"\n' )

result ={ 'zz': l }
print( "value of { 'zz': l }= \n", type( result ), ':\n"',
   result, '"\n' )

print( result )

   Now you can see what each single step does!

df =
   :
"  foo1 foo2 foo3 foo4 foo5 foo6
obj
foo1   aa   ab   zz   ad   ae   af
foo2   ba   bb   bc   bd   zz   bf
foo3   ca   zz   cc   cd   ce   zz
foo4   da   db   dc   dd   de   df
foo5   ea   eb   ec   zz   ee   ef
foo6   fa   fb   fc   fd   fe   ff "

result of where( df == 'zz' ) =
   :
"  foo1 foo2 foo3 foo4 foo5 foo6
obj
foo1  NaN  NaN   zz  NaN  NaN  NaN
foo2  NaN  NaN  NaN  NaN   zz  NaN
foo3  NaN   zz  NaN  NaN  NaN   zz
foo4  NaN  NaN  NaN  NaN  NaN  NaN
foo5  NaN  NaN  NaN   zz  NaN  NaN
foo6  NaN  NaN  NaN  NaN  NaN  NaN "

result of stack() =
   :
" obj
foo1  foo3zz
foo2  foo5zz
foo3  foo2zz
   foo6zz
foo5  foo4zz
dtype: object "

result of reset_index() =
   :
" obj level_1   0
0  foo1foo3  zz
1  foo2foo5  zz
2  foo3foo2  zz
3  foo3foo6  zz
4  foo5foo4  zz "

value of .iloc[ :, 0 ]=
   :
" 0foo1
1foo2
2foo3
3foo3
4foo5
Name: obj, dtype: object "

value of .iloc[ :, 1 ] =
   :
" 0foo3
1foo5
2foo2
3foo6
4foo4
Name: level_1, dtype: object "

result of zip( df0, df1 )=
   :
" "

result of list( z )=
   :
" [('foo1', 'foo3'), ('foo2', 'foo5'), ('foo3', 'foo2'), ('foo3', 'foo6'), ('foo5', 
'foo4')]"

value of { 'zz': l }=
   :
" {'zz': [('foo1', 'foo3'), ('foo2', 'foo5'), ('foo3', 'foo2'), ('foo3', 'foo6'), 
('foo5', 'foo4')]}"

{'zz': [('foo1', 'foo3'), ('foo2', 'foo5'), ('foo3', 'foo2'), ('foo3', 'foo6'), 
('foo5', 'foo4')]}

   The script reads a CSV file and stores the data in a Pandas
   DataFrame object named "df". The "index_col=0" parameter tells
   Pandas to use the first column as the index for the DataFrame,
   which is kinda like column headers.

   The "where" creates a new DataFrame selection that contains
   the same data as df, but with all values replaced by NaN (Not
   a Number) except for the values that are equal to 'zz'.

   "stack" returns a Series with a multi-level index created
   by pivoting the columns. Here it gives a Series with the
   row-col-addresses of a all the non-NaN values. The general
   meaning of "stack" might be the most complex operation of
   this script. It's explained in the pandas manual (see there).

   "reset_index" then just transforms this Series back into a
   DataFrame, and ".iloc[ :, 0 ]" and ".iloc[ :, 1 ]" are the
   first and second column, respectively, of that DataFrame. These
   then are zipped to get the desired form as a list of pairs.



And this is a technique very similar to reverse engineering. Thanks for
the explanation and examples. All this is really clear and I was able to
follow 

Re: help: pandas and 2d table

2024-04-16 Thread jak via Python-list

Stefan Ram ha scritto:

df = df.where( df == 'zz' ).stack().reset_index()
result ={ 'zz': list( zip( df.iloc[ :, 0 ], df.iloc[ :, 1 ]))}


Since I don't know Pandas, I will need a month at least to understand
these 2 lines of code. Thanks again.
--
https://mail.python.org/mailman/listinfo/python-list


Re: help: pandas and 2d table

2024-04-13 Thread Tim Williams via Python-list
On Sat, Apr 13, 2024 at 1:10 PM Mats Wichmann via Python-list <
python-list@python.org> wrote:

> On 4/13/24 07:00, jak via Python-list wrote:
>
> doesn't Pandas have a "where" method that can do this kind of thing? Or
> doesn't it match what you are looking for?  Pretty sure numpy does, but
> that's a lot to bring in if you don't need the rest of numpy.
>
> pandas.DataFrame.where — pandas 2.2.2 documentation (pydata.org)

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help: pandas and 2d table

2024-04-13 Thread Mats Wichmann via Python-list

On 4/13/24 07:00, jak via Python-list wrote:

Stefan Ram ha scritto:

jak  wrote or quoted:

Would you show me the path, please?


   I was not able to read xls here, so I used csv instead; Warning:
   the script will overwrite file "file_20240412201813_tmp_DML.csv"!

import pandas as pd

with open( 'file_20240412201813_tmp_DML.csv', 'w' )as out:
 print( '''obj,foo1,foo2,foo3,foo4,foo5,foo6
foo1,aa,ab,zz,ad,ae,af
foo2,ba,bb,bc,bd,zz,bf
foo3,ca,zz,cc,cd,ce,zz
foo4,da,db,dc,dd,de,df
foo5,ea,eb,ec,zz,ee,ef
foo6,fa,fb,fc,fd,fe,ff''', file=out )

df = pd.read_csv( 'file_20240412201813_tmp_DML.csv' )

result = {}

for rownum, row in df.iterrows():
 iterator = row.items()
 _, rowname = next( iterator )
 for colname, value in iterator:
 if value not in result: result[ value ]= []
 result[ value ].append( ( rowname, colname ))

print( result )



In reality what I wanted to achieve was this:

     what = 'zz'
     result = {what: []}

     for rownum, row in df.iterrows():
     iterator = row.items()
     _, rowname = next(iterator)
     for colname, value in iterator:
     if value == what:
     result[what] += [(rowname, colname)]
     print(result)

In any case, thank you again for pointing me in the right direction. I
had lost myself looking for a pandas method that would do this in a
single shot or almost.




doesn't Pandas have a "where" method that can do this kind of thing? Or 
doesn't it match what you are looking for?  Pretty sure numpy does, but 
that's a lot to bring in if you don't need the rest of numpy.



--
https://mail.python.org/mailman/listinfo/python-list


Re: help: pandas and 2d table

2024-04-13 Thread jak via Python-list

Stefan Ram ha scritto:

jak  wrote or quoted:

Would you show me the path, please?


   I was not able to read xls here, so I used csv instead; Warning:
   the script will overwrite file "file_20240412201813_tmp_DML.csv"!

import pandas as pd

with open( 'file_20240412201813_tmp_DML.csv', 'w' )as out:
 print( '''obj,foo1,foo2,foo3,foo4,foo5,foo6
foo1,aa,ab,zz,ad,ae,af
foo2,ba,bb,bc,bd,zz,bf
foo3,ca,zz,cc,cd,ce,zz
foo4,da,db,dc,dd,de,df
foo5,ea,eb,ec,zz,ee,ef
foo6,fa,fb,fc,fd,fe,ff''', file=out )

df = pd.read_csv( 'file_20240412201813_tmp_DML.csv' )

result = {}

for rownum, row in df.iterrows():
 iterator = row.items()
 _, rowname = next( iterator )
 for colname, value in iterator:
 if value not in result: result[ value ]= []
 result[ value ].append( ( rowname, colname ))

print( result )



In reality what I wanted to achieve was this:

what = 'zz'
result = {what: []}

for rownum, row in df.iterrows():
iterator = row.items()
_, rowname = next(iterator)
for colname, value in iterator:
if value == what:
result[what] += [(rowname, colname)]
print(result)

In any case, thank you again for pointing me in the right direction. I
had lost myself looking for a pandas method that would do this in a
single shot or almost.


--
https://mail.python.org/mailman/listinfo/python-list


help: pandas and 2d table

2024-04-12 Thread jak via Python-list

Hi everyone.
I state that I don't know anything about 'pandas' but I intuited that
it could do what I want. I get, through the "read_excel" method, a
table similar to this:

  obj| foo1 foo2 foo3 foo4 foo5 foo6
  ---
 foo1|   aa   ab   zz   ad   ae   af
 |
 foo2|   ba   bb   bc   bd   zz   bf
 |
 foo3|   ca   zz   cc   cd   ce   zz
 |
 foo4|   da   db   dc   dd   de   df
 |
 foo5|   ea   eb   ec   zz   ee   ef
 |
 foo6|   fa   fb   fc   fd   fe   ff


And I would like to get a result similar to this:

{
'zz':[('foo1','foo3'),
  ('foo2','foo5'),
  ('foo3','foo2'),
  ('foo3','foo6'),
  ('foo5','foo4')
 ]
}

Would you show me the path, please?
Thank you in advance.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Help Needed With a Python Gaming Module

2024-04-03 Thread Thomas Passin via Python-list

On 4/3/2024 3:06 PM, WordWeaver Evangelist via Python-list wrote:

Hello everyone! It has been a l-o-n-g time -- nine years in fact --since I last 
participated on this mailing list.


[snip]

3. You are very familiar with the Jython 2 environment, which I am told is 
based on Python 2 and NOT Python 3.


Yes, Jython 2 is currently more or less even with Python 2.7.

You are presumably writing or hosting this in a java environment, and 
you may not realize that you can call Jython code from a java class 
(calling java classes from Jython code is dead simple).  For example, I 
have some java servlet classes that invoke Jython classes and call their 
methods.  If that sounds useful for your project, I can let you know how 
to do it.


[more snips...]

--
https://mail.python.org/mailman/listinfo/python-list


Help Needed With a Python Gaming Module

2024-04-03 Thread WordWeaver Evangelist via Python-list
Hello everyone! It has been a l-o-n-g time -- nine years in fact --since I last 
participated on this mailing list.

At that time, I was trying to write a door/external for my PC-ANSI, 
Macintosh-based BBS. Thanks to some of the folks here, I got it done  
although I eventually lost the module a number of years later when I left 
BBSing behind, because I assumed it to be dead.

Anyway, just recently I put my BBS back online again for the fourth time since 
1993, and I am again endeavoring to write a new python-based external -- a game 
-- for my BBS.

Before I continue, let me inform you that I am 70 years old, I am NOT a 
programmer, and I do not know any programming languages. Yes, I am a newbie, a 
noob, a greenhorn. :) So, if anyone here is willing to help me, you are going 
to need a lot of patience . like ChatGPT :)

Following the coding example of another open-source external that was written 
for my BBS, I have made some significant progress, thanks in large part to 
spending hours and hours chatting with ChatGPT over the past two days.

However, due my lack of expertise, and even though ChatGPT had me try all sorts 
of functions and codes and methods, there is one very perplexing issue which 
has prevented me from further development on my game. Even ChatGPT couldn't 
figure it out.

But before I get into the meat of the matter and waste everyone's time here, I 
need to address several questions to all of you Python brainiacs. )

Is there anyone -- or any group of someones -- amongst this noble assemblage, 
who meets all of the following qualifications:

1. You are very familiar with Mac OS 9.2.2

2. You are either moderately or very familiar with Hermes II BBS software.

3. You are very familiar with the Jython 2 environment, which I am told is 
based on Python 2 and NOT Python 3.

If you meet all three of those qualifications, then you may possibly be able to 
help me to overcome the mysterious obstacle I am now facing. Once I see what 
kind of responses I get, I will be very happy to share my nagging problem with 
you.

Thank you for taking the time to read this. Here is to hoping that my coding 
genius is out there, ready and eager to come to my aid.

Thank you in advance.

Kind regads,

Bill Kochman

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can you help me with this memoization simple example?

2024-03-31 Thread AVI GROSS via Python-list
I am not sure if it was made clear that there is a general rule in python for 
what is HASHABLE and lists are changeable while tuples are not so the latter 
can be hashed as a simple copy of a list, albeit the contents must also be 
immutable.

The memorize function uses a dictionary to store things and thus the things are 
hashed to decide how to store it in the inner representation of a dictionary 
and anything new that you want to look up in the dictionary has similar 
considerations as it is hashed to see where in the dictionary to look for it.

Of course, if you add enough overhead and the memorize function you make gets 
relatively few requests that are identical, it may not be worthwhile.

-Original Message-
From: Python-list  On 
Behalf Of MRAB via Python-list
Sent: Sunday, March 31, 2024 3:24 PM
To: python-list@python.org
Subject: Re: Can you help me with this memoization simple example?

On 2024-03-31 09:04, marc nicole wrote:
> Thanks for the first comment which I incorporated
>
> but when you say "You can't use a list as a key, but you can use a 
> tuple as a key,
> provided that the elements of the tuple are also immutable."
>
> does it mean  the result of sum of the array is not convenient to use 
> as key as I do?
> Which tuple I should use to refer to the underlying list value as you 
> suggest?
>
I was suggesting using `tuple` on the argument:

def memoize(f):
  cache = {}

  def g(*args):
  key = tuple(args[0]), args[1]

  if key not in cache:
  cache[key] = f(args[0], args[1])

  return cache[key]

  return g

> Anything else is good in my code ?
>
> Thanks
>
> Le dim. 31 mars 2024 à 01:44, MRAB via Python-list 
>  a écrit :
>
> On 2024-03-31 00:09, marc nicole via Python-list wrote:
> > I am creating a memoization example with a function that adds up
> / averages
> > the elements of an array and compares it with the cached ones to
> retrieve
> > them in case they are already stored.
> >
> > In addition, I want to store only if the result of the function
> differs
> > considerably (passes a threshold e.g. 50 below).
> >
> > I created an example using a decorator to do so, the results
> using the
> > decorator is slightly faster than without the memoization which
> is OK, but
> > is the logic of the decorator correct ? anybody can tell me ?
> >
> > My code is attached below:
> >
> >
> >
> > import time
> >
> >
> > def memoize(f):
> >  cache = {}
> >
> >  def g(*args):
> >  if args[1] == "avg":
> >  sum_key_arr = sum(list(args[0])) / len(list(args[0]))
>
> 'list' will iterate over args[0] to make a list, and 'sum' will
> iterate
> over that list.
>
> It would be simpler to just let 'sum' iterate over args[0].
>
> >  elif args[1] == "sum":
> >  sum_key_arr = sum(list(args[0]))
> >  if sum_key_arr not in cache:
> >  for (
> >  key,
> >  value,
> >  ) in (
> >  cache.items()
> >  ):  # key in dict cannot be an array so I use the
> sum of the
> > array as the key
>
> You can't use a list as a key, but you can use a tuple as a key,
> provided that the elements of the tuple are also immutable.
>
> >  if (
> >  abs(sum_key_arr - key) <= 50
> >  ):  # threshold is great here so that all
> values are
> > approximated!
> >  # print('approximated')
> >  return cache[key]
> >  else:
> >  # print('not approximated')
> >  cache[sum_key_arr] = f(args[0], args[1])
> >  return cache[sum_key_arr]
> >
> >  return g
> >
> >
> > @memoize
> > def aggregate(dict_list_arr, operation):
> >  if operation == "avg":
> >  return sum(list(dict_list_arr)) / len(list(dict_list_arr))
> >  if operation == "sum":
> >  return sum(list(dict_list_arr))
> >  return None
> >
> >
> > t = time.time()
> > for i in range(200, 15000):
> >  res = aggregate(list(range(i)), "avg")
> >
> > elapsed = time.time() - t
> > print(res)
> > print(elapsed)
>
>
> -- 
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can you help me with this memoization simple example?

2024-03-31 Thread MRAB via Python-list

On 2024-03-31 09:04, marc nicole wrote:

Thanks for the first comment which I incorporated

but when you say "You can't use a list as a key, but you can use a 
tuple as a key,

provided that the elements of the tuple are also immutable."

does it mean  the result of sum of the array is not convenient to use 
as key as I do?
Which tuple I should use to refer to the underlying list value as you 
suggest?



I was suggesting using `tuple` on the argument:

def memoize(f):
 cache = {}

 def g(*args):
 key = tuple(args[0]), args[1]

 if key not in cache:
 cache[key] = f(args[0], args[1])

 return cache[key]

 return g


Anything else is good in my code ?

Thanks

Le dim. 31 mars 2024 à 01:44, MRAB via Python-list 
 a écrit :


On 2024-03-31 00:09, marc nicole via Python-list wrote:
> I am creating a memoization example with a function that adds up
/ averages
> the elements of an array and compares it with the cached ones to
retrieve
> them in case they are already stored.
>
> In addition, I want to store only if the result of the function
differs
> considerably (passes a threshold e.g. 50 below).
>
> I created an example using a decorator to do so, the results
using the
> decorator is slightly faster than without the memoization which
is OK, but
> is the logic of the decorator correct ? anybody can tell me ?
>
> My code is attached below:
>
>
>
> import time
>
>
> def memoize(f):
>      cache = {}
>
>      def g(*args):
>          if args[1] == "avg":
>              sum_key_arr = sum(list(args[0])) / len(list(args[0]))

'list' will iterate over args[0] to make a list, and 'sum' will
iterate
over that list.

It would be simpler to just let 'sum' iterate over args[0].

>          elif args[1] == "sum":
>              sum_key_arr = sum(list(args[0]))
>          if sum_key_arr not in cache:
>              for (
>                  key,
>                  value,
>              ) in (
>                  cache.items()
>              ):  # key in dict cannot be an array so I use the
sum of the
> array as the key

You can't use a list as a key, but you can use a tuple as a key,
provided that the elements of the tuple are also immutable.

>                  if (
>                      abs(sum_key_arr - key) <= 50
>                  ):  # threshold is great here so that all
values are
> approximated!
>                      # print('approximated')
>                      return cache[key]
>              else:
>                  # print('not approximated')
>                  cache[sum_key_arr] = f(args[0], args[1])
>          return cache[sum_key_arr]
>
>      return g
>
>
> @memoize
> def aggregate(dict_list_arr, operation):
>      if operation == "avg":
>          return sum(list(dict_list_arr)) / len(list(dict_list_arr))
>      if operation == "sum":
>          return sum(list(dict_list_arr))
>      return None
>
>
> t = time.time()
> for i in range(200, 15000):
>      res = aggregate(list(range(i)), "avg")
>
> elapsed = time.time() - t
> print(res)
> print(elapsed)


-- 
https://mail.python.org/mailman/listinfo/python-list



--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you help me with this memoization simple example?

2024-03-31 Thread marc nicole via Python-list
Thanks for the first comment which I incorporated

but when you say "You can't use a list as a key, but you can use a tuple as
a key,
provided that the elements of the tuple are also immutable."

does it mean  the result of sum of the array is not convenient to use as
key as I do?
Which tuple I should use to refer to the underlying list value as you
suggest?

Anything else is good in my code ?

Thanks

Le dim. 31 mars 2024 à 01:44, MRAB via Python-list 
a écrit :

> On 2024-03-31 00:09, marc nicole via Python-list wrote:
> > I am creating a memoization example with a function that adds up /
> averages
> > the elements of an array and compares it with the cached ones to retrieve
> > them in case they are already stored.
> >
> > In addition, I want to store only if the result of the function differs
> > considerably (passes a threshold e.g. 50 below).
> >
> > I created an example using a decorator to do so, the results using the
> > decorator is slightly faster than without the memoization which is OK,
> but
> > is the logic of the decorator correct ? anybody can tell me ?
> >
> > My code is attached below:
> >
> >
> >
> > import time
> >
> >
> > def memoize(f):
> >  cache = {}
> >
> >  def g(*args):
> >  if args[1] == "avg":
> >  sum_key_arr = sum(list(args[0])) / len(list(args[0]))
>
> 'list' will iterate over args[0] to make a list, and 'sum' will iterate
> over that list.
>
> It would be simpler to just let 'sum' iterate over args[0].
>
> >  elif args[1] == "sum":
> >  sum_key_arr = sum(list(args[0]))
> >  if sum_key_arr not in cache:
> >  for (
> >  key,
> >  value,
> >  ) in (
> >  cache.items()
> >  ):  # key in dict cannot be an array so I use the sum of the
> > array as the key
>
> You can't use a list as a key, but you can use a tuple as a key,
> provided that the elements of the tuple are also immutable.
>
> >  if (
> >  abs(sum_key_arr - key) <= 50
> >  ):  # threshold is great here so that all values are
> > approximated!
> >  # print('approximated')
> >  return cache[key]
> >  else:
> >  # print('not approximated')
> >  cache[sum_key_arr] = f(args[0], args[1])
> >  return cache[sum_key_arr]
> >
> >  return g
> >
> >
> > @memoize
> > def aggregate(dict_list_arr, operation):
> >  if operation == "avg":
> >  return sum(list(dict_list_arr)) / len(list(dict_list_arr))
> >  if operation == "sum":
> >  return sum(list(dict_list_arr))
> >  return None
> >
> >
> > t = time.time()
> > for i in range(200, 15000):
> >  res = aggregate(list(range(i)), "avg")
> >
> > elapsed = time.time() - t
> > print(res)
> > print(elapsed)
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can you help me with this memoization simple example?

2024-03-30 Thread MRAB via Python-list

On 2024-03-31 00:09, marc nicole via Python-list wrote:

I am creating a memoization example with a function that adds up / averages
the elements of an array and compares it with the cached ones to retrieve
them in case they are already stored.

In addition, I want to store only if the result of the function differs
considerably (passes a threshold e.g. 50 below).

I created an example using a decorator to do so, the results using the
decorator is slightly faster than without the memoization which is OK, but
is the logic of the decorator correct ? anybody can tell me ?

My code is attached below:



import time


def memoize(f):
 cache = {}

 def g(*args):
 if args[1] == "avg":
 sum_key_arr = sum(list(args[0])) / len(list(args[0]))


'list' will iterate over args[0] to make a list, and 'sum' will iterate 
over that list.


It would be simpler to just let 'sum' iterate over args[0].


 elif args[1] == "sum":
 sum_key_arr = sum(list(args[0]))
 if sum_key_arr not in cache:
 for (
 key,
 value,
 ) in (
 cache.items()
 ):  # key in dict cannot be an array so I use the sum of the
array as the key


You can't use a list as a key, but you can use a tuple as a key, 
provided that the elements of the tuple are also immutable.



 if (
 abs(sum_key_arr - key) <= 50
 ):  # threshold is great here so that all values are
approximated!
 # print('approximated')
 return cache[key]
 else:
 # print('not approximated')
 cache[sum_key_arr] = f(args[0], args[1])
 return cache[sum_key_arr]

 return g


@memoize
def aggregate(dict_list_arr, operation):
 if operation == "avg":
 return sum(list(dict_list_arr)) / len(list(dict_list_arr))
 if operation == "sum":
 return sum(list(dict_list_arr))
 return None


t = time.time()
for i in range(200, 15000):
 res = aggregate(list(range(i)), "avg")

elapsed = time.time() - t
print(res)
print(elapsed)



--
https://mail.python.org/mailman/listinfo/python-list


Can you help me with this memoization simple example?

2024-03-30 Thread marc nicole via Python-list
I am creating a memoization example with a function that adds up / averages
the elements of an array and compares it with the cached ones to retrieve
them in case they are already stored.

In addition, I want to store only if the result of the function differs
considerably (passes a threshold e.g. 50 below).

I created an example using a decorator to do so, the results using the
decorator is slightly faster than without the memoization which is OK, but
is the logic of the decorator correct ? anybody can tell me ?

My code is attached below:



import time


def memoize(f):
cache = {}

def g(*args):
if args[1] == "avg":
sum_key_arr = sum(list(args[0])) / len(list(args[0]))
elif args[1] == "sum":
sum_key_arr = sum(list(args[0]))
if sum_key_arr not in cache:
for (
key,
value,
) in (
cache.items()
):  # key in dict cannot be an array so I use the sum of the
array as the key
if (
abs(sum_key_arr - key) <= 50
):  # threshold is great here so that all values are
approximated!
# print('approximated')
return cache[key]
else:
# print('not approximated')
cache[sum_key_arr] = f(args[0], args[1])
return cache[sum_key_arr]

return g


@memoize
def aggregate(dict_list_arr, operation):
if operation == "avg":
return sum(list(dict_list_arr)) / len(list(dict_list_arr))
if operation == "sum":
return sum(list(dict_list_arr))
return None


t = time.time()
for i in range(200, 15000):
res = aggregate(list(range(i)), "avg")

elapsed = time.time() - t
print(res)
print(elapsed)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can u help me?

2024-03-06 Thread Grant Edwards via Python-list
On 2024-03-06, MRAB via Python-list  wrote:
> On 2024-03-06 01:44, Ethan Furman via Python-list wrote:
>> On 3/5/24 16:49, MRAB via Python-list wrote:
>>   > On 2024-03-06 00:24, Ethan Furman via Python-list wrote:
>>   >> On 3/5/24 16:06, Chano Fucks via Python-list wrote:
>>   >>
>>   >>> [image: image.png]
>>   >>
>>   >> The image is of MS-Windows with the python installation window of 
>> "Repair Successful".  Hopefully somebody better at
>>   >> explaining that problem can take it from here...
>>   >>
>>   > If the repair was successful, what's the problem?
>> 
>> I imagine the issue is trying get Python to run (as I recall, the python 
>> icon on the MS-Windows desktop is the
>> installer, not Python itself).
>
> There was an issue 3 years ago about renaming the installer for clarity:
>
> https://github.com/python/cpython/issues/87322

Yea, this problem comes up constantly (and has for many years).

People have suggested renaming the installer so it has "setup" or
"install" in the name.

People have suggested adding text to the installer splash screen to
explain that it's the installer and not python itself, that you
already have python installed, and if you want to _run_ python instead
of _install_ python, here's how.

People have suggested having the installer remove itself by default
when it's done installing.

People have suggested lots of solutions.

AFAICT, nobody has actually done anything.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can u help me?

2024-03-05 Thread MRAB via Python-list

On 2024-03-06 01:44, Ethan Furman via Python-list wrote:

On 3/5/24 16:49, MRAB via Python-list wrote:
  > On 2024-03-06 00:24, Ethan Furman via Python-list wrote:
  >> On 3/5/24 16:06, Chano Fucks via Python-list wrote:
  >>
  >>> [image: image.png]
  >>
  >> The image is of MS-Windows with the python installation window of "Repair 
Successful".  Hopefully somebody better at
  >> explaining that problem can take it from here...
  >>
  > If the repair was successful, what's the problem?

I imagine the issue is trying get Python to run (as I recall, the python icon 
on the MS-Windows desktop is the
installer, not Python itself).


There was an issue 3 years ago about renaming the installer for clarity:

https://github.com/python/cpython/issues/87322

--
https://mail.python.org/mailman/listinfo/python-list


Re: Can u help me?

2024-03-05 Thread Mats Wichmann via Python-list

On 3/5/24 18:44, Ethan Furman via Python-list wrote:

On 3/5/24 16:49, MRAB via Python-list wrote:
 > On 2024-03-06 00:24, Ethan Furman via Python-list wrote:
 >> On 3/5/24 16:06, Chano Fucks via Python-list wrote:
 >>
 >>> [image: image.png]
 >>
 >> The image is of MS-Windows with the python installation window of 
"Repair Successful".  Hopefully somebody better at

 >> explaining that problem can take it from here...
 >>
 > If the repair was successful, what's the problem?

I imagine the issue is trying get Python to run (as I recall, the python 
icon on the MS-Windows desktop is the installer, not Python itself).


that's often it, yes - you keep getting the installer when you think you 
should get a snazzy Python window. Of course, you don't - Python is a 
command-line/terminal program, not a windows app.  Now if you tried to 
launch IDLE instead, you'd get at least a window.


But we're just guessing here. Perhaps Chano will come back with an 
updated question with some details.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Can u help me?

2024-03-05 Thread Ethan Furman via Python-list

On 3/5/24 16:49, MRAB via Python-list wrote:
> On 2024-03-06 00:24, Ethan Furman via Python-list wrote:
>> On 3/5/24 16:06, Chano Fucks via Python-list wrote:
>>
>>> [image: image.png]
>>
>> The image is of MS-Windows with the python installation window of "Repair 
Successful".  Hopefully somebody better at
>> explaining that problem can take it from here...
>>
> If the repair was successful, what's the problem?

I imagine the issue is trying get Python to run (as I recall, the python icon on the MS-Windows desktop is the 
installer, not Python itself).

--
https://mail.python.org/mailman/listinfo/python-list


Re: Can u help me?

2024-03-05 Thread MRAB via Python-list

On 2024-03-06 00:24, Ethan Furman via Python-list wrote:

On 3/5/24 16:06, Chano Fucks via Python-list wrote:


[image: image.png]


The image is of MS-Windows with the python installation window of "Repair 
Successful".  Hopefully somebody better at
explaining that problem can take it from here...


If the repair was successful, what's the problem?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can u help me?

2024-03-05 Thread MRAB via Python-list

On 2024-03-06 00:06, Chano Fucks via Python-list wrote:

[image: image.png]


This list removes all images.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can u help me?

2024-03-05 Thread Ethan Furman via Python-list

On 3/5/24 16:06, Chano Fucks via Python-list wrote:


[image: image.png]


The image is of MS-Windows with the python installation window of "Repair Successful".  Hopefully somebody better at 
explaining that problem can take it from here...


--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Can u help me?

2024-03-05 Thread Chano Fucks via Python-list
[image: image.png]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help

2023-11-07 Thread Mike Dewhirst via Python-list

On 7/11/2023 9:02 am, Jason Friedman via Python-list wrote:

On Sun, Nov 5, 2023 at 1:23 PM office officce via Python-list <
python-list@python.org> wrote:


which python version is better to be used and how to make sure it works on
my window 10 because i downloaded it and it never worked so I uninstall to
do that again please can you give me the steps on how it will work perfectly


1. Download from https://python.org (not Microsoft) and always choose 
the 64-bit stable version


2. Choose the installation location as C:\Python311 (avoid the default)

4. Accept other recommended installation options especially to include 
Python on the path (if offered)


Guaranteed to work. Also, you will never have to uninstall. Install the 
next version in C:\Python312 etc


In due course, investigate virtual environments so you can work on 
projects simultaneously using different versions of Python or different 
versions of various Python libraries.


Good luck

Mike





If you are just starting out, the most recent version is 3.12 and is
probably your best choice.

When you say it never worked, can you describe in more detail what you did
and what error messages you encountered?

This mailing list does not accept screenshots.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.



OpenPGP_signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help

2023-11-06 Thread Jason Friedman via Python-list
On Sun, Nov 5, 2023 at 1:23 PM office officce via Python-list <
python-list@python.org> wrote:

> which python version is better to be used and how to make sure it works on
> my window 10 because i downloaded it and it never worked so I uninstall to
> do that again please can you give me the steps on how it will work perfectly
>
>
If you are just starting out, the most recent version is 3.12 and is
probably your best choice.

When you say it never worked, can you describe in more detail what you did
and what error messages you encountered?

This mailing list does not accept screenshots.
-- 
https://mail.python.org/mailman/listinfo/python-list


Help

2023-11-05 Thread office officce via Python-list
which python version is better to be used and how to make sure it works on my 
window 10 because i downloaded it and it never worked so I uninstall to do that 
again please can you give me the steps on how it will work perfectly


from
Kenny
-- 
https://mail.python.org/mailman/listinfo/python-list


Mtg ANN: Using computer vision AI to help protect the worlds rarest dolphin

2023-08-08 Thread dn via Python-list

Wed 16 Aug 2023, 1800~20:30 NZST (0600~0830 UTC, late-Tue in US)
Details and RSVP at https://www.meetup.com/nzpug-auckland/events/295091858/


Teaching a computer to see. How computer vision is helping to protect 
the world’s rarest dolphin and how you can train your own model.


Tane van der Boon will talk about the MAUI63 project, and then lead us 
through how to train and utilise a custom computer vision object 
detector. Essentially allowing our software to be able to see.


MAUI63 was given its name because when the venture began, there were 
only 63 Māui dolphins left in existence. Using drone technology and AI 
to collect and process visual data, the founders took action to collect 
data to help save the world’s rarest dolphin from extinction and 
influence future marine conservation efforts.


The MAUI63 team uses a customised drone to find and track the movement 
of dolphins, and enables individual dolphins to be identified through 
their fin markings. The information collected can then be used to inform 
better data driven decisions on how best to protect them.


Later, Tane will lead us through a smaller task to build our own image 
recognizer. (more details in due course...)



The Auckland Branch of the New Zealand Python Users' Group meet twice 
monthly. You're very welcome to attend online or in-person (as 
available). Meeting location-details or URL will be sent to those who RSVP.


We are a healthy mix of Python users. Students, academics, hobbyists, 
industry professionals, and many completely new to Python.


The "room" opens at 1800 (local time) with an opportunity to network 
with colleagues. Everything should be wrapped up by 2030.


We are always keen to hear suggestions for meeting-topics, and to meet 
with folk who'd like to present or lead - eg a brief lightning talk, a 
practical coaching-session, a full lecture... Help is available if 
you've never done such a thing before!


We follow the NZPUG Code of Conduct (https://python.nz/code-of-conduct) 
to create an inclusive and friendly environment.


We express thanks to, and encourage you to investigate, our sponsors: 
Catalyst Cloud, New Zealand Open Source Society, JetBrains, and IceHouse 
Ventures.


--
Regards =dn

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ImportError('Error: Reinit is forbidden')

2023-05-18 Thread Barry
 On 18 May 2023, at 13:56, Jason Qian  wrote:

 
 Hi Barry,
 void handleError(const char* msg)
 {
 ...
 PyErr_Fetch(, , );
 PyErr_NormalizeException(, , );

 PyObject* str_value = PyObject_Repr(pyExcValue);
 PyObject* pyExcValueStr = PyUnicode_AsEncodedString(str_value, "utf-8",
 "Error ~");
 const char *strErrValue = PyBytes_AS_STRING(pyExcValueStr);
 //where   strErrValue   = "ImportError('Error: Reinit is forbidden')"
 ...
 }
 What we imported is a Python file which import some pyd libraries.

   Please do not top post replies.
   Ok so assume the error is correct and hunt for the code that does the
   reimport.
   You may need to set break points in you C code to find tnw caller.
   Barry

 Thanks 
 Jason 
 On Thu, May 18, 2023 at 3:53 AM Barry <[1]ba...@barrys-emacs.org> wrote:

   > On 17 May 2023, at 20:35, Jason Qian via Python-list
   <[2]python-list@python.org> wrote:
   >
   >  Hi,
   >
   >   I Need some of your help.
   >
   > I have the following C code to import *Import python.*   It works
   99% of
   > the time, but sometimes  receives  "*ImportError('Error: Reinit is
   > forbidden')*". error.
   > **We run multiple instances of the app parallelly.
   >
   > *** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51)
   [MSC
   > v.1914 64 bit (AMD64)]
   >
   > PyObject * importPythonModule(const char* pmodName)
   > {
   >    const char* errors = NULL;
   >     int nlen = strlen(pmodName);
   >     PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
   >     PyObject *pModule = *PyImport_Import*(pName);
   >     Py_DECREF(pName);
   >     if (pModule == NULL) {
   >     if (*PyErr_Occurred*()) {
   >            handleError("PyImport_Import()");
   >      }
   >   }
   > }
   > void handleError(const char* msg)
   > {
   >  ...
   >  "PyImport_Import() - ImportError('Error: Reinit is forbidden')"
   > }

   You do not seem to printing out msg, you have assumed it means reinit
   it seems.
   What does msg contain when it fails?

   Barry
   >
   >
   > Thanks
   > Jason
   > --
   > [3]https://mail.python.org/mailman/listinfo/python-list
   >

References

   Visible links
   1. mailto:ba...@barrys-emacs.org
   2. mailto:python-list@python.org
   3. https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ImportError('Error: Reinit is forbidden')

2023-05-18 Thread Jason Qian via Python-list
Hi Barry,

void handleError(const char* msg)
{
...
PyErr_Fetch(, , );
PyErr_NormalizeException(, , );

PyObject* str_value = PyObject_Repr(pyExcValue);
PyObject* pyExcValueStr = PyUnicode_AsEncodedString(str_value, "utf-8",
"Error ~");
const char **strErrValue* = PyBytes_AS_STRING(pyExcValueStr);

//where   *strErrValue*   = "ImportError('Error: Reinit is forbidden')"
...
}

What we imported is a Python file which import some pyd libraries.


Thanks
Jason


On Thu, May 18, 2023 at 3:53 AM Barry  wrote:

>
>
> > On 17 May 2023, at 20:35, Jason Qian via Python-list <
> python-list@python.org> wrote:
> >
> >  Hi,
> >
> >   I Need some of your help.
> >
> > I have the following C code to import *Import python.*   It works 99% of
> > the time, but sometimes  receives  "*ImportError('Error: Reinit is
> > forbidden')*". error.
> > **We run multiple instances of the app parallelly.
> >
> > *** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC
> > v.1914 64 bit (AMD64)]
> >
> > PyObject * importPythonModule(const char* pmodName)
> > {
> >const char* errors = NULL;
> > int nlen = strlen(pmodName);
> > PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
> > PyObject *pModule = *PyImport_Import*(pName);
> > Py_DECREF(pName);
> > if (pModule == NULL) {
> > if (*PyErr_Occurred*()) {
> >handleError("PyImport_Import()");
> >  }
> >   }
> > }
> > void handleError(const char* msg)
> > {
> >  ...
> >  "PyImport_Import() - ImportError('Error: Reinit is forbidden')"
> > }
>
> You do not seem to printing out msg, you have assumed it means reinit it
> seems.
> What does msg contain when it fails?
>
> Barry
> >
> >
> > Thanks
> > Jason
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ImportError('Error: Reinit is forbidden')

2023-05-18 Thread Barry


> On 17 May 2023, at 20:35, Jason Qian via Python-list  
> wrote:
> 
>  Hi,
> 
>   I Need some of your help.
> 
> I have the following C code to import *Import python.*   It works 99% of
> the time, but sometimes  receives  "*ImportError('Error: Reinit is
> forbidden')*". error.
> **We run multiple instances of the app parallelly.
> 
> *** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC
> v.1914 64 bit (AMD64)]
> 
> PyObject * importPythonModule(const char* pmodName)
> {
>const char* errors = NULL;
> int nlen = strlen(pmodName);
> PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
> PyObject *pModule = *PyImport_Import*(pName);
> Py_DECREF(pName);
> if (pModule == NULL) {
> if (*PyErr_Occurred*()) {
>handleError("PyImport_Import()");
>  }
>   }
> }
> void handleError(const char* msg)
> {
>  ...
>  "PyImport_Import() - ImportError('Error: Reinit is forbidden')"
> }

You do not seem to printing out msg, you have assumed it means reinit it seems.
What does msg contain when it fails?

Barry
> 
> 
> Thanks
> Jason
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Help on ImportError('Error: Reinit is forbidden')

2023-05-17 Thread Jason Qian via Python-list
 Hi,

   I Need some of your help.

 I have the following C code to import *Import python.*   It works 99% of
the time, but sometimes  receives  "*ImportError('Error: Reinit is
forbidden')*". error.
 **We run multiple instances of the app parallelly.

*** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC
v.1914 64 bit (AMD64)]

PyObject * importPythonModule(const char* pmodName)
{
const char* errors = NULL;
 int nlen = strlen(pmodName);
 PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
 PyObject *pModule = *PyImport_Import*(pName);
 Py_DECREF(pName);
 if (pModule == NULL) {
 if (*PyErr_Occurred*()) {
handleError("PyImport_Import()");
  }
   }
}
void handleError(const char* msg)
{
  ...
  "PyImport_Import() - ImportError('Error: Reinit is forbidden')"
}


Thanks
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
Awesome, thanks!

On Thu, May 11, 2023 at 1:47 PM Eryk Sun  wrote:

> On 5/11/23, Jason Qian via Python-list  wrote:
> >
> > in the Python, I have a array of string
> > var_array=["Opt1=DG","Opt1=DG2"]
> > I need to call c library and  pass var_array as parameter
> > In the   argtypes,  how do I set up ctypes.POINTER(???)  for var_array?
> >
> > func.argtypes=[ctypes.c_void_p,ctypes.c_int, ctypes.POINTER()]
> >
> > In the c code:
> > int  func (void* obj, int index,  char** opt)
>
> The argument type is ctypes.POINTER(ctypes.c_char_p), but that's not
> sufficient. It doesn't implement converting a list of str objects into
> an array of c_char_p pointers that reference byte strings. You could
> write a wrapper function that implements the conversion before calling
> func(), or you could set the argument type to a custom subclass of
> ctypes.POINTER(ctypes.c_char_p) that implements the conversion via the
> from_param() class method.
>
> https://docs.python.org/3/library/ctypes.html#ctypes._CData.from_param
>
> Here's an example of the latter.
>
> C library:
>
> #include 
>
> int
> func(void *obj, int index, char **opt)
> {
> int length;
> for (length=0; opt[length]; length++);
> if (index < 0 || index >= length) {
> return -1;
> }
> return printf("%s\n", opt[index]);
> }
>
>
> Python:
>
> import os
> import ctypes
>
> lib = ctypes.CDLL('./lib.so')
> BaseOptions = ctypes.POINTER(ctypes.c_char_p)
>
> class Options(BaseOptions):
> @classmethod
> def from_param(cls, param):
> if isinstance(param, list):
> new_param = (ctypes.c_char_p * (len(param) + 1))()
> for i, p in enumerate(param):
> new_param[i] = os.fsencode(p)
> param = new_param
> return BaseOptions.from_param(param)
>
> lib.func.argtypes = (ctypes.c_void_p, ctypes.c_int, Options)
>
>
> demo:
>
> >>> opts = ['Opt1=DG', 'Opt1=DG2']
> >>> lib.func(None, 0, opts)
> Opt1=DG
> 8
> >>> lib.func(None, 1, opts)
> Opt1=DG2
> 9
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Eryk Sun
On 5/11/23, Jason Qian via Python-list  wrote:
>
> in the Python, I have a array of string
> var_array=["Opt1=DG","Opt1=DG2"]
> I need to call c library and  pass var_array as parameter
> In the   argtypes,  how do I set up ctypes.POINTER(???)  for var_array?
>
> func.argtypes=[ctypes.c_void_p,ctypes.c_int, ctypes.POINTER()]
>
> In the c code:
> int  func (void* obj, int index,  char** opt)

The argument type is ctypes.POINTER(ctypes.c_char_p), but that's not
sufficient. It doesn't implement converting a list of str objects into
an array of c_char_p pointers that reference byte strings. You could
write a wrapper function that implements the conversion before calling
func(), or you could set the argument type to a custom subclass of
ctypes.POINTER(ctypes.c_char_p) that implements the conversion via the
from_param() class method.

https://docs.python.org/3/library/ctypes.html#ctypes._CData.from_param

Here's an example of the latter.

C library:

#include 

int
func(void *obj, int index, char **opt)
{
int length;
for (length=0; opt[length]; length++);
if (index < 0 || index >= length) {
return -1;
}
return printf("%s\n", opt[index]);
}


Python:

import os
import ctypes

lib = ctypes.CDLL('./lib.so')
BaseOptions = ctypes.POINTER(ctypes.c_char_p)

class Options(BaseOptions):
@classmethod
def from_param(cls, param):
if isinstance(param, list):
new_param = (ctypes.c_char_p * (len(param) + 1))()
for i, p in enumerate(param):
new_param[i] = os.fsencode(p)
param = new_param
return BaseOptions.from_param(param)

lib.func.argtypes = (ctypes.c_void_p, ctypes.c_int, Options)


demo:

>>> opts = ['Opt1=DG', 'Opt1=DG2']
>>> lib.func(None, 0, opts)
Opt1=DG
8
>>> lib.func(None, 1, opts)
Opt1=DG2
9
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Jim Schwartz
I’m not sure this is the shortest method, but you could set up two python 
scripts to do the same thing and convert them to c using cython. I wouldn’t be 
able to read the c scripts, but maybe you could. 

Maybe someone else has a more direct answer. 

Sent from my iPhone

> On May 11, 2023, at 10:00 AM, Jason Qian via Python-list 
>  wrote:
> 
> Hi,
> 
> Need some help,
> 
> in the Python, I have a array of string
> 
> var_array=["Opt1=DG","Opt1=DG2"]
> 
> I need to call c library and  pass var_array as parameter
> 
> In the   argtypes,  how do I set up ctypes.POINTER(???)  for var_array?
> 
> func.argtypes=[ctypes.c_void_p,ctypes.c_int, ctypes.POINTER()]
> 
> In the c code:
> 
> int  func (void* obj, int index,  char** opt)
> 
> Thanks
> Jason
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
Hi,

Need some help,

in the Python, I have a array of string

 var_array=["Opt1=DG","Opt1=DG2"]

I need to call c library and  pass var_array as parameter

In the   argtypes,  how do I set up ctypes.POINTER(???)  for var_array?

func.argtypes=[ctypes.c_void_p,ctypes.c_int, ctypes.POINTER()]

In the c code:

int  func (void* obj, int index,  char** opt)

Thanks
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help please

2023-04-10 Thread Thomas Passin

On 4/10/2023 9:59 AM, Jack Gilbert wrote:

I D/L 3.11.3, I can see it in CMD

running W10 64bit

I have IDL on my desktop,

HOW do I get 3.11.3 on my desktop?


If you mean "How can I create a shortcut to Python 3.11.3 on my desktop 
that opens an interactive Python session", here is one way:


1. Find where your Python 3.11.3 program has been installed.  On the 
command line in a console, type:


py -c "import sys; print(sys.executable)"

You will get a response like this:

C:\Users\tom\AppData\Local\Programs\Python\Python311\python.exe

NOTE:  If the "py" command is not on your computer or does not open 
Python 3.11, then open a python 3.11 session and type the same commands:


import sys
print(sys.executable)

2. Open the Windows file browser ("Windows Explorer") and navigate to 
that directory.  On my computer this is


C:\Users\tom\AppData\Local\Programs\Python\Python311

3. Press and hold both the CTRL and SHIFT keys down at the same time, 
and with the mouse drag the icon for "python.exe" to a blank space on 
the desktop.  This will not drag the program itself but will create a 
shortcut and drag that.


4. Test the new shortcut by double-clicking on it and seeing that a new 
console window opens with the Python interpreter running in it.


If you do not like the size, shape, or font of this new console, change 
them by clicking on the icon in the upper left, then selecting 
"Properties", and making changes in the dialog box that opens.  The new 
choices will be used whenever you use this shortcut again.


5. The new shortcut will probably be named "python.ex".  I suggest that 
you rename it to "Python 3.11".  This way you can create other python 
shortcuts without having their names conflict.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help please

2023-04-10 Thread Sravan Kumar Chitikesi
use where cmd to find out the path of the binary and create a shortcut to
that file on desktop

Regards,
*Sravan Chitikesi*
AWS Solutions Architect - Associate


On Mon, Apr 10, 2023 at 10:03 AM Jack Gilbert <00jhen...@gmail.com> wrote:

> I D/L 3.11.3, I can see it in CMD
>
> running W10 64bit
>
> I have IDL on my desktop,
>
> HOW do I get 3.11.3 on my desktop?
>
> Thanks
>
> Jack g
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Need help please

2023-04-10 Thread Jack Gilbert
I D/L 3.11.3, I can see it in CMD

running W10 64bit

I have IDL on my desktop,

HOW do I get 3.11.3 on my desktop?

Thanks

Jack g
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-28 Thread Thomas Passin

On 3/28/2023 1:50 PM, a a wrote:

On Tuesday, 28 March 2023 at 18:12:40 UTC+2, Thomas Passin wrote:

On 3/28/2023 8:47 AM, a a wrote:

Ok, I can export bookmarks to html file and open it in Firefox to get
a long list of clickable urls but icon of the bookmarked web page is missing.

When I open Bookmarks as right a side-bar I can view and identify an individual 
Boomarks by icon,
so I would like Firefox Library to export Bookmarks to html file, icons 
included 

Since accessing opened Tabs is my default use of history in Firefox and has 
worked fine for years
I paid no special interest to bookmark opened Tabs and assign labels to 
individual bookmark.

So, generally speaking, I am happy with 1,000+ opened Tabs in Firefox , not 
being sure if this number is for real or refers to every bookmark from the 
history + opened Tabs

But definitely I need a smarter solution and approach to manage 10,000+ opened 
Tabs in Firefox in a future 


I think you had better start using another name for this thread, if it
continues.

The HTML export file will contain the icons, but the HTML elements do
not provide for showing them.

I can't imagine how you can find anything among nor navigate through
1000 open tabs, let alone 10,000 in the future. I would think the memory
usage would be impossibly high. So I hope you are mostly using the
history and do not really have that many tabs open at once!



I am a plain guy, so if Firefox counted 1,000+ opened Tabs, I can be surprised, 
but have no idea how to check that number.

You are exactly right, icon URI and icon data come with saved opened Tabs,
a single example below.

So I am going to ask Firefox team to offer
export to html, modified to have :
icon, name of web page, url address
to appear in a single row (feature already supported by Firefox, when you open 
new Tab
and click: enter URL or search string - input field,
you get such list
List is limited in size for the reasons unknown to me, but feature works fine.


You should be aware that the HTML format for bookmarks is a standard 
developed back in the day by Netscape. It goes back to the early 1990s, 
I think. The FF folks will not be modifying it, since all browsers know 
how to generate it and consume it, and who knows how many software 
packages consume it.  No one can afford to have a change, even one 
that's supposed to be harmless, inadvertently break software that's 
worked for years.


They are going to need a lot of persuading.

Maybe there's something else they would be willing and able to do.  But 
you can expect that any proposed new feature will probably need to have 
some strong support.  Raymond Chen at Microsoft has written how each new 
feature proposal starts off with -100 points.  Only if the advantages 
get the score up above zero can the feature have any chance of getting 
adopted - and then it has to compete with other potential features that 
have their own scores.




--
So would prefer a horizontal list of opened Tabs
by htmlized, vertical list of the same opened Tabs,
featuring:
icon, name of web-site, URL address

Thank you for your excellent support


You're welcome.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-28 Thread a a
On Tuesday, 28 March 2023 at 18:12:40 UTC+2, Thomas Passin wrote:
> On 3/28/2023 8:47 AM, a a wrote: 
> > Ok, I can export bookmarks to html file and open it in Firefox to get 
> > a long list of clickable urls but icon of the bookmarked web page is 
> > missing. 
> > 
> > When I open Bookmarks as right a side-bar I can view and identify an 
> > individual Boomarks by icon,
> > so I would like Firefox Library to export Bookmarks to html file, icons 
> > included 
> > 
> > Since accessing opened Tabs is my default use of history in Firefox and has 
> > worked fine for years 
> > I paid no special interest to bookmark opened Tabs and assign labels to 
> > individual bookmark. 
> > 
> > So, generally speaking, I am happy with 1,000+ opened Tabs in Firefox , not 
> > being sure if this number is for real or refers to every bookmark from the 
> > history + opened Tabs 
> >
> > But definitely I need a smarter solution and approach to manage 10,000+ 
> > opened Tabs in Firefox in a future  
> 
> I think you had better start using another name for this thread, if it 
> continues. 
> 
> The HTML export file will contain the icons, but the HTML elements do 
> not provide for showing them. 
> 
> I can't imagine how you can find anything among nor navigate through 
> 1000 open tabs, let alone 10,000 in the future. I would think the memory 
> usage would be impossibly high. So I hope you are mostly using the 
> history and do not really have that many tabs open at once!


I am a plain guy, so if Firefox counted 1,000+ opened Tabs, I can be surprised, 
but have no idea how to check that number.

You are exactly right, icon URI and icon data come with saved opened Tabs,
a single example below.

So I am going to ask Firefox team to offer
export to html, modified to have :
icon, name of web page, url address
to appear in a single row (feature already supported by Firefox, when you open 
new Tab
and click: enter URL or search string - input field,
you get such list
List is limited in size for the reasons unknown to me, but feature works fine.

--
So would prefer a horizontal list of opened Tabs
by htmlized, vertical list of the same opened Tabs,
featuring:
icon, name of web-site, URL address

Thank you for your excellent support

darius


"https://www.nasa.gov/feature/goddard/2017/nasas-sdo-watches-a-sunspot-turn-toward-earth;
 add_date="1499899506" last_modified="1499899507" 
icon_uri="https://www.nasa.gov/favicon.ico; 

Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-28 Thread Thomas Passin

On 3/28/2023 8:47 AM, a a wrote:

Ok, I can export bookmarks to html file and open it in Firefox to get
a long list of clickable urls but icon of the bookmarked web page is missing.

When I open Bookmarks as right a side-bar I can view and identify an individual 
Boomarks by icon,
so I would like Firefox Library to export Bookmarks to html file, icons 
included 

Since accessing opened Tabs is my default use of history in Firefox and has 
worked fine for years
I paid no special interest to bookmark opened Tabs and assign labels to 
individual bookmark.

So, generally speaking, I am happy with 1,000+ opened Tabs in Firefox , not 
being sure if this number is for real or refers to every bookmark from the 
history + opened Tabs

But definitely I need a smarter solution and approach to manage 10,000+ opened 
Tabs in Firefox in a future 


I think you had better start using another name for this thread, if it 
continues.


The HTML export file will contain the icons, but the HTML elements do 
not provide for showing them.


I can't imagine how you can find anything among nor navigate through 
1000 open tabs, let alone 10,000 in the future. I would think the memory 
usage would be impossibly high.  So I hope you are mostly using the 
history and do not really have that many tabs open at once!


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-28 Thread a a
On Tuesday, 28 March 2023 at 06:33:44 UTC+2, Thomas Passin wrote:
> On 3/27/2023 8:37 PM, a a wrote: 
> >> To save the tabs, right click any one of them and select the "Select All 
> >> Tabs" item. They will all highlight. Right click on one of them and 
> >> select the "Bookmark Tabs" item. A dialog box will open with an entry 
> >> lone for the Name to use (like "Tabset1") and a location - a bookmark 
> >> folder - for them to go into. CAREFUL - if you just click "Save", you 
> >> may not be able to find them. Use the dropdown arrow to save them in 
> >> one of the top level folders, like "Bookmarks Toolbars". 
> > I can select All Opened Tabs (as from the given link) 
> > and get 1,000+ Opened Tabs ( I am afraid, this is s number of all saved 
> > bookmarks in the past) 
> > I go to menu, Bookmarks, Manage Boomarks and copy Tabs 
> > 
> > and 
> > https://www.textfixer.com/html/convert-url-to-html-link.php 
> > 
> > does the job, converting text urls into clickable web links 
> > 
> > I copy the result and past into Notepad++ to save file as html 
> > 
> > and what I get is web page of clickable Opened Tabs 
> > 
> > since icon and page name are lost
> I don't understand this. You don't really have 1000 tabs open at the 
> same time, do you? If you select all the open tabs - I think you wrote 
> that you only have 50 - then you can save them as bookmarks under a 
> folder name you choose. That folder will contain the 50 open links. I 
> tried it this evening, so I know that's how it works. (It happens that 
> I'm working on my own bookmark manager just now, so I've been messing 
> around with importing, exporting, and reading the bookmark files). 
> 
> Then you can export them and import the same bookmark file into another 
> browser on another computer. Whenever you want to reopen some of those 
> tabs, you would navigate to that part of the bookmarks and open the tabs 
> you want. 
> 
> Maybe you have something else in mind? Do you want to send the links of 
> the opened tab set to someone else, but not all your bookmarks? Please 
> explain more carefully what you want to do.

Ok, I can export bookmarks to html file and open it in Firefox to get
a long list of clickable urls but icon of the bookmarked web page is missing.

When I open Bookmarks as right a side-bar I can view and identify an individual 
Boomarks by icon,
so I would like Firefox Library to export Bookmarks to html file, icons 
included ;)

Since accessing opened Tabs is my default use of history in Firefox and has 
worked fine for years
I paid no special interest to bookmark opened Tabs and assign labels to 
individual bookmark.

So, generally speaking, I am happy with 1,000+ opened Tabs in Firefox , not 
being sure if this number is for real or refers to every bookmark from the 
history + opened Tabs

But definitely I need a smarter solution and approach to manage 10,000+ opened 
Tabs in Firefox in a future ;)

- I just build personal search engine resembling targets set by MyLifeBits 
Project by Microsoft in the past.

darius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-28 Thread a a
On Tuesday, 28 March 2023 at 06:33:44 UTC+2, Thomas Passin wrote:
> On 3/27/2023 8:37 PM, a a wrote: 
> >> To save the tabs, right click any one of them and select the "Select All 
> >> Tabs" item. They will all highlight. Right click on one of them and 
> >> select the "Bookmark Tabs" item. A dialog box will open with an entry 
> >> lone for the Name to use (like "Tabset1") and a location - a bookmark 
> >> folder - for them to go into. CAREFUL - if you just click "Save", you 
> >> may not be able to find them. Use the dropdown arrow to save them in 
> >> one of the top level folders, like "Bookmarks Toolbars". 
> > I can select All Opened Tabs (as from the given link) 
> > and get 1,000+ Opened Tabs ( I am afraid, this is s number of all saved 
> > bookmarks in the past) 
> > I go to menu, Bookmarks, Manage Boomarks and copy Tabs 
> > 
> > and 
> > https://www.textfixer.com/html/convert-url-to-html-link.php 
> > 
> > does the job, converting text urls into clickable web links 
> > 
> > I copy the result and past into Notepad++ to save file as html 
> > 
> > and what I get is web page of clickable Opened Tabs 
> > 
> > since icon and page name are lost
> I don't understand this. You don't really have 1000 tabs open at the 
> same time, do you? If you select all the open tabs - I think you wrote 
> that you only have 50 - then you can save them as bookmarks under a 
> folder name you choose. That folder will contain the 50 open links. I 
> tried it this evening, so I know that's how it works. (It happens that 
> I'm working on my own bookmark manager just now, so I've been messing 
> around with importing, exporting, and reading the bookmark files). 
> 
> Then you can export them and import the same bookmark file into another 
> browser on another computer. Whenever you want to reopen some of those 
> tabs, you would navigate to that part of the bookmarks and open the tabs 
> you want. 
> 
> Maybe you have something else in mind? Do you want to send the links of 
> the opened tab set to someone else, but not all your bookmarks? Please 
> explain more carefully what you want to do.

Ok, I was not aware of the real number of the opened Tabs in Firefox, since I 
can jump from left to right and vice versa in real time, so the number given by 
me: 50 opened Tabs was my general estimate, but I can read the real number of 
opened Tabs from the same menu (line below) to be 1,000+

What I copy and paste into Notepad++ is 1,000+ -line file.
It's hard to verify if the above number is made of opened Tabs only or 
bookmarks are included, 
since I exactly use and keep multi Tabs opened as my live bookmarks and cache 
memory, when I work on my projects (watching, counting sunspots,   Earthquakes 
prediction in Turkey, ... )

I would like to fund the development of such smart Tabs Manager to replace 
boomarks, to let me group Tabs belonging to different projects.

It doesn't look to be complicated, if supported by the Firefox team.

Firefox 97. comes with alike functionality (when I open a new Tab)  but limited 
to 4 rows of web-page icons + names and 4 rows called: Recent activity

All I need is to replace opened Tabs by history of the Recent activity - 
default Firefox page, when I open a new Tab

It's hard to imagine, I can have 1,000+ Tabs live opened in Firefox
but I really need such feature, called in the past as: MyLifeBits by MS

So I have to ask Firefox team today  to lift 4 rows limit on web links and 4 
rows limit on the recent activity, coming with
New Tab opened


When I am busy on a project I can open 100+ web pages via search engine  in one 
day and would prefer
100+ opened Tabs to be saved in html format for the records as a reference.

Hope to get some support from Firefox team via Twitter.

Ok, smart bookmarks manager can offer the above functionality right now, so I 
go to search engine to get one.

darius

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread Thomas Passin

On 3/27/2023 8:37 PM, a a wrote:

I can select All Opened Tabs (as from the given link)
and get 1,000+ Opened Tabs ( I am afraid, this is s number of all saved 
bookmarks in the past)
I go to menu, Bookmarks, Manage Boomarks and copy Tabs

and
https://www.textfixer.com/html/convert-url-to-html-link.php

does the job, converting text urls into clickable web links

I copy the result and past into Notepad++ to save file as html

and what I get is web page of clickable Opened Tabs
You can get that directly in Notepad++.  Load Firefox's HTML format 
bookmark file into Notepad++. View it in a browser using the "View/View 
Current File In" menu item. True, you could have opened it directly in 
the browser, but now you can edit the file and cut out the parts you 
don't need, and check to make sure you get what you intended. The 
structure of the HTML is very regular.


If you have saved your set of opened links under a distinctive heading 
near the top of the collection - as I suggested earlier - it should be 
easy to find the start and end points of their HTML elements, and delete 
all the ones you don't want. You could import this shortened bookmark 
file into another installation of Firefox and this would add them to the 
bookmarks in the other browser, all grouped by your custom heading.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread Thomas Passin

On 3/27/2023 8:37 PM, a a wrote:

To save the tabs, right click any one of them and select the "Select All
Tabs" item. They will all highlight. Right click on one of them and
select the "Bookmark Tabs" item. A dialog box will open with an entry
lone for the Name to use (like "Tabset1") and a location - a bookmark
folder - for them to go into. CAREFUL - if you just click "Save", you
may not be able to find them. Use the dropdown arrow to save them in
one of the top level folders, like "Bookmarks Toolbars".

I can select All Opened Tabs (as from the given link)
and get 1,000+ Opened Tabs ( I am afraid, this is s number of all saved 
bookmarks in the past)
I go to menu, Bookmarks, Manage Boomarks and copy Tabs

and
https://www.textfixer.com/html/convert-url-to-html-link.php

does the job, converting text urls into clickable web links

I copy the result and past into Notepad++ to save file as html

and what I get is web page of clickable Opened Tabs

since icon and page name are lost


I don't understand this. You don't really have 1000 tabs open at the 
same time, do you?  If you select all the open tabs - I think you wrote 
that you only have 50 - then you can save them as bookmarks under a 
folder name you choose. That folder will contain the 50 open links. I 
tried it this evening, so I know that's how it works. (It happens that 
I'm working on my own bookmark manager just now, so I've been messing 
around with importing, exporting, and reading the bookmark files).


Then you can export them and import the same bookmark file into another 
browser on another computer.  Whenever you want to reopen some of those 
tabs, you would navigate to that part of the bookmarks and open the tabs 
you want.


Maybe you have something else in mind?  Do you want to send the links of 
the opened tab set to someone else, but not all your bookmarks? Please 
explain more carefully what you want to do.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread a a
On Tuesday, 28 March 2023 at 02:07:43 UTC+2, Thomas Passin wrote:
> On 3/27/2023 4:02 PM, Thomas Passin wrote:
> > On 3/27/2023 3:07 PM, a a wrote: 
> >> On Monday, 27 March 2023 at 19:19:41 UTC+2, Thomas Passin wrote: 
> >>> On 3/27/2023 10:07 AM, a a wrote: 
> >>>> Ok, I know, I need to switch to Windows 10 run on another PC next to 
> >>>> me. 
> >>>> 
> >>>> I need to learn how to copy and move every web page opened in 
> >>>> Firefox as a reference to social media, web sites for Python, chat 
> >>>> and more (about 50 web pages live opened  
> >>> 
> >>> This sounds like you mean when you get a new Windows 10 PC, you will 
> >>> want to move your open tabs to the new machine. I see several 
> >>> possibilities for this. 
> >>> 
> >>> 1. Copy your Firefox profile folder to the new computer, and tell 
> >>> Firefox to use it as the default profile. I *think* this will include 
> >>> the open tabs, but I haven't tried it. Saving that folder is useful for 
> >>> backup anyway. (If you use Thunderbird for email, you really *must* 
> >>> back up its profile folder because all your email with its folder 
> >>> structure is there. BTW, you can even copy the profile over to a Linux 
> >>> machine that has Thunderbird, and presto, all your email will be there. 
> >>> The Firefox profile would probably transfer just as well). 
> >>> 
> >>> 2. Bookmark all your open tabs under a new heading "open tabs", then 
> >>> export the bookmarks. In the new machine, import them into Firefox 
> >>> there. They won't open in tabs, but it will be easy to find them and 
> >>> open them when you want to. You probably will want to copy over your 
> >>> bookmarks anyway, so this adds little effort. 
> >>> 
> >>> 3. There may be a specific record of open tabs that you can copy or 
> >>> export. I don't know about this but an internet search should help. 
> >>> 
> >>> Good luck. 
> >> 
> >> a nice solution comes from 
> >> 
> >> How to Copy URLs of All Open Tabs in Firefox 
> >> 
> >> https://www.howtogeek.com/723921/how-to-copy-urls-of-all-open-tabs-in-firefox/
> >>  
> >> 
> >> right clicking opened tab, all opened tabs can be selected 
> >> moving via menu to bookmarks/ booksmarks management 
> >> url bookmarks can be right-mouse clicked to copy urls 
> >> finally, urls can be pasted into Notepad++ 
> >> and saved as a file 
> >> unfortunately, saving as .html file 
> >> fails to generate html file with clickable web links 
> >> 
> >
> > Don't go pasting urls into a text file one by one.  Instead, do my #2 
> > above. That will import all the bookmarks, including the tabs you saved 
> > as bookmarks.  Then import the exported bookmark file into the new 
> > browser.  There's no reason to fuss around trying to get text copies of 
> > urls to open. 
> > 
> > For that matter, the exported bookmarks file is an HTML file and can be 
> > opened directly in a browser, with clickable links.
> All right, I think I've got the easiest way to go. You *can* bookmark 
> all the tabs at once - see below. Then, as I already proposed, export 
> the bookmarks and import them into Firefox on the new computer. 
> 
> To save the tabs, right click any one of them and select the "Select All 
> Tabs" item. They will all highlight. Right click on one of them and 
> select the "Bookmark Tabs" item. A dialog box will open with an entry 
> lone for the Name to use (like "Tabset1") and a location - a bookmark 
> folder - for them to go into. CAREFUL - if you just click "Save", you 
> may not be able to find them. Use the dropdown arrow to save them in 
> one of the top level folders, like "Bookmarks Toolbars".

I can select All Opened Tabs (as from the given link)
and get 1,000+ Opened Tabs ( I am afraid, this is s number of all saved 
bookmarks in the past)
I go to menu, Bookmarks, Manage Boomarks and copy Tabs

and 
https://www.textfixer.com/html/convert-url-to-html-link.php

does the job, converting text urls into clickable web links

I copy the result and past into Notepad++ to save file as html

and what I get is web page of clickable Opened Tabs

since icon and page name are lost 
I would prefer another solution already ofered by Firex to generate web page of 
recently visited web pages,
unfortunately coming with  limits on the number of visited
web pages,
so I contacted Firefox, Notepad++ for help
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread Thomas Passin

On 3/27/2023 4:02 PM, Thomas Passin wrote:

On 3/27/2023 3:07 PM, a a wrote:

On Monday, 27 March 2023 at 19:19:41 UTC+2, Thomas Passin wrote:

On 3/27/2023 10:07 AM, a a wrote:
Ok, I know, I need to switch to Windows 10 run on another PC next to 
me.


I need to learn how to copy and move every web page opened in 
Firefox as a reference to social media, web sites for Python, chat 
and more (about 50 web pages live opened 


This sounds like you mean when you get a new Windows 10 PC, you will
want to move your open tabs to the new machine. I see several
possibilities for this.

1. Copy your Firefox profile folder to the new computer, and tell
Firefox to use it as the default profile. I *think* this will include
the open tabs, but I haven't tried it. Saving that folder is useful for
backup anyway. (If you use Thunderbird for email, you really *must*
back up its profile folder because all your email with its folder
structure is there. BTW, you can even copy the profile over to a Linux
machine that has Thunderbird, and presto, all your email will be there.
The Firefox profile would probably transfer just as well).

2. Bookmark all your open tabs under a new heading "open tabs", then
export the bookmarks. In the new machine, import them into Firefox
there. They won't open in tabs, but it will be easy to find them and
open them when you want to. You probably will want to copy over your
bookmarks anyway, so this adds little effort.

3. There may be a specific record of open tabs that you can copy or
export. I don't know about this but an internet search should help.

Good luck.


a nice solution comes from

How to Copy URLs of All Open Tabs in Firefox

https://www.howtogeek.com/723921/how-to-copy-urls-of-all-open-tabs-in-firefox/

right clicking opened tab, all opened tabs can be selected
moving via menu to bookmarks/ booksmarks management
url bookmarks can be right-mouse clicked to copy urls
finally, urls can be pasted into Notepad++
and saved as a file
unfortunately, saving as .html file
fails to generate html file with clickable web links



Don't go pasting urls into a text file one by one.  Instead, do my #2 
above. That will import all the bookmarks, including the tabs you saved 
as bookmarks.  Then import the exported bookmark file into the new 
browser.  There's no reason to fuss around trying to get text copies of 
urls to open.


For that matter, the exported bookmarks file is an HTML file and can be 
opened directly in a browser, with clickable links.


All right, I think I've got the easiest way to go.  You *can* bookmark 
all the tabs at once - see below.  Then, as I already proposed, export 
the bookmarks and import them into Firefox on the new computer.


To save the tabs, right click any one of them and select the "Select All 
Tabs" item.  They will all highlight.  Right click on one of them and 
select the "Bookmark Tabs" item. A dialog box will open with an entry 
lone for the Name to use (like "Tabset1") and a location - a bookmark 
folder - for them to go into.  CAREFUL - if you just click "Save", you 
may not be able to find them.  Use the dropdown arrow to save them in 
one of the top level folders, like "Bookmarks Toolbars".


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread Thomas Passin

On 3/27/2023 3:07 PM, a a wrote:

On Monday, 27 March 2023 at 19:19:41 UTC+2, Thomas Passin wrote:

On 3/27/2023 10:07 AM, a a wrote:

Ok, I know, I need to switch to Windows 10 run on another PC next to me.

I need to learn how to copy and move every web page opened in Firefox as a 
reference to social media, web sites for Python, chat and more (about 50 web 
pages live opened 


This sounds like you mean when you get a new Windows 10 PC, you will
want to move your open tabs to the new machine. I see several
possibilities for this.

1. Copy your Firefox profile folder to the new computer, and tell
Firefox to use it as the default profile. I *think* this will include
the open tabs, but I haven't tried it. Saving that folder is useful for
backup anyway. (If you use Thunderbird for email, you really *must*
back up its profile folder because all your email with its folder
structure is there. BTW, you can even copy the profile over to a Linux
machine that has Thunderbird, and presto, all your email will be there.
The Firefox profile would probably transfer just as well).

2. Bookmark all your open tabs under a new heading "open tabs", then
export the bookmarks. In the new machine, import them into Firefox
there. They won't open in tabs, but it will be easy to find them and
open them when you want to. You probably will want to copy over your
bookmarks anyway, so this adds little effort.

3. There may be a specific record of open tabs that you can copy or
export. I don't know about this but an internet search should help.

Good luck.


a nice solution comes from

How to Copy URLs of All Open Tabs in Firefox

https://www.howtogeek.com/723921/how-to-copy-urls-of-all-open-tabs-in-firefox/

right clicking opened tab, all opened tabs can be selected
moving via menu to bookmarks/ booksmarks management
url bookmarks can be right-mouse clicked to copy urls
finally, urls can be pasted into Notepad++
and saved as a file
unfortunately, saving as .html file
fails to generate html file with clickable web links



Don't go pasting urls into a text file one by one.  Instead, do my #2 
above. That will import all the bookmarks, including the tabs you saved 
as bookmarks.  Then import the exported bookmark file into the new 
browser.  There's no reason to fuss around trying to get text copies of 
urls to open.


For that matter, the exported bookmarks file is an HTML file and can be 
opened directly in a browser, with clickable links.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread a a
On Monday, 27 March 2023 at 19:19:41 UTC+2, Thomas Passin wrote:
> On 3/27/2023 10:07 AM, a a wrote: 
> > Ok, I know, I need to switch to Windows 10 run on another PC next to me. 
> >
> > I need to learn how to copy and move every web page opened in Firefox as a 
> > reference to social media, web sites for Python, chat and more (about 50 
> > web pages live opened  
> 
> This sounds like you mean when you get a new Windows 10 PC, you will 
> want to move your open tabs to the new machine. I see several 
> possibilities for this. 
> 
> 1. Copy your Firefox profile folder to the new computer, and tell 
> Firefox to use it as the default profile. I *think* this will include 
> the open tabs, but I haven't tried it. Saving that folder is useful for 
> backup anyway. (If you use Thunderbird for email, you really *must* 
> back up its profile folder because all your email with its folder 
> structure is there. BTW, you can even copy the profile over to a Linux 
> machine that has Thunderbird, and presto, all your email will be there. 
> The Firefox profile would probably transfer just as well). 
> 
> 2. Bookmark all your open tabs under a new heading "open tabs", then 
> export the bookmarks. In the new machine, import them into Firefox 
> there. They won't open in tabs, but it will be easy to find them and 
> open them when you want to. You probably will want to copy over your 
> bookmarks anyway, so this adds little effort. 
> 
> 3. There may be a specific record of open tabs that you can copy or 
> export. I don't know about this but an internet search should help. 
> 
> Good luck.

a nice solution comes from

How to Copy URLs of All Open Tabs in Firefox

https://www.howtogeek.com/723921/how-to-copy-urls-of-all-open-tabs-in-firefox/

right clicking opened tab, all opened tabs can be selected
moving via menu to bookmarks/ booksmarks management 
url bookmarks can be right-mouse clicked to copy urls
finally, urls can be pasted into Notepad++
and saved as a file
unfortunately, saving as .html file
fails to generate html file with clickable web links

Notepad++ keeps urls active, selectable but not ready to be opened in Firefox

so I need to learn how to make Notepad++ or another editor to save urls as
html file

BTW

Selecting all opened tabs I get 1,000+ active urls (opened web pages ), so 
something must be wrong
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread Thomas Passin

On 3/27/2023 10:07 AM, a a wrote:

Ok, I know, I need to switch to Windows 10 run on another PC next to me.

I need to learn how to copy and move every web page opened in Firefox as a 
reference to social media, web sites for Python, chat and more (about 50 web 
pages live opened 


This sounds like you mean when you get a new Windows 10 PC, you will 
want to move your open tabs to the new machine.  I see several 
possibilities for this.


1. Copy your Firefox profile folder to the new computer, and tell 
Firefox to use it as the default profile.  I *think* this will include 
the open tabs, but I haven't tried it.  Saving that folder is useful for 
backup anyway.  (If you use Thunderbird for email, you really *must* 
back up its profile folder because all your email with its folder 
structure is there. BTW, you can even copy the profile over to a Linux 
machine that has Thunderbird, and presto, all your email will be there. 
The Firefox profile would probably transfer just as well).


2. Bookmark all your open tabs under a new heading "open tabs", then 
export the bookmarks. In the new machine, import them into Firefox 
there.  They won't open in tabs, but it will be easy to find them and 
open them when you want to.  You probably will want to copy over your 
bookmarks anyway, so this adds little effort.


3. There may be a specific record of open tabs that you can copy or 
export.  I don't know about this but an internet search should help.


Good luck.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-27 Thread a a
On Thursday, 23 March 2023 at 22:15:10 UTC+1, Thomas Passin wrote:
> On 3/23/2023 3:38 PM, Mats Wichmann wrote: 
> > On 3/23/23 09:48, Thomas Passin wrote: 
> > 
> >> I didn't realize that Christoph Gohlke is still maintaining this site. 
> > 
> > Unless the the last-changed stuff stopped working, it's in a static state: 
> > 
> > by Christoph Gohlke. Updated on 26 June 2022 at 07:27 UTC
> I did see that. The OP needs a version that would work with Windows 7 
> and an older version of Python (3.7 or 3.8, IIRC), so things may work out.
Thank you Thomas for your excellent work you did for me.

Ok, I know, I need to switch to Windows 10 run on another PC next to me.

I need to learn how to copy and move every web page opened in Firefox as a 
reference to social media, web sites for Python, chat and more (about 50 web 
pages live opened ;)

I really love the limited functionality of w3schools to let me live open and 
run Python examples, especiallly Matplotlib examples.

Unfortunately chat forum at w3schools is low traffic, showing no interest to 
add more examples.


https://www.w3schools.com/python/trypython.asp?filename=demo_matplotlib_subplots3

https://www.w3schools.com/python/matplotlib_subplot.asp

thank you Thomas,

darius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-23 Thread Thomas Passin

On 3/23/2023 3:38 PM, Mats Wichmann wrote:

On 3/23/23 09:48, Thomas Passin wrote:

I didn't realize that Christoph Gohlke is still maintaining this site. 


Unless the the last-changed stuff stopped working, it's in a static state:

by Christoph Gohlke. Updated on 26 June 2022 at 07:27 UTC


I did see that.  The OP needs a version that would work with Windows 7 
and an older version of Python (3.7 or 3.8, IIRC), so things may work out.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-23 Thread Mats Wichmann

On 3/23/23 09:48, Thomas Passin wrote:

I didn't realize that Christoph Gohlke is still maintaining this site. 


Unless the the last-changed stuff stopped working, it's in a static state:

by Christoph Gohlke. Updated on 26 June 2022 at 07:27 UTC



--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-23 Thread Thomas Passin

On 3/18/2023 3:05 PM, Thomas Passin wrote:

downloaded and run HWiNFO and AVE not supported, not greened out


That's too bad; you may be out of luck.  It's possible that someone
has compiled the .pyd library in such a way that it does not need the
 instruction set extensions.  I'm sorry but I don't know how to find
out except by trying internet searches - or by downgrading to earlier
 versions of Numpy hoping to find one that works and also can be used
by the other libraries/programs that need to use it.


Here's a possibility to try -

https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

"NumPy: a fundamental package needed for scientific computing with Python.

Numpy+MKL is linked to the Intel® Math Kernel Library and includes
required DLLs in the numpy.DLLs directory.

Numpy+Vanilla is a minimal distribution, which does not include any
optimized BLAS libray or C runtime DLLs."

I didn't realize that Christoph Gohlke is still maintaining this site. I 
haven't needed to use it since PyPi got so much more complete about 
packages with binary code. He has tons of binary packages for all kinds 
of Python libraries.  I think this one might work for you because it 
links to the Intel math library. So it may be able to use various or no 
instruction set extensions. If so, it could work with your old processor.


Worth trying, anyway.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-22 Thread Thomas Passin

On 3/22/2023 8:09 AM, a a wrote:

On Saturday, 18 March 2023 at 20:12:22 UTC+1, Thomas Passin wrote:

On 3/17/2023 11:52 AM, a a wrote:

On Friday, 17 March 2023 at 16:32:53 UTC+1, a a wrote:

On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:

On 3/16/2023 8:07 PM, a a wrote:

Crash report:

Problem Caption:
Problem Event Name: APPCRASH
Application name: python.exe
Application version: 3.8.7150.1013
Application time signature: 5fe0df5a
Error module name: _multiarray_umath.cp38-win32.pyd
Version of the module with the error: 0.0.0.0
Time signature of the module with the error: 63dfe4cf
Exception code: c01d
Exception offset: 000269c9
Operating system version: 6.1.7601.2.1.0.256.48
Regional Settings ID: 1045
Additional information 1: 0a9e
Additional information 2: 0a9e372d3b4ad19135b953a78882e789
Additional information 3: 0a9e
Additional information 4: 0a9e372d3b4ad19135b953a78882e789

This exception has been reported to have many causes, but one
possibility seems to be that your computer may not support an advanced
instruction set that the .pyd was compiled for. I found this one
specifically mentioned on the Internet: Advanced Vector Extensions. If
that were the case, you would either need to find a different version of
the module, or upgrade the computer/OS.

It would be worth trying to downgrade the multiarray version to an
earlier one and see if that fixes the problem.

Thank you Thomas
for your kind reply.

I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
system
but I have visited every social chat support forum on the Internet: from Python 
to Matplotlib, Numpy, Twitter, Github.

As a newbie I am not aware how to downgrade "the multiarray version to an
earlier one

I simply tried to test Python code from


https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/


# Python program to read .csv file

import numpy as np
import matplotlib.pyplot as plt
import csv


"After importing the libraries, we now read the .csv file:

with open('accl1.csv', 'r') as f:
data = list(csv.reader(f, delimiter=',')) #reading csv file


Just read about AVE from Wikipedia

https://en.wikipedia.org/wiki/Advanced_Vector_Extensions



downloaded and run
HWiNFO
and AVE not supported, not greened out

That's too bad; you may be out of luck. It's possible that someone has
compiled the .pyd library in such a way that it does not need the
instruction set extensions. I'm sorry but I don't know how to find out
except by trying internet searches - or by downgrading to earlier
versions of Numpy hoping to find one that works and also can be used by
the other libraries/programs that need to use it.



Thank you Thomas for youre kind help.

You are the real Python PRO, you deserve Nobel Prize in Python.

:)


I operated an old Dell computer with Windows XP preinstalled
and upgraded XP to Windows 7 to get some web services to work.

Unfortunately I failed to find and install driver for video controller since 
none supported by Dell.

Visited many driver sites (Intel Driver Assistant included and more)
without any success.

So life with an old PC is not easy


I reused my 10-year-old Sony VAIO laptop (it had Windows 8, IIRC) to be 
a Linux machine - I got a 1T external solid state drive, set up the BIOS 
to boot from it, and installed Linux Mint.  If you are willing to tackle 
Linux, this might be a good way to go.  I recommend Mint for newcomers 
to Linux.  The computer is much snappier and pleasant to use than it was 
under Windows.


I mostly use it as a backup computer.  I had to to without my main 
computer for a week or so, and the old machine made a fine substitute. 
I even copied all my Thunderbird emails over and used email all the week 
without losing any messages. Actually, the keyboard on that old computer 
is much better than I've got on my new one, although a few keys are 
getting a little flaky.


I was able to compile some version of Python on it, though I forget why 
I needed to do that.  With this setup, you could install a newer version 
of Python, and Numpy would work - it might get compiled during 
installation, but that's not a problem.  It happens automatically.


If fact, I know that it works because I have Numpy working on the 
computer.  Of course, my computer has the instruction set extensions and 
your does not, so who knows if can be compiled for you.  But it would 
probably be your best bet.


Anyway, if you decide to try it out, let us know.  And if you hit any 
problems, I might be able to help you.  I'm not a Linux expert but I've 
installed various distributions maybe 20 times or more as virtual 
machines, and twice using an external drive, including running Tomcat 
and MySQL as services.  Once you get it installed and working, and 
learned some of its quirks (not too bad, mostly about installing 
programs and configuring the desktop to be more to your liking), it's 
not much diff

Re: Hello I want help get rid of that message and help install Python properly and thank you

2023-03-22 Thread Igor Korot
Hi,

On Wed, Mar 22, 2023 at 11:37 AM Mohammed nour Koujan
 wrote:
>
>
> --

What message?

Please don't post screenshots - copy and paste the errors from your machine...

Thank you.

> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-22 Thread a a
On Saturday, 18 March 2023 at 20:12:22 UTC+1, Thomas Passin wrote:
> On 3/17/2023 11:52 AM, a a wrote: 
> > On Friday, 17 March 2023 at 16:32:53 UTC+1, a a wrote: 
> >> On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote: 
> >>> On 3/16/2023 8:07 PM, a a wrote: 
> >>>> Crash report: 
> >>>> 
> >>>> Problem Caption: 
> >>>> Problem Event Name: APPCRASH 
> >>>> Application name: python.exe 
> >>>> Application version: 3.8.7150.1013 
> >>>> Application time signature: 5fe0df5a 
> >>>> Error module name: _multiarray_umath.cp38-win32.pyd 
> >>>> Version of the module with the error: 0.0.0.0 
> >>>> Time signature of the module with the error: 63dfe4cf 
> >>>> Exception code: c01d 
> >>>> Exception offset: 000269c9 
> >>>> Operating system version: 6.1.7601.2.1.0.256.48 
> >>>> Regional Settings ID: 1045 
> >>>> Additional information 1: 0a9e 
> >>>> Additional information 2: 0a9e372d3b4ad19135b953a78882e789 
> >>>> Additional information 3: 0a9e 
> >>>> Additional information 4: 0a9e372d3b4ad19135b953a78882e789 
> >>> This exception has been reported to have many causes, but one 
> >>> possibility seems to be that your computer may not support an advanced 
> >>> instruction set that the .pyd was compiled for. I found this one 
> >>> specifically mentioned on the Internet: Advanced Vector Extensions. If 
> >>> that were the case, you would either need to find a different version of 
> >>> the module, or upgrade the computer/OS. 
> >>> 
> >>> It would be worth trying to downgrade the multiarray version to an 
> >>> earlier one and see if that fixes the problem. 
> >> Thank you Thomas 
> >> for your kind reply. 
> >> 
> >> I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
> >> system 
> >> but I have visited every social chat support forum on the Internet: from 
> >> Python to Matplotlib, Numpy, Twitter, Github. 
> >> 
> >> As a newbie I am not aware how to downgrade "the multiarray version to an 
> >> earlier one 
> >> 
> >> I simply tried to test Python code from 
> >> 
> >> 
> >> https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/
> >>  
> >> 
> >>  
> >> # Python program to read .csv file 
> >> 
> >> import numpy as np 
> >> import matplotlib.pyplot as plt 
> >> import csv 
> >>  
> >> 
> >> "After importing the libraries, we now read the .csv file: 
> >> 
> >> with open('accl1.csv', 'r') as f: 
> >> data = list(csv.reader(f, delimiter=',')) #reading csv file 
> >> 
> >>  
> >> Just read about AVE from Wikipedia 
> >> 
> >> https://en.wikipedia.org/wiki/Advanced_Vector_Extensions 
> > 
> > 
> > downloaded and run 
> > HWiNFO 
> > and AVE not supported, not greened out
> That's too bad; you may be out of luck. It's possible that someone has 
> compiled the .pyd library in such a way that it does not need the 
> instruction set extensions. I'm sorry but I don't know how to find out 
> except by trying internet searches - or by downgrading to earlier 
> versions of Numpy hoping to find one that works and also can be used by 
> the other libraries/programs that need to use it.


Thank you Thomas for youre kind help.

You are the real Python PRO, you deserve Nobel Prize in Python.

I operated an old Dell computer with Windows XP preinstalled
and upgraded XP to Windows 7 to get some web services to work.

Unfortunately I failed to find and install driver for video controller since 
none supported by Dell.

Visited many driver sites (Intel Driver Assistant included and more)
without any success.

So life with an old PC is not easy



-- 
https://mail.python.org/mailman/listinfo/python-list


Hello I want help get rid of that message and help install Python properly and thank you

2023-03-22 Thread Mohammed nour Koujan


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread Thomas Passin

On 3/17/2023 11:52 AM, a a wrote:

On Friday, 17 March 2023 at 16:32:53 UTC+1, a a wrote:

On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:

On 3/16/2023 8:07 PM, a a wrote:

Crash report:

Problem Caption:
Problem Event Name: APPCRASH
Application name: python.exe
Application version: 3.8.7150.1013
Application time signature: 5fe0df5a
Error module name: _multiarray_umath.cp38-win32.pyd
Version of the module with the error: 0.0.0.0
Time signature of the module with the error: 63dfe4cf
Exception code: c01d
Exception offset: 000269c9
Operating system version: 6.1.7601.2.1.0.256.48
Regional Settings ID: 1045
Additional information 1: 0a9e
Additional information 2: 0a9e372d3b4ad19135b953a78882e789
Additional information 3: 0a9e
Additional information 4: 0a9e372d3b4ad19135b953a78882e789

This exception has been reported to have many causes, but one
possibility seems to be that your computer may not support an advanced
instruction set that the .pyd was compiled for. I found this one
specifically mentioned on the Internet: Advanced Vector Extensions. If
that were the case, you would either need to find a different version of
the module, or upgrade the computer/OS.

It would be worth trying to downgrade the multiarray version to an
earlier one and see if that fixes the problem.

Thank you Thomas
for your kind reply.

I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
system
but I have visited every social chat support forum on the Internet: from Python 
to Matplotlib, Numpy, Twitter, Github.

As a newbie I am not aware how to downgrade "the multiarray version to an
earlier one

I simply tried to test Python code from


https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/


# Python program to read .csv file

import numpy as np
import matplotlib.pyplot as plt
import csv


"After importing the libraries, we now read the .csv file:

with open('accl1.csv', 'r') as f:
data = list(csv.reader(f, delimiter=',')) #reading csv file


Just read about AVE from Wikipedia

https://en.wikipedia.org/wiki/Advanced_Vector_Extensions



downloaded and run
HWiNFO
and AVE not supported, not greened out


That's too bad; you may be out of luck.  It's possible that someone has 
compiled the .pyd library in such a way that it does not need the 
instruction set extensions.  I'm sorry but I don't know how to find out 
except by trying internet searches - or by downgrading to earlier 
versions of Numpy hoping to find one that works and also can be used by 
the other libraries/programs that need to use it.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread Thomas Passin

On 3/17/2023 11:32 AM, a a wrote:

On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:


It would be worth trying to downgrade the multiarray version to an 
earlier one and see if that fixes the problem.


Thank you Thomas for your kind reply.

I am fully aware to be living on an old machine, old OS, Windows 7,
32-bit system but I have visited every social chat support forum on
the Internet: from Python to Matplotlib, Numpy, Twitter, Github.

I mentioned the "multiarray" just because of its name in the error message:

"Error module name: _multiarray_umath.cp38-win32.pyd "

I assumed that the code you tried to run required an import from a
module or package whose name included "multiarray".  But I didn't try to
actually look for one.  Now I've checked, and I see it's included with
NumPy.


I simply tried to test Python code from


https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/

  # Python program to read .csv file

import numpy as np import matplotlib.pyplot as plt import csv 

"After importing the libraries, we now read the .csv file:

with open('accl1.csv', 'r') as f: data = list(csv.reader(f,
delimiter=',')) #reading csv file


You don't need numpy just to do this import, so you could remove the
numpy import just to test reading the csv file.  But I imagine you do
need numpy for later steps.



As a newbie I am not aware how to downgrade "the multiarray version
to an earlier one.
I just had to do this myself to work around a change in an import that 
broke one of my programs (not a numpy import).  If you can identify an 
earlier version that work - we will use proglib v 3.72 as an example - 
with pip you would use


python3 -m pip install --upgrade proglib<=3.72

To get exactly version 3.72, you would use "==3.72".

NOTE - no space allowed before the first "=" character!.
NOTE - you may need to type "python" or "py" instead of "python3".  Just 
use the one that runs the version of Python that you want to run.


To find which versions are available:

python3 -m pip install --upgrade proglib==

To find out which version you have installed on your computer:

python3 -m pip show numpy

After you downgrade to an earlier version, you can test it just by 
trying to import numpy.  In an interpreter session, just try to import it:


>>> import numpy

If that succeeds, chances are you will be all set.


 Just read about AVE from Wikipedia

https://en.wikipedia.org/wiki/Advanced_Vector_Extensions


I have read that there are other instruction set extensions that could 
be missing besides AVE, that could cause that exception code.  The fact 
that you have a relatively old computer suggests that could be the problem.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread a a
On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:
> On 3/16/2023 8:07 PM, a a wrote: 
> > Crash report: 
> > 
> > Problem Caption: 
> > Problem Event Name: APPCRASH 
> > Application name: python.exe 
> > Application version: 3.8.7150.1013 
> > Application time signature: 5fe0df5a 
> > Error module name: _multiarray_umath.cp38-win32.pyd 
> > Version of the module with the error: 0.0.0.0 
> > Time signature of the module with the error: 63dfe4cf 
> > Exception code: c01d 
> > Exception offset: 000269c9 
> > Operating system version: 6.1.7601.2.1.0.256.48 
> > Regional Settings ID: 1045 
> > Additional information 1: 0a9e 
> > Additional information 2: 0a9e372d3b4ad19135b953a78882e789 
> > Additional information 3: 0a9e 
> > Additional information 4: 0a9e372d3b4ad19135b953a78882e789
> This exception has been reported to have many causes, but one 
> possibility seems to be that your computer may not support an advanced 
> instruction set that the .pyd was compiled for. I found this one 
> specifically mentioned on the Internet: Advanced Vector Extensions. If 
> that were the case, you would either need to find a different version of 
> the module, or upgrade the computer/OS. 
> 
> It would be worth trying to downgrade the multiarray version to an 
> earlier one and see if that fixes the problem.


Just reading from search engine:

https://www.bing.com/search?q=how+to+downgrade+_multiarray_umath.cp38-win32.pyd+=QBLH=-1=0=how+to+downgrade+_multiarray_umath.cp38-win32.pyd+=1-50=n=
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread a a
On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:
> On 3/16/2023 8:07 PM, a a wrote: 
> > Crash report: 
> > 
> > Problem Caption: 
> > Problem Event Name: APPCRASH 
> > Application name: python.exe 
> > Application version: 3.8.7150.1013 
> > Application time signature: 5fe0df5a 
> > Error module name: _multiarray_umath.cp38-win32.pyd 
> > Version of the module with the error: 0.0.0.0 
> > Time signature of the module with the error: 63dfe4cf 
> > Exception code: c01d 
> > Exception offset: 000269c9 
> > Operating system version: 6.1.7601.2.1.0.256.48 
> > Regional Settings ID: 1045 
> > Additional information 1: 0a9e 
> > Additional information 2: 0a9e372d3b4ad19135b953a78882e789 
> > Additional information 3: 0a9e 
> > Additional information 4: 0a9e372d3b4ad19135b953a78882e789
> This exception has been reported to have many causes, but one 
> possibility seems to be that your computer may not support an advanced 
> instruction set that the .pyd was compiled for. I found this one 
> specifically mentioned on the Internet: Advanced Vector Extensions. If 
> that were the case, you would either need to find a different version of 
> the module, or upgrade the computer/OS. 
> 
> It would be worth trying to downgrade the multiarray version to an 
> earlier one and see if that fixes the problem.

Thank you Thomas
for your kind reply.

I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
system
but I have visited every social chat support forum on the Internet: from Python 
to Matplotlib, Numpy, Twitter, Github.

As a newbie I am not aware how to downgrade "the multiarray version to an 
 earlier one

I simply tried to test Python code from


https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/


# Python program to read .csv file

import numpy as np
import matplotlib.pyplot as plt
import csv


"After importing the libraries, we now read the .csv file:

with open('accl1.csv', 'r') as f:
data = list(csv.reader(f, delimiter=',')) #reading csv file


Just read about AVE from Wikipedia

https://en.wikipedia.org/wiki/Advanced_Vector_Extensions

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread a a
On Friday, 17 March 2023 at 16:32:53 UTC+1, a a wrote:
> On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote: 
> > On 3/16/2023 8:07 PM, a a wrote: 
> > > Crash report: 
> > > 
> > > Problem Caption: 
> > > Problem Event Name: APPCRASH 
> > > Application name: python.exe 
> > > Application version: 3.8.7150.1013 
> > > Application time signature: 5fe0df5a 
> > > Error module name: _multiarray_umath.cp38-win32.pyd 
> > > Version of the module with the error: 0.0.0.0 
> > > Time signature of the module with the error: 63dfe4cf 
> > > Exception code: c01d 
> > > Exception offset: 000269c9 
> > > Operating system version: 6.1.7601.2.1.0.256.48 
> > > Regional Settings ID: 1045 
> > > Additional information 1: 0a9e 
> > > Additional information 2: 0a9e372d3b4ad19135b953a78882e789 
> > > Additional information 3: 0a9e 
> > > Additional information 4: 0a9e372d3b4ad19135b953a78882e789 
> > This exception has been reported to have many causes, but one 
> > possibility seems to be that your computer may not support an advanced 
> > instruction set that the .pyd was compiled for. I found this one 
> > specifically mentioned on the Internet: Advanced Vector Extensions. If 
> > that were the case, you would either need to find a different version of 
> > the module, or upgrade the computer/OS. 
> > 
> > It would be worth trying to downgrade the multiarray version to an 
> > earlier one and see if that fixes the problem.
> Thank you Thomas 
> for your kind reply. 
> 
> I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
> system 
> but I have visited every social chat support forum on the Internet: from 
> Python to Matplotlib, Numpy, Twitter, Github. 
> 
> As a newbie I am not aware how to downgrade "the multiarray version to an 
> earlier one 
> 
> I simply tried to test Python code from 
> 
> 
> https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/
>  
> 
>  
> # Python program to read .csv file 
> 
> import numpy as np 
> import matplotlib.pyplot as plt 
> import csv 
>  
> 
> "After importing the libraries, we now read the .csv file: 
> 
> with open('accl1.csv', 'r') as f: 
> data = list(csv.reader(f, delimiter=',')) #reading csv file 
> 
>  
> Just read about AVE from Wikipedia 
> 
> https://en.wikipedia.org/wiki/Advanced_Vector_Extensions


downloaded and run
HWiNFO
and AVE not supported, not greened out
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-17 Thread Thomas Passin

On 3/16/2023 8:07 PM, a a wrote:

Crash report:

Problem Caption:
   Problem Event Name:  APPCRASH
   Application name: python.exe
   Application version: 3.8.7150.1013
   Application time signature:  5fe0df5a
   Error module name:   _multiarray_umath.cp38-win32.pyd
   Version of the module with the error:0.0.0.0
   Time signature of the module with the error: 63dfe4cf
   Exception code: c01d
   Exception offset:000269c9
   Operating system version:6.1.7601.2.1.0.256.48
   Regional Settings ID:1045
   Additional information 1: 0a9e
   Additional information 2: 0a9e372d3b4ad19135b953a78882e789
   Additional information 3: 0a9e
   Additional information 4: 0a9e372d3b4ad19135b953a78882e789


This exception has been reported to have many causes, but one 
possibility seems to be that your computer may not support an advanced 
instruction set that the .pyd was compiled for.  I found this one 
specifically mentioned on the Internet: Advanced Vector Extensions.  If 
that were the case, you would either need to find a different version of 
the module, or upgrade the computer/OS.


It would be worth trying to downgrade the multiarray version to an 
earlier one and see if that fixes the problem.

--
https://mail.python.org/mailman/listinfo/python-list


Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-17 Thread a a
Crash report:

Problem Caption:
  Problem Event Name:   APPCRASH
  Application name: python.exe
  Application version:  3.8.7150.1013
  Application time signature:   5fe0df5a
  Error module name:_multiarray_umath.cp38-win32.pyd
  Version of the module with the error: 0.0.0.0
  Time signature of the module with the error:  63dfe4cf
  Exception code: c01d
  Exception offset: 000269c9
  Operating system version: 6.1.7601.2.1.0.256.48
  Regional Settings ID: 1045
  Additional information 1: 0a9e
  Additional information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional information 3: 0a9e
  Additional information 4: 0a9e372d3b4ad19135b953a78882e789
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Custom help format for a choice argparse argument

2023-01-30 Thread Peter Otten

On 27/01/2023 21:31, Ivan "Rambius" Ivanov wrote:

Hello,

I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have

def main():
 parser = argparse.ArgumentParser()
 parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
 args = parser.parse_args()
 print(args)
 print(f"Specified timezone: {args.zone}")

It works, but when I run it with the -h option it dumps all entries in
pytz.all_timezones. I would like to modify the help format for just
-z|--zone option. I read the docs about HelpFormatter and argparse.py
and I ended up with

class CustomHelpFormatter(argparse.HelpFormatter):
 def _metavar_formatter(self, action, default_metavar):
 if action.dest == 'zone':
 result = 'zone from pytz.all_timezones'
 def format(tuple_size):
 if isinstance(result, tuple):
 return result
 else:
 return (result, ) * tuple_size
 return format
 else:
 return super(CustomHelpFormatter,
self)._metavar_formatter(action, default_metavar)


def main():
 parser = argparse.ArgumentParser(formatter_class=CustomHelpFormatter)
 parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
 args = parser.parse_args()
 print(args)
 print(f"Specified timezone: {args.zone}")

This works, but is there a more elegant way to achieve it?


It may be sufficient to specify a metavar:

>>> import argparse
>>> p = argparse.ArgumentParser()
>>> p.add_argument("--foo", choices="alpha beta gamma".split(),
metavar="")
[...]
>>> p.parse_args(["-h"])
usage: [-h] [--foo ]

optional arguments:
  -h, --helpshow this help message and exit
  --foo 

While that helps with --help it doesn't always prevent the choices list
from being spelt out:

>>> p.parse_args(["--foo", "whatever"])
usage: [-h] [--foo ]
: error: argument --foo: invalid choice: 'whatever' (choose from
'alpha', 'beta', 'gamma')

--
https://mail.python.org/mailman/listinfo/python-list


Re: Custom help format for a choice argparse argument

2023-01-27 Thread Thomas Passin

On 1/27/2023 4:53 PM, Ivan "Rambius" Ivanov wrote:

Hello Cameron,

On Fri, Jan 27, 2023 at 4:45 PM Cameron Simpson  wrote:


On 27Jan2023 15:31, Ivan "Rambius" Ivanov  wrote:

I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have

def main():
parser = argparse.ArgumentParser()
parser.add_argument("-z", "--zone", choices=pytz.all_timezones)

[...]


It works, but when I run it with the -h option it dumps all entries in
pytz.all_timezones.


What happens if you just presupply a `help=` parameter in
`add_argument`?


I tried with def main():
 parser = argparse.ArgumentParser()
 parser.add_argument("-z", "--zone", choices=pytz.all_timezones,
help="a timezone from pytz.all_timezones")
 args = parser.parse_args()
 print(args)

-h still shows all the contents of pytz.all_timezones.



Adding a few arguments makes it work (with the help of the argparse doc 
page and Stack Overflow:


https://stackoverflow.com/questions/14950964/overriding-default-argparse-h-behaviour):

import argparse
import pytz

HELP ="""\nThis is the help message.
This is the second line of the help message."""

def main():
parser = argparse.ArgumentParser(add_help=False, usage = HELP)
parser.add_argument("-z", "--zone", choices=pytz.all_timezones,
help = argparse.SUPPRESS)
parser.add_argument('-h', '--h', action = 'help',
help = argparse.SUPPRESS)
args = parser.parse_args()
print(args)
print(f"Specified timezone: {args.zone}")


main()

Your help message will display after "usage", like this -

usage:
This is the help message.
This is the second line of the help message.

You would give up have argparse automatically list all the options, but 
you can add add them manually to the HELP string.



--
https://mail.python.org/mailman/listinfo/python-list


Re: Custom help format for a choice argparse argument

2023-01-27 Thread Ivan "Rambius" Ivanov
Hello Cameron,

On Fri, Jan 27, 2023 at 4:45 PM Cameron Simpson  wrote:
>
> On 27Jan2023 15:31, Ivan "Rambius" Ivanov  
> wrote:
> >I am developing a script that accepts a time zone as an option. The
> >time zone can be any from pytz.all_timezones. I have
> >
> >def main():
> >parser = argparse.ArgumentParser()
> >parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
> [...]
> >
> >It works, but when I run it with the -h option it dumps all entries in
> >pytz.all_timezones.
>
> What happens if you just presupply a `help=` parameter in
> `add_argument`?

I tried with def main():
    parser = argparse.ArgumentParser()
parser.add_argument("-z", "--zone", choices=pytz.all_timezones,
help="a timezone from pytz.all_timezones")
args = parser.parse_args()
print(args)

-h still shows all the contents of pytz.all_timezones.

Regards
rambius

>
> Cheers,
> Cameron Simpson 
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Tangra Mega Rock: http://www.radiotangra.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Custom help format for a choice argparse argument

2023-01-27 Thread Cameron Simpson

On 27Jan2023 15:31, Ivan "Rambius" Ivanov  wrote:

I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have

def main():
   parser = argparse.ArgumentParser()
   parser.add_argument("-z", "--zone", choices=pytz.all_timezones)

[...]


It works, but when I run it with the -h option it dumps all entries in
pytz.all_timezones.


What happens if you just presupply a `help=` parameter in 
`add_argument`?


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Custom help format for a choice argparse argument

2023-01-27 Thread Ivan "Rambius" Ivanov
Hello,

On Fri, Jan 27, 2023 at 4:22 PM Weatherby,Gerard  wrote:
>
> Why not something like:
>
>
> parser.add_argument("-z", "--zone")
>
>args = parser.parse_args()
>if args.zone and args.zone not in ptyz.all_timezones:
>
> print(“Invalid timezone”,file=sys.stderr)
>
This is what I use now. I still wonder if I can mold HelpFormatter to
do what I want it to do.

> …
>
>
>
>
> From: Python-list  on 
> behalf of Ivan "Rambius" Ivanov 
> Date: Friday, January 27, 2023 at 3:33 PM
> To: Python 
> Subject: Custom help format for a choice argparse argument
>
> *** Attention: This is an external email. Use caution responding, opening 
> attachments or clicking on links. ***
>
> Hello,
>
> I am developing a script that accepts a time zone as an option. The
> time zone can be any from pytz.all_timezones. I have
>
> def main():
> parser = argparse.ArgumentParser()
> parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
> args = parser.parse_args()
> print(args)
> print(f"Specified timezone: {args.zone}")
>
> It works, but when I run it with the -h option it dumps all entries in
> pytz.all_timezones. I would like to modify the help format for just
> -z|--zone option. I read the docs about HelpFormatter and argparse.py
> and I ended up with
>
> class CustomHelpFormatter(argparse.HelpFormatter):
> def _metavar_formatter(self, action, default_metavar):
> if action.dest == 'zone':
> result = 'zone from pytz.all_timezones'
> def format(tuple_size):
> if isinstance(result, tuple):
> return result
> else:
> return (result, ) * tuple_size
> return format
> else:
> return super(CustomHelpFormatter,
> self)._metavar_formatter(action, default_metavar)
>
>
> def main():
> parser = argparse.ArgumentParser(formatter_class=CustomHelpFormatter)
> parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
> args = parser.parse_args()
> print(args)
> print(f"Specified timezone: {args.zone}")
>
> This works, but is there a more elegant way to achieve it?
>
> Regards
> rambius
>
> --
> Tangra Mega Rock: 
> https://urldefense.com/v3/__http://www.radiotangra.com__;!!Cn_UX_p3!kiJusdm5pCptP3sOBX85KXqUJkqr2jSa4C_-WAqND7WkL-aw3BYbW50td_AcuzJ1XUPYIVO3JiLMc4gRWS885vTKFsFvaQ$
> --
> https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!kiJusdm5pCptP3sOBX85KXqUJkqr2jSa4C_-WAqND7WkL-aw3BYbW50td_AcuzJ1XUPYIVO3JiLMc4gRWS885vRXq-JKLg$



-- 
Tangra Mega Rock: http://www.radiotangra.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Custom help format for a choice argparse argument

2023-01-27 Thread Weatherby,Gerard
Why not something like:

parser.add_argument("-z", "--zone")
   args = parser.parse_args()
   if args.zone and args.zone not in ptyz.all_timezones:
print(“Invalid timezone”,file=sys.stderr)
…



From: Python-list  on 
behalf of Ivan "Rambius" Ivanov 
Date: Friday, January 27, 2023 at 3:33 PM
To: Python 
Subject: Custom help format for a choice argparse argument
*** Attention: This is an external email. Use caution responding, opening 
attachments or clicking on links. ***

Hello,

I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have

def main():
parser = argparse.ArgumentParser()
parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
args = parser.parse_args()
print(args)
print(f"Specified timezone: {args.zone}")

It works, but when I run it with the -h option it dumps all entries in
pytz.all_timezones. I would like to modify the help format for just
-z|--zone option. I read the docs about HelpFormatter and argparse.py
and I ended up with

class CustomHelpFormatter(argparse.HelpFormatter):
def _metavar_formatter(self, action, default_metavar):
if action.dest == 'zone':
result = 'zone from pytz.all_timezones'
def format(tuple_size):
if isinstance(result, tuple):
return result
else:
return (result, ) * tuple_size
return format
else:
return super(CustomHelpFormatter,
self)._metavar_formatter(action, default_metavar)


def main():
parser = argparse.ArgumentParser(formatter_class=CustomHelpFormatter)
parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
args = parser.parse_args()
print(args)
print(f"Specified timezone: {args.zone}")

This works, but is there a more elegant way to achieve it?

Regards
rambius

--
Tangra Mega Rock: 
https://urldefense.com/v3/__http://www.radiotangra.com__;!!Cn_UX_p3!kiJusdm5pCptP3sOBX85KXqUJkqr2jSa4C_-WAqND7WkL-aw3BYbW50td_AcuzJ1XUPYIVO3JiLMc4gRWS885vTKFsFvaQ$<https://urldefense.com/v3/__http:/www.radiotangra.com__;!!Cn_UX_p3!kiJusdm5pCptP3sOBX85KXqUJkqr2jSa4C_-WAqND7WkL-aw3BYbW50td_AcuzJ1XUPYIVO3JiLMc4gRWS885vTKFsFvaQ$>
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!kiJusdm5pCptP3sOBX85KXqUJkqr2jSa4C_-WAqND7WkL-aw3BYbW50td_AcuzJ1XUPYIVO3JiLMc4gRWS885vRXq-JKLg$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!kiJusdm5pCptP3sOBX85KXqUJkqr2jSa4C_-WAqND7WkL-aw3BYbW50td_AcuzJ1XUPYIVO3JiLMc4gRWS885vRXq-JKLg$>
-- 
https://mail.python.org/mailman/listinfo/python-list


Custom help format for a choice argparse argument

2023-01-27 Thread Ivan "Rambius" Ivanov
Hello,

I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have

def main():
parser = argparse.ArgumentParser()
parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
args = parser.parse_args()
print(args)
print(f"Specified timezone: {args.zone}")

It works, but when I run it with the -h option it dumps all entries in
pytz.all_timezones. I would like to modify the help format for just
-z|--zone option. I read the docs about HelpFormatter and argparse.py
and I ended up with

class CustomHelpFormatter(argparse.HelpFormatter):
def _metavar_formatter(self, action, default_metavar):
if action.dest == 'zone':
result = 'zone from pytz.all_timezones'
def format(tuple_size):
if isinstance(result, tuple):
return result
else:
return (result, ) * tuple_size
return format
else:
return super(CustomHelpFormatter,
self)._metavar_formatter(action, default_metavar)


def main():
parser = argparse.ArgumentParser(formatter_class=CustomHelpFormatter)
parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
args = parser.parse_args()
print(args)
print(f"Specified timezone: {args.zone}")

This works, but is there a more elegant way to achieve it?

Regards
rambius

-- 
Tangra Mega Rock: http://www.radiotangra.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Help Request] Embedding Python in a CPP Application Responsibly & Functionally

2023-01-26 Thread Dieter Maurer
John McCardle wrote at 2023-1-25 22:31 -0500:
> ...
>1) To get the compiled Python to run independently, I have to hack
>LD_LIBRARY_PATH to get it to execute. `LD_LIBRARY_PATH=./Python-3.11.1
>./Python-3.11.1/python` .

The need to set `LD_LIBRARY_PATH` usually can be avoided via
a link time option: it tells the linker to add library path
information into the created shared object.

Read the docs to find out which option this is (I think it
was `-r` but I am not sure).

>Even when trying to execute from the same
>directory as the binary & executable, I get an error, `/python: error
>while loading shared libraries: libpython3.11.so.1.0: cannot open shared
>object file: No such file or directory`.

It might be necessary, to provide the option mentioned above
for all shared libraries involved in your final application.

Alternatively, you could try to put the shared objects
into a stadard place (searched by default).

>2) When running the C++ program that embeds Python, I see these messages
>after initializing:
>`Could not find platform independent libraries 
>Could not find platform dependent libraries `

Again: either put your installation in a standard place
or tell the Python generation process about your non-standard place.


>This is seemingly connected to some issues regarding libraries: When I
>run the Python interpreter directly, I can get some of the way through
>the process of creating a virtual environment, but it doesn't seem to
>leave me with a working pip:
>
>`$ LD_LIBRARY_PATH=./Python-3.11.1 ./Python-3.11.1/python
> >>> import venv
> >>> venv.create("./venv", with_pip=True)
>subprocess.CalledProcessError: Command
>'['/home/john/Development/7DRL/cpp_embedded_python/venv/bin/python',
>'-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit
>status 127.`

Run the command manually and see what errors this gives.

> ...

>3) I'm not sure I even need to be statically linking the interpreter.

There should be no need (if all you want in the embedding).
-- 
https://mail.python.org/mailman/listinfo/python-list


[Help Request] Embedding Python in a CPP Application Responsibly & Functionally

2023-01-25 Thread John McCardle

Greetings,

I'm working on embedding a Python interpreter into a C++ application. My 
embedding example program is here, largely taken from Python docs: 
https://gist.github.com/jmccardle/f3f19d3753ae023aa52b927f0d181c43


I'm simply not interested in writing in Lua, so regardless of any 
particular downsides like `sys` in the standard library or performance 
issues, I'm committed to Python itself as what I want to hack in. This 
is for fun.


I started by compiling Python:

`./configure --enable-shared --enable-optimizations`

Then I can compile my example embedded program:

`g++ -I Python-3.11.1/Include -I Python-3.11.1 -L Python-3.11.1 -pthread 
scripting_engine.cpp libpython3.11.a -o scripteng -lm -ldl -lutil`


This is working not so bad! I can control what C++ functionality is 
exposed and I seemingly don't need anything but the Python shared object 
to execute. But the finer details of making this work truly correctly 
are eluding me.


1) To get the compiled Python to run independently, I have to hack 
LD_LIBRARY_PATH to get it to execute. `LD_LIBRARY_PATH=./Python-3.11.1 
./Python-3.11.1/python` . Even when trying to execute from the same 
directory as the binary & executable, I get an error, `/python: error 
while loading shared libraries: libpython3.11.so.1.0: cannot open shared 
object file: No such file or directory`.


2) When running the C++ program that embeds Python, I see these messages 
after initializing:

`Could not find platform independent libraries 
Could not find platform dependent libraries `

This is seemingly connected to some issues regarding libraries: When I 
run the Python interpreter directly, I can get some of the way through 
the process of creating a virtual environment, but it doesn't seem to 
leave me with a working pip:


`$ LD_LIBRARY_PATH=./Python-3.11.1 ./Python-3.11.1/python
>>> import venv
>>> venv.create("./venv", with_pip=True)
subprocess.CalledProcessError: Command 
'['/home/john/Development/7DRL/cpp_embedded_python/venv/bin/python', 
'-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit 
status 127.`


Meanwhile, if I try to run a script from the C++ program that includes 
`import venv`, I get a traceback about a platform library:


`Traceback (most recent call last):
  File "engine_user.py", line 7, in 
    import venv
  File 
"/home/john/Development/7DRL/cpp_embedded_python/Python-3.11.1/Lib/venv/__init__.py", 
line 10, in 

    import subprocess
  File 
"/home/john/Development/7DRL/cpp_embedded_python/Python-3.11.1/Lib/subprocess.py", 
line 104, in 

    from _posixsubprocess import fork_exec as _fork_exec
ModuleNotFoundError: No module named '_posixsubprocess'
`

3) I'm not sure I even need to be statically linking the interpreter.

My desired end state is this:
* Deploy a C++ program that doesn't rely on a system Python. I'm not 
sure if I need just the shared object / DLLs, or a Python executable in 
a subdirectory - I'd like to "do it the right way".
* C++ program can run a script to create a virtual environment, which 
the embedded Python environment will use. Users can activate the venv 
like any other Python environment and install packages with pip.
* ideally, some sort of "inside-out" runnable mode, where the API 
exposed by the C++ executable is available in that venv, so that I can 
test a script in Thonny or other IDE. I think I'd do this by providing a 
separate test-mode library in the venv, and when C++ executes 
`PyImport_AppendInittab("scriptable", _scriptable);` then the 
module of the same name should be overwritten with the C++ program's 
functionality.


I've been through the embedded programming docs a bit, and they seem 
quite good as a reference, but I don't know what I'm doing well enough 
to solve my problems using them. Thanks for reading.


My ultimate goal is to expose features written in C++ for a game engine 
using SFML, and run .py files in a subdirectory to generate maps, 
control NPC dialogue and actions, etc. I'm hoping to have something 
usable for this year's 7DRL, which starts March 4th. I'd like to spend 
the time until then getting this engine working smoothly and porting it 
to Windows, so I can focus exclusively on "game content" for the 
timeboxed 7-day portion.


Kind Regards,
-John McCardle

--
https://mail.python.org/mailman/listinfo/python-list


Re: help

2022-12-30 Thread Chris Grace
Hello,

The mailing list strips all images. We cannot see the error you posted. I'd
recommend posting it in text form.

What is the script you are running?

What do you expect your script to do?

On Fri, Dec 30, 2022, 3:14 PM Mor yosef  wrote:

> Hello guys,
> i install python 3.11.1, and i have google chrome so i download the
> Webdriver Chrome
> and i just add it on my c:// driver and when i add some script on my
> desktop i try to run it from the terminal and all the time i receive this
> error message : maybe you guys can help me with this one?
> when i add some random code the terminal like "python -m webbrowser
> https://www.google.com; it's just works (it's open the website in new tab)
> Regards
> Mor yosef
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


help

2022-12-30 Thread Mor yosef
Hello guys,
i install python 3.11.1, and i have google chrome so i download the
Webdriver Chrome
and i just add it on my c:// driver and when i add some script on my
desktop i try to run it from the terminal and all the time i receive this
error message : maybe you guys can help me with this one?
when i add some random code the terminal like "python -m webbrowser
https://www.google.com; it's just works (it's open the website in new tab)
Regards
Mor yosef
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help Merging Of Separate Python Codes

2022-11-19 Thread dn

On 20/11/2022 02.20, maria python wrote:
Hello, I have these two python codes that work well separately and I 
want to combine them, but I am not sure how to do it. Also after that, I 
want to print the result in txt cvs or another file format. Do you have 
a code for that? Thank you.



Have you tried joining them together, one after the other?

Have you looked at the Python docs?
eg https://docs.python.org/3/library/csv.html

Do you need the help of a professional to write code for you?

If you are learning Python, perhaps the Tutor list will be a more 
appropriate for you...


--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help with custom string formatter

2022-11-05 Thread MRAB

On 2022-11-05 11:07, Stefan Ram wrote:

Robert Latest  writes:

result += ' ' *( length - len( result ))

Nice, I didn't know that one could multiply strings by negative numbers without
error.


   Thanks, but today I thought that maybe there might
   be a solution for getting a field of a fixed length
   that is even shorter. It uses Python's string
   formatting, here in the form of an "f" string.

   main.py

def f( result, length ):
 # get a field with the given length from the string "result"
 # - as used in postings from october
 result = result[ :length ]
 result += ' ' *( length - len( result ))


That can be done more compactly as:

 result = result[ : length].ljust(length)


 return result


[snip]


--
https://mail.python.org/mailman/listinfo/python-list


Re: need help

2022-10-24 Thread Peter J. Holzer
On 2022-10-24 01:02:24 +, rbowman wrote:
> On Mon, 24 Oct 2022 10:02:10 +1100, Cameron Simpson wrote:
> > I'd say GMail are rudely dropping traffic to port 2525. Maybe try just
> > 25,
> > the normal SMTP port?
> 
> 2525 is an alternative to 587, the standard TLS port.

Port 587 is not the standard TLS port. Port 587 is the standard mail
submission port (i.e., a MUA should use port 587 when sending mail; MTAs
should use port 25 when relaying mails to other MTAs).

Traffic on both port 25 and 587 starts in plain text. The server can
indicate that it supports TLS and the client can then send a STARTTLS
command to start a TLS session.

If you want to start the connection with TLS, you can (usually) use port
465. Like 587, this is only intended for mail submission, not mail
transport.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need help

2022-10-23 Thread Cameron Simpson

On 24Oct2022 01:02, rbowman  wrote:

On Mon, 24 Oct 2022 10:02:10 +1100, Cameron Simpson wrote:
I'd say GMail are rudely dropping traffic to port 2525. Maybe try 
just 25, the normal SMTP port?


2525 is an alternative to 587, the standard TLS port.


Yah. My point was more focussed on GMail's shoddy firewall practices not 
returning connection refused.



25  and 587 work.


Good to know. Thanks!
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: need help

2022-10-23 Thread rbowman
On Mon, 24 Oct 2022 10:02:10 +1100, Cameron Simpson wrote:


> I'd say GMail are rudely dropping traffic to port 2525. Maybe try just
> 25,
> the normal SMTP port?

2525 is an alternative to 587, the standard TLS port. 25  and 587 work.

telnet smtp.gmail.com 587
Trying 2607:f8b0:4023:1004::6d...
Connected to smtp.gmail.com.
Escape character is '^]'.
220 smtp.gmail.com ESMTP s6-20020a056870ea8600b0010bf07976c9sm13154711oap.
41 - gsmtp
EHLO
501-5.5.4 Empty HELO/EHLO argument not allowed, closing connection.
501 5.5.4  https://support.google.com/mail/?p=helo 
s6-20020a056870ea8600b0010bf07976c9sm13154711oap.41 - gsmtp
Connection closed by foreign host.


The EHLO needs a domain.  Port 25 is the same. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need help

2022-10-23 Thread Cameron Simpson
Please try to choose more descriptive subject lines (eg "problem with 
sock.connect" or similar). That you want help is almost implicit, and 
what the whole list is for.


Anyway, to your problem:

On 23Oct2022 10:19, Shuaib Akhtar  wrote:

  How to fix Traceback (most recent call last):
    File "C:\Program
  
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\socket.py",
  line 833, in create_connection
      sock.connect(sa)
  TimeoutError: [WinError 10060] A connection attempt failed because 
  the connected party did not properly respond after a period of time, or

  established connection failed because connected host has failed to respond


This usually means that either the host address is legal but incorrect 
(there's no host/server listening with that address) or that the port is 
incorrect and some firewall is _discarding_ your traffic because of the 
wrong port instead of returning a nice "connection refused", which is 
usually instant.


Fortunately you've listed your call:

    File "C:\Users\i9shu\Downloads\python email bot\email bot.py", 
  line 25,

  in 
      server = smtplib.SMTP('smtp.gmail.com',2525)


So, I'll try that by hand here:

% telnet smtp.gmail.com 2525
Trying 142.250.4.108...
telnet: connect to address 142.250.4.108: Operation timed out
Trying 2404:6800:4003:c0f::6d...
telnet: connect to address 2404:6800:4003:c0f::6d: No route to host
telnet: Unable to connect to remote host
%

I'd say GMail are rudely dropping traffic to port 2525. Maybe try just 
25, the normal SMTP port?


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


need help

2022-10-23 Thread Shuaib Akhtar
   How to fix Traceback (most recent call last):

     File "C:\Program
   
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\socket.py",
   line 833, in create_connection

       sock.connect(sa)

   TimeoutError: [WinError 10060] A connection attempt failed because the
   connected party did not properly respond after a period of time, or
   established connection failed because connected host has failed to respond

    

   During handling of the above exception, another exception occurred:

    

   Traceback (most recent call last):

     File "C:\Users\i9shu\Downloads\python email bot\email bot.py", line 25,
   in 

       server = smtplib.SMTP('smtp.gmail.com',2525)

     File "C:\Program
   
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\smtplib.py",
   line 255, in __init__

       (code, msg) = self.connect(host, port)

     File "C:\Program
   
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\smtplib.py",
   line 341, in connect

       self.sock = self._get_socket(host, port, self.timeout)

     File "C:\Program
   
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\smtplib.py",
   line 312, in _get_socket

       return socket.create_connection((host, port), timeout,

     File "C:\Program
   
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\socket.py",
   line 833, in create_connection

       sock.connect(sa)

   KeyboardInterrupt

    

   Process finished with exit code -1073741510 (0xC13A: interrupted by
   Ctrl+C)

   eorr

    

   Sent from [1]Mail for Windows

    

References

   Visible links
   1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help with custom string formatter

2022-10-22 Thread Robert Latest via Python-list
Cameron Simpson wrote:
> Stefan's code implements it's own format_field and falls back to the 
> original format_field(). That's standard subclassing practice, and worth 
> doing reflexively more of the time - it avoids _knowing_ that 
> format_field() just calls format().
>
> So I'd take Stefan's statement above to imply that calling format() 
> directly should work.

Yup, makes sense.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help with custom string formatter

2022-10-21 Thread Cameron Simpson

On 21Oct2022 16:55, Stefan Ram  wrote:

 I was not aware of "isdigit".


There's also "isdecimal" and "isnumeric". They all have subtly different 
meanings :-)


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help with custom string formatter

2022-10-21 Thread Cameron Simpson

On 21Oct2022 16:55, Stefan Ram  wrote:

Robert Latest  writes:

return super().format_field( value, format_string )

Why do you prefer super().format_field() over plain format()? The doc says:
"format_field() simply calls format()." So I figured I might do the same.


 I am not aware of any reason not to call "format" directly.


Stefan's code implements it's own format_field and falls back to the 
original format_field(). That's standard subclassing practice, and worth 
doing reflexively more of the time - it avoids _knowing_ that 
format_field() just calls format().


So I'd take Stefan's statement above to imply that calling format() 
directly should work.


My own habit would be to stick with the original, if only for semantic 
reasons. Supposing you switched from subclassing Formatter to some other 
class which itself subclasses Formatter. (Yes, that is probably 
something you will never do.) Bypassing the call to 
super().format_field(...) prevents shoehorning some custom format_fields 
from the changed superclass. Which you'd then need to debug.


That's all.

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help with custom string formatter

2022-10-21 Thread Robert Latest via Python-list
Stefan Ram wrote:

[the solution]

thanks, right on the spot. I had already figured out that format_field() is the
one method I need, and thanks for the str.translate method. I knew that raking
seven RE's across the same string HAD to be stupid.

Have a nice weekend!

-- 
https://mail.python.org/mailman/listinfo/python-list


Need help with custom string formatter

2022-10-21 Thread Robert Latest via Python-list
Hi all,

I would like to modify the standard str.format() in a way that when the
input field is of type str, there is some character replacement, and the
string gets padded or truncated to the given field width. Basically like
this:

fmt = MagicString('<{s:6}>')
print(fmt.format(s='Äußerst'))

Output:


I've written a function fix_format() which, given a string and a field width,
does just that. However, I find myself unable to implement a Formatter that
uses this function in the intened way. See the example below, I hope I
sprinkled it with enough comments to make my intents clear.  Thanks for any
enlightenment. The interesting part starts somewhere in the middle.

### Self contained example
import re
from string import Formatter

_replacements = [(re.compile(rx), repl) for rx, repl in (\
('Ä', 'Ae'),
('ä', 'ae'),
('Ö', 'Oe'),
('ö', 'oe'),
('Ü', 'Ue'),
('ü', 'ue'),
('ß', 'ss'))]

def fix_format(text, width):

# Seven regex passes seems awfully inefficient. I can't think of a
# better way. Besides the point though.
for rx, repl in _replacements:
text = re.sub(rx, repl, text)

# return truncated / padded version of string
return text[:width] + ' ' * max(0, width - len(text))

class Obj():
"""I'm just an object with some attributes"""
def __init__(self, **kw):
self.__dict__.update(kw)

o = Obj(x="I am X, and I'm too long",
y="ÄÖÜ Ich bin auch zu lang")
z = 'Pad me!'

format_spec = '<{o.x:6}>\n<{o.y:6}>\n<{z:10}>'

# Standard string formatting
print('Standard string formatting:')
print(format_spec.format(o=o, z=z))

# Demonstrate fix_format()
print('\nWanted output:')
print('<' + fix_format(o.x, 6) + '>')
print('<' + fix_format(o.y, 6) + '>')
print('<' + fix_format(z, 10) + '>')

# This is where my struggle begins. #

class MagicString(Formatter):
def __init__(self, format_spec):
self.spec = format_spec
super().__init__()

def format(self, **kw):
return(self.vformat(self.spec, [], kw))

def get_field(self, name, a, kw):
# Compound fields have a dot:
obj_name, _, key = name.partition('.')
obj = getattr(kw[obj_name], key) if key else kw[obj_name]
if isinstance(obj, str):
# Here I would like to call fix_format(), but I don't know where
# to get the field width.
print('get_field(): <' + obj + '>')
else:
# Here I'd like to use the "native" formatter of whatever type
# the field is.
pass
return obj, key

def get_value(self, key, a, kw):
'''I don't understand what this method is for, it never gets called'''
raise NotImplementedError

fmt = MagicString(format_spec)
print('\nReal output:')
print(fmt.format(o=o, z=z))

# Weirdly, somewhere on the way the standard formatting kicks in, too, as
# the 'Pad me!' string does get padded (which must be some postprocessing,
# as the string is still unpadded when passed into get_field())

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help with custom string formatter

2022-10-21 Thread Robert Latest via Python-list


Hi Stefan, 

I have now implemented a version of this, works nicely. I have a few minor
questions / remarks:

>   result += ' ' *( length - len( result ))

Nice, I didn't know that one could multiply strings by negative numbers without
error.

> def __init__( self ):
> super().__init__()

Isn't this a no-op? Probably a leftover from my stuff.

> def format_field( self, value, format_string ):
> if re.match( r'\d+', format_string )and type( value )== str:

Why do you prefer re.match(r'\d+', x) over x.isdigit()?

> return super().format_field( value, format_string )

Why do you prefer super().format_field() over plain format()? The doc says:
"format_field() simply calls format()." So I figured I might do the same.

Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Can you help me with this Python question?

2022-10-13 Thread Axy via Python-list
Well, although I never used pandas and never will, if that's about 
artworks, that's mine.


Obviously, you need to iterate columns and sum values returned by the 
snippet you provided. A quick search tells us to use colums property. 
So, it might look like this:


na_sum = sum(df[name].isnull().sum() for name in df.columns)

Axy

On 13/10/2022 13:44, Sarah Wallace wrote:

For a python class I am taking..

In this challenge, you'll be working with a DataFrame that contains data
about artworks, and it contains many missing values.

Your task is to create a variable called na_sum that contains the total
number of missing values in the DataFrame. When that's completed, print out
your answer!

Hint: The code given below will give you the number of missing (NaN) values
for the *Name* column in the DataFrame. How would you edit the code to get
the missing values for every column in the DataFrame?
Extra hint: You'll be returning a single number which is the final sum() of
everything.

df['Name'].isnull().sum()


--
https://mail.python.org/mailman/listinfo/python-list


Fwd: Can you help me with this Python question?

2022-10-13 Thread Sarah Wallace
For a python class I am taking..

In this challenge, you'll be working with a DataFrame that contains data
about artworks, and it contains many missing values.

Your task is to create a variable called na_sum that contains the total
number of missing values in the DataFrame. When that's completed, print out
your answer!

Hint: The code given below will give you the number of missing (NaN) values
for the *Name* column in the DataFrame. How would you edit the code to get
the missing values for every column in the DataFrame?
Extra hint: You'll be returning a single number which is the final sum() of
everything.

df['Name'].isnull().sum()

-- 
Thanks!

*Sarah Wallace*
sarah.wallac...@gmail.com




-- 
Thanks!

*Sarah Wallace*
sarah.wallac...@gmail.com
214.300.1064
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help, PyCharm fails to recognize my tab setting...See attached picture of the code.

2022-10-11 Thread dn

On 11/10/2022 10.48, Kevin M. Wilson via Python-list wrote:

C:\Users\kevin\PycharmProjects\Myfuturevalue\venv\Scripts\python.exe 
C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py   File 
"C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py", line 31    elif 
(years > 50.0) or (years < 1.0) :    ^IndentationError: expected an indented block after 
'if' statement on line 29
Process finished with exit code 1


Indentation depends upon what went before, as well as what is being 
indented 'right now'.


As you can see from the reproduction of the OP (above), any comment on 
formatting would be a guess.


Please copy-paste the entire block of the if-statement and its nested 
suites...

(this list will not pass-along images)
--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


Help, PyCharm fails to recognize my tab setting...See attached picture of the code.

2022-10-10 Thread Kevin M. Wilson via Python-list
C:\Users\kevin\PycharmProjects\Myfuturevalue\venv\Scripts\python.exe 
C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py   File 
"C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py", line 31    
elif (years > 50.0) or (years < 1.0) :    ^IndentationError: expected an 
indented block after 'if' statement on line 29
Process finished with exit code 1


Good sense makes one slow to anger, and it is his glory tooverlook an offense.

Proverbs 19:11

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help in blockchain coding.

2022-06-11 Thread Mats Wichmann
On 6/11/22 15:29, dn wrote:
> On 12/06/2022 02.51, Ayesha Tassaduq wrote:
>> I am a beginner in python I want to transfer generated hash to a local 
>> database. I try it with socket programming but I fail. can anyone please 
>> help me ow I can do this?
> 
> Where is the database?
> Where is the socket?
> What are the (full) error messages?

Indeed... what you've posted, with the exception that we don't see what
these two _df values are:

t1 = Time_sensitive_df
...
t3 = normal_df

looks basically workable for what it is.

Guessing at your intent here - presumably you want your chain to be
persistent and not be created from scratch each time you go to access
it. You *could* use a database for this, and there are lots of Python
technologies for talking to databases, but there's none of that in your
code so we can't comment on it.

For early experiments you could just use a text file.  Then you need to
code a way to load the existing chain from the file into your working
copy, if the file exists, rather than instantiating a copy of
Blockchain, which will always start over:

def __init__( self ):
self.chain = [ ]
self.generate_genesis_block()

since the chain itself is a list, perhaps you could dump that list to a
json file, and reload it into self.chain if the json file is found to
exist, instead of doing the initial-setup?

Apologies if I have completely misunderstood what you are seeking...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help in blockchain coding.

2022-06-11 Thread dn
On 12/06/2022 02.51, Ayesha Tassaduq wrote:
> I am a beginner in python I want to transfer generated hash to a local 
> database. I try it with socket programming but I fail. can anyone please help 
> me ow I can do this?

Where is the database?
Where is the socket?
What are the (full) error messages?


> class Block:
> def __init__( self, previous_block_hash, transaction_list ):
> self.previous_block_hash = previous_block_hash
> self.transaction_list = transaction_list
> 
> self.block_data = f"{' - '.join(transaction_list)} - 
> {previous_block_hash}"
> self.block_hash = hashlib.sha256(self.block_data.encode()).hexdigest()
> 
> 
> class Blockchain:
> def __init__( self ):
> self.chain = [ ]
> self.generate_genesis_block()
> 
> def generate_genesis_block( self ):
> self.chain.append(Block("0", [ 'Genesis Block' ]))
> 
> def create_block_from_transaction( self, transaction_list ):
> previous_block_hash = self.last_block.block_hash
> self.chain.append(Block(previous_block_hash, transaction_list))
> 
> def display_chain( self ):
> for i in range(len(self.chain)):
> print(f"Hash {i + 1}: {self.chain [ i ].block_hash}\n")
> 
> @property
> def last_block( self ):
> return self.chain [ -1 ]
> 
> 
> **t1 = Time_sensitive_df
> t2 = "abcdefghijklmnopqrstuvwxyz"
> t3 = normal_df
> myblockchain = Blockchain()
> myblockchain.create_block_from_transaction(t1)
> myblockchain.create_block_from_transaction(t2)
> myblockchain.create_block_from_transaction(t3)
> myblockchain.display_chain()**

-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Need help in blockchain coding.

2022-06-11 Thread Ayesha Tassaduq
I am a beginner in python I want to transfer generated hash to a local 
database. I try it with socket programming but I fail. can anyone please help 
me ow I can do this?

class Block:
def __init__( self, previous_block_hash, transaction_list ):
self.previous_block_hash = previous_block_hash
self.transaction_list = transaction_list

self.block_data = f"{' - '.join(transaction_list)} - 
{previous_block_hash}"
self.block_hash = hashlib.sha256(self.block_data.encode()).hexdigest()


class Blockchain:
def __init__( self ):
self.chain = [ ]
self.generate_genesis_block()

def generate_genesis_block( self ):
self.chain.append(Block("0", [ 'Genesis Block' ]))

def create_block_from_transaction( self, transaction_list ):
previous_block_hash = self.last_block.block_hash
self.chain.append(Block(previous_block_hash, transaction_list))

def display_chain( self ):
for i in range(len(self.chain)):
print(f"Hash {i + 1}: {self.chain [ i ].block_hash}\n")

@property
def last_block( self ):
return self.chain [ -1 ]


**t1 = Time_sensitive_df
t2 = "abcdefghijklmnopqrstuvwxyz"
t3 = normal_df
myblockchain = Blockchain()
myblockchain.create_block_from_transaction(t1)
myblockchain.create_block_from_transaction(t2)
myblockchain.create_block_from_transaction(t3)
myblockchain.display_chain()**
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with Python/Eyed3 MusicCDIdFrame method

2022-06-06 Thread Dennis Lee Bieber
On Mon, 6 Jun 2022 12:37:47 +0200, Dave  declaimed
the following:

>Hi,
>
>I’m trying to get the ID3 tags of an mp3 file. I trying to use the 
>MusicCDIdFrame
> method but I can’t seem to get it right. Here is a code snippet:
>
>
> import eyed3
>import eyed3.id3
>import eyed3.id3.frames
>import eyed3.id3.apple

As I understand the documentation, The last is Apple
specific/non-standard information...
https://eyed3.readthedocs.io/en/latest/eyed3.id3.html

"""
eyed3.id3.apple module

Here lies Apple frames, all of which are non-standard. All of these would
have been standard user text frames by anyone not being a bastard, on
purpose.
"""

{I'm not thrilled by the documentation -- it is basically a collection on
one-line doc-strings with absolutely no hints as to proper usage}

>  File "/Documents/Python/Test1/main.py", line 94, in 
>myCDID = myID3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')
>AttributeError: 'Mp3AudioFile' object has no attribute 'id3'

"""
 eyed3.core.load(path, tag_version=None)[source]

Loads the file identified by path and returns a concrete type of
eyed3.core.AudioFile. If path is not a file an IOError is raised. None is
returned when the file type (i.e. mime-type) is not recognized. The
following AudioFile types are supported:

eyed3.mp3.Mp3AudioFile - For mp3 audio files.

eyed3.id3.TagFile - For raw ID3 data files.
"""

eyed3.id3. would appear to be specific to non-MP3 data files.

So... I'd try the interactive environment and check each layer...

dir(myID3)

(based upon the error, there will not be a "id3" key; so try
dir(myID3.) for each key you do find).

>
>
>Any help or suggestion greatly appreciated.
>

Given this bit of source code from the documentation...

def initTag(self, version=id3.ID3_DEFAULT_VERSION):
"""Add a id3.Tag to the file (removing any existing tag if one
exists).
"""
self.tag = id3.Tag()
self.tag.version = version
self.tag.file_info = id3.FileInfo(self.path)
return self.tag

... you probably need to be looking at 
myID3.tag.

... try
dir(myID3.tag)
and see what all may appear...

IOW: the ID3 information has already been parsed into separate "tag"
fields.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with Python/Eyed3 MusicCDIdFrame method

2022-06-06 Thread Dave
Thanks! That fixed it!

> On 6 Jun 2022, at 18:46, MRAB  wrote:
> 
> On 2022-06-06 11:37, Dave wrote:
>> Hi,
>> I’m trying to get the ID3 tags of an mp3 file. I trying to use the 
>> MusicCDIdFrame
>>  method but I can’t seem to get it right. Here is a code snippet:
>>  import eyed3
>> import eyed3.id3
>> import eyed3.id3.frames
>> import eyed3.id3.apple
>> import eyed3.mp3
>> myID3 = eyed3.load("/Users/Test/Life in the fast lane.mp3")
>> myTitle = myID3.tag.title
>> myArtist = myID3.tag.artist
>> myAlbum = myID3.tag.album
>> myAlbumArtist = myID3.tag.album_artist
>> myComposer = myID3.tag.composer
>> myPublisher = myID3.tag.publisher
>> myGenre = myID3.tag.genre.name
>> myCDID = myID3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')
>> When I run this, I get the following error:
>>   File "/Documents/Python/Test1/main.py", line 94, in 
>> myCDID = myID3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')
>> AttributeError: 'Mp3AudioFile' object has no attribute 'id3'
>> Any help or suggestion greatly appreciated.
> That line should be:
> 
> myCDID = eyed3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')
> 
> Also remember that some attributes might be None, e.g. 'myID3.tag.genre' 
> might be None.
> 
> Another point: it's probably not worth importing the submodules of 'eyed3'; 
> you're not gaining anything from it.
> -- 
> https://mail.python.org/mailman/listinfo/python-list 
> <https://mail.python.org/mailman/listinfo/python-list>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with Python/Eyed3 MusicCDIdFrame method

2022-06-06 Thread MRAB

On 2022-06-06 11:37, Dave wrote:

Hi,

I’m trying to get the ID3 tags of an mp3 file. I trying to use the 
MusicCDIdFrame
  method but I can’t seem to get it right. Here is a code snippet:


  import eyed3
import eyed3.id3
import eyed3.id3.frames
import eyed3.id3.apple
import eyed3.mp3
myID3 = eyed3.load("/Users/Test/Life in the fast lane.mp3")
myTitle = myID3.tag.title
myArtist = myID3.tag.artist
myAlbum = myID3.tag.album
myAlbumArtist = myID3.tag.album_artist
myComposer = myID3.tag.composer
myPublisher = myID3.tag.publisher
myGenre = myID3.tag.genre.name
myCDID = myID3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')

When I run this, I get the following error:

   File "/Documents/Python/Test1/main.py", line 94, in 
 myCDID = myID3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')
AttributeError: 'Mp3AudioFile' object has no attribute 'id3'


Any help or suggestion greatly appreciated.


That line should be:

myCDID = eyed3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')

Also remember that some attributes might be None, e.g. 'myID3.tag.genre' 
might be None.


Another point: it's probably not worth importing the submodules of 
'eyed3'; you're not gaining anything from it.

--
https://mail.python.org/mailman/listinfo/python-list


Help with Python/Eyed3 MusicCDIdFrame method

2022-06-06 Thread Dave
Hi,

I’m trying to get the ID3 tags of an mp3 file. I trying to use the 
MusicCDIdFrame
 method but I can’t seem to get it right. Here is a code snippet:


 import eyed3
import eyed3.id3
import eyed3.id3.frames
import eyed3.id3.apple
import eyed3.mp3
myID3 = eyed3.load("/Users/Test/Life in the fast lane.mp3")
myTitle = myID3.tag.title
myArtist = myID3.tag.artist
myAlbum = myID3.tag.album
myAlbumArtist = myID3.tag.album_artist
myComposer = myID3.tag.composer
myPublisher = myID3.tag.publisher
myGenre = myID3.tag.genre.name
myCDID = myID3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')

When I run this, I get the following error:

  File "/Documents/Python/Test1/main.py", line 94, in 
myCDID = myID3.id3.frames.MusicCDIdFrame(id=b'MCDI', toc=b'')
AttributeError: 'Mp3AudioFile' object has no attribute 'id3'


Any help or suggestion greatly appreciated.

All the Best
Dave

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help, please, with 3.10.4 install

2022-05-30 Thread Dennis Lee Bieber
On Sat, 28 May 2022 21:11:00 -0500, Jack Gilbert <00jhen...@gmail.com>
declaimed the following:

>also, the same line: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022,
>23:13:41) [MSC v.1929 64 bit (AMD64)] on win32 in CMD prompt
>
>for the life of me I can't figure out how to launch python??
>

Well, what did you type in that command shell to get the line you
report above? (Cut and Paste the TEXT from that command shell -- don't just
transcribe by hand). That version string is only displayed when one starts
Python in interactive mode.

-=-=-
Microsoft Windows [Version 10.0.19044.1706]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Wulfraed>python
Python ActivePython 3.8.2 (ActiveState Software Inc.) based on
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

-=-=-



-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help, please, with 3.10.4 install

2022-05-30 Thread Mats Wichmann
On 5/28/22 20:11, Jack Gilbert wrote:
> I downloaded 3.10.4 on a 64 bit , 8.1

> also, the same line: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022,
> 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32 in CMD prompt
> 
> for the life of me I can't figure out how to launch python??

Sounds like you're launching it already?

In a cmd shell, type:

py


And you should be good to go.  See the page @dn pointed to.


-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >