Re: [ANN] Python Brain Teasers Book is Out

2020-05-04 Thread Abdur-Rahmaan Janhangeer
Greetings,

Would be grateful if you could post it to python-authors also:
https://mail.python.org/mailman/listinfo/python-authors

Thanks!

Kind Regards,

Abdur-Rahmaan Janhangeer
compileralchemy.com  | github

Mauritius


On Tue, May 5, 2020 at 8:40 AM Miki Tebeka  wrote:

> Hi All,
>
> I'm excited that my book "Python Brain Teasers: 30 brain teasers to tickle
> your mind and help become a better developer." is out.
>
> You can grab is from https://gum.co/iIQT (PDF & ePUB). Let me know how
> many teasers did you get right.
>
> If you're curious, a sample of the book, including the forward by Raymond
> Hettinger is at https://www.353solutions.com/python-brain-teasers
>
> Stay curious, keep hacking,
> Miki
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[ANN] Python Brain Teasers Book is Out

2020-05-04 Thread Miki Tebeka
Hi All,

I'm excited that my book "Python Brain Teasers: 30 brain teasers to tickle your 
mind and help become a better developer." is out.

You can grab is from https://gum.co/iIQT (PDF & ePUB). Let me know how many 
teasers did you get right.

If you're curious, a sample of the book, including the forward by Raymond 
Hettinger is at https://www.353solutions.com/python-brain-teasers

Stay curious, keep hacking,
Miki
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Consumer trait recognition

