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 reference page you

Re: Newbie question about Python syntax

2019-08-24 Thread Cameron Simpson
On 24Aug2019 21:52, Paul St George wrote: Have you not got one of these handed to you from something? Or are you right at the outside with some "opaque" blender handle or something? (Disclaimer: I've never used Blender.) Thank you once again. If I understand your question, I am right

Re: Newbie question about Python syntax

2019-08-24 Thread Barry
Have you tried asking on a blender user mailing list for help with this problem? It seems that someone familiar with blender and its python interface should be able to help get you going. Barry > On 24 Aug 2019, at 20:52, Paul St George wrote: > >> On 24/08/2019 01:23, Cameron Simpson wrote:

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:

Re: Newbie question about Python syntax

2019-08-23 Thread Cameron Simpson
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, I want to look at the attribute of an

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

Re: Newbie question about Python syntax

2019-08-22 Thread Kyle Stanley
> You are right, but it is even worse than you think. I do not have a tutorial so I have no examples to understand. 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:

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: . All well and good. Now I just want to write a simple line of code such as:

Re: Newbie question about Python syntax

2019-08-22 Thread Terry Reedy
On 8/22/2019 3:34 AM, Paul St George wrote: 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 ...

Re: Newbie question about Python syntax

2019-08-22 Thread Chris Angelico
On Thu, Aug 22, 2019 at 9:20 PM Paul St George wrote: > > 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: > >> . > >> > >>

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: . All well and good. Now I just want to write a simple line of code such as:

Re: Newbie question about Python syntax

2019-08-22 Thread Cameron Simpson
On 22Aug2019 09:34, Paul St George wrote: 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

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

Re: newbie question

2019-08-01 Thread Sidney Langweil
On Thursday, August 1, 2019 at 7:57:31 AM UTC-7, Calvin Spealman wrote: > Sorry, but you can't. If you have two python modules, neither has access to > things in the other without an import. > > That's the whole point of an import. > > On Thu, Aug 1, 2019 at 10:30 AM Sidney Langweil > wrote: >

Re: newbie question

2019-08-01 Thread Calvin Spealman
Sorry, but you can't. If you have two python modules, neither has access to things in the other without an import. That's the whole point of an import. On Thu, Aug 1, 2019 at 10:30 AM Sidney Langweil wrote: > A Python script invokes a function in another file in the same directory. > > I would

newbie question

2019-08-01 Thread Sidney Langweil
A Python script invokes a function in another file in the same directory. I would like to invoke that function without the need for an import. I think I read that having an empty __init__.py is sufficient. But it does not seem to work for me. I'm sure this is obvious to many of you. Thanks

tix.FileSelectBox causes crash: was A newbie question about using tix

2019-05-03 Thread David Sumbler
On Wed, 2019-05-01 at 19:11 +0100, MRAB wrote: > On 2019-05-01 17:44, David Sumbler wrote: > > > > On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: ... > > > For some reason, tix widgets don't work with normal tkinter > widgets, > > > so > > > you can't put a tix FileSelectBox on a

Re: A newbie question about using tix

2019-05-01 Thread MRAB
On 2019-05-01 17:44, David Sumbler wrote: > > On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: > > On 2019-04-30 16:40, David Sumbler wrote: > > > Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6 > > > > > > I am very new to tkinter.  The simple program I am writing requires > > > a > > > user file

Re: A newbie question about using tix

2019-05-01 Thread David Sumbler
On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: > On 2019-04-30 16:40, David Sumbler wrote: > > Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6 > > > > I am very new to tkinter. The simple program I am writing requires > > a > > user file to be selected before it does anything else, so I would

Re: A newbie question about using tix

2019-04-30 Thread MRAB
On 2019-04-30 16:40, David Sumbler wrote: Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6 I am very new to tkinter. The simple program I am writing requires a user file to be selected before it does anything else, so I would like a file selection dialog in the main window as soon as the

A newbie question about using tix

2019-04-30 Thread David Sumbler
Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6 I am very new to tkinter. The simple program I am writing requires a user file to be selected before it does anything else, so I would like a file selection dialog in the main window as soon as the program launches. Tkinter only has

Re: TKinter Newbie question

2019-01-18 Thread TUA
Thanks for your fresh pair of eyes! -- https://mail.python.org/mailman/listinfo/python-list

Re: TKinter Newbie question

2019-01-17 Thread Peter Otten
TUA wrote: > Why does the button frame in the code below not show? > tk.Button(bf, padx = 10, relief = tk.GROOVE, text = 'Help') You forgot to layout it with .pack(). > I intend to have it displayed in between the notebook at the top and the > fake statusbar at the bottom. I think for

TKinter Newbie question

2019-01-17 Thread TUA
Why does the button frame in the code below not show? I intend to have it displayed in between the notebook at the top and the fake statusbar at the bottom. Thanks for any help! from tkinter import ttk import tkinter as tk class MainForm(): def __init__(self, master):

Re: RE newbie question

2018-04-18 Thread Steven D'Aprano
On Wed, 18 Apr 2018 12:37:29 -0700, TUA wrote: > My intention is to implement a max. length of 8 for an input string. The > above works well in all other respects, but does allow for strings that > are too long. if len(input_string) > 8: raise ValueError('string is too long') -- Steve

Re: RE newbie question

2018-04-18 Thread Albert-Jan Roskam
On Apr 18, 2018 21:42, TUA wrote: > > import re > > compval = 'A123456_8' > regex = '[a-zA-Z]\w{0,7}' > > if re.match(regex, compval): >print('Yes') > else: >print('No') > > > My intention is to implement a max. length of 8 for an input string. The > above works

Re: RE newbie question

2018-04-18 Thread TUA
Thanks much! -- https://mail.python.org/mailman/listinfo/python-list

Re: RE newbie question

2018-04-18 Thread Ian Kelly
On Wed, Apr 18, 2018 at 1:57 PM, Rob Gaddi wrote: > On 04/18/2018 12:37 PM, TUA wrote: >> >> import re >> >> compval = 'A123456_8' >> regex = '[a-zA-Z]\w{0,7}' >> >> if re.match(regex, compval): >> print('Yes') >> else: >> print('No') >> >> >> My

Re: RE newbie question

2018-04-18 Thread Rob Gaddi
On 04/18/2018 12:37 PM, TUA wrote: import re compval = 'A123456_8' regex = '[a-zA-Z]\w{0,7}' if re.match(regex, compval): print('Yes') else: print('No') My intention is to implement a max. length of 8 for an input string. The above works well in all other respects, but does allow

RE newbie question

2018-04-18 Thread TUA
import re compval = 'A123456_8' regex = '[a-zA-Z]\w{0,7}' if re.match(regex, compval): print('Yes') else: print('No') My intention is to implement a max. length of 8 for an input string. The above works well in all other respects, but does allow for strings that are too long. What is

Re: ARGPARSE Newbie question

2018-04-17 Thread TUA
Thanks for the pointers! -- https://mail.python.org/mailman/listinfo/python-list

Re: ARGPARSE Newbie question

2018-04-17 Thread paulclarke345
On Tuesday, April 17, 2018 at 7:09:45 PM UTC-5, TUA wrote: > I'd like to create a script that handles a number of verbs with mandatory and > /or optional parameters like listed in the table below. > > Can ARGPARSE do this and how? > > Thanks for all help! > > > > > > Script Verb

ARGPARSE Newbie question

2018-04-17 Thread TUA
I'd like to create a script that handles a number of verbs with mandatory and /or optional parameters like listed in the table below. Can ARGPARSE do this and how? Thanks for all help! Script VerbMandatory parameters Optional parameters

Re: newbie question re classes and self

2017-03-29 Thread Rick Johnson
On Tuesday, March 28, 2017 at 3:09:45 AM UTC-5, loial wrote: > Can I pass self(or all its variables) to a class? > Basically, how do I make all the variables defined in self > in the calling python script available to the python class > I want to call? Your question, as presented, is difficult to

Re: newbie question re classes and self

2017-03-28 Thread Terry Reedy
On 3/28/2017 4:09 AM, loial wrote: Can I pass self(or all its variables) to a class? In Python, every argument to every function is an instance of some class. The function can access any attribute of the arguments it receives with arg.attribute. -- Terry Jan Reedy --

Re: newbie question re classes and self

2017-03-28 Thread Peter Otten
loial wrote: > Can I pass self(or all its variables) to a class? > > Basically, how do I make all the variables defined in self in the calling > python script available to the python class I want to call? Inside a method you can access attributes of an instance as self.whatever: >>> class A:

newbie question re classes and self

2017-03-28 Thread loial
Can I pass self(or all its variables) to a class? Basically, how do I make all the variables defined in self in the calling python script available to the python class I want to call? -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-29 Thread Sven R. Kunze
On 28.03.2016 17:34, ast wrote: "Matt Wheeler" a écrit dans le message de news:mailman.92.1458825746.2244.python-l...@python.org... On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote: On 24.03.2016 11:57, Matt Wheeler wrote: import ast s = "(1,

Re: newbie question

2016-03-28 Thread ast
"Matt Wheeler" a écrit dans le message de news:mailman.92.1458825746.2244.python-l...@python.org... On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote: On 24.03.2016 11:57, Matt Wheeler wrote: import ast s = "(1, 2, 3, 4)" t =

Re: newbie question

2016-03-24 Thread Sven R. Kunze
On 24.03.2016 14:22, Matt Wheeler wrote: On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote: On 24.03.2016 11:57, Matt Wheeler wrote: import ast s = "(1, 2, 3, 4)" t = ast.literal_eval(s) t (1, 2, 3, 4) I suppose that's the better solution in terms of safety. It has the

Re: newbie question

2016-03-24 Thread Grant Edwards
On 2016-03-24, Steven D'Aprano wrote: > On Thu, 24 Mar 2016 09:49 pm, David Palao wrote: > >> Hi, >> Use "eval": >> s = "(1, 2, 3, 4)" >> t = eval(s) > > Don't use eval unless you absolutely, categorically, 100% trust the source > of the string. And then still don't use it.

Re: newbie question

2016-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2016 09:49 pm, David Palao wrote: > Hi, > Use "eval": > s = "(1, 2, 3, 4)" > t = eval(s) Don't use eval unless you absolutely, categorically, 100% trust the source of the string. Otherwise, you are letting the person who provided the string run any code they like on your

Re: newbie question

2016-03-24 Thread Matt Wheeler
On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote: > On 24.03.2016 11:57, Matt Wheeler wrote: > import ast > s = "(1, 2, 3, 4)" > t = ast.literal_eval(s) > t > > (1, 2, 3, 4) > > I suppose that's the better solution in terms of safety. > It has the added

Re: newbie question

2016-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2016 09:39 pm, ast wrote: > Hi > > I have a string which contains a tupe, eg: > > s = "(1, 2, 3, 4)" > > and I want to recover the tuple in a variable t > > t = (1, 2, 3, 4) > > how would you do ? py> import ast py> ast.literal_eval("(1, 2, 3, 4)") (1, 2, 3, 4) -- Steven

Re: newbie question

2016-03-24 Thread Sven R. Kunze
On 24.03.2016 11:57, Matt Wheeler wrote: import ast s = "(1, 2, 3, 4)" t = ast.literal_eval(s) t (1, 2, 3, 4) I suppose that's the better solution in terms of safety. -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-24 Thread Tim Chase
On 2016-03-24 11:49, David Palao wrote: >> s = "(1, 2, 3, 4)" >> >> and I want to recover the tuple in a variable t >> >> t = (1, 2, 3, 4) >> >> how would you do ? > > Use "eval": > s = "(1, 2, 3, 4)" > t = eval(s) Using eval() has security implications. Use ast.literal_eval for safety instead:

Re: newbie question

2016-03-24 Thread Matt Wheeler
>>> import ast >>> s = "(1, 2, 3, 4)" >>> t = ast.literal_eval(s) >>> t (1, 2, 3, 4) On 24 March 2016 at 10:39, ast wrote: > Hi > > I have a string which contains a tupe, eg: > > s = "(1, 2, 3, 4)" > > and I want to recover the tuple in a variable t > > t = (1, 2, 3, 4) > >

Re: newbie question

2016-03-24 Thread ast
"David Palao" a écrit dans le message de news:mailman.86.1458816553.2244.python-l...@python.org... Hi, Use "eval": s = "(1, 2, 3, 4)" t = eval(s) Best Thank you -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-24 Thread David Palao
Hi, Use "eval": s = "(1, 2, 3, 4)" t = eval(s) Best 2016-03-24 11:39 GMT+01:00 ast : > Hi > > I have a string which contains a tupe, eg: > > s = "(1, 2, 3, 4)" > > and I want to recover the tuple in a variable t > > t = (1, 2, 3, 4) > > how would you do ? > > > -- >

newbie question

2016-03-24 Thread ast
Hi I have a string which contains a tupe, eg: s = "(1, 2, 3, 4)" and I want to recover the tuple in a variable t t = (1, 2, 3, 4) how would you do ? -- https://mail.python.org/mailman/listinfo/python-list

Re: tkinter newbie question

2016-01-25 Thread KP
On Sunday, 24 January 2016 20:20:07 UTC-8, KP wrote: > See my code below (which works). I'd like to have the 2nd window as a class > in a separate unit. How do I code that unit and how do I call it from my > first unit? > > As always, thanks for all help! > > > > > #!/usr/bin/env python >

Re: tkinter newbie question

2016-01-25 Thread KP
On Monday, 25 January 2016 08:22:12 UTC-8, KP wrote: > On Monday, 25 January 2016 00:51:34 UTC-8, Peter Otten wrote: > > KP wrote: > > > > > See my code below (which works). > > > > >From the import of lowercase "tkinter" I conclude you are using Python 3. > > > > > I'd like to have the 2nd

Re: tkinter newbie question

2016-01-25 Thread KP
On Monday, 25 January 2016 00:51:34 UTC-8, Peter Otten wrote: > KP wrote: > > > See my code below (which works). > > >From the import of lowercase "tkinter" I conclude you are using Python 3. > > > I'd like to have the 2nd window as a > > class in a separate unit. How do I code that unit and

Re: tkinter newbie question

2016-01-25 Thread Peter Otten
KP wrote: > See my code below (which works). >From the import of lowercase "tkinter" I conclude you are using Python 3. > I'd like to have the 2nd window as a > class in a separate unit. How do I code that unit and how do I call it > from my first unit? > > As always, thanks for all help!

tkinter newbie question

2016-01-24 Thread KP
See my code below (which works). I'd like to have the 2nd window as a class in a separate unit. How do I code that unit and how do I call it from my first unit? As always, thanks for all help! #!/usr/bin/env python """ """ from tkinter import * from settings import * class window1():

Re: Newbie question about text encoding

2015-03-09 Thread Rustom Mody
On Monday, March 9, 2015 at 12:05:05 PM UTC+5:30, Steven D'Aprano wrote: Chris Angelico wrote: As to the notion of rejecting the construction of strings containing these invalid codepoints, I'm not sure. Are there any languages out there that have a Unicode string type that requires that

Re: Newbie question about text encoding

2015-03-09 Thread Marko Rauhamaa
Ben Finney ben+pyt...@benfinney.id.au: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: '\udd00' should be a SyntaxError. I find your argument convincing, that attempting to construct a Unicode string of a lone surrogate should be an error. Then we're back to square one:

Re: Newbie question about text encoding

2015-03-09 Thread Chris Angelico
On Mon, Mar 9, 2015 at 5:34 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Chris Angelico wrote: As to the notion of rejecting the construction of strings containing these invalid codepoints, I'm not sure. Are there any languages out there that have a Unicode string type that

Re: Newbie question about text encoding

2015-03-09 Thread Steven D'Aprano
Chris Angelico wrote: As to the notion of rejecting the construction of strings containing these invalid codepoints, I'm not sure. Are there any languages out there that have a Unicode string type that requires that all codepoints be valid (no surrogates, no U+FFFE, etc)? U+FFFE and U+

Re: Newbie question about text encoding

2015-03-08 Thread Chris Angelico
On Mon, Mar 9, 2015 at 5:25 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Marko Rauhamaa wrote: Chris Angelico ros...@gmail.com: Once again, you appear to be surprised that invalid data is failing. Why is this so strange? U+DD00 is not a valid character. But it is a valid

Re: Newbie question about text encoding

2015-03-08 Thread Chris Angelico
On Mon, Mar 9, 2015 at 5:25 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Perhaps the bug is not UTF-8's inability to encode lone surrogates, but that Python allows you to create lone surrogates in the first place. That's not a rhetorical question. It's a genuine question. As

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
Rustom Mody wrote: On Saturday, March 7, 2015 at 4:39:48 PM UTC+5:30, Steven D'Aprano wrote: Rustom Mody wrote: This includes not just bug-prone-system code such as Java and Windows but seemingly working code such as python 3. What Unicode bugs do you think Python 3.3 and above have?

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
Marko Rauhamaa wrote: Chris Angelico ros...@gmail.com: Once again, you appear to be surprised that invalid data is failing. Why is this so strange? U+DD00 is not a valid character. But it is a valid non-character code point. It is quite correct to throw this error. '\udd00' is a

Re: Newbie question about text encoding

2015-03-08 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: '\udd00' is a valid str object: Is it though? Perhaps the bug is not UTF-8's inability to encode lone surrogates, but that Python allows you to create lone surrogates in the first place. That's not a rhetorical

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
Steven D'Aprano wrote: Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: That said, UTF-8 does suffer badly from its not being a bijective mapping. Can you explain? In Python terms, there are bytes objects b that don't satisfy:

Re: Newbie question about text encoding

2015-03-08 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: Once again, you appear to be surprised that invalid data is failing. Why is this so strange? U+DD00 is not a valid character. It is quite correct to throw this error. '\udd00' is a valid str object: '\udd00' '\udd00' '\udd00'.encode('utf-32')

Re: Newbie question about text encoding

2015-03-08 Thread Chris Angelico
On Sun, Mar 8, 2015 at 7:09 PM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: Once again, you appear to be surprised that invalid data is failing. Why is this so strange? U+DD00 is not a valid character. It is quite correct to throw this error. '\udd00' is a valid

Re: Newbie question about text encoding

2015-03-08 Thread Rustom Mody
On Monday, March 9, 2015 at 7:39:42 AM UTC+5:30, Cameron Simpson wrote: On 07Mar2015 22:09, Steven D'Aprano wrote: Rustom Mody wrote: [...big snip...] Some parts are here some earlier and from my memory. If details wrong please correct: - 200 million records - Containing 4 strings with

Re: Newbie question about text encoding

2015-03-08 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: '\udd00' should be a SyntaxError. I find your argument convincing, that attempting to construct a Unicode string of a lone surrogate should be an error. Shouldn't the error type be a ValueError, though? The statement is not, to my

Re: Newbie question about text encoding

2015-03-08 Thread Cameron Simpson
On 07Mar2015 22:09, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Rustom Mody wrote: [...big snip...] Some parts are here some earlier and from my memory. If details wrong please correct: - 200 million records - Containing 4 strings with SMP characters - System made with python

Re: Newbie question about text encoding

2015-03-08 Thread Chris Angelico
On Mon, Mar 9, 2015 at 1:09 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: '\udd00' should be a SyntaxError. I find your argument convincing, that attempting to construct a Unicode string of a lone surrogate should be an error.

Re: Newbie question about text encoding

2015-03-08 Thread random832
On Sun, Mar 8, 2015, at 22:09, Ben Finney wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: '\udd00' should be a SyntaxError. I find your argument convincing, that attempting to construct a Unicode string of a lone surrogate should be an error. Shouldn't the error

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: '\udd00' is a valid str object: Is it though? Perhaps the bug is not UTF-8's inability to encode lone surrogates, but that Python allows you to create lone surrogates in the first place.

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: For those cases where you do wish to take an arbitrary byte stream and round-trip it, Python now provides an error handler for that. py import random py b = bytes([random.randint(0, 255) for _ in range(1)]) py s = b.decode('utf-8')

Re: Newbie question about text encoding

2015-03-07 Thread Rustom Mody
On Saturday, March 7, 2015 at 4:39:48 PM UTC+5:30, Steven D'Aprano wrote: Rustom Mody wrote: This includes not just bug-prone-system code such as Java and Windows but seemingly working code such as python 3. What Unicode bugs do you think Python 3.3 and above have? Literal/Legalistic

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 6:20 PM, Marko Rauhamaa ma...@pacujo.net wrote: * it still isn't bijective between str and bytes: '\udd00'.encode('utf-8', errors='surrogateescape') Traceback (most recent call last): File stdin, line 1, in module UnicodeEncodeError: 'utf-8' codec can't

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: That said, UTF-8 does suffer badly from its not being a bijective mapping. Can you explain? In Python terms, there are bytes objects b that don't satisfy: b.decode('utf-8').encode('utf-8') == b Marko --

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 2:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: That said, UTF-8 does suffer badly from its not being a bijective mapping. Can you explain? In Python terms, there are bytes objects b that

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 3:25 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: On Sun, Mar 8, 2015 at 2:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: That said, UTF-8 does suffer badly from

Re: Newbie question about text encoding

2015-03-07 Thread Mark Lawrence
On 07/03/2015 16:25, Marko Rauhamaa wrote: Chris Angelico ros...@gmail.com: On Sun, Mar 8, 2015 at 2:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: That said, UTF-8 does suffer badly from its not being a bijective

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: On Sun, Mar 8, 2015 at 3:25 AM, Marko Rauhamaa ma...@pacujo.net wrote: Marko Rauhamaa wrote: That said, UTF-8 does suffer badly from its not being a bijective mapping. Here's an example: b = b'\x80' Yes, it generates an exception. IOW, UTF-8 is not a

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa ma...@pacujo.net wrote: There are two things happening here: 1) The underlying file system is not UTF-8, and you can't depend on that, Correct. Linux pathnames are octet strings regardless of the locale. That's why Linux developers should

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 5:34 AM, Dan Sommers d...@tombstonezero.net wrote: I think we're all agreeing: not all file systems are the same, and Python doesn't smooth out all of the bumps, even for something that seems as simple as displaying the names of files in a directory. And that's *after*

