Re: Converting hex data to image

2019-03-12 Thread Peter Otten
[email protected] wrote:

> On Monday, March 11, 2019 at 4:32:48 PM UTC+5:30, Peter Otten wrote:
>> [email protected] wrote:
>> 
>> > Hi i have a similar challenge where i need to store the thumbnailPhoto
>> > attribute to my local db and display the image every-time user logs in.
>> > But this solution does work . data looks like this:
>> > 
>> 
\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00
>> 
>> > import PIL
>> > from PIL import Image
>> > import io
>> > data = open("bytes.txt")
>> > my_data=(data.read())
>> > photo_inline = io.StringIO(my_data)
>> > photo = PIL.Image.open(photo_inline)
>> > error:
>> > Traceback (most recent call last):
>> > File "convertToImage.py", line 9, in 
>> > photo = PIL.Image.open(photo_inline)
>> > File "", line 2657, in open
>> > % (filename if filename else fp))
>> > OSError: cannot identify image file <_io.StringIO object at 0x0367FD00>
>> 
>> Did you try
>> 
>> photo = PIL.Image.open("bytes.txt")
>> 
>> ?
>> 
>> If the above code is illustrative, and you really need the bytes in
>> memory remember to open the file in binary mode:
>> 
>> with open("bytes.txt", "rb") as instream:
>> data = instream.read()
>> 
>> To create the image later the file-like objects needs to produce bytes:
>> 
>> instream = io.BytesIO(data)  # not StringIO!
>> photo = Image.open(instream)
> 
> Hey,
> It shows the same error.
> I am actually getting that image from ldap in bytes:
> 
'\xef\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c.
> I want to display this image on my template.

Save the image to a file (in binary mode!) and then try to open it with an 
image viewer. The data may be corrupted.

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


Re: Converting hex data to image

2019-03-12 Thread dimplemathew . 17
On Tuesday, March 12, 2019 at 2:09:06 PM UTC+5:30, Peter Otten wrote:
> [email protected] wrote:
> 
> > On Monday, March 11, 2019 at 4:32:48 PM UTC+5:30, Peter Otten wrote:
> >> [email protected] wrote:
> >> 
> >> > Hi i have a similar challenge where i need to store the thumbnailPhoto
> >> > attribute to my local db and display the image every-time user logs in.
> >> > But this solution does work . data looks like this:
> >> > 
> >> 
> \xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00
> >> 
> >> > import PIL
> >> > from PIL import Image
> >> > import io
> >> > data = open("bytes.txt")
> >> > my_data=(data.read())
> >> > photo_inline = io.StringIO(my_data)
> >> > photo = PIL.Image.open(photo_inline)
> >> > error:
> >> > Traceback (most recent call last):
> >> > File "convertToImage.py", line 9, in 
> >> > photo = PIL.Image.open(photo_inline)
> >> > File "", line 2657, in open
> >> > % (filename if filename else fp))
> >> > OSError: cannot identify image file <_io.StringIO object at 0x0367FD00>
> >> 
> >> Did you try
> >> 
> >> photo = PIL.Image.open("bytes.txt")
> >> 
> >> ?
> >> 
> >> If the above code is illustrative, and you really need the bytes in
> >> memory remember to open the file in binary mode:
> >> 
> >> with open("bytes.txt", "rb") as instream:
> >> data = instream.read()
> >> 
> >> To create the image later the file-like objects needs to produce bytes:
> >> 
> >> instream = io.BytesIO(data)  # not StringIO!
> >> photo = Image.open(instream)
> > 
> > Hey,
> > It shows the same error.
> > I am actually getting that image from ldap in bytes:
> > 
> '\xef\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c.
> > I want to display this image on my template.
> 
> Save the image to a file (in binary mode!) and then try to open it with an 
> image viewer. The data may be corrupted.

When i tried doing that it says Invalid Image...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting hex data to image

2019-03-12 Thread Peter Otten
[email protected] wrote:

>> Save the image to a file (in binary mode!) and then try to open it with
>> an image viewer. The data may be corrupted.
> 
> When i tried doing that it says Invalid Image...

