String to Float, without introducing errors

2022-12-17 Thread Paul St George
I have a large/long array of numbers in an external file. The numbers look like this: -64550.727 -64511.489 -64393.637 -64196.763 -63920.2 -63563.037 -63124.156 -62602.254 -61995.895 -61303.548 -60523.651 -59654.66 ... When I bring the numbers into my code, they are Strings. To use the numbers i

Re: String to Float, without introducing errors

2022-12-17 Thread Paul St George
+ (7 * 0.1) + (2 * 0.01) + (7 * 0.001) Now I do not need to! > On 17 Dec 2022, at 13:11, Alan Gauld wrote: > > On 17/12/2022 11:51, Paul St George wrote: >> I have a large/long array of numbers in an external file. The numbers look >> like this: >> >> -6455

String to Float, without introducing errors

2022-12-18 Thread Paul St George
fully aware of what goes on under the bonnet. Here is a picture: https://paulstgeorge.com/newton/cyclography.html Thanks, Paul >> On 17 Dec 2022, at 16:54:05 EST 2022, Thomas Passin wrote: On 12/17/2022 3:45 PM, Paul St George wrote: > Thanks to all! > It was the rounding roundin

String to Float, without introducing errors

2022-12-18 Thread Paul St George
fully aware of what goes on under the bonnet.  >> On 17 Dec 2022, at 16:54:05 EST 2022, Thomas Passin wrote: On 12/17/2022 3:45 PM, Paul St George wrote: > Thanks to all! > It was the rounding rounding error that I needed to avoid (as Peter J. Holzer > suggested). The

for convenience

2022-03-21 Thread Paul St George
When I am writing code, I often do things like this: context = bpy.context # convenience then whenever I need bpy.context, I only need to write context Here’s my question: When I forget to use the convenient shorter form why is bpy.context not interpreted as bpy.bpy.context? — Paul St

Re: for convenience

2022-03-21 Thread Paul St George
; the `context` attribute in the `bpy` module. > > On Mon, 2022-03-21 at 22:12 +0100, Paul St George wrote: >> >> When I am writing code, I often do things like this: >> >> context = bpy.context # convenience >> >> then whenever I need bpy.context, I only

Re: for convenience

2022-03-22 Thread Paul St George
On 21/03/2022 18.04, dn wrote: > On 22/03/2022 10.17, Chris Angelico wrote: > > On Tue, 22 Mar 2022 at 08:13, Paul St George > <https://mail.python.org/mailman/listinfo/python-list>> wrote: > >> > >> > >> When I am writing code, I often do t

Re: for convenience

2022-03-22 Thread Paul St George
On 21/03/2022 18.02, Cameron Simpson wrote: > On 21Mar2022 22:12, Paul St George wrote: > >When I am writing code, I often do things like this: > > > >context = bpy.context # convenience > > > >then whenever I need bpy.context, I only need to write cont

Re: for convenience

2022-03-22 Thread Paul St George
On 21/03/2022 17.47, Avi Gross wrote: > So, I ask Paul what other language than python he has used before, just out > of curiosity. The other language I have used (and often) is Processing. Before that, and a long time ago, Lingo. — Paul -- https://mail.python.org/mailman/listinfo/pyth

Re: for convenience

2022-03-24 Thread Paul St George
is super interesting. You have my permission, and please feel free to contact me offline if you want to ask anything. Yes, I had noticed the tandem with @Chris. I think I needed both! I already have a folder on my Mac called ‘Cameron’. Perhaps I now need an additional folder. Then I can ask my question about whether Python grows to be more like its programmers, or do programmers learn to think Pythonically? — Paul St George -- https://mail.python.org/mailman/listinfo/python-list

