473,467 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

We need PIGs :)

Hello,

having worked quite a bit with python in the last months (some Java
before, and some C++ before that) I was very impressed by an idea the
Java people had.

Explanation: the JSRs define how to implement certain services and or
features in Java so that they can be reused. I haven't found such a
thing for python yet.

Say I have the problem of authentication. Now I can implement
authentication against a text file with a "key : value" format.

However someone may find it more suitable to implement a
authentication backend for exactly this app that can use postgres.

Who else can use the authentication for my program created by a third
party in his or her own app/package/module? To my knowledge noone as
there's nothing you could at least theoretically keep to.

My idea was to define "Python Implementation Guidelines" (PIGs) that
specify a problem formalize it enough so that implementations are
interchangeable (in this example create a module that has an
"authenticate(username, password)" method so that one could easily
take that module for any given app and then authenticate against
postgres, and also against my plaintext file (which was the original -
quite useless - implementation).

Does that sound like a good idea or would that be over formalization?

Personally I think that would be great as I could search the PIGs at
(hopefully) python.org find out the number and search at koders.com or
code.google.com for python code that has "PIG: XXX" in the metadata
docstring or wherever - maybe even a __pig__ = XXX variable.

any input is welcome (also point me to the place where that can be
found if it already exists)
martin
Aug 30 '07 #1
7 1325
On Thu, 30 Aug 2007 07:10:47 +0200, Martin Marcher wrote:
Does that sound like a good idea or would that be over formalization?
Sounds like over engineering/formalization to me.

You are aware of the Python Enhancement Proposals (PEPs)?

Is something like the `Python Database API Specification v2.0`_ or `API
for Block Encryption Algorithms v1.0`_ what you are looking for?

... _API for Block Encryption Algorithms v1.0:
http://www.python.org/dev/peps/pep-0272/
... _Python Database API Specification v2.0:
http://www.python.org/dev/peps/pep-0249/

Ciao,
Marc 'BlackJack' Rintsch
Aug 30 '07 #2
On Thu, 30 Aug 2007 07:10:47 +0200, Martin Marcher wrote:
My idea was to define "Python Implementation Guidelines" (PIGs) that
specify a problem formalize it enough so that implementations are
interchangeable (in this example create a module that has an
"authenticate(username, password)" method so that one could easily take
that module for any given app and then authenticate against postgres,
and also against my plaintext file (which was the original - quite
useless - implementation).

Does that sound like a good idea or would that be over formalization?
The Python community already did something for web applications (WSGI, I
think). Not sure how well that's working out.

Doing this kind of thing is not, of course, something that can be done in
general for all problems. It would only help if there's enough demand
for interoperability that developers make the effort to adhere to the
guidelines (which are rarely ideal for any particular situation).
Although there are some informal standards that Python programmers often
observe (for example, the interface of file-like objects), there isn't
too much demand to standardize them.

I believe the Python language itself makes formal guidelines less
helpful, because its dynamicism (among other things) makes is so good at
interfacing. That is, if you have two pieces of code that don't work
together, it's easy to connect them. Many people often call Python a
good "glue" language for this reason. And when you have a good "glue"
language, formal interface guidelines aren't so important.

Carl Banks
Aug 30 '07 #3
Hello,

On 30 Aug 2007 07:14:25 GMT, Marc 'BlackJack' Rintsch <bj****@gmx.netwrote:
On Thu, 30 Aug 2007 07:10:47 +0200, Martin Marcher wrote:
Does that sound like a good idea or would that be over formalization?

Sounds like over engineering/formalization to me.
You are aware of the Python Enhancement Proposals (PEPs)?
Yes I am thought I mentioned the wsgi pep in the mail...
Is something like the `Python Database API Specification v2.0`_ or `API
for Block Encryption Algorithms v1.0`_ what you are looking for?
http://en.wikipedia.org/wiki/Java_Au...zation_Service
http://en.wikipedia.org/wiki/Content...y_API_for_Java
http://jcp.org/en/jsr/all

But since python is much more open in these terms these hints should
guide developers thru solutions so that they know they can use other
modules/classes without any effort if such a specificaton exists. In
Java it is more like not implementing any of these things is
>
.. _API for Block Encryption Algorithms v1.0:
http://www.python.org/dev/peps/pep-0272/
.. _Python Database API Specification v2.0:
http://www.python.org/dev/peps/pep-0249/
Indeed i wasn't aware of these (I know the wsgi spec) but I was more
thinking about guidelines where you can be quite sure that because of
not being able to provide an implementation that is so general that it
could be incorporated in the standard library.

Think of

* object relational mappers (probably a bad example - but would be still nice)
* service registries
* service repositories
* ....

that use the same interface so that you can swap them effordlessly.
I'm thinking big here so that generalization has to be applied to the
problems but also that you can keep to well known interface to
implement so that it will work out for the majority of situations in
these fields.

I do know the WSGI spec but I do think that (otherwise I wouldn't have
had the idea) that PEPs are the wrong place for that. To me PEPs are
(better should be) about the plain stock standard library and how to
work with it (coding guidelines, docstring, iterators, generators -
specification of the language) PIGs (given the name is arguable - I
just like it it removes a bit of the necessary formal taste it has)
should define:

* problem
* solution
* expected behaviour
* interface

(probably even prepare unit tests if the interface is stabilized)

but should by itself not implement anything as for example the DBAPI
does. and given the nature of the field (spezialized for a task but
still applies to a lot of people) an general purpose implementation
wouldn't be useful

hope that explains it well enough. I've been in a couple of projects
where problems where common to all those projects but the
specification made up by individual (project) managers made it
impossible to reuse parts of other apps (and I guess with some
"official" backup one could point back on proven recipies - that's
probably the term that describes it best)

greetings (always wondered is that a formal or informal closing part
in english letters?)
martin
Aug 30 '07 #4
On Aug 30, 12:10 am, "Martin Marcher" <martin.marc...@gmail.com>
wrote:

[snip!]
>
My idea was to define "Python Implementation Guidelines" (PIGs) that
specify a problem formalize it enough so that implementations are
interchangeable (in this example create a module that has an
"authenticate(username, password)" method so that one could easily
take that module for any given app and then authenticate against
postgres, and also against my plaintext file (which was the original -
quite useless - implementation).

Does that sound like a good idea or would that be over formalization?
This may be over-formalization. For specific problems, there
generally is a pythonic choice. For instance, suppose your problem is
'I need an ORM' - well the pythonic choice is something along the
lines of SQLObject or SQLAlchemy.

Then there are other cases where there are too many choices - "I need
a web framework." -- turbogears, django, pylons, and whatever else you
want to throw into the pot. (Be smart, choose pylons [just kidding,
but I did promote pylons and attach a just kidding disclaimer --
clever, huh?])
Personally I think that would be great as I could search the PIGs at
(hopefully) python.org find out the number and search at koders.com or
code.google.com for python code that has "PIG: XXX" in the metadata
docstring or wherever - maybe even a __pig__ = XXX variable.
I think most of what you're after may be in the python cookbook
(http://aspn.activestate.com/ASPN/Cookbook/Python) or the PyPi (http://
pypi.python.org/pypi).
any input is welcome (also point me to the place where that can be
found if it already exists)
martin
Or maybe I completely misunderstand what you mean.

G' Day!
jw

Aug 30 '07 #5
Martin Marcher a écrit :
Hello,

having worked quite a bit with python in the last months (some Java
before, and some C++ before that) I was very impressed by an idea the
Java people had.

Explanation: the JSRs define how to implement certain services and or
features in Java so that they can be reused. I haven't found such a
thing for python yet.
(snip)
My idea was to define "Python Implementation Guidelines" (PIGs) that
specify a problem formalize it enough so that implementations are
interchangeable (in this example create a module that has an
"authenticate(username, password)" method so that one could easily
take that module for any given app and then authenticate against
postgres, and also against my plaintext file (which was the original -
quite useless - implementation).

Does that sound like a good idea or would that be over formalization?
The problem with Java is that it makes it very painfull to bridge two
APIs together, while Python usually makes it a breeze (easy delegation,
no dumb-ass psycho-rigid type system). So Java's solution
(hyper-formalization) isn't necessary here.

Now there's something along this line - just much more useful and
flexible IMHO - in Zope3 and Twisted. You may want to look at Zope's
"Interfaces" for more infos on this, or to read this post by the BDFL:
http://www.artima.com/weblogs/viewpo...?thread=155123

HTH
Aug 30 '07 #6
Stefan Arentz a écrit :
Bruno Desthuilliers <bd*****************@free.quelquepart.frwrites:

...
>The problem with Java is that it makes it very painfull to bridge two
APIs together, while Python usually makes it a breeze (easy
delegation, no dumb-ass psycho-rigid type system). So Java's solution
(hyper-formalization) isn't necessary here.

Interesting. I find Java much more predictable with APIs than Python
actually.
I'm not going to debate on this because it's absolutely not what I'm
talking about. My point is that Python has:

- duck typing, so you don't need one class subclassing another just to
satisfy the compiler - as long as the object you send respects the
expected protocol, everything's ok

- good support for delegation (via the __getattr__/__setattr__ magic
methods), so you don't have to go thru the pain of hand-writing all the
delegate methods - only the ones for which there's more to be done than
straightforward delegation.

Java has pretty strict rules for style and API design,
Java has pretty strict rules for almost anything.
Sep 6 '07 #7
On Sun, 16 Sep 2007 10:17:18 -0400, Colin J. Williams wrote:
Marc 'BlackJack' Rintsch wrote:
>`getFoo()` is discouraged by PEP 8. […]

Perhaps PEP 8 needs rethinking. I prefer getFoo().
Yeah, *your* preference is a very good reason to rethink PEPÂ*8… ;-)

Ciao,
Marc 'BlackJack' Rintsch
Sep 16 '07 #8

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

Similar topics

0
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its...
6
by: Robert Maas, see http://tinyurl.com/uh3t | last post by:
System login message says PHP is available, so I tried this: http://www.rawbw.com/~rem/HelloPlus/h.php It doesn't work at all. Browser just shows the source. What am I doing wrong?
2
by: Todd Shillam | last post by:
Here's my script--need help with output to text file (must be missing something here like closing the file or something). Any help would be greatly appreciated here. Lastly, I'm using Visual Basic...
0
by: Gregory Nans | last post by:
hello, i need some help to 'tree-ify' a string... for example i have strings such as : s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i need))""" and i need to...
7
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a...
8
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl...
3
by: Bob.Henkel | last post by:
I write this to tell you why we won't use postgresql even though we wish we could at a large company. Don't get me wrong I love postgresql in many ways and for many reasons , but fact is fact. If...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.