So it looks like the problem occurs somewhere before you are decoding the 
image with the PIL...


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


Re: Converting hex data to image

2019-03-12 Thread dimplemathew . 17
On Tuesday, March 12, 2019 at 2:53:49 PM UTC+5:30, Peter Otten wrote:
> [email protected] wrote:
> 
> >> Save the image to a file (in binary mode!) and then try to open it with
> >> an image viewer. The data may be corrupted.
> > 
> > When i tried doing that it says Invalid Image...
> 
> So it looks like the problem occurs somewhere before you are decoding the 
> image with the PIL...
This is what i am doing :
for associate in self.conn.response[:-1]:
attributes = associate['attributes']
 obj = {
 'img':attributes['thumbnailPhoto'],}
This img i am calling in my view and writing to the file...

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


Re: "use strict"

2019-03-12 Thread Rhodri James

On 11/03/2019 19:08, Abdur-Rahmaan Janhangeer wrote:

proposing a special python syntax for it, like if flag set, it halts
execution. not relying on external tools like linters.


Do you mean on the command line, like "python --lint-me-baby myprog.py"? 
 I could live with that, though I'd hate to be the one trying to 
implement it and I imagine it's likely to slow down execution a fair bit.


Under what condition do you want execution halted?  At the moment you 
haven't been much more specific than "when my program is wrong", which 
isn't very helpful.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Abdur-Rahmaan Janhangeer
no i mean

# *-* use strict *-*

program
 typovar = x # line y

...


Traceback:
 on the fly var at line y

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Rhodri James

On 12/03/2019 11:32, Abdur-Rahmaan Janhangeer wrote:

no i mean

# *-* use strict *-*


Ugh.


program
  typovar = x # line y

...


Traceback:
  on the fly var at line y


Yes, but how is the program supposed to know that typovar is a typo? 
Are you proposing mandatory declarations for all variables, because I 
think you know what the answer to that one will be.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Abdur-Rahmaan Janhangeer
no just the var you want to track maybe

_var

or something like that, i want to solve that problem and this is just a
proposal

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Abdur-Rahmaan Janhangeer
i also proposed

# -*- explicit -*-

above

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Chris Angelico
On Tue, Mar 12, 2019 at 10:43 PM Abdur-Rahmaan Janhangeer
 wrote:
>
> no just the var you want to track maybe
>
> _var
>
> or something like that, i want to solve that problem and this is just a
> proposal
>

How do you specify which variables should be tracked? What defines
this? Be completely clear here - "I wish Python could catch my bugs"
isn't enough. What is legal code and what isn't?

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


Re: "use strict"

2019-03-12 Thread Chris Angelico
On Tue, Mar 12, 2019 at 10:58 PM Abdur-Rahmaan Janhangeer
 wrote:
>
> by some special symbols before the variable name
>
> like
>
> _that
>
> some code:
>  _tht
>

I don't understand. How is Python to know that "_that" is correct but
"_tht" is not?

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


Re: "use strict"

2019-03-12 Thread Abdur-Rahmaan Janhangeer
by some special symbols before the variable name

like

_that

some code:
 _tht

^
Traceback:
...

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Abdur-Rahmaan Janhangeer
by keeping a list /a record of those variables beforehand and knowing that
no new assignments in loops or such blocks of code.

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Chris Angelico
On Tue, Mar 12, 2019 at 11:02 PM Abdur-Rahmaan Janhangeer
 wrote:
>
> by keeping a list /a record of those variables beforehand and knowing that no 
> new assignments in loops or such blocks of code.
>

Please, quote posts with proper context. Your posts are all
context-free, which is great for a grammar but not for a discussion.

Okay, so you're saying that all variables (with this tag) must be
created outside of... what blocks of code exactly?

Also, I can't get away from the thought that a linter can most likely
find this. Unless you spell something correctly in two places AND
incorrectly in two places (and the same way), one of the usages is
going to show up as either NameError or "unused variable".

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


Re: "use strict"

2019-03-12 Thread Abdur-Rahmaan Janhangeer
excuses.

