Re: xml.etree and namespaces -- why?

2022-10-19 Thread Robert Latest via Python-list
ieces of XML should be understood > identically: > > http://www.inkscape.org/namespaces/inkscape";> > > > and: > > http://www.inkscape.org/namespaces/inkscape";> > > > So you can see why e.get('inkscape:label') cannot p

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Axy via Python-list
I have no idea why, I used to remove namespaces, following the advice from stackoverflow: https://stackoverflow.com/questions/4255277/lxml-etree-xmlparser-remove-unwanted-namespace _ns_removal_xslt_transform = etree.XSLT(etree.fromstring('''     xmlns:xsl="http://www.w3.or

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Jon Ribbens via Python-list
On 2022-10-19, Robert Latest wrote: > If the XML input has namespaces, tags and attributes with prefixes > in the form prefix:sometag get expanded to {uri}sometag where the > prefix is replaced by the full URI. > > Which means that given an Element e, I cannot dire

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Axy via Python-list
fully self-contained Python example that illustrates my problem. I'm struggling to understand xml.etree's handling of namespaces. I'm trying to parse an Inkscape document which uses several namespaces. From etree's documentation: If the XML input has namespaces, tags and at

xml.etree and namespaces -- why?

2022-10-19 Thread Robert Latest via Python-list
Hi all, For the impatient: Below the longish text is a fully self-contained Python example that illustrates my problem. I'm struggling to understand xml.etree's handling of namespaces. I'm trying to parse an Inkscape document which uses several namespaces. From etree's docume

Re: Friday Finking: Imports, Namespaces, Poisoning, Readability

2020-06-05 Thread Rhodri James
AFAIKT the "three" are readability, naming conflicts and source location. On 05/06/2020 01:15, DL Neil via Python-list wrote: - how do you like to balance these three (and any other criteria)? Readability is king. Or queen, if you prefer. Anything that damages readability drops dramatically

Re: Friday Finking: Imports, Namespaces, Poisoning, Readability

2020-06-04 Thread Tim Chase
On 2020-06-05 12:15, DL Neil via Python-list wrote: > Finking/discussion: > > - how do you like to balance these three (and any other criteria)? For most of what I do, I only ever have one such module so I'm not trying keep multiple short-names in my head concurrently. For me, it's usually tkint

Friday Finking: Imports, Namespaces, Poisoning, Readability