2020-05-04 Thread Jason Friedman
>
> I constructed a lexicon for words that show how different words are linked
> to consumer traits and motivations (e.g. Achievement and Power Motivation).
> Now I have collected a large amount of online customer reviews and want to
> match each review with the word definitions of the consumer traits and
> motivations in order to identify whether they influence the consumer
> preferences.
>
> How do I that? Both the lexicons and the customer reviews are csv files.
>
> I was going to reply that you should consider the https://www.nltk.org/ 
> mailing
list, but I see you have already done so (
https://groups.google.com/forum/#!topic/nltk-users/LWllpEiW65k).

Someone replied asking for what you have so far, "preferably in code". You
might also show on that forum the first 5-or-so lines of your two files,
along with what you expect the first 5-or-so lines of output to look like.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: phyton hata

2020-05-04 Thread Michael Torrie
On 5/4/20 4:15 AM, HÜSEYİN KOÇ wrote:
> Phyton 3.8.2 versiyonu bilgisayarıma indirdim fakat sorunlar ile 
> karşılaştınız diyerek hata veriyor
> 
> 
> Windows 10 için Posta ile 
> gönderildi
> 

Please ensure Windows is up to date using Windows Update. That will
solve most installation problems.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiprocessing vs. concurrent.futures, Linux vs. Windows

2020-05-04 Thread John Ladasky
On Monday, May 4, 2020 at 4:09:53 PM UTC-7, Terry Reedy wrote:
> On 5/4/2020 3:26 PM, John Ladasky wrote:
> > Several years ago I built an application using multiprocessing.  It only 
> > needed to work in Linux.  I got it working fine.  At the time, 
> > concurrent.futures did not exist.
> > 
> > My current project is an application which includes a PyQt5 GUI, and a live 
> > video feed with some real-time image processing.  Running all this in one 
> > process resulted in unacceptable performance, so I'm trying to move all of 
> > the heavy video work into its own process.  I only need to define one child 
> > process.  I don't need a Pool.  The child Process can run indefinitely, and 
> > it will communicate multiple messages to the main process using a Pipe.
> > 
> > I built a working example in Linux, but it hangs in Windows.  I built a 
> > minimum example.  My problem has nothing to do with PyQt.  In Windows, my 
> > example hangs when I try to create the child Process.  Code:
> > 
> > 
> > import os
> > from multiprocessing import Pipe, Process
> > 
> > def child_app():
> >  inlet.send("Child process id = {}".format(os.getpid()))
> > 
> > if __name__ == "__main__":
> >  outlet, inlet = Pipe()
> >  print("Parent process id =", os.getpid())
> >  child_process = Process(target=child_app)  # Windows hangs here
> >  child_process.start()
> >  print(outlet.recv())
> >  child_process.join()
> >  child_process.close()
> >  print("Program complete.")
> > 
> > 
> > I'm working in Python 3.7.6 on Windows 10, and 3.7.5 on Ubuntu Linux 19.10.
> 
> Does the minimal example in the doc work for you?
> (IE, do you only have a problem with Pipe?)
> 
> from multiprocessing import Process
> 
> def f(name):
>  print('hello', name)
> 
> if __name__ == '__main__':
>  p = Process(target=f, args=('bob',))
>  p.start()
>  p.join()
> 
> How about the Pipe example?
> 
> from multiprocessing import Process, Pipe
> 
> def f(conn):
>  conn.send([42, None, 'hello'])
>  conn.close()
> 
> if __name__ == '__main__':
>  parent_conn, child_conn = Pipe()
>  p = Process(target=f, args=(child_conn,))
>  p.start()
>  print(parent_conn.recv())   # prints "[42, None, 'hello']"
>  p.join()
> 
> If this does not work on Windows, the example or doc should be changed.
> But I believe I tested it once. Note that unlike your code, the 
> child_conn is sent as argument.  The relation between the module code 
> and child processes is different on Windows than *nix.

Hi Terry,

Thanks for your reply.  I have been hacking at this for a few hours.  I have 
learned two things:

1. Windows hangs unless you explicitly pass any references you want to use in 
the subprocess through args.  That would include the Pipe connection. 
 Using multiprocessing in Linux requires the reference names to be global, 
however the use of args is not required.  Finally, Linux does not appear to 
cause any problems if args are specified.

2. Even if you fix problem 1, the parent process must be distinguished by 
creating the subprocess inside an "if __name__ == '__main__'" block.  Again, 
Linux just pushes on through, but Windows will hang if you don't do this.

The example code you posted shows exactly these two changes.  They are 
OS-specific, and my multiprocessing code has been (up to now) only required to 
run on Linux.  These recommendations can be found in the official Python docs, 
e.g.:

https://docs.python.org/3.7/library/multiprocessing.html#programming-guidelines
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: phyton hata

2020-05-04 Thread Souvik Dutta
ne hatası alıyorsun

Souvik flutter dev

On Tue, May 5, 2020, 1:28 AM HÜSEYİN KOÇ  wrote:

> Phyton 3.8.2 versiyonu bilgisayarıma indirdim fakat sorunlar ile
> karşılaştınız diyerek hata veriyor
>
>
> Windows 10 için Posta ile
> gönderildi
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there anything in the script which could cause it to not run its full course please?

2020-05-04 Thread ozstar1
On Tuesday, 5 May 2020 01:35:42 UTC+10, David Raymond  wrote:
> Not necessarily the cause of your problem, but if you're going to compare 
> dates it should be as objects, or as text as year-month-day. Here you're 
> comparing dates as text in day-month-year format. So January first  comes 
> before May 4th 2020
> 
> "01-01-" < "04-05-2020"
> 
> ...
> 04-05-2020 09:30:00 40
> 04-05-2020 12:30:00 40
> 04-05-2020 15:30:00 40
> 04-05-2020 22:30:00 40
> ...
> input_date,input_time,input_duration=date_time_duration.split(' ')
> current_datetime = datetime.datetime.now()
> current_date = current_datetime.strftime('%d-%m-%Y')
> if(input_date>=current_date):
>while(True):
> ...

Thank you, see what you mean. I have corrected this now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiprocessing vs. concurrent.futures, Linux vs. Windows

2020-05-04 Thread Terry Reedy

On 5/4/2020 3:26 PM, John Ladasky wrote:

Several years ago I built an application using multiprocessing.  It only needed 
to work in Linux.  I got it working fine.  At the time, concurrent.futures did 
not exist.

My current project is an application which includes a PyQt5 GUI, and a live 
video feed with some real-time image processing.  Running all this in one 
process resulted in unacceptable performance, so I'm trying to move all of the 
heavy video work into its own process.  I only need to define one child 
process.  I don't need a Pool.  The child Process can run indefinitely, and it 
will communicate multiple messages to the main process using a Pipe.

I built a working example in Linux, but it hangs in Windows.  I built a minimum 
example.  My problem has nothing to do with PyQt.  In Windows, my example hangs 
when I try to create the child Process.  Code:


import os
from multiprocessing import Pipe, Process

def child_app():
 inlet.send("Child process id = {}".format(os.getpid()))

if __name__ == "__main__":
 outlet, inlet = Pipe()
 print("Parent process id =", os.getpid())
 child_process = Process(target=child_app)  # Windows hangs here
 child_process.start()
 print(outlet.recv())
 child_process.join()
 child_process.close()
 print("Program complete.")


I'm working in Python 3.7.6 on Windows 10, and 3.7.5 on Ubuntu Linux 19.10.


Does the minimal example in the doc work for you?
(IE, do you only have a problem with Pipe?)

from multiprocessing import Process

def f(name):
print('hello', name)

if __name__ == '__main__':
p = Process(target=f, args=('bob',))
p.start()
p.join()

How about the Pipe example?

from multiprocessing import Process, Pipe

def f(conn):
conn.send([42, None, 'hello'])
conn.close()

if __name__ == '__main__':
parent_conn, child_conn = Pipe()
p = Process(target=f, args=(child_conn,))
p.start()
print(parent_conn.recv())   # prints "[42, None, 'hello']"
p.join()

If this does not work on Windows, the example or doc should be changed.
But I believe I tested it once. Note that unlike your code, the 
child_conn is sent as argument.  The relation between the module code 
and child processes is different on Windows than *nix.


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


Re: Is there anything in the script which could cause it to not run its full course please?

2020-05-04 Thread ozstar1


Many thanks for your help. It is really appreciated. I see both your points and 
maybe this is where my problems lays. 

If for example it starts (and it does) at 9.30am then the print is.. 
streaming  It is supposed to wait for the 40 minutes, stop then print 
this.. Waiting for the next stream to start at 12:30 however I get this same 
message maybe 4 minutes in, not 40.

I have checked for admin 'events' in Win10 1909 however there is nothing there, 
and the start menu has only 3 items, none that would effect this.

The box doesn't have anything else running, as it is virtually dedicated to 
this streaming. It has two displays, one for the stream program and the other 
for the dos box, so nothing is on the streamer screen where the mouse clicks.

Once again many thanks and let me digest your info. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: naN values

2020-05-04 Thread Peter Otten
J Conrado wrote:

> I have a 2d array and I would  how can I replace NaN values for example
> with - value or other value.

>>> a
array([[ nan,   1.,   2.,   3.],
   [  4.,   5.,   6.,   7.],
   [  8.,   9.,  10.,  nan]])
>>> a[numpy.isnan(a)] = 42
>>> a
array([[ 42.,   1.,   2.,   3.],
   [  4.,   5.,   6.,   7.],
   [  8.,   9.,  10.,  42.]])


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


naN values

2020-05-04 Thread J Conrado



Hi,


I have a 2d array and I would  how can I replace NaN values for example 
with - value or other value.



Thank,


Conrado

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


phyton hata

2020-05-04 Thread HÜSEYİN KOÇ
Phyton 3.8.2 versiyonu bilgisayarıma indirdim fakat sorunlar ile karşılaştınız 
diyerek hata veriyor


Windows 10 için Posta ile 
gönderildi

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


Multiprocessing vs. concurrent.futures, Linux vs. Windows

2020-05-04 Thread John Ladasky
Several years ago I built an application using multiprocessing.  It only needed 
to work in Linux.  I got it working fine.  At the time, concurrent.futures did 
not exist.

My current project is an application which includes a PyQt5 GUI, and a live 
video feed with some real-time image processing.  Running all this in one 
process resulted in unacceptable performance, so I'm trying to move all of the 
heavy video work into its own process.  I only need to define one child 
process.  I don't need a Pool.  The child Process can run indefinitely, and it 
will communicate multiple messages to the main process using a Pipe.

I built a working example in Linux, but it hangs in Windows.  I built a minimum 
example.  My problem has nothing to do with PyQt.  In Windows, my example hangs 
when I try to create the child Process.  Code:


import os
from multiprocessing import Pipe, Process

def child_app():
inlet.send("Child process id = {}".format(os.getpid()))

if __name__ == "__main__":
outlet, inlet = Pipe()
print("Parent process id =", os.getpid())
child_process = Process(target=child_app)  # Windows hangs here
child_process.start()
print(outlet.recv())
child_process.join()
child_process.close()
print("Program complete.")


I'm working in Python 3.7.6 on Windows 10, and 3.7.5 on Ubuntu Linux 19.10.

I am reading through the multiprocessing documentation, and I'm guessing that 
I've run into a problem with spawning vs. forking a new Process.  The former is 
the Windows default, and the latter is the Posix default.

Before I dig too deeply, I am wondering whether this cross-platform problem is 
something that concurrent.futures might handle automatically.  The concurrent 
API looks foreign to me.  But if it is meant to replace multiprocessing, I 
suppose this would be a good time for me to learn it.

Thanks for any advice and suggestions!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with doctest

2020-05-04 Thread Dieter Maurer
ast wrote at 2020-5-4 15:20 +0200:
>doctest of the sample function funct() doesn't works
>because flag used by funct() is the one defined in
>first line "flag = True" and not the one in the
>doctest code ">>> flag = False".
>
>Any work around known ?
>
>
>flag = True  # <- funct() always use this one
>
>def funct():
> """
> Code for doctest:
>
> >>> flag = True
> >>> funct()
> 'Yes'
> >>> flag = False #  <- Ignored unfortunalely
> >>> funct()
> 'No'
> """
>
> if flag:
> return "Yes"
> else:
> return "No"
>
>if __name__ == "__main__":
> import doctest
> doctest.testmod()
>
>
>
>Failed example:
> funct()
>Expected:
> 'No'
>Got:
> 'Yes'
>**
>1 items had failures:
>1 of   4 in __main__.funct
>***Test Failed*** 1 failures.

The "flag" used inside "funct" refers to the definition
in "funct.__globals__" (i.e. the module where "funct" is defined in).

As your observation shows, this is not the "flag" changed by the
doctest. The doctest behavior reflects the use in a function or a
foreign module (rather than a use at the top level of the module
defining "funct").
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Is there anything in the script which could cause it to not run its full course please?

2020-05-04 Thread David Raymond
Not necessarily the cause of your problem, but if you're going to compare dates 
it should be as objects, or as text as year-month-day. Here you're comparing 
dates as text in day-month-year format. So January first  comes before May 
4th 2020

"01-01-" < "04-05-2020"

...
04-05-2020 09:30:00 40
04-05-2020 12:30:00 40
04-05-2020 15:30:00 40
04-05-2020 22:30:00 40
...
input_date,input_time,input_duration=date_time_duration.split(' ')
current_datetime = datetime.datetime.now()
current_date = current_datetime.strftime('%d-%m-%Y')
if(input_date>=current_date):
   while(True):
...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with doctest

2020-05-04 Thread Peter Otten
Unknown wrote:

> Hello
> 
> doctest of the sample function funct() doesn't works
> because flag used by funct() is the one defined in
> first line "flag = True" and not the one in the
> doctest code ">>> flag = False".
> 
> Any work around known ?

You can import the module where funct() is defined:

def funct()
"""
>>> import module
>>> module.flag = False
>>> funct()
'No'
"""
...

> flag = True  # <- funct() always use this one
> 
> def funct():
>  """
>  Code for doctest:
> 
>  >>> flag = True
>  >>> funct()
>  'Yes'
>  >>> flag = False #  <- Ignored unfortunalely
>  >>> funct()
>  'No'
>  """
> 
>  if flag:
>  return "Yes"
>  else:
>  return "No"
> 
> if __name__ == "__main__":
>  import doctest
>  doctest.testmod()
> 
> 
> 
> Failed example:
>  funct()
> Expected:
>  'No'
> Got:
>  'Yes'
> **
> 1 items had failures:
> 1 of   4 in __main__.funct
> ***Test Failed*** 1 failures.


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


Problem with doctest

2020-05-04 Thread ast

Hello

doctest of the sample function funct() doesn't works
because flag used by funct() is the one defined in
first line "flag = True" and not the one in the
doctest code ">>> flag = False".

Any work around known ?


flag = True  # <- funct() always use this one

def funct():
"""
Code for doctest:

>>> flag = True
>>> funct()
'Yes'
>>> flag = False #  <- Ignored unfortunalely
>>> funct()
'No'
"""

if flag:
return "Yes"
else:
return "No"

if __name__ == "__main__":
import doctest
doctest.testmod()



Failed example:
funct()
Expected:
'No'
Got:
'Yes'
**
1 items had failures:
   1 of   4 in __main__.funct
***Test Failed*** 1 failures.
--
https://mail.python.org/mailman/listinfo/python-list