have you used Js? well a bit like that in py.

not necessarily unused as currently as it is, you can use the real one many
times, the typo one many times. it's not an error but it's not what you
expect. a linter basically parses the text, proposing to catch that without
linter.

the root catch is by catching undeclared variables usage. since in python
you don't have declaration then assignment but you have both at the same
time, i am proposing we solve this issue by having a special type of
variables.

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Chris Angelico
On Tue, Mar 12, 2019 at 11:18 PM Abdur-Rahmaan Janhangeer
 wrote:
>
> excuses.
>
> have you used Js? well a bit like that in py.

Yes, I have used JS, and in fact it's a critical part of my day job.
But JS has a big difference in that you *declare* variables. As Rhodri
says, asking for mandatory variable declarations in Python is unlikely
to fly.

> not necessarily unused as currently as it is, you can use the real one many 
> times, the typo one many times. it's not an error but it's not what you 
> expect. a linter basically parses the text, proposing to catch that without 
> linter.
>
> the root catch is by catching undeclared variables usage. since in python you 
> don't have declaration then assignment but you have both at the same time, i 
> am proposing we solve this issue by having a special type of variables.
>

You still haven't explained how your special type of variable will
work. Does it need to be declared? Is it that none of these special
variables are allowed to be created inside loops? What is it? BE
SPECIFIC.

And please, quote some context in your replies.

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


Re: "use strict"

2019-03-12 Thread Abdur-Rahmaan Janhangeer
ok, writing a pep-like document to explain all at once. sorry for
eyes-hurting and brain-hunting.

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


"Post install setup does not work as expected with pip install"

2019-03-12 Thread Saba Kauser
Hello,