2020-06-04 Thread DL Neil via Python-list
How do you prefer to balance all of the above when import-ing? Python offers a number of options for importing modules, eg import module, ... from importable import object, ... most of which can be augmented with the "as preferred_name" syntax. (ignoring the much-reviled "*" (import ev

Re: Namespaces: memory vs 'pollution'

2019-07-23 Thread Ethan Furman
On 07/22/2019 08:12 PM, DL Neil wrote: On 22/07/19 9:40 PM, Thomas Jollans wrote: Just FYI, in the scientific Python community certain short abbreviations are the norm. Many modules have a ‘standard’ abbreviation that most people use, minimizing confusion. import numpy as np import matplotlib

Re: Namespaces: memory vs 'pollution'

2019-07-23 Thread Ethan Furman
On 07/22/2019 07:27 PM, DL Neil wrote: NameError conveys nothing to the user. PythonVersionError is more communicative - and speaks volumes to 'us'. The mainline code is something like: p = PythonEnvironment() try:     p.compatibility( ...spec... )    # eg must be Py3 not 2.n  

Re: Namespaces: memory vs 'pollution'

2019-07-23 Thread Thomas Jollans
On 23/07/2019 04.27, DL Neil wrote: > On 23/07/19 11:00 AM, Ethan Furman wrote: >> On 07/20/2019 05:02 PM, DL Neil wrote: >> >>> Upon closer inspection, I realised it didn't just fail; it failed >>> badly! Some silly, little, boy had imported the PythonEnvironment >>> class but failed to ALSO impor

Re: Namespaces: memory vs 'pollution'

2019-07-23 Thread Rhodri James
On 23/07/2019 03:27, DL Neil wrote: On 23/07/19 11:00 AM, Ethan Furman wrote: On 07/20/2019 05:02 PM, DL Neil wrote: Upon closer inspection, I realised it didn't just fail; it failed badly! Some silly, little, boy had imported the PythonEnvironment class but failed to ALSO import PythonVersio

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread DL Neil
On 22/07/19 9:40 PM, Thomas Jollans wrote: On 22/07/2019 07.06, DL Neil wrote: Current thoughts: import environment_module as em - so, even more of an abbreviation than suggested!? - I rarely need to write a long list of import statements, so there won't be many. - not normally using suc

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread DL Neil
On 23/07/19 11:00 AM, Ethan Furman wrote: On 07/20/2019 05:02 PM, DL Neil wrote: Upon closer inspection, I realised it didn't just fail; it failed badly! Some silly, little, boy had imported the PythonEnvironment class but failed to ALSO import PythonVersionError. So, the reported error was n

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread Thomas Jollans
On 22/07/2019 07.06, DL Neil wrote: > > Current thoughts: > > import environment_module as em > > - so, even more of an abbreviation than suggested!? > - I rarely need to write a long list of import statements, so there > won't be many. > - not normally using such abbreviations in my code, they

Re: Namespaces: memory vs 'pollution'

2019-07-22 Thread Ethan Furman
On 07/20/2019 05:02 PM, DL Neil wrote: Upon closer inspection, I realised it didn't just fail; it failed badly! Some silly, little, boy had imported the PythonEnvironment class but failed to ALSO import PythonVersionError. So, the reported error was not the expected exception! I don't under

Re: Namespaces: memory vs 'pollution'

2019-07-21 Thread DL Neil
On 22/07/19 5:30 AM, Roel Schroeven wrote: DL Neil schreef op 21/07/2019 om 2:02: How do you remember to from-import- 'everything' that is needed? ... > Upon closer inspection, I realised it didn't just fail; it failed badly! Some silly, little, boy had imported the PythonEnvironment class but

Re: Namespaces: memory vs 'pollution'

2019-07-21 Thread Roel Schroeven
DL Neil schreef op 21/07/2019 om 2:02: How do you remember to from-import- 'everything' that is needed? ... > Upon closer inspection, I realised it didn't just fail; it failed badly! Some silly, little, boy had imported the PythonEnvironment class but failed to ALSO import PythonVersionError. So,

Re: Namespaces: memory vs 'pollution'

2019-07-21 Thread Peter J. Holzer
On 2019-07-21 12:02:27 +1200, DL Neil wrote: > What do you do to (respecting purism) ensure 'everything' (necessary) is > imported (and nothing more), preferably without relying upon (faulty, in my > case) human-memory or reading through volumes of code/documentation? I write tests (not as consist

Namespaces: memory vs 'pollution'

2019-07-20 Thread DL Neil
How do you remember to from-import- 'everything' that is needed? I have a 'utility module' which contains a bunch of classes which examine/check/log aspects of the execution environment. One of which is PythonEnvironment, another relates to the HostSystem (as examples). They are most-frequent

Re: How do native namespaces work?

2017-10-05 Thread Peter Otten
Thomas Nyberg wrote: > Hello, > > I'm trying to understand native namespaces. I'm currently using python > 3.5 as packaged in debian 9. I've been following the instructions here: > > https://packaging.python.org/guides/packaging-namespace-packages/#nat

Re: How do native namespaces work?

2017-10-05 Thread Thomas Nyberg
On 10/05/2017 04:07 PM, Peter Otten wrote: > Are you sure you are using the correct interpreter? When I activate a > virtual environment it changes the prompt like so: Sorry I just cut out the extra cruft from my prompt for clarity. (In hindsight, I should probably have left the `(venv)` prompt i

Re: How do native namespaces work?

2017-10-05 Thread Peter Otten
Thomas Nyberg wrote: > Hello, > > I'm trying to understand native namespaces. I'm currently using python > 3.5 as packaged in debian 9. I've been following the instructions here: > > https://packaging.python.org/guides/packaging-namespace-packages/#nat

How do native namespaces work?

2017-10-05 Thread Thomas Nyberg
Hello, I'm trying to understand native namespaces. I'm currently using python 3.5 as packaged in debian 9. I've been following the instructions here: https://packaging.python.org/guides/packaging-namespace-packages/#native-namespace-packages Those instructions link t

Re: Namespaces are one honking great idea

2016-07-09 Thread carlosjosepita
Hi all, although it doesn't fit the bill 100%, I sometimes use this extremely simple function as a decorator: def new(call): return call() For example: @new class MySingleton: x = 2 y = 2 def sum(self, x, y): return x + y @new def my_obj(): x = 2 y = 2 de

A nestedmodule decorator (Re: Namespaces are one honking great idea)

2016-07-05 Thread Gregory Ewing
Steven D'Aprano wrote: There's only so far I can go without support from the compiler. It turns out one can go surprisingly far. Here's something I cooked up that seems to meet almost all the requirements. The only shortcoming I can think of is that a nestedmodule inside another nestedmodule wo

Re: Namespaces are one honking great idea

2016-07-04 Thread Steven D'Aprano
to a new > file if you want to break it out" equivalency, but it does make sense > - it's a *nested* namespace, which modules (even in a package) are > not. So you have the outer namespace acting pretty much the way > builtins do. (Do nested namespaces work?) I haven't g

Re: Namespaces are one honking great idea

2016-07-04 Thread Chris Angelico
n in a package) are not. So you have the outer namespace acting pretty much the way builtins do. (Do nested namespaces work?) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Namespaces are one honking great idea

2016-07-04 Thread Steven D'Aprano
On Tue, 5 Jul 2016 12:58 pm, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 12:34 PM, Steven D'Aprano > wrote: >> *** IF *** you are willing to push the code out into its own separate .py >> file, you can use a module and write your code in a more natural form: >> >> >> # module example.py >> var

Re: Namespaces are one honking great idea

2016-07-04 Thread Chris Angelico
On Tue, Jul 5, 2016 at 12:34 PM, Steven D'Aprano wrote: > *** IF *** you are willing to push the code out into its own separate .py > file, you can use a module and write your code in a more natural form: > > > # module example.py > var = 999 > > def spam(arg): > return eggs(arg) + var > > def

Re: Namespaces are one honking great idea

2016-07-04 Thread Steven D'Aprano
pport inheritance. Classes should be used for >> "is-a" relationships, not "has-a" relationships. Although classes (and >> instances) are namespaces, they provide fundamentally different kind of >> behaviour than modules and packages. > > A namespace wo

Re: Namespaces are one honking great idea

2016-07-04 Thread Lawrence D’Oliveiro
On Tuesday, July 5, 2016 at 10:10:04 AM UTC+12, I wrote: > > On Monday, July 4, 2016 at 11:37:44 PM UTC+12, Chris Angelico wrote: > > > Functions within the namespace can't call other functions within the > > same namespace using unqualified names. This was a stated requirement. > > Doesn’t my @n

Re: Namespaces are one honking great idea

2016-07-04 Thread Lawrence D’Oliveiro
On Monday, July 4, 2016 at 11:37:44 PM UTC+12, Chris Angelico wrote: > Functions within the namespace can't call other functions within the > same namespace using unqualified names. This was a stated requirement. Doesn’t my @namespace decorator provide that? -- https://mail.python.org/mailman/li

Re: Namespaces are one honking great idea

2016-07-04 Thread jmp
lated entities. Classes support inheritance. Classes should be used for "is-a" relationships, not "has-a" relationships. Although classes (and instances) are namespaces, they provide fundamentally different kind of behaviour than modules and packages. A namespace would not hurt but I

Re: Namespaces are one honking great idea

2016-07-04 Thread Chris Angelico
ies. Classes support inheritance. Classes should be used for "is-a" >> relationships, not "has-a" relationships. Although classes (and instances) >> are namespaces, they provide fundamentally different kind of behaviour >> than >> modules and packages. &g

Re: Namespaces are one honking great idea

2016-07-04 Thread jmp
ips, not "has-a" relationships. Although classes (and instances) are namespaces, they provide fundamentally different kind of behaviour than modules and packages. A namespace would not hurt but I really don't get why you don't consider classes a valid and rather helpful namesp

Re: Namespaces are one honking great idea

2016-07-03 Thread Ethan Furman
On 07/03/2016 03:02 PM, Kevin Conway wrote: >At some point earlier Ethan Furman declared: It's not a language change. Perhaps. My argument is that anything that introduces a new class-like construct and set of lexical scoping rules is a language change. For example, if this change went into 2.

Re: Namespaces are one honking great idea

2016-07-03 Thread BartC
On 04/07/2016 00:21, Lawrence D’Oliveiro wrote: On Monday, July 4, 2016 at 10:02:59 AM UTC+12, Kevin Conway wrote: If the problem with using classes to satisfy the namespace need is that it's unwieldy to use dot qualified paths then isn't that quite similar to saying namespaces ar

Re: Namespaces are one honking great idea

2016-07-03 Thread Lawrence D’Oliveiro
On Monday, July 4, 2016 at 10:02:59 AM UTC+12, Kevin Conway wrote: > If the problem with using classes to satisfy the namespace need is > that it's unwieldy to use dot qualified paths then isn't that quite similar > to saying namespaces are unwieldy? Python has a simple solut

Re: Namespaces are one honking great idea

2016-07-03 Thread Kevin Conway
r to each > other by their dotted names. My response to this may come off as a bit glib, but it isn't intended that way. If the problem with using classes to satisfy the namespace need is that it's unwieldy to use dot qualified paths then isn't that quite similar to saying name

Re: Namespaces are one honking great idea

2016-07-02 Thread Ethan Furman
On 07/02/2016 08:44 PM, Steven D'Aprano wrote: Try getting this behaviour from within a class: class Food(metaclass=Namespace): # (1) no special decorators required def spam(n): return ' '.join(['spam']*n) # (2) can call functions from inside the namespace breakf

Re: Namespaces are one honking great idea

2016-07-02 Thread Steven D'Aprano
On Sun, 3 Jul 2016 01:34 am, Kevin Conway wrote: > staticmethod isn't technically required to use a method through the class > (or subclasses), it simply provides the appropriate magic to allow it to > be called through instances. > > For example, the following code covers all described use cases

Re: Namespaces are one honking great idea

2016-07-02 Thread Steven D'Aprano
attern. In other words, exactly not like a class *wink* Classes and modules are both namespaces: "an abstract container or environment created to hold a logical grouping of unique identifiers or symbols (i.e. names)", to quote Wikipedia: https://en.wikipedia.org/wiki/Namespa

Re: Namespaces are one honking great idea

2016-07-02 Thread Ethan Furman
On 07/02/2016 08:34 AM, Kevin Conway wrote: For the proponents of namespace, what is deficient in the above example that necessitates a language change? Adding a new widget is not changing the language. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Namespaces are one honking great idea

2016-07-02 Thread Kevin Conway
> staticmethod isn't technically required to use a method through the class (or subclasses), it simply provides the appropriate magic to allow it to be called through instances. For example, the following code covers all described use cases of the proposed namespace. Methods are invoked without cr

Re: Namespaces are one honking great idea

2016-07-01 Thread Random832
On Fri, Jul 1, 2016, at 21:50, Kevin Conway wrote: > I believe the namespace object you are referring to is exactly a > class. IIRC, classes came about as a "module in a module". No, because classes have instances. And conceptually they seem like they *should* have instances. Just using the term "

Re: Namespaces are one honking great idea

2016-07-01 Thread Lawrence D’Oliveiro
On Saturday, July 2, 2016 at 1:50:56 PM UTC+12, Kevin Conway wrote: > Regardless, all use cases you've listed are already satisfied by use of the > static and class method decorators. Except for the need to decorate every such function inside the class. How about: import types def namesp

Re: Namespaces are one honking great idea

2016-07-01 Thread Rustom Mody
On Friday, July 1, 2016 at 8:19:36 PM UTC+5:30, BartC wrote: > On 01/07/2016 15:13, Steven D'Aprano wrote: > > > Sometimes we have a group of related functions and variables that belong > > together, but are not sufficiently unrelated to the rest of the module that > > we want to split them out in

Re: Namespaces are one honking great idea

2016-07-01 Thread Kevin Conway
I believe the namespace object you are referring to is exactly a class. IIRC, classes came about as a "module in a module". Regardless, all use cases you've listed are already satisfied by use of the static and class method decorators. Methods decorated with these do not require an instance initia

Re: Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
On Sat, 2 Jul 2016 05:29 am, Ethan Furman wrote: > On 07/01/2016 10:10 AM, Steven D'Aprano wrote: >> On Sat, 2 Jul 2016 02:00 am, Ethan Furman wrote: > >>> Did you mean for this to go to -Ideas? >> >> Not yet. I wanted some initial feedback to see if anyone else liked the >> idea before taking it

Re: Namespaces are one honking great idea

2016-07-01 Thread Ethan Furman
On 07/01/2016 10:10 AM, Steven D'Aprano wrote: On Sat, 2 Jul 2016 02:00 am, Ethan Furman wrote: Did you mean for this to go to -Ideas? Not yet. I wanted some initial feedback to see if anyone else liked the idea before taking it to Bikeshedding Central :-) Besides, I expect Python-Ideas wil

Re: Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
ype` then returns the new class K. But if you use a metaclass (usually, but not necessarily a subclass of `type`) you can customize the creation of the new class, or even return a completely different object altogether. That's what I'm doing. Why am I returning a module instead of a c

Re: Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
ion of Python's lack of dedicated >> syntax for namespaces), the Example namespace behaves like (in fact, >> *is*) a module embedded inside a module. > > So the idea is to have several "mini-modules" inside a single file? That would certainly be possible. > Can a

Re: Namespaces are one honking great idea

2016-07-01 Thread Chris Angelico
On Sat, Jul 2, 2016 at 12:49 AM, BartC wrote: > Why not just extend the capabilities of a class? I actually thought this > would work until I tried it and it didn't: > > class C(): > def fn(): > print ("Hi!") > > C.fn() > > The error message suggests Python knows what's going on. So wh

Re: Namespaces are one honking great idea

2016-07-01 Thread Ethan Furman
On 07/01/2016 07:13 AM, Steven D'Aprano wrote: I like the idea, but I have a couple questions about the design choices. Comments below. The Zen of Python says: Namespaces are one honking great idea -- let's do more of those! Proposal = Add a new "names

Re: Namespaces are one honking great idea

2016-07-01 Thread BartC
On 01/07/2016 15:13, Steven D'Aprano wrote: Sometimes we have a group of related functions and variables that belong together, but are not sufficiently unrelated to the rest of the module that we want to split them out into another file. Here's a proof of concept. I use a class with a custom

Re: Namespaces are one honking great idea

2016-07-01 Thread Random832
[] > def test(n): ... > > although others might argue that *not* needing a dedicated keyword is, in > fact, better. What might be nice would be a single syntax that isn't specific to classes or your "namespaces". namespace(type) Name: "equivalent to class Name:&q

Namespaces are one honking great idea

2016-07-01 Thread Steven D'Aprano
The Zen of Python says: Namespaces are one honking great idea -- let's do more of those! Proposal = Add a new "namespace" object to Python. Rationale == Sometimes we have a group of related functions and variables that belong together, but are not suffici

Re: lxml and namespaces

2014-07-29 Thread Irmen de Jong
On 29-7-2014 20:35, Marc Aymerich wrote: > Got it! > xml = lxml.builder.ElementMaker( > nsmap = { > None: "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02", > 'xsi': "http://www.w3.org/2001/XMLSchema-instance";, > } > ) > doc = xml.Document() Thanks for taking the tim

Re: lxml and namespaces

2014-07-29 Thread Marc Aymerich
On Tue, Jul 29, 2014 at 8:19 PM, Marc Aymerich wrote: > Hi, I'm desperately trying to construct an XML with the following document > declaration: > > xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”> > > I'm using LXML, and what I'm doing is this > > >>> from lxml import etree > >>>

lxml and namespaces

2014-07-29 Thread Marc Aymerich
Hi, I'm desperately trying to construct an XML with the following document declaration: http://www.w3.org/2001/XMLSchema-instance”> I'm using LXML, and what I'm doing is this >>> from lxml import etree >>> from lxml.builder import E >>> doc = E.Document( ... { ... 'xmlns': "urn:iso:s

Re: Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-27 Thread alex23
On 27 Dec, 22:58, Chris Angelico wrote: > Rick, ever heard of the ELIZA Effect? Can we _please_ stop feeding this troll? -- http://mail.python.org/mailman/listinfo/python-list

Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-27 Thread Chris Angelico
On Thu, Dec 27, 2012 at 5:50 PM, Ranting Rick wrote: > Every keyword, syntactical structure, style, etc, etc, should be based > on logical foundations; not adolescent fads or propagating more > idiotic cultural traditions. You piss and moan about language X and > how asinine the language is, them

Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Ranting Rick
On Dec 26, 11:02 pm, Steven D'Aprano wrote: > On Wed, 26 Dec 2012 20:07:53 -0800, Rick Johnson wrote: > > My specific point is that the English word "variable" is unambiguous > > I'm sorry, do you mean "variable" the noun, or "variable" the adjective? > [snip: sliding down the rabbit hole of a pol

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Steven D'Aprano
On Wed, 26 Dec 2012 20:07:53 -0800, Rick Johnson wrote: > My specific point is that the English word "variable" is unambiguous I'm sorry, do you mean "variable" the noun, or "variable" the adjective? If you mean the adjective, do you mean something which naturally changes, in the sense that the

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Rick Johnson
On Wednesday, December 26, 2012 2:29:13 AM UTC-6, Steven D'Aprano wrote: > [snip] I won't reply to your last post on a line-by-line basis because i feel we are straying from my general point: which is that we should NEVER re-interpret existing words (in an illogical manner) whilst transforming t

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Michael Torrie
On 12/25/2012 04:42 PM, Rick Johnson wrote: > With that accurate definition in mind you can now understand how > Python classes CAN and DO have variables, just as Python modules have > variables; psst: they're called "global variables"! Nice ascii graphic, but citation needed. What CS text book a

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Michael Torrie
On 12/25/2012 04:42 PM, Rick Johnson wrote: > What IS a variable Dennis? > # > > #Variable (ComputerScience)# > Found the reference you are quot

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Steven D'Aprano
On Tue, 25 Dec 2012 16:19:21 -0800, Rick Johnson wrote: > On Tuesday, December 25, 2012 4:56:44 PM UTC-6, Steven D'Aprano wrote: > >> Rick, what makes you think that this is logically inconsistent? >> "Method" is the accepted name for functions attached to classes. They >> report themselves as "m

Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread alex23
On 26 Dec, 09:42, Rick Johnson wrote: > Python classes CAN and DO have variables, just as Python modules > have variables; psst: they're called "global variables"! Actually, they're called "module attributes", but don't let the facts get in the way of your little rant. You never have before. --

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Rick Johnson
On Tuesday, December 25, 2012 4:56:44 PM UTC-6, Steven D'Aprano wrote: > Rick, what makes you think that this is logically inconsistent? > "Method" is the accepted name for functions attached to classes. They > report themselves as "methods": > [...] > There are two built-ins for creating differen

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Rick Johnson
interpret these terms in their current context. For instance, Python has no REAL "global variables", so we can happily refer to module level variables as global variables. However in many other languages (like Ruby for instance) we can declare REAL "global variables" that ar

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Steven D'Aprano
On Tue, 25 Dec 2012 12:16:16 -0800, Rick Johnson wrote: > On Tuesday, December 25, 2012 11:10:49 AM UTC-6, Dave Angel wrote: > >> We all make mistakes, like my referring to class methods when I meant >> instance methods. > > This mistake reminded of how people in this group (maybe not you in > p

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Rick Johnson
On Tuesday, December 25, 2012 11:10:49 AM UTC-6, Dave Angel wrote: > We all make mistakes, like my referring to class methods when I > meant instance methods. This mistake reminded of how people in this group (maybe not you in particular) happily accept the terms "instance method" and "class me

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread prilisauer
By the way i haven't add the Title because it's a german only book named "Python 3: Das umfangreiche Handbuch, Published by Galileo Computing" and also, because I've registered to first check if the Autor has allready published a update. Too many information's could ocurre in an avalanche I se

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Dave Angel
On 12/25/2012 09:41 AM, prilisa...@googlemail.com wrote: > Hello Steven, > > to "learn python" I've bought a book, and it's not a "thin" one :-) it's more > a 788p. long documentation about python. > > BUT! I have to say: The autor started using the "self." argument at the > chapter classes.

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread prilisauer
Hello Steven, to "learn python" I've bought a book, and it's not a "thin" one :-) it's more a 788p. long documentation about python. BUT! I have to say: The autor started using the "self." argument at the chapter classes. So You've shown me the book descr. non "correct" way. Better using t

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Steven D'Aprano
On Mon, 24 Dec 2012 00:19:18 -0500, Dave Angel wrote: > Nobody's going to be able to understand your code if you persist in > using self in unpythonic ways. It's used as the first argument of a > class method. Period. To be pedantic, "self" is the conventional argument for *instance* methods, n

Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread prilisauer
Hey :-P I think I should rename the threads name into a new "Doc" project, I'm sure It won't take much time to fill a book with our knowledge. Thanks to Rick, you have Posted exactly what I wanted to ask. I know the that __variable = 'xyz' _variable = 'xyz' are used to make them private, but I

Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Ranting Rick
On Dec 24, 9:48 am, Dave Angel wrote: > Pep8 recommends a particular style within a function name, separating > 'words of a name by underscore.  I happen to loathe that style, so I'm > clearly not the one who would critique someone for not following the > guideline.  I say getFile(), the pep says

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Dave Angel
(Part 3 of my dissertation; I hope it's useful for you in particular) Up to now in my discussion, it wasn't usually important to know that everything is a class. You just know that everything has attributes, and that you use the dot notation to get at an attribute. So what if "%x".format() is

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Dave Angel
Python is a flexible language, but manages to let one write readable code even while using that flexibility. It does, however, require that one gets a grasp of some concepts that may differ greatly, either in implementation or in name, from other languages. Every language has its quirks and const

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Dave Angel
On 12/24/2012 03:23 AM, prilisa...@googlemail.com wrote: > Hello Dave, > > Thank you, for your help, I'll try my best. > > To all others, PLEASE be pleasant with my nescience, I'll tried to describe > not a specific error at my Program. I'll tried to get rid of that missing > link this sample is

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Alexander Blinne
At this point I think i could just refer to my other 2 postings and urge you to read them again. They offer the idea of encapsulating the function QuerySqlite into a method of an object that can be passed over to some object (possibly throu the __init__-method) and store it in an attribute of that

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Cameron Simpson
On 24Dec2012 00:23, prilisa...@googlemail.com wrote: | To all others, PLEASE be pleasant with my nescience, I'll tried to | describe not a specific error at my Program. If you don't describe specific errors, you won't get specific advice. If you're after stylistic and technique advice, please of

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread prilisauer
Hello Dave, Thank you, for your help, I'll try my best. To all others, PLEASE be pleasant with my nescience, I'll tried to describe not a specific error at my Program. I'll tried to get rid of that missing link this sample is only theoretic, but the code really exists and is over 1000 lines lo

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Dave Angel
On 12/23/2012 04:42 PM, prilisa...@googlemail.com wrote: > Okay, I try to publish this sample, and yes it's not a working piece of code, > but I try to "draw" my problem that way. As you will see, I load modules, > create cursor,... in the main.py. In the lower section you see, that the > module

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Thomas Bach
Hi there, On Sun, Dec 23, 2012 at 01:42:14PM -0800, prilisa...@googlemail.com wrote: > […] In the lower section you see, that the modules should execute > sqls. In case It could occur that two queries occur at the same > time. PS: IT IS NOT A QUESTION ABOUT SQL, etc. I do not understand, > how I

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Terry Reedy
On 12/23/2012 4:32 AM, prilisa...@googlemail.com wrote: By the way, I think I have found the correct "wording". for my understood, the "handover" of objects to imported modules doesn't work because, e.g. trying to hand-over an SQLite connection into a imported module, can't work because the "attr

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Rhodri James
On Sun, 23 Dec 2012 21:42:14 -, wrote: Okay, I try to publish this sample, and yes it's not a working piece of code, but I try to "draw" my problem that way. So instead of telling us what your problem is, you're going to give us an artist's impression of your code and leave us to guess

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
Okay, I try to publish this sample, and yes it's not a working piece of code, but I try to "draw" my problem that way. As you will see, I load modules, create cursor,... in the main.py. In the lower section you see, that the modules should execute sqls. In case It could occur that two queries oc

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Roy Smith
In article , prilisa...@googlemail.com wrote: > Thanks to all your answers, I have read a lot about namespaces, but still > there's something I do not understood. I have tried your example but as I > expected: > > line 13, in HandoverSQLCursor > curs.execu

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Peter Otten
prilisa...@googlemail.com wrote: > Thanks to all your answers, I have read a lot about namespaces, but still > there's something I do not understood. I have tried your example but as I > expected: > > line 13, in HandoverSQLCursor > curs.execute("SELECT * F

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
Thanks to all your answers, I have read a lot about namespaces, but still there's something I do not understood. I have tried your example but as I expected: line 13, in HandoverSQLCursor curs.execute("SELECT * FROM lager") AttributeError: 'builtin_function_or_m

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Cameron Simpson
On 22Dec2012 12:43, prilisa...@googlemail.com wrote: | I Think I describe my Situation wrong, the written Project is a | Server, that should store sensor data, perfoms makros on lamps according | a sequence stored in the DB and Rule systems schould regulate home devices and plan scheduler jobs so

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
secondly, it is absolutely not bad meaned, but, why does people post, their personal meaning, but nothing about the "Posters" Problem? Everybody is free to read or not, but correcting the WWW could became a very very big task, (maybe it's easier to climb the 7 summits) Best Regards. -- http://

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
By the way, I think I have found the correct "wording". for my understood, the "handover" of objects to imported modules doesn't work because, e.g. trying to hand-over an SQLite connection into a imported module, can't work because the "attributes" are not transfered. I'm sorry for my bad engli

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Dave Angel
On 12/22/2012 03:43 PM, prilisa...@googlemail.com wrote: > > I Think I describe my Situation wrong, the written Project is a > Server, that should store sensor data, perfoms makros on lamps > according a sequence stored in the DB and Rule systems schould > regulate home devices and plan scheduler

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Alexander Blinne
Am 22.12.2012 21:43, schrieb prilisa...@googlemail.com: > I Think I describe my Situation wrong, the written Project is a > Server, that should store sensor data, perfoms makros on lamps according > a sequence stored in the DB and Rule systems schould regulate home devices > and plan scheduler job

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Terry Reedy
On 12/22/2012 7:45 AM, prilisa...@googlemail.com wrote: Am Samstag, 22. Dezember 2012 13:38:11 UTC+1 schrieb prili...@googlemail.com: Am Samstag, 22. Dezember 2012 12:43:54 UTC+1 schrieb Peter Otten: wrote: Hello, to all, And my mail reader text window is fille

  1   2   3   4   5   6   >