Re: Newbie question about text encoding

2015-03-07 Thread Mark Lawrence
On 07/03/2015 16:48, Marko Rauhamaa wrote: Mark Lawrence breamore...@yahoo.co.uk: On 07/03/2015 16:25, Marko Rauhamaa wrote: Here's an example: b = b'\x80' Yes, it generates an exception. IOW, UTF-8 is not a bijective mapping from str objects to bytes objects. Python 2 might, Python

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Dan Sommers d...@tombstonezero.net: I think we're all agreeing: not all file systems are the same, and Python doesn't smooth out all of the bumps, even for something that seems as simple as displaying the names of files in a directory. And that's *after* we've agreed that filesystems contain

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 3:40 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: Here's an example: b = b'\x80' Yes, it generates an exception. IOW, UTF-8 is not a bijective mapping from str objects to bytes objects. Python 2 might, Python 3 doesn't. He was talking about this line of

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Mark Lawrence breamore...@yahoo.co.uk: It would clearly help if you were to type in the correct UK English accent. Your ad-hominem-to-contribution ratio is alarmingly high. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 4:14 AM, Marko Rauhamaa ma...@pacujo.net wrote: See: $ mkdir /tmp/xyz $ touch /tmp/xyz/ \x80' $ python3 Python 3.3.2 (default, Dec 4 2014, 12:49:00) [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux Type help, copyright, credits or license for more

Re: Newbie question about text encoding

2015-03-07 Thread Mark Lawrence
On 07/03/2015 17:16, Marko Rauhamaa wrote: Mark Lawrence breamore...@yahoo.co.uk: It would clearly help if you were to type in the correct UK English accent. Your ad-hominem-to-contribution ratio is alarmingly high. Marko You've been a PITA ever since you first joined this list, what

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sun, 08 Mar 2015 05:13:09 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 5:02 AM, Dan Sommers d...@tombstonezero.net wrote: On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa ma...@pacujo.net wrote: Correct. Linux pathnames are

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 3:54 AM, Marko Rauhamaa ma...@pacujo.net wrote: You can't operate on file names and text files using Python strings. Or at least, you will need to add (nontrivial) exception catching logic. You can't operate on a JPG file using a Unicode string, nor an array of integers.

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: If you really REALLY can't use the bytes() type to work with something that is, yaknow, bytes, then you could use an alternative encoding that has a value for every byte. It's still not Unicode text, so it doesn't much matter which encoding you use. But it's

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa ma...@pacujo.net wrote: Correct. Linux pathnames are octet strings regardless of the locale. That's why Linux developers should refer to filenames using bytes. Unfortunately, Python

Re: Newbie question about text encoding

2015-03-07 Thread Mark Lawrence
On 07/03/2015 18:34, Dan Sommers wrote: On Sun, 08 Mar 2015 05:13:09 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 5:02 AM, Dan Sommers d...@tombstonezero.net wrote: On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Mark Lawrence breamore...@yahoo.co.uk: On 07/03/2015 16:25, Marko Rauhamaa wrote: Here's an example: b = b'\x80' Yes, it generates an exception. IOW, UTF-8 is not a bijective mapping from str objects to bytes objects. Python 2 might, Python 3 doesn't. Python 3.3.2 (default, Dec

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 3:54 AM, Marko Rauhamaa ma...@pacujo.net wrote: All you've proven is that there are bit patterns which are not UTF-8 streams... And that causes problems. Demonstrate. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-07 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: On Sun, Mar 8, 2015 at 4:14 AM, Marko Rauhamaa ma...@pacujo.net wrote: File names encoded with Latin-X are quite commonplace even in UTF-8 locales. That is not a problem with UTF-8, though. I don't understand how you're blaming UTF-8 for that. I'm saying it

Re: Newbie question about text encoding

2015-03-07 Thread Chris Angelico
On Sun, Mar 8, 2015 at 5:02 AM, Dan Sommers d...@tombstonezero.net wrote: On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa ma...@pacujo.net wrote: Correct. Linux pathnames are octet strings regardless of the locale. That's why Linux

Re: Newbie question about text encoding

2015-03-07 Thread Albert-Jan Roskam
--- Original Message - From: Chris Angelico ros...@gmail.com To: Cc: python-list@python.org python-list@python.org Sent: Saturday, March 7, 2015 6:26 PM Subject: Re: Newbie question about text encoding On Sun, Mar 8, 2015 at 4:14 AM, Marko Rauhamaa ma...@pacujo.net wrote: See

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sat, 07 Mar 2015 19:00:47 +, Mark Lawrence wrote: Isn't pathlib https://docs.python.org/3/library/pathlib.html#module-pathlib effectively a more recent attempt at smoothing or even removing (some of) the bumps? Has anybody here got experience of it as I've never used it? I almost

  1   2   3   4   5   6   7   8   9   10   >