I have a post install class that looks like this:
if('darwin' in sys.platform):
class PostInstall(install):
""" Post installation - run install_name_tool on Darwin """
def run(self):
clipath = os.getenv('IBM_DB_HOME', '@loader_path/clidriver')
print("in PostInstall with {}".format(clipath))
for so in glob.glob(r'build/lib*/ibm_db*.so'):
os.system("install_name_tool -change libdb2.dylib 
{}/lib/libdb2.dylib {}".format(clipath, so))
install.run(self)
cmd_class = dict(install = PostInstall)


And I pass cmd_class to setup(..) as:
setup(..
  include_package_data = True,
   cmdclass = cmd_class,
   **extra
 )

When I execute setup.py as "python setup.py install", then the PostInstall 
operation is executed after the ibm_db.so is built and installed and I see the 
intended result.
Howeever, when I run "pip install ibm_db" or "pip install .",
the execution order looks like this:
  warnings.warn(notifyString)
running install
in PostInstall with /Applications/dsdriver/  ==> this is my post install 
script
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7==> I need to traverse to this 
folder to find my shared library

I would expect it to be run post the ibm_db is installed, not before it gets 
built.

Can you please let me know how can this be fixed. Is this a bug with pip?


Saba Kauser
Db2 Connect development and support.

Rocket Software Development India Pvt Ltd
Karle Town Centre - SEZ,
HUB 1 building, 4th Floor (North West Wing),
100 ft. Kempapura road, adjacent to Nagawara lake,
Nagawara, Bangalore - 560 045
E: [email protected]
-



Rocket Software, Inc. and subsidiaries ? 77 Fourth Avenue, Waltham MA 02451 ? 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Rhodri James

On 12/03/2019 11:41, Abdur-Rahmaan Janhangeer wrote:

i also proposed

# -*- explicit -*-


To expand on my previous "ugh", I don't like hiding major run-time 
changes in cryptic comments.  Behaviour like this should be very 
explicit in the way that a comment isn't, and shouldn't be so easily the 
default.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Rhodri James

[[Replacing snipped context:]]
> = Abdur-Rahmaan, no indent is me.
On 12/03/2019 11:32, Abdur-Rahmaan Janhangeer wrote:
> no i mean
>
> # *-* use strict *-*

Ugh.

> program
>   typovar = x # line y
>
> ...
>
>
> Traceback:
>   on the fly var at line y

Yes, but how is the program supposed to know that typovar is a typo? Are 
you proposing mandatory declarations for all variables, because I think 
you know what the answer to that one will be.

[[End of previous post]]


On 12/03/2019 11:40, Abdur-Rahmaan Janhangeer wrote:

no just the var you want to track maybe

_var

or something like that, i want to solve that problem and this is just a
proposal


Sorry, I still don't understand.  *What* do you want to mark with 
"_var"?  It that a comment?  A new keyword?  Just a leading underscore? 
Could you give a full example, please?


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: System Beep?

2019-03-12 Thread ssmitch
On Saturday, March 9, 2019 at 12:53:35 AM UTC-5, Terry Reedy wrote:
> On 3/8/2019 1:13 PM, Steve wrote:
> > How can I cause a system beep using code?
> 
>  >>> import winsound as ws
>  >>> ws.Beep(500, 1000)
> 
> and
> 
>  >>> from tkinter import Tk
>  >>> root = Tk()
>  >>> root.bell()
> 
> work for me.  The bell is not exactly a bell, but different from a 
> monotone beep.
> 
> -- 
> Terry Jan Reedy

Another way that works (at least in Python 2.7) is
>>> import winsound
>>> winsound.MessageBeep(-1)

Not exactly a beep, but definitely a pleasant alert.

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


Re: "Post install setup does not work as expected with pip install"

2019-03-12 Thread Peter Otten
Saba Kauser wrote:

> Hello,
> 
> I have a post install class that looks like this:
> if('darwin' in sys.platform):
> class PostInstall(install):
> """ Post installation - run install_name_tool on Darwin """
> def run(self):
> clipath = os.getenv('IBM_DB_HOME', '@loader_path/clidriver')
> print("in PostInstall with {}".format(clipath))
> for so in glob.glob(r'build/lib*/ibm_db*.so'):
> os.system("install_name_tool -change libdb2.dylib
> {}/lib/libdb2.dylib {}".format(clipath, so))
> install.run(self)

I know nothing about what you are up to, but this looks odd to me. Wouldn't 
you need to call the superclass method install.run(self) *before* your 
custom code with the for loop?


> cmd_class = dict(install = PostInstall)
> 
> 
> And I pass cmd_class to setup(..) as:
> setup(..
>   include_package_data = True,
>cmdclass = cmd_class,
>**extra
>  )
> 
> When I execute setup.py as "python setup.py install", then the PostInstall
> operation is executed after the ibm_db.so is built and installed and I see
> the intended result. Howeever, when I run "pip install ibm_db" or "pip
> install .", the execution order looks like this:
>   warnings.warn(notifyString)
> running install
> in PostInstall with /Applications/dsdriver/  ==> this is my post
> install script running build
> running build_py
> creating build
> creating build/lib.macosx-10.9-x86_64-3.7==> I need to traverse to
> this folder to find my shared library
> 
> I would expect it to be run post the ibm_db is installed, not before it
> gets built.
> 
> Can you please let me know how can this be fixed. Is this a bug with pip?
> 
> 
> Saba Kauser
> Db2 Connect development and support.
> 
> Rocket Software Development India Pvt Ltd
> Karle Town Centre - SEZ,
> HUB 1 building, 4th Floor (North West Wing),
> 100 ft. Kempapura road, adjacent to Nagawara lake,
> Nagawara, Bangalore - 560 045
> E: [email protected]
> -
> 
> 
> 
> Rocket Software, Inc. and subsidiaries ? 77 Fourth Avenue, Waltham MA
> 02451 ? Main Office Toll Free Number: +1 855.577.4323 Contact Customer
> Support: https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
> Unsubscribe from Marketing Messages/Manage Your Subscription Preferences -
> http://www.rocketsoftware.com/manage-your-email-preferences Privacy Policy
> - http://www.rocketsoftware.com/company/legal/privacy-policy
> 
> 
> This communication and any attachments may contain confidential
> information of Rocket Software, Inc. All unauthorized use, disclosure or
> distribution is prohibited. If you are not the intended recipient, please
> notify Rocket Software immediately and destroy all copies of this
> communication. Thank you.


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


Re: System Beep?

2019-03-12 Thread Chris Angelico
On Wed, Mar 13, 2019 at 12:16 AM  wrote:
>
> On Saturday, March 9, 2019 at 12:53:35 AM UTC-5, Terry Reedy wrote:
> > On 3/8/2019 1:13 PM, Steve wrote:
> > > How can I cause a system beep using code?
> >
> >  >>> import winsound as ws
> >  >>> ws.Beep(500, 1000)
> >
> > and
> >
> >  >>> from tkinter import Tk
> >  >>> root = Tk()
> >  >>> root.bell()
> >
> > work for me.  The bell is not exactly a bell, but different from a
> > monotone beep.
> >
> > --
> > Terry Jan Reedy
>
> Another way that works (at least in Python 2.7) is
> >>> import winsound
> >>> winsound.MessageBeep(-1)
>
> Not exactly a beep, but definitely a pleasant alert.

Something to be careful of is that the message beep is controlled by
the user's sound configs (along with warning, error, etc). This may
include it having no audio attached to it at all. If your intention is
"tell the user there's a message", then by all means, use it; but
otherwise, you may want to stick with winsound.Beep.

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


Python scope question

2019-03-12 Thread Arup Rakshit
I have questions how nonlocal and global affecting the variable assignment. 
Also how each print statement looking up the values for the spam variable. This 
scope thing in python is very confusing too me still. Can anyone help me to 
understand this code w.r.t to scope in Python?

def scope_test():
def do_local():
spam = "local spam"

def do_nonlocal():
nonlocal spam
spam = "nonlocal spam"

def do_global():
global spam
spam = "global spam"

spam = "test spam"
do_local()
print("After local assignment:", spam)
do_nonlocal()
print("After nonlocal assignment:", spam)
do_global()
print("After global assignment:", spam)

scope_test()
print("In global scope:", spam)


——

$ python3 sample.py 
After local assignment: test spam
After nonlocal assignment: nonlocal spam
After global assignment: nonlocal spam
In global scope: global spam


Thanks,

Arup Rakshit
[email protected]



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


Re: Python scope question

2019-03-12 Thread Grant Edwards
On 2019-03-12, Arup Rakshit  wrote:

> I have questions how nonlocal and global affecting the variable
> assignment. Also how each print statement looking up the values for
> the spam variable. This scope thing in python is very confusing too
> me still. Can anyone help me to understand this code w.r.t to scope
> in Python?

https://www.ynonperek.com/2017/09/11/python-variable-scope-implicit-global-and-nonlocal/

-- 
Grant Edwards   grant.b.edwardsYow! If I pull this SWITCH
  at   I'll be RITA HAYWORTH!!
  gmail.comOr a SCIENTOLOGIST!

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


Convert Windows paths to Linux style paths

2019-03-12 Thread Malcolm Greene
Looking for best practice technique for converting Windows style paths to Linux 
paths. Is there an os function or pathlib method that I'm missing or is it some 
combination of replacing Windows path separators with Linux path separators 
plus some other platform specific logic?

Thank you,
Malcolm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "use strict"

2019-03-12 Thread Michael Torrie
On 03/11/2019 01:00 PM, Abdur-Rahmaan Janhangeer wrote:
> the problem was that i was reviewing the code, since everything worked (no
> errors but wrong output for sure) it took sometimes to find that var. it
> was like someone telling me there is fish in that lake and i was throwing
> my line trying ...

Code review is precisely the sort of time when a linter should be run on
the code to try to flag potential problems like this.  Sure it will flag
things that don't really matter, but you can ignore those.

Additionally using the type annotations that are now a part of Python
(3) will help the linter be even more useful to you in this scenario.

> just a way to flag those types of vars when needed.

Until you forget to flag one sometime.  Or end up flagging every
variable, which takes us back around to type annotations and linters.

So no, the answer is probably still, use a linter.


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


0x80070005 - acess denied when installing Python

2019-03-12 Thread Louis Aucamp
Goodday to all Members
I need help with an installation problem. The background is as follows:
I used PyScripter and Python 3.7 for learning python. I am taking a course
on Edx "introduction to data science" and one of the requirements is that
you install Anaconda. I have had bad experiences with anaconda in a
previous attempt and was reluctant to try again but decided to give it
another try . I had the same problems of programs freezing and crashing and
uninstalled anaconda. This cured my PC but now I cannot install Python 37
at all and get the error notice above. I have been through the usual google
recommended fixes but none works and I have checked that anaconda is
cleanly removed and that I have full administartors rights for installing
programs.

Can somebody out there please supply some help?
Enjoy the day
Louis Aucamp
-- 
https://mail.python.org/mailman/listinfo/python-list


Multiprocessing vs subprocess to run Python scripts in parallel

2019-03-12 Thread Malcolm Greene
Use case: I have a Python manager script that monitors several conditions (not 
just time based schedules) that needs to launch Python worker scripts to 
respond to the conditions it detects. Several of these worker scripts may end 
up running in parallel. There are no dependencies between individual worker 
scripts. I'm looking for the pros and cons of using multiprocessing or 
subprocess to launch these worker scripts. Looking for a solution that works 
across Windows and Linux. Open to using a 3rd party library. Hoping to avoid 
the use of yet another system component like Celery if possible and rational.

My understanding (so far) is that the tradeoff of using multiprocessing is that 
my manager script can not exit until all the work processes it starts finish. 
If one of the worker scripts locks up, this could be problematic. Is there a 
way to use multiprocessing where processes are launched independent of the 
parent (manager) process?

Thank you,
Malcolm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiprocessing vs subprocess to run Python scripts in parallel

2019-03-12 Thread Chris Angelico
On Wed, Mar 13, 2019 at 2:01 AM Malcolm Greene  wrote:
>
> Use case: I have a Python manager script that monitors several conditions 
> (not just time based schedules) that needs to launch Python worker scripts to 
> respond to the conditions it detects. Several of these worker scripts may end 
> up running in parallel. There are no dependencies between individual worker 
> scripts. I'm looking for the pros and cons of using multiprocessing or 
> subprocess to launch these worker scripts. Looking for a solution that works 
> across Windows and Linux. Open to using a 3rd party library. Hoping to avoid 
> the use of yet another system component like Celery if possible and rational.
>
> My understanding (so far) is that the tradeoff of using multiprocessing is 
> that my manager script can not exit until all the work processes it starts 
> finish. If one of the worker scripts locks up, this could be problematic. Is 
> there a way to use multiprocessing where processes are launched independent 
> of the parent (manager) process?
>

One advantage of multiprocessing is that it can fork, rather than
spinning up an entire new Python process from scratch. This doesn't
work on Windows, but it can give huge performance advantages on Unix
systems.

If the subprocesses are basically spun off and abandoned, you probably
want to use subprocess, but at this point, you're talking
architectural style and there are no right/wrong answers, just
consequences of different decisions. For instance, multiprocessing
will always run all the children in the exact same Python interpreter
that the master was invoked from, but with subprocess, you can invoke
anything you like (doesn't even have to be Python). OTOH, the
aforementioned performance advantage could be pretty significant if
you're starting lots of different processes in a short space of time.
And maybe you don't even need subprocesses at all, but could do it all
with threads or other forms of asynchronicity. You may need to mess
around a bit before making a decision.

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


Re: Convert Windows paths to Linux style paths

2019-03-12 Thread Thomas Jollans
On 12/03/2019 15.51, Malcolm Greene wrote:
> Looking for best practice technique for converting Windows style paths to 
> Linux paths. Is there an os function or pathlib method that I'm missing or is 
> it some combination of replacing Windows path separators with Linux path 
> separators plus some other platform specific logic?
> 
> Thank you,
> Malcolm
> 

Could you give some examples of what sort of paths you want to convert
in what way?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert Windows paths to Linux style paths

2019-03-12 Thread Bill Campbell
On Tue, Mar 12, 2019, Malcolm Greene wrote:

>Looking for best practice technique for converting Windows style paths to
>Linux paths. Is there an os function or pathlib method that I'm missing or
>is it some combination of replacing Windows path separators with Linux path
>separators plus some other platform specific logic?

See os.path.join

Bill
-- 
INTERNET:   [email protected]  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

The very concept of objective truth is fading out of the world.  Lies will
pass into history.  -- George Orwell
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert Windows paths to Linux style paths

2019-03-12 Thread Paul Moore
On Tue, 12 Mar 2019 at 14:54, Malcolm Greene  wrote:
>
> Looking for best practice technique for converting Windows style paths to 
> Linux paths. Is there an os function or pathlib method that I'm missing or is 
> it some combination of replacing Windows path separators with Linux path 
> separators plus some other platform specific logic?

You need to explain what you mean by "converting". How would you want
"C:\Windows" to be converted? Or
"\\myserver\myshare\path\to\file.txt"? Or "\\?\D:\very long path"?
What if the path is too long for POSIX filename length limitations?
How do you want to handle Unicode? Do you care about case sensitivity
(for example, is it important to you whether filenames "foo" and "FOO"
map to the same file or not on Linux, given that they do on Windows)?

It's quite possible that your answer to any or all of these questions
are "I don't need to consider these cases". But we don't know which
cases matter to you unless you clarify, and the *general* problem of
"converting filenames" between operating systems is essentially
impossible, because semantics are radically different.

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


RE: Multiprocessing vs subprocess

2019-03-12 Thread Schachner, Joseph
Re: " My understanding (so far) is that the tradeoff of using multiprocessing 
is that my manager script can not exit until all the work processes it starts 
finish. If one of the worker scripts locks up, this could be problematic. Is 
there a way to use multiprocessing where processes are launched independent of 
the parent (manager) process?"

I just want to point out that subprocess (which uses the operating system to 
start another processes, to run whatever you say - doesn't have to be Python 
running another script, can be an .exe)  does not have that restriction.  The 
subprocess call can be blocking (the caller waits), or not.   If not the caller 
can do whatever it wants including decide not to wait forever, and it can even 
exit.  

Of course, if one of the processes you launched is locked up that is a problem 
all by itself, even thought the manager can exit.

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


Re: Python scope question

2019-03-12 Thread DL Neil

Arup,


On 13/03/19 3:38 AM, Arup Rakshit wrote:

I have questions how nonlocal and global affecting the variable assignment. 
Also how each print statement looking up the values for the spam variable. This 
scope thing in python is very confusing too me still. Can anyone help me to 
understand this code w.r.t to scope in Python?

...

$ python3 sample.py
After local assignment: test spam
After nonlocal assignment: nonlocal spam
After global assignment: nonlocal spam
In global scope: global spam



Think this will help.

Watch the scopes 'appear' and operate in front of your very eyes: 
https://goo.gl/JC6SSh


or
http://pythontutor.com/visualize.html#code=def%20scope_test%28%29%3A%0A%20%20%20%20def%20do_local%28%29%3A%0A%20%20%20%20%20%20%20%20spam%20%3D%20%22local%20spam%22%0A%0A%20%20%20%20def%20do_nonlocal%28%29%3A%0A%20%20%20%20%20%20%20%20nonlocal%20spam%0A%20%20%20%20%20%20%20%20spam%20%3D%20%22nonlocal%20spam%22%0A%0A%20%20%20%20def%20do_global%28%29%3A%0A%20%20%20%20%20%20%20%20global%20spam%0A%20%20%20%20%20%20%20%20spam%20%3D%20%22global%20spam%22%0A%0A%20%20%20%20spam%20%3D%20%22test%20spam%22%0A%20%20%20%20do_local%28%29%0A%20%20%20%20print%28%22After%20local%20assignment%3A%22,%20spam%29%0A%20%20%20%20do_nonlocal%28%29%0A%20%20%20%20print%28%22After%20nonlocal%20assignment%3A%22,%20spam%29%0A%20%20%20%20do_global%28%29%0A%20%20%20%20print%28%22After%20global%20assignment%3A%22,%20spam%29%0A%0Ascope_test%28%29%0Aprint%28%22In%20global%20scope%3A%22,%20spam%29%0A&cumulative=false&curInstr=24&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=3&rawInputLstJSON=%5B%5D&te
xtReferences=false


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


3D visualizations in Python

2019-03-12 Thread Jakub Bista
Hello. I want to do 3D visualization in Python. Which framework do you 
recommend me for creating such a Interface?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 3D visualizations in Python

2019-03-12 Thread Larry Martell
On Tue, Mar 12, 2019 at 6:55 PM Jakub Bista  wrote:
>
> Hello. I want to do 3D visualization in Python. Which framework do you 
> recommend me for creating such a Interface?

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


[RELEASE] Python 3.7.3rc1 is now available for testing.

2019-03-12 Thread Ned Deily
Python 3.7.3rc1 is now available for testing. 3.7.3rc1 is the release
preview of the next maintenance release of Python 3.7, the latest
feature release of Python. Assuming no critical problems are found
prior to 2019-03-25, no code changes are planned between now and the
final release. This release candidate is intended to give you the
opportunity to test the new security and bug fixes in 3.7.3. We
strongly encourage you to test your projects and report issues found
to bugs.python.org as soon as possible. Please keep in mind that this
is a preview release and, thus, its use is not recommended for
production environments.

You can find the release files, a link to the changelog, and more
information here:
https://www.python.org/downloads/release/python-373rc1/

--
  Ned Deily
  [email protected] -- []

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


Re: Python scope question

2019-03-12 Thread Arup Rakshit
Hello,


Thanks for this beautiful link. This is amazing.


Thanks,

Arup Rakshit
[email protected]



> On 13-Mar-2019, at 12:11 AM, DL Neil  wrote:
> 
> Arup,
> 
> 
> On 13/03/19 3:38 AM, Arup Rakshit wrote:
>> I have questions how nonlocal and global affecting the variable assignment. 
>> Also how each print statement looking up the values for the spam variable. 
>> This scope thing in python is very confusing too me still. Can anyone help 
>> me to understand this code w.r.t to scope in Python?
> ...
>> $ python3 sample.py
>> After local assignment: test spam
>> After nonlocal assignment: nonlocal spam
>> After global assignment: nonlocal spam
>> In global scope: global spam
> 
> 
> Think this will help.
> 
> Watch the scopes 'appear' and operate in front of your very eyes: 
> https://goo.gl/JC6SSh
> 
> or
> http://pythontutor.com/visualize.html#code=def%20scope_test%28%29%3A%0A%20%20%20%20def%20do_local%28%29%3A%0A%20%20%20%20%20%20%20%20spam%20%3D%20%22local%20spam%22%0A%0A%20%20%20%20def%20do_nonlocal%28%29%3A%0A%20%20%20%20%20%20%20%20nonlocal%20spam%0A%20%20%20%20%20%20%20%20spam%20%3D%20%22nonlocal%20spam%22%0A%0A%20%20%20%20def%20do_global%28%29%3A%0A%20%20%20%20%20%20%20%20global%20spam%0A%20%20%20%20%20%20%20%20spam%20%3D%20%22global%20spam%22%0A%0A%20%20%20%20spam%20%3D%20%22test%20spam%22%0A%20%20%20%20do_local%28%29%0A%20%20%20%20print%28%22After%20local%20assignment%3A%22,%20spam%29%0A%20%20%20%20do_nonlocal%28%29%0A%20%20%20%20print%28%22After%20nonlocal%20assignment%3A%22,%20spam%29%0A%20%20%20%20do_global%28%29%0A%20%20%20%20print%28%22After%20global%20assignment%3A%22,%20spam%29%0A%0Ascope_test%28%29%0Aprint%28%22In%20global%20scope%3A%22,%20spam%29%0A&cumulative=false&curInstr=24&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=3&rawInputLstJSON=%5B%5D&;
 te
> xtReferences=false
> 
> 
> -- 
> Regards =dn
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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