The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-25 Thread Paul St George
I am using the Python Imaging Library (PIL), Python 2 and Raspberry Pi 3 B+ My code is simply:     from PIL import Image     im = Image.open(‘somepic.jpg’)     im.show() # display image But the show() method looks for the default viewer (probably xv). How do I change this (in the code, or in

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-26 Thread Paul St George
tml#PIL.Image.Image.show>, but I am none the wiser. On 26/05/2018 01:02, boB Stepp wrote: On Fri, May 25, 2018 at 6:04 AM, Paul St George wrote: I am using the Python Imaging Library (PIL), Python 2 and Raspberry Pi 3 B+ My code is simply: from PIL import Image im = Image.open(‘somep

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-27 Thread Paul St George
mand". If you need to provide more than the program name, you may have to instead create a shell-script, set it executable, and pass the script name -- have the script then invoke the program with the options and forwarding the temporary file name to it. -- Paul St George http:/

Re: Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-27 Thread Paul St George
", file=sys.stderr) else: image = Image.open(file) image.show() Here's another, even simpler one: class Gwenview(ImageShow.UnixViewer): def get_command_ex(self, file, **options): return ("gwenview",) * 2 -- Paul St George http://www.p

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-29 Thread Paul St George
Should the PIL code be corrected? On 28/05/2018 06:34, Christian Gollwitzer wrote: Am 27.05.18 um 23:58 schrieb Cameron Simpson: On 27May2018 20:15, Paul St George wrote: This is very helpful indeed, thank you. Awe-inspiring. It occurred to me that I could edit the PIL/ImageShow.py

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-29 Thread Paul St George
Thank you. For the advice, and for the new word 'monkeypatch'. On 27/05/2018 23:58, Cameron Simpson wrote: On 27May2018 20:15, Paul St George wrote: This is very helpful indeed, thank you. Awe-inspiring. It occurred to me that I could edit the PIL/ImageShow.py, replacing ‘xv

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-29 Thread Paul St George
I tried this anyway. The error was:     non-keyword arg after keyword arg On 27/05/2018 21:51, Dennis Lee Bieber wrote: On Sun, 27 May 2018 19:59:41 +0200, Paul St George declaimed the following: So, on Unix I would use Image.show(title=None, nameofdisplayutilty), or Image.show(title

Re: Re: Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-29 Thread Paul St George
Is there, somewhere, a list of viewers and their names (for the purposes of this script)? I am assuming that if I want to ImageMagick (for example), there would be some shorter name - such as 'magick' - and it would be lower case . On 29/05/2018 08:58, Peter Otten wrote: Paul

Re: Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-30 Thread Paul St George
tml#frequently-used-arguments>. Is this equivalent? p = subprocess.Popen('display',  + imagepath) so p = subprocess.Popen('display',  'test.png') On 30/05/2018 03:04, Ian Kelly wrote: On Sat, May 26, 2018 at 9:17 AM, Paul St George wrote: Thank you. You

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-30 Thread Paul St George
he name of my favourite viewer (for example: ‘ImageMagick’). On 30/05/2018 02:31, Steven D'Aprano wrote: On Tue, 29 May 2018 20:02:22 +0200, Paul St George wrote: Is there, somewhere, a list of viewers and their names (for the purposes of this script)? Do you mean a list of programs cap

Re: Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-31 Thread Paul St George
That's what I wanted! But, I didn't know the question because I didn't know the answer. On 30/05/2018 23:09, Karsten Hilbert wrote: On Wed, May 30, 2018 at 11:01:17PM +0200, Peter J. Holzer wrote: On 2018-05-30 22:08:45 +0200, Paul St George wrote: Ha! No, my question wa

FULLSCREEN and DOUBLEBUF

2018-06-07 Thread Paul St George
, I can use screen = pygame.display.set_mode((screen_width,screen_height),pygame.DOUBLEBUF) to set DOUBLEBUF But how do I set both FULLSCREEN and DOUBLEBUF? And, how can I test or check that DOUBLEBUF is set? -- Paul St George http://www.paulstgeorge.com http://www.devices-of-wonder.com -- https

Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-08 Thread Paul St George
or DOUBLEBUF. No errors were reported, but how would I check that DOUBLEBUF had been set? Is there a general rule, such as replace 'set_something' with 'get_something'? Paul St George On 07/06/2018 19:56, Chris Angelico wrote: On Fri, Jun 8, 2018 at 3:12 AM, Paul St Geo

Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-09 Thread Paul St George
On 08/06/18 09:00, Paul St George wrote: Excellent. Now I know what to do in this instance and I understand the principle. I hesitantly tried this: screen = pygame.display.set_mode((720,480), pygame.FULLSCREEN | pygame.DOUBLEBUF) Hesitantly because I expected the *bitwise or

Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-10 Thread Paul St George
To recap: this thread started with a question. How do I know whether DOUBLEBUF has been set with:     screen = pygame.display.set_mode((720,480), pygame.DOUBLEBUF | pygame.FULLSCREEN) On 09/06/2018 22:04, Mark Lawrence wrote: On 09/06/18 20:31, Paul St George wrote: print

Re: Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-10 Thread Paul St George
Paul St George wrote: So... print pygame.display.get_surface() gives and print screen.get_flags() gives -2147483648 To recap: this thread started with a question. How do I know whether DOUBLEBUF has been set with: screen = pygame.display.set_mode((720,480), pygame.DOUBLEBUF

Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-12 Thread Paul St George
Dennis Lee Bieber wrote: Both may be dependent upon the actual hardware graphics board and the drivers for said board. On 11/06/2018 01:47, Gregory Ewing wrote: My guess is that if your surface is not fullscreen or is not a hardware surface, then you're always drawing into an ofscreen bu

Re: Python list vs google group

2018-06-16 Thread Paul St George
On 15/06/2018 17:33, T Berger wrote: On Friday, June 15, 2018 at 12:14:30 PM UTC-4, Mark Lawrence wrote: On 15/06/18 16:47, T Berger wrote: On Friday, June 15, 2018 at 11:31:47 AM UTC-4, Alister wrote: it certainly seems to be the source of most SPAM as such some users of this list/newsgroup

Re: Feeding the trolls

2018-06-22 Thread Paul St George
On 21/06/2018 10:05, Anssi Saari wrote: D'Arcy Cain writes: One of these days I will have to figure out how to block replies to the trolls as well. Benefit of reading the mailing list via nntp (i.e. gmane): can easily score down follow-ups to annoying people in addition to their posts. Well,

Accessing the Python list

2018-06-25 Thread Paul St George
Understanding and having an interest in Python does not imply knowledge of Usenet, mailing lists, NNTP, gateways, gmane, bottom-posting, vanilla-flopping, /et al/. But, knowledge of these seems to be needed (or is at least useful) in order to fully benefit from the Python list. Would it be a

Accessing the Python list

2018-06-26 Thread Paul St George
From: Paul St George Understanding and having an interest in Python does not imply knowledge of Usenet, mailing lists, NNTP, gateways, gmane, bottom-posting, vanilla-flopping, /et al/. But, knowledge of these seems to be needed (or is at least useful) in order to fully benefit from the Python

Python in Blender. Writing information to a file.

2019-08-08 Thread Paul St George
I am using Python 3.5 within Blender. I want to collect values of the current settings and then write all the results to a file. I can see the settings and the values in the Python console by doing this for each of the settings | | |print(“Focal length:”,bpy.context.object.data.lens)| ---Foc

Re: Re: Python in Blender. Writing information to a file.

2019-08-08 Thread Paul St George
On 08/08/2019 10:18, Peter Otten wrote: Paul St George wrote: I am using Python 3.5 within Blender. I want to collect values of the current settings and then write all the results to a file. I can see the settings and the values in the Python console by doing this for each of the settings

Re: Python in Blender. Writing information to a file.

2019-08-09 Thread Paul St George
On 09/08/2019 04:09, Cameron Simpson wrote: On 08Aug2019 22:42, Paul St George wrote: On 08/08/2019 10:18, Peter Otten wrote: The print() function has a keyword-only file argument. So: with open(..., "w") as outstream:     print("Focal length:", bpy.context.object.data.l

String slices

2019-08-09 Thread Paul St George
In the code (below) I want a new line like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 But not like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 Is it possible? (I am using Python 3.5 within Blender.) # import os outstream = open(os.path

Re: Re: Python in Blender. Writing information to a file.

2019-08-09 Thread Paul St George
On 09/08/2019 15:59, Rhodri James wrote: On 09/08/2019 14:54, Paul St George wrote: On 09/08/2019 04:09, Cameron Simpson wrote: On 08Aug2019 22:42, Paul St George wrote: On 08/08/2019 10:18, Peter Otten wrote: The print() function has a keyword-only file argument. So: with open(..., &q

Re: Re: String slices

2019-08-09 Thread Paul St George
On 09/08/2019 16:29, Rhodri James wrote: On 09/08/2019 15:13, Paul St George wrote: In the code (below) I want a new line like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 But not like this: Plane rotation X: 0.0 Plane rotation Y: 0.0 Plane rotation Z: 0.0 Is it

Re: Re: String slices

2019-08-10 Thread Paul St George
On 10/08/2019 17:35, Dennis Lee Bieber wrote: On Sat, 10 Aug 2019 11:45:43 +0200, "Peter J. Holzer" declaimed the following: There are of course many variants to all three methods. And then one can get downright nasty... X = 3.14 Y = 2.78 Z = 6.226E23 print("".join(["Plane rotation

absolute path to a file

2019-08-15 Thread Paul St George
ses image02.tif saved at //../images/image02.tif which is at //images/image02.tif But I want an absolute path such as: ---Plane uses image01.tif saved at /Users/Lion/Desktop/test8/image01.tif ---Plane uses image02.tif saved at /Users/Lion/Desktop/images/image02.tif If it is relevant, my files are on a M

Re: Re: absolute path to a file

2019-08-16 Thread Paul St George
lso accepts a Pathlike object. Thanks for this. I changed my code to use your suggestion which seems to be better for the situation where I used resolve() before. -- Paul St George http://www.paulstgeorge.com http://www.devices-of-wonder.com +44(0)7595 37 1302 -- https://mail.python.org/mailman/listinfo/python-list

Re: absolute path to a file

2019-08-16 Thread Paul St George
On 16/08/2019 18:37, Chris Angelico wrote: On Sat, Aug 17, 2019 at 2:27 AM Paul St George wrote: BUT does not work with | print('test2:',os.path.realpath(n.image.filepath))| This returns only |/image01.tif| Notes: Chris, I only mention the extra leading slash on my Mac in c

Re: absolute path to a file

2019-08-17 Thread Paul St George
On 17/08/2019 01:07, Gregory Ewing wrote: On Sat, Aug 17, 2019 at 2:27 AM Paul St George wrote: BUT does not work with | print('test2:',os.path.realpath(n.image.filepath))| This returns only |/image01.tif| What does n.image.filepath look like on its own? If it starts with a lea

Re: absolute path to a file

2019-08-17 Thread Paul St George
On 17/08/2019 15:37, Peter Otten wrote: Paul St George wrote: Can someone please tell me how to get the absolute path to a file? I have tried os.path.abspath. In the code below I have a problem in the final line (15). # |import bpy|| Is this blender? If so the "//" prefix sta

Re: absolute path to a file

2019-08-17 Thread Paul St George
On 17/08/2019 16:32, Dennis Lee Bieber wrote: On Sat, 17 Aug 2019 11:51:47 +0200, Paul St George declaimed the following: print('Track E from Track B:',os.path.realpath(n.image.filepath[1:])) ---Track E from Track B: /image01.tif Just for giggles, what happens if y

Re: absolute path to a file

2019-08-17 Thread Paul St George
On 17/08/2019 15:37, Peter Otten wrote: Paul St George wrote: Can someone please tell me how to get the absolute path to a file? I have tried os.path.abspath. In the code below I have a problem in the final line (15). # |import bpy|| Is this blender? If so the "//" prefix sta

Re: absolute path to a file

2019-08-18 Thread Paul St George
On 18/08/2019 02:03, Cameron Simpson wrote: On 17Aug2019 11:51, Paul St George wrote: print('Track D  from Track B:',os.path.realpath(n.image.filepath)) ---Track D  from Track B: /image01.tif print('Track E  from Track B:',os.path.realpath(n.image.filepath[1:])) ---T

Re: absolute path to a file

2019-08-18 Thread Paul St George
On 19/08/2019 01:31, Cameron Simpson wrote: Paul, I can see we must train you in the interleaved response style :-) On 18Aug2019 17:29, Paul St George wrote: On 18/08/2019 02:03, Cameron Simpson wrote: 1: Is image01.tif a real existing file when you ran this code? Yes. image01.tif is real

Re: absolute path to a file

2019-08-19 Thread Paul St George
On 19/08/2019 14:16, Cameron Simpson wrote: On 19Aug2019 08:52, Paul St George wrote: On 19/08/2019 01:31, Cameron Simpson wrote: On 18Aug2019 17:29, Paul St George wrote: On 18/08/2019 02:03, Cameron Simpson wrote: 1: Is image01.tif a real existing file when you ran this code? Yes. image01

Re: absolute path to a file

2019-08-20 Thread Paul St George
On 20/08/2019 11:43, Cameron Simpson wrote: Please remember to CC the list. Instead of 'Post a followup to this newsgroup' or 'To: python-list@python.org'? On 19Aug2019 22:06, Paul St George wrote: On 19/08/2019 14:16, Cameron Simpson wrote: [...] There's a

Re: absolute path to a file

2019-08-20 Thread Paul St George
On 21/08/2019 04:09, Grant Edwards wrote: On 2019-08-21, Richard Damon wrote: I think gmane feed the newsgroup comp.lang.python which feeds python-list@python.org. No, gmane is a gateway to python-list@python.org. -- Grant I use https://mail.python.org/pipermail/python-list/ to confirm tha

Newbie question about Python syntax

2019-08-22 Thread Paul St George
I have the Python API for the Map Value Node here: . All well and good. Now I just want to write a simple line of code such as: import bpy ... >>>print(bpy.types.CompositorNodeMapValue.max[0]) If this works, I will d

Re: Newbie question about Python syntax

2019-08-22 Thread Paul St George
On 22/08/2019 11:49, Cameron Simpson wrote: On 22Aug2019 09:34, Paul St George wrote: I have the Python API for the Map Value Node here: <https://docs.blender.org/api/current/bpy.types.CompositorNodeMapValue.html>. All well and good. Now I just want to write a simple line of code su

Re: Newbie question about Python syntax

2019-08-22 Thread Paul St George
On 22/08/2019 20:02, Terry Reedy wrote: On 8/22/2019 3:34 AM, Paul St George wrote: I have the Python API for the Map Value Node here: <https://docs.blender.org/api/current/bpy.types.CompositorNodeMapValue.html>. All well and good. Now I just want to write a simple line of code su

Re: Newbie question about Python syntax

2019-08-23 Thread Paul St George
On 22/08/2019 23:21, Kyle Stanley wrote: [snip] The tutorial that Terry was referring to was the one on docs.python.org, here's a couple of links for the sections he was referring to: Full section on classes: https://docs.python.org/3/tutorial/classes.html Section on instantiating objects from

Re: Newbie question about Python syntax

2019-08-24 Thread Paul St George
On 24/08/2019 01:23, Cameron Simpson wrote: On 23Aug2019 13:49, Paul St George wrote: Context: I am using Python to interrogate the value of some thing in Blender (just as someone else might want to use Python to look at an email in a Mail program or an image in Photoshop). Assumptions: So

Re: Newbie question about Python syntax

2019-08-26 Thread Paul St George
On 25/08/2019 02:39, Cameron Simpson wrote: On 24Aug2019 21:52, Paul St George wrote: [snip]> Aside from "map" being a poor name (it is also a builtin Python function), it seems that one creates one of these to control how some rendering process is done. The class refer