Re: lxml namespace as an attribute

2018-08-15 Thread dieter
Skip Montanaro writes: > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces are defined at the top level, then > adding namespaces=root.nsmap works when calling the xpath method. I > more-or-less get that. > > What I don't understand is how I'm

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread Ben Finney
David Raymond writes: > So what are you saying is an option vs an argument? Because I see no > distinction whatsoever. The command-line conventions do recognise the distinction. * A command-line argument specifies input to the program. For example, the destination file for a ‘cp’ command is

Re: lxml namespace as an attribute

2018-08-15 Thread Skip Montanaro
> See https://lxml.de/tutorial.html#namespaces and > https://lxml.de/2.1/FAQ.html#how-can-i-specify-a-default-namespace-for-xpath-expressions > for direction. I had read at least the namespaces section of the tutorial. I could see the namespace definition right there in the XML and figured somehow

RE: lxml namespace as an attribute

2018-08-15 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of Skip Montanaro Sent: Wednesday, August 15, 2018 3:26 PM To: Python Subject: lxml namespace as an attribute > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces are defined at the top

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread Malcolm Greene
Thanks to everyone who contributed to this thread. Great feedback and suggestions! - Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 8:51 AM, Cameron Simpson wrote: > And as an additional alternative, when I want something weird (extra python > args or the like) I usually make my script.py into a module and invoke it > via a shell script, eg: > > #!/bin/sh > exec /particular/python python-opts... -m sc

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread Cameron Simpson
On 15Aug2018 20:54, eryk sun wrote: On Wed, Aug 15, 2018 at 9:22 AM, Thomas Jollans wrote: If you really want to, you can pass a *single* argument in your #! line, e.g.: #!/usr/bin/python3 -Wd This works for options that can be grouped into a single argument. Multiple -X options aren't supp

Re: how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread Paint-It-Black via Python-list
> ChrisA Yes, that works. Thank you all for your help. --> class A: def __init__(self): self.number = 1 def A_biginc(self): self.number += 107 A.biginc = A_biginc class B(A): def __init__(self): super().__init__() print("making a B") def B_biginc(self): super(B,self).bi

Re: lxml namespace as an attribute

2018-08-15 Thread Skip Montanaro
Ack. Of course I meant the subject to be "XML namespace as an attribute". I happen to be using lxml.etree. (Long day, I guess...) S On Wed, Aug 15, 2018 at 4:25 PM Skip Montanaro wrote: > > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces ar

lxml namespace as an attribute

2018-08-15 Thread Skip Montanaro
Much of XML makes no sense to me. Namespaces are one thing. If I'm parsing a document where namespaces are defined at the top level, then adding namespaces=root.nsmap works when calling the xpath method. I more-or-less get that. What I don't understand is how I'm supposed to search for a tag when

Re: how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 6:00 AM, thomas.lynch--- via Python-list wrote: > Appreciate some help in how in Python a person can add some external methods > to existing classes in the presence of simple one level inheritance. Here is > an example stripped down to the shiny brass tacks: > > class A:

Re: how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread Calvin Spealman
You really can't, and shouldn't. The super() helper relies on information that exists inside the class definition and which is not available simply at runtime by virtue of being attached to the class. Besides, modifying classes externally is generally considered a bad idea. Maybe you could accompl

Re: how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread Paint-It-Black via Python-list
> # this prints for me when I run this in 3.6 excuse me, that is an extraneous comment from a cut and paste, in fact the example never makes it to the prints, as shown in the transcript just below the source code -- https://mail.python.org/mailman/listinfo/python-list

how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread thomas.lynch--- via Python-list
Appreciate some help in how in Python a person can add some external methods to existing classes in the presence of simple one level inheritance. Here is an example stripped down to the shiny brass tacks: class A: def __init__(self): self.number = 1 def A_biginc(self): self.number += 1

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread eryk sun
On Wed, Aug 15, 2018 at 9:22 AM, Thomas Jollans wrote: > > If you really want to, you can pass a *single* argument in your #! line, > e.g.: > > #!/usr/bin/python3 -Wd This works for options that can be grouped into a single argument. Multiple -X options aren't supported, nor is combining a -X opt

