473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

decorator with ```


One more crazy syntax before-def but which could be treated
more generally:

```""" Factory for new decorator syntaxes.

Keeps all proposals in a list and will recombine
them at random if called without a spec. """
staticmethod```
def makeDecoratorSyntax(spec=None):
raise NotImplementedException()

New execution block type (in addition to exec, eval and
interactive) could be added to allow needed behaviour.

Less-decorated are also fine:

```staticmethod```
def makeDecoratorSyntax(spec=None):
raise NotImplementedException()

Several block could also concatewnate:

```staticmethod```
```decor2```
def makeDecoratorSyntax(spec=None):
raise NotImplementedException()

Or use ; to put them into one line:

```staticmethod; decor2```
def makeDecoratorSyntax(spec=None):
raise NotImplementedException()
Of course, the same could be put AFTER def, like docstring.

Sincerely yours, Roman A.Suzi
--
- Petrozavodsk - Karelia - Russia - mailto:rn*@onego.ru -

Jul 18 '05 #1
3 1440

"Roman Suzi" <rn*@onego.ru> wrote in message
news:ma**************************************@pyth on.org...

One more crazy syntax before-def but which could be treated
more generally:

```""" Factory for new decorator syntaxes.

Keeps all proposals in a list and will recombine
them at random if called without a spec. """
staticmethod```
def makeDecoratorSyntax(spec=None):
raise NotImplementedException()

New execution block type (in addition to exec, eval and
interactive) could be added to allow needed behaviour.

[snip]

I think it would be interesting if triple-back-ticks could be used to
introduce a kind of meta-scope, using 'this' to refer to the namespace being
operated upon (so you wouldn't have to spell out the object's name all the
time). For example:
def makeDecoratorSyntax(spec=None):
```""" Factory for new decorator syntaxes.

Keeps all proposals in a list and will recombine
them at random if called without a spec.
"""
this = staticmethod(this) # <- transformation explicit
this.author = "somebody" # <- add attributes normally
```
raise NotImplementedException()

This idea could be used to do transformations on classes and modules as
well.

Jul 18 '05 #2

"Sean Ross" <sr***@connectmail.carleton.ca> wrote in message
news:0z********************@news20.bellglobal.com. ..
[snip]
def makeDecoratorSyntax(spec=None):
```""" Factory for new decorator syntaxes.

Keeps all proposals in a list and will recombine
them at random if called without a spec.
"""
this = staticmethod(this) # <- transformation explicit
this.author = "somebody" # <- add attributes normally
```
raise NotImplementedException()

[snip]

It would work something like this:

def triplebacktick(this, transform):
this.doc = transform.doc
return transform(this)

def transform(f):
""" Factory for new decorator syntaxes.

Keeps all proposals in a list and will recombine
them at random if called without a spec.
"""
f = staticmethod(f)
f.author = "somebody"
return f

def makeDecoratorSyntax(spec=None):
raise NotImplementedException()

makeDecoratorSyntax = triplebacktick(makeDecoratorSyntax, transform)

Jul 18 '05 #3
Roman Suzi <rn*@onego.ru> writes:
```staticmethod```
def makeDecoratorSyntax(spec=None):
raise NotImplementedException()


That's already legal Python, although it's not very useful:
```staticmethod``` '\'"<type \\\'staticmethod\\\'>"\'' def makeDecoratorSyntax(spec=None): .... raise NotImplementedException()
....


Bernhard

--
Intevation GmbH http://intevation.de/
Skencil http://sketch.sourceforge.net/
Thuban http://thuban.intevation.org/
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ville Vainio | last post by:
It might just be that @decorator might not be all that bad. When you look at code that uses it it's not that ugly after all. A lot of the furor about this is probably because it happened so...
41
by: John Marshall | last post by:
How about the following, which I am almost positive has not been suggested: ----- class Klass: def __init__(self, name): self.name = name deco meth0: staticmethod def meth0(x):
17
by: Jim Jewett | last post by:
Guido has said that he is open to considering *one* alternative decorator syntax. At the moment, (Phillip Eby's suggestion) J4 <URL: http://www.python.org/moin/PythonDecorators > (section 5.21...
30
by: Ron_Adam | last post by:
I was having some difficulty figuring out just what was going on with decorators. So after a considerable amount of experimenting I was able to take one apart in a way. It required me to take a...
22
by: Ron_Adam | last post by:
Hi, Thanks again for all the helping me understand the details of decorators. I put together a class to create decorators that could make them a lot easier to use. It still has a few glitches...
3
by: Ron_Adam | last post by:
Ok... it's works! :) So what do you think? Look at the last stacked example, it process the preprocess's first in forward order, then does the postprocess's in reverse order. Which might be...
6
by: Michele Simionato | last post by:
could ildg wrote: > I think decorator is a function which return a function, is this right? > e.g. The decorator below if from http://www.python.org/peps/pep-0318.html#id1. > > def...
5
by: Doug | last post by:
I am looking at using the decorator pattern to create a rudimentary stored proc generator but am unsure about something. For each class that identifies a part of the stored proc, what if I want to...
4
by: thomas.karolski | last post by:
Hi, I would like to create a Decorator metaclass, which automatically turns a class which inherits from the "Decorator" type into a decorator. A decorator in this case, is simply a class which...
8
by: Chris Forone | last post by:
hello group, is there a possibility to implement the decorator-pattern without new/delete (nor smartpt)? if not, how to ensure correct deletion of the objects? thanks & hand, chris
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.