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
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
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
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
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
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
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
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
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
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,
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
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
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
On Tuesday 05 July 2016 13:47, Chris Angelico wrote:
> On Tue, Jul 5, 2016 at 1:35 PM, Steven D'Aprano wrote:
>>> If you push your code into a separate .py file, you can reference the
>>> original module by importing it. Is that also the normal way to use
>>> "outer" functions etc from inside a n
On Tue, Jul 5, 2016 at 1:35 PM, Steven D'Aprano wrote:
>> If you push your code into a separate .py file, you can reference the
>> original module by importing it. Is that also the normal way to use
>> "outer" functions etc from inside a namespace?
>
> Good question!
>
> With the current implement
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
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
On Mon, 4 Jul 2016 09:23 pm, jmp wrote:
> On 07/01/2016 04:13 PM, Steven D'Aprano wrote:
>> But classes are not like the others: they must be instantiated before
>> they can be used, and they are more than just a mere namespace grouping
>> related entities. Classes support inheritance. Classes sho
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
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
On 07/04/2016 01:37 PM, Chris Angelico wrote:
On Mon, Jul 4, 2016 at 9:23 PM, jmp wrote:
On 07/01/2016 04:13 PM, Steven D'Aprano wrote:
But classes are not like the others: they must be instantiated before they
can be used, and they are more than just a mere namespace grouping related
entitie
On Mon, Jul 4, 2016 at 9:23 PM, jmp wrote:
> On 07/01/2016 04:13 PM, Steven D'Aprano wrote:
>>
>> But classes are not like the others: they must be instantiated before they
>> can be used, and they are more than just a mere namespace grouping related
>> entities. Classes support inheritance. Class
On 07/01/2016 04:13 PM, Steven D'Aprano wrote:
But classes are not like the others: they must be instantiated before they
can be used, and they are more than just a mere namespace grouping related
entities. Classes support inheritance. Classes should be used for "is-a"
relationships, not "has-a"
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.
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 are unwieldy?
P
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 solution to that:
a =
>> 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 initialization to use.
> And are significantly less easy to use, as the functions MUST refer to
each
> other by their dot
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
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
On Sat, 2 Jul 2016 11:50 am, Kevin Conway wrote:
> I believe the namespace object you are referring to is exactly a class.
Yes, a namespace is exactly like a class, minus inheritance, instantiation,
the implied "is-a" relationship, and the whole Java "utility class"
anti-pattern.
In other words,
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
> 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
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 "
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
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
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
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
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
On Sat, 2 Jul 2016 12:49 am, 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 into another file.
>
>
On Sat, 2 Jul 2016 02:00 am, Ethan Furman wrote:
> 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.
Thanks!
> Comments below.
[...]
>> Despite the "class" statement (a limitation of Python's lack of dedicated
>> synt
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
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 "namespace" object to Python
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
On Fri, Jul 1, 2016, at 10:13, Steven D'Aprano wrote:
> The biggest limitation is that I have to abuse the class statement to do
> this. In an ideal world, there would be syntactic support and a keyword:
>
> namespace Example:
> x = 0
> y = []
> def test(n): ...
>
> al
On Wed, Apr 20, 2011 at 8:00 AM, Rhodri James
wrote:
> Language abuse: it's not just Python. A donation of just $5 will keep a
> programmer in prepositions for a month. $50 will supply enough articles to
> keep a small company understandable for over a year. With your generous
> help, we can be
On Tue, 19 Apr 2011 17:47:40 +0100, Gerald Britton
wrote:
Gerald Britton wrote:
I now understand the Python does
not consider a class definition as a separate namespace as it does for
function definitions. That is a helpful understanding.
That is not correct. Classes are separate namesp
On 4/19/2011 10:58 AM, Gerald Britton wrote:
serve method unless it is qualified. I now understand the Python does
not consider a class definition as a separate namespace as it does for
function definitions.
Class namespaces are separate namespaces but not in the same way as for
functions. C
On Tue, Apr 19, 2011 at 10:31 AM, Ethan Furman wrote:
> Gerald Britton wrote:
>>
>> I now understand the Python does
>> not consider a class definition as a separate namespace as it does for
>> function definitions. That is a helpful understanding.
>
> That is not correct. Classes are separate n
>Gerald Britton wrote:
>> I now understand the Python does
>> not consider a class definition as a separate namespace as it does for
>> function definitions. That is a helpful understanding.
>That is not correct. Classes are separate namespaces -- they just
>aren't automatically searched. The o
Gerald Britton wrote:
I now understand the Python does
not consider a class definition as a separate namespace as it does for
function definitions. That is a helpful understanding.
That is not correct. Classes are separate namespaces -- they just
aren't automatically searched. The only name
Ethan -- I'm just getting back to this question. If you recall, you asked:
[snip]
8<
"script with possible name clashes"
eggs = 'scrambled eggs'
meat = 'steak'
class Breakfast():
meat = 'spam'
def serve(self):
print("Here's
On Apr 17, 8:56 pm, Chris Rebert wrote:
> On Sun, Apr 17, 2011 at 12:30 PM, Gerald Britton
>
>
>
>
>
>
>
>
>
> wrote:
> > I apologize if this has been answered before or if it is easy to find
> > in the docs. (I couldn't find it but might have missed it)
>
> > I'm trying to understand the differe
Gerald Britton wrote:
For my
final attempt, I add the prefix "a." to my use of "foo"
class a():
... foo = 'foo'
... def g(x):
... return a.foo
...
The first parameter to any method in a class* is going to be the
instance of that class, and is usually named 'self'. So your
Gerald Britton wrote:
However, I would like a deeper
understanding of why I cannot use "foo" as an unqualified variable
inside the method in the class. If Python allowed such a thing, what
problems would that cause?
8<
"script with possible
On Sun, Apr 17, 2011 at 12:30 PM, Gerald Britton
wrote:
> I apologize if this has been answered before or if it is easy to find
> in the docs. (I couldn't find it but might have missed it)
>
> I'm trying to understand the differences between namespaces in class
> definitions vs. function definitio
> What is namespace? And what is built-in namespace?
> --
> http://mail.python.org/mailman/listinfo/python-list
http://lmgtfy.com/?q=python+namespace
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 21, 10:39 am, sl33k_ wrote:
> What is namespace? And what is built-in namespace?
tl;dr - Namespaces are sets that contain names. You can think of
namespaces as being /like/ boxes. A namespace is therefore an
organisational tool, forming a similar purpose to human names &
surnames - to iden
On 01/-10/-28163 02:59 PM, sl33k_ wrote:
What is namespace? And what is built-in namespace?
A namespace is a mapping from names to objects. When you write a statement
xyz = 42
the system looks up "xyz" in some namespace and associates that
"variable" with the object int(42).
The key i
On Jan 21, 10:39 am, sl33k_ wrote:
> What is namespace? And what is built-in namespace?
A namespace is a container for names, like a directory is a container
for files. Names are the labels we use to refer to python objects
(e.g. int, bool, sys), and each Python object - particularly modules
and
rantingrick wrote:
On Aug 2, 3:12 pm, Chris Hare wrote:
Also you should use 4 space indention and never use tabs. This is the
accepted way.
Then ask yourself why tabs are still in python 3.
Nice troll by the way.
JM
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 2, 3:12 pm, Chris Hare wrote:
> Thanks to everyone for answering my question. I think its clear now. I'll
> just go the "stuff 'em in a module and import that" route.
Chris, first of all i want you to know that this message is not meant
to offend but it may offend you -- hopefully your
Thanks to everyone for answering my question. I think its clear now. I'll
just go the "stuff 'em in a module and import that" route.
Chris
On Aug 2, 2010, at 3:03 PM, MRAB wrote:
> Chris Hare wrote:
>> I am having a problem getting around this variable namespace thing.
>> Consider these code
Chris Hare wrote:
I am having a problem getting around this variable namespace thing.
Consider these code bits
File a.py
from Tkinter import *
import a1
def doAgain():
x = a1.Net()
x.show("Again!")
root = Tk()
root.title("test")
f = Frame(root,bg="Yellow")
l = Button(root,text
Chris Hare wrote:
I am having a problem getting around this variable namespace thing.
Consider these code bits
File a.py
from Tkinter import *
import a1
def doAgain():
x = a1.Net()
x.show("Again!")
root = Tk()
root.title("test")
f = Frame(root,bg="Yellow")
l = Button(root,text
Chris Hare wrote:
I am having a problem getting around this variable namespace thing.
Consider these code bits
File a.py
from Tkinter import *
import a1
def doAgain():
x =1.Net()
x.show("Again!")
root =k()
root.title("test")
f =rame(root,bg="Yellow")
l =utton(root,text="window
On 08/02/2010 09:33 PM, Chris Hare wrote:
> I am having a problem getting around this variable namespace thing.
>
> Consider these code bits
>
> File a.py
> from Tkinter import *
> import a1
>
> def doAgain():
> x = a1.Net()
> x.show("Again!")
>
> root = Tk()
> root.title("test")
>
On Sat, 20 Dec 2008, John O'Hagan wrote:
> On Sat, 20 Dec 2008, Terry Reedy wrote:
> > John O'Hagan wrote:
> > > I have a lot of repetitive assignments to make, within a generator,
> > > that use a function outside the generator:
> > >
> > > var1 = func("var1", args)
> > > var2 = func("var2", args)
On Dec 19, 11:34 pm, John O'Hagan wrote:
> I have a lot of repetitive assignments to make, within a generator, that use a
> function outside the generator:
>
> var1 = func("var1", args)
> var2 = func("var2", args)
> var3 = func("var3", args)
> etc...
>
> In each case the args are identical, but th
On Sat, 20 Dec 2008, Terry Reedy wrote:
> John O'Hagan wrote:
> > I have a lot of repetitive assignments to make, within a generator, that
> > use a function outside the generator:
> >
> > var1 = func("var1", args)
> > var2 = func("var2", args)
> > var3 = func("var3", args)
> > etc...
> >
> > In ea
On Sat, 20 Dec 2008, Steven D'Aprano wrote:
> On Sat, 20 Dec 2008 02:53:16 +, MRAB wrote:
> > If you're sure you want to use the current namespace then:
> >
> > for name in namelist:
> > vars()[name] = func(name, args)
>
> Doesn't work inside a function:
> >>> def parrot():
>
> ..
On Sat, 20 Dec 2008, Arnaud Delobelle wrote:
> John O'Hagan writes:
> > I have a lot of repetitive assignments to make, within a generator,
> > that use a function outside the generator:
> >
> > var1 = func("var1", args)
> > var2 = func("var2", args)
> > var3 = func("var3", args)
> > etc...
> >
>
John O'Hagan writes:
> I have a lot of repetitive assignments to make, within a generator,
> that use a function outside the generator:
>
> var1 = func("var1", args)
> var2 = func("var2", args)
> var3 = func("var3", args)
> etc...
>
> In each case the args are identical, but the first argument is
On Sat, 20 Dec 2008 02:53:16 +, MRAB wrote:
> If you're sure you want to use the current namespace then:
>
> for name in namelist:
> vars()[name] = func(name, args)
Doesn't work inside a function:
>>> def parrot():
... for name in ['A', 'B', 'C']:
... vars()[na
Terry Reedy wrote:
John O'Hagan wrote:
I have a lot of repetitive assignments to make, within a generator,
that use a function outside the generator:
var1 = func("var1", args)
var2 = func("var2", args)
var3 = func("var3", args)
etc...
In each case the args are identical, but the first argumen
John O'Hagan wrote:
I have a lot of repetitive assignments to make, within a generator, that use a
function outside the generator:
var1 = func("var1", args)
var2 = func("var2", args)
var3 = func("var3", args)
etc...
In each case the args are identical, but the first argument is a string of the
On May 16, 5:02 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] writes:
> > Sorry for the repost, didnt' quite finish
>
> > Suppose I have a function in module X that calls eval e.g,
>
> > X.py
> > ___
> > Def foo(bar):
> > Eval(bar)
> > ___
>
> > Now eval will b
On May 17, 12:20 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] writes:
> > On May 16, 2:47 pm, "[EMAIL PROTECTED]"
> > <[EMAIL PROTECTED]> wrote:
> >> On 16 mai, 23:23, [EMAIL PROTECTED] wrote:
>
> >> > Thanks for the responses. I'm well aware that the function can be
> >> >
[EMAIL PROTECTED] writes:
> On May 16, 2:47 pm, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>> On 16 mai, 23:23, [EMAIL PROTECTED] wrote:
>>
>> > Thanks for the responses. I'm well aware that the function can be
>> > passed in the parameters, passing in the functino as an arg defeats
>> > th
On May 16, 2:47 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> On 16 mai, 23:23, [EMAIL PROTECTED] wrote:
>
> > Thanks for the responses. I'm well aware that the function can be
> > passed in the parameters, passing in the functino as an arg defeats
> > the purpose of what I'm going after.
>
On 16 mai, 23:23, [EMAIL PROTECTED] wrote:
> Thanks for the responses. I'm well aware that the function can be
> passed in the parameters, passing in the functino as an arg defeats
> the purpose of what I'm going after.
Why so ?
> @ Arnaud - Nice. I'm not sure what the performance of mine vs. yo
Thanks for the responses. I'm well aware that the function can be
passed in the parameters, passing in the functino as an arg defeats
the purpose of what I'm going after.
@ Arnaud - Nice. I'm not sure what the performance of mine vs. yours,
but a perfunctory glance looks like we're doing the clos
On 16 mai, 20:44, [EMAIL PROTECTED] wrote:
> Suppose I have a function in module X that calls eval e.g,
>
> X.py
> ___
> Def foo(bar):
> Eval(bar)
> ___
>
> Now eval will be called using the default eval(bar,globals(),locals())
> and globals will pull in anything in module X.
>
> No
[EMAIL PROTECTED] writes:
> Sorry for the repost, didnt' quite finish
>
> Suppose I have a function in module X that calls eval e.g,
>
> X.py
> ___
> Def foo(bar):
> Eval(bar)
> ___
>
> Now eval will be called using the default eval(bar,globals(),locals())
> and globals will pull i
In article <[EMAIL PROTECTED]>,
Alex Martelli <[EMAIL PROTECTED]> wrote:
>Aahz <[EMAIL PROTECTED]> wrote:
>>Alex:
>>>
>>>But don't put such black magic in production. The completely different
>>>way is: just don't.
>>
>> Could you expand on that? After all, that's exactly what we do to
>> implem
Martin Drautzburg <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
>
> > Yes, there is: use an ORM to do the SQL generation for you. Check out
> > SQLAlchemy, it will buy you much more than what you asked for.
>
> Might look, though in general I don't like OR mappers much. Having SQL
> generate
Aahz <[EMAIL PROTECTED]> wrote:
> >But don't put such black magic in production. The completely different
> >way is: just don't.
>
> Could you expand on that? After all, that's exactly what we do to
> implement a super() that works with classic classes -- and it's certainly
> production code.
In article <[EMAIL PROTECTED]>,
Alex Martelli <[EMAIL PROTECTED]> wrote:
>Martin Drautzburg <[EMAIL PROTECTED]> wrote:
>>
>> The problem is the first part: how can I lookup the callers module and
>> the classobjs defined in there? Or finding any constant strings in the
>> caller's module would also
Peter Otten wrote:
def SQL(sql):
> ... print sql
> ...
a = SQL("module")
> module # that one was obvious
class A:
> ... b = SQL("class")
> ... def method(self, c=SQL("default arg")):
> ... d = SQL("method")
> ...
You are my hero. Indeed very cool!
--
http:/
George Sakkis wrote:
> Yes, there is: use an ORM to do the SQL generation for you. Check out
> SQLAlchemy, it will buy you much more than what you asked for.
Might look, though in general I don't like OR mappers much. Having SQL
generated feels as strange as having python code generated. Too much
Martin Drautzburg wrote:
> > def SQL(sql, checked=set()):
> > if sql in checked:
> > return True
> > if not valid_sql(sql): raise ValueError
> > checked.add(sql)
> > return sql
>
> No this does not do the trick. I will not be able to validate an sql
> statement bofore I ru
Martin Drautzburg <[EMAIL PROTECTED]> wrote:
...
> The problem is the first part: how can I lookup the callers module and
> the classobjs defined in there? Or finding any constant strings in the
> caller's module would also be just fine. Or is there a completely
> different way to do such a thin
On Apr 21, 4:16 pm, Martin Drautzburg <[EMAIL PROTECTED]>
wrote:
> I would like to validate sql strings, which are spread all over the
> code, i.e. I run ("prepare") them against a database to see if it happy
> with the statements. Spelling errors in sql have been a major pain for
> me.
>
> The sta
Martin Drautzburg wrote:
> I would like to validate sql strings, which are spread all over the
> code, The statements will not be assembled from smaller pieces,
> but they will not neccessarily be defined at module level. I could
> live with class level,
> parse the source file, but I am
Peter Otten wrote:
> Martin Drautzburg wrote:
>
>> I would like to validate sql strings, which are spread all over the
>> code, i.e. I run ("prepare") them against a database to see if it
>> happy with the statements. Spelling errors in sql have been a major
>> pain for me.
>
> def validateSQL(
Martin Drautzburg wrote:
> I would like to validate sql strings, which are spread all over the
> code, i.e. I run ("prepare") them against a database to see if it happy
> with the statements. Spelling errors in sql have been a major pain for
> me.
>
> The statements will not be assembled from sma
Bengt Richter wrote:
> Another thought/bf would be a way to extend the attribute namespace of an
> arbitrary object
> by chaining the attribute name spaces of a sequence of objects (this would be
> a language mod)
> e.g., (sort of a dynamic instance attribute mixin)
>
> obj ..= a, b, c #
Scott David Daniels wrote:
> Well, an entry in the dictionary "sys.modules" is what is returned by
> imports, so you could either pre-replace or post-replace a module by
> an object which uses the descriptor technique to get to some (but not
> necessarily all) of the attributes. Think of this tec
I've been needing a module level __getattr__ for some c library
wrapping. This has solved the problem:
# mymod.py:
import sys
from new import module
class ModuleProxy(module):
def __init__( self, name, master ):
module.__init__( self, name )
self._master = master
self.__dict__["__all
In article <[EMAIL PROTECTED]>,
Paolino <[EMAIL PROTECTED]> wrote:
>
>Why descriptor mechanism doesn't apply to modules?
The real answer: Because Guido doesn't want it to
--
Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/
The way to build large Python applications is
On Tue, 09 Aug 2005 08:35:38 -0700, Scott David Daniels <[EMAIL PROTECTED]>
wrote:
>Paolino wrote:
>> Peter Otten wrote:
>>> Paolino wrote:
Why descriptor mechanism doesn't apply to modules?
>>> Because modules are instances of the module class and the descriptor
>>> has to be defined in th
1 - 100 of 152 matches
Mail list logo