Re: Program to output a subset of the composite numbers

2018-08-15 Thread Peter Otten
tomusa...@gmail.com wrote: > Thank you very much! Do you also know how I might slightly alter to > composite numbers that are one less than twice a composite number? > > 15 would be the first number > Since 8 is composite then > > 2*8=16 > 16 - 1=15 Is composite Like >>> def is_composite(n): .

Re: Program to output a subset of the composite numbers

2018-08-15 Thread tomusatov
Thank you very much! Do you also know how I might slightly alter to composite numbers that are one less than twice a composite number? 15 would be the first number Since 8 is composite then 2*8=16 16 - 1=15 Is composite -- https://mail.python.org/mailman/listinfo/python-list

RE: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread David Raymond
So what are you saying is an option vs an argument? Because I see no distinction whatsoever. When you run something you give it a bunch of strings. That's it. There is nothing magical about putting a dash in front of a letter, nothing magical about putting in a string that might possibly also b

Re: Program to output a subset of the composite numbers

2018-08-15 Thread Peter Otten
Steven D'Aprano wrote: > On Wed, 15 Aug 2018 05:34:06 -0700, tomusatov wrote: > >> I am not terribly familiar with Python, but am currently authoring an >> integer sequence for www.oeis.org and was wondering if anyone in the >> community could help me with authoring a Python program that outputs,

Re: Program to output a subset of the composite numbers

2018-08-15 Thread Steven D'Aprano
On Wed, 15 Aug 2018 05:34:06 -0700, tomusatov wrote: > I am not terribly familiar with Python, but am currently authoring an > integer sequence for www.oeis.org and was wondering if anyone in the > community could help me with authoring a Python program that outputs, > "Composite numbers that are

Re: Program to output a subset of the composite numbers

2018-08-15 Thread Joel Goldstick
On Wed, Aug 15, 2018 at 8:36 AM wrote: > > I am not terribly familiar with Python, but am currently authoring an integer > sequence for www.oeis.org and was wondering if anyone in the community could > help me with authoring a Python program that outputs, "Composite numbers that > are one less

Program to output a subset of the composite numbers

2018-08-15 Thread tomusatov
I am not terribly familiar with Python, but am currently authoring an integer sequence for www.oeis.org and was wondering if anyone in the community could help me with authoring a Python program that outputs, "Composite numbers that are one less than a composite number." Thanks! Musatov -- htt

Re: Pylint false positives

2018-08-15 Thread Jon Ribbens
On 2018-08-15, Steven D'Aprano wrote: > On Tue, 14 Aug 2018 15:18:13 +, Jon Ribbens wrote: >> On 2018-08-14, Steven D'Aprano >> wrote: >>> # === process abstract methods en masse === >>> for name in "method_a method_b method_c method_d".split(): >>> @abstractmethod >>>

Re: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread Thomas Jollans
On 14/08/18 23:45, Malcolm Greene wrote: > When you run a script via "python3 script.py" you can include command > line options like -b, -B, -O, -OO, etc between the "python3" interpreter > reference and the script.py file, eg. "python3 -b -B -O -OO script.py". > When you create a script that is ex

Re: Pylint false positives

2018-08-15 Thread Steven D'Aprano
On Tue, 14 Aug 2018 15:18:13 +, Jon Ribbens wrote: > On 2018-08-14, Steven D'Aprano > wrote: >> If there really are a lot of such missing methods, I'd consider writing >> something like this: >> >> class A: >> def __init__(self, ...): >> ... >> >> # === process abstract method

Re: right way to use zipimport, zipimport.ZipImportError: not a Zip file

2018-08-15 Thread iMath
Not works on Windows >>> import sys >>> sys.path.insert(0, >>> 'C:/Users/i/Downloads/you-get-0.4.1128.zip/you-get-0.4.1128/src') >>> from you_get import common