Re: Google Cloud Platform and GlassSolver Project

2014-02-18 Thread MRAB

On 2014-02-18 03:09, Chris Angelico wrote:

On Tue, Feb 18, 2014 at 1:52 PM, Steven D'Aprano  wrote:

On Mon, 17 Feb 2014 16:57:34 -0800, Physics wrote:


Does ANYONE have a clue how to do this? I understand that it is hard but
geez...



Absolutely no clue what your question is. You seem to assume that:

- we know what "God's algorithm" is;

- we know what "God's Number" is;

- we understand what you mean by 3x3s, 2x2s, 4x4s and 5x5s (five
  what by five what?).


They'll be Rubik's Cubes, as Dave said earlier in the thread. God's
Number is the theoretical fewest-moves-to-solve, called that because
you would need to be the omniscient Deity to know which moves to
actually do. But I agree that it should have been said. Not everyone
knows what your research is :)


Where I'm from, Rubik's Cubes are, well, cubes, thus 3x3x3,
etc.
--
https://mail.python.org/mailman/listinfo/python-list


IDLE won't run after installing Python 3.3 in Windows

2014-02-18 Thread eglowstein . h
The next adventure in Python was to install Python 3 into a Windows XP machine. 
I had a previous 2.7 installation that I uninstalled and carefully removed all 
traces of from the directory and the registry.

I got the 'python-3.3.3.msi' from Python.org and installed it. From a command 
window I can run 'python' and I get the Python prompt. I have several Python 
programs on the machine. If I right click o one, I have the option of 'Edit in 
IDLE'. If I do that, the disk light blinks briefly, and then nothing. So I went 
into the \python33\lib\idlelib directory and from a CMD window, ran 'python 
idle.py'. That loads IDLE. but when I ask IDLE to load a file, it navigates to 
a FileOpen dialog and then closes everything when I actually open the file. I 
then tried the same thing but used 'pythonw' instead. Same deal.

I also saw some other threads here about how Python can get befuddled by 
firewalls, so I disabled that with no effect.

Any suggestions?  Thanks in advance!

Howard
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: IDLE won't run after installing Python 3.3 in Windows

2014-02-18 Thread behrooz . abbasy
On Tuesday, February 18, 2014 6:26:51 PM UTC+3:30, eglows...@gmail.com wrote:
> The next adventure in Python was to install Python 3 into a Windows XP 
> machine. I had a previous 2.7 installation that I uninstalled and carefully 
> removed all traces of from the directory and the registry.
> 
> 
> 
> I got the 'python-3.3.3.msi' from Python.org and installed it. From a command 
> window I can run 'python' and I get the Python prompt. I have several Python 
> programs on the machine. If I right click o one, I have the option of 'Edit 
> in IDLE'. If I do that, the disk light blinks briefly, and then nothing. So I 
> went into the \python33\lib\idlelib directory and from a CMD window, ran 
> 'python idle.py'. That loads IDLE. but when I ask IDLE to load a file, it 
> navigates to a FileOpen dialog and then closes everything when I actually 
> open the file. I then tried the same thing but used 'pythonw' instead. Same 
> deal.
> 
> 
> 
> I also saw some other threads here about how Python can get befuddled by 
> firewalls, so I disabled that with no effect.
> 
> 
> 
> Any suggestions?  Thanks in advance!
> 
> 
> 
> Howard

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can one use Python to learn and even apply Functional Programming?

2014-02-18 Thread Neil Cerutti
On 2014-02-16, Sam  wrote:
> I would like to learn and try out functional programming (FP).
> I love Python and would like to use it to try FP. Some have
> advised me to use Haskell instead because Python is not a good
> language for FP. I am sort of confused at the moment. Is Python
> a dysfunctional programming language to apply FP? Can the more
> experienced Python users advise?

I recommend Scheme to learn functional programming style.

There's a short scheme tutorial that was entered in the
Interactive Fiction competition in 1998 or so. You can play it
online here, and try out functional programming on a scheme
interepreter implemented in Inform and running on a Z-machine
interpreter written in javascript. It was *my* first introduction
to functional programming.

http://www.eblong.com/zarf/if.html#lists

I purchased and really enjoyed Simply Scheme as a followup to
that mind-bending experience.

http://www.eecs.berkeley.edu/~bh/ss-toc2.html

I wouldn't recommend trying to learn anything at the same time as
learning Haskell. ;)

-- 
Neil Cerutti

-- 
https://mail.python.org/mailman/listinfo/python-list


Bad Code Snippet of the Day

2014-02-18 Thread Chris Angelico
I call this "Russian Exception Roulette". It came about because of
some discussions on python-ideas regarding the new PEP 463 and
exception handling.

try:
exc = getattr(__builtins__,random.choice(list(filter(lambda x:
x.endswith("Error"),dir(__builtins__)
f()
except exc:
print("You win!")


Given a function f(), defined elsewhere, what will this do?

Note that this was developed on Python 3.4, and some of the details
may be different on other versions (especially 2.x).

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Dictionary help

2014-02-18 Thread kjakupak
So let's say I have a file and it looks like this:
Title 1: item 
Title 2: item 
etc

Is it possible to use a dictionary for something like the input above? Because 
I want to be able to use the input above to delete the "Title 1" and "Title 2" 
but still show the items (on separate lines).
Basically I want it to just show:
item
item 
etc..

What I've got is 
dict(item.split(":") for item in cInfo.split(" "))

Where cInfo is a function that extracts the first 5 lines of a file
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dictionary help

2014-02-18 Thread Tim Chase
On 2014-02-18 10:30, kjaku...@gmail.com wrote:
> So let's say I have a file and it looks like this:
> Title 1: item 
> Title 2: item 
> etc
> 
> Is it possible to use a dictionary for something like the input
> above? Because I want to be able to use the input above to delete
> the "Title 1" and "Title 2" but still show the items (on separate
> lines). Basically I want it to just show: item item 
> etc..
> 
> What I've got is 
> dict(item.split(":") for item in cInfo.split(" "))
> 
> Where cInfo is a function that extracts the first 5 lines of a file

It sounds like all you need is some basic string functions, not a
dictionary:

  for line in file('input.txt'):
title, _, item = line.partition(':')
print(item.strip())

-tkc



-- 
https://mail.python.org/mailman/listinfo/python-list


Help creating new module which inherits existing class from another module.

2014-02-18 Thread Jonno
I'm not sure if this list is a suitable place to ask for this kind of help
so if it's not please just suggest another forum which might be more
suitable.

I'm looking for help/suggestions how to architect a module (perhaps just a
class).

There is an existing module I want to use which has a class we'll call
*Existing
Class*.

I want to create a python module which allows me to create *new_objects* with
the following properties:

   - The new_objects have all the attributes of the Existing_Class (simply
   create a class that inherits from Existing_Class)
   - I then want to create a nested structure under the new_objects
   something like:

new_object.foo

new_object.foo.bar

new_object.foo.bar.baz

Where foo, bar, baz have the following properties:

   - All have *docstrings*
   - All are available for *tab completion* tools upon new_object creation.
   -

   Some of which will have *new methods* which act in the following way:
   - new_object.foo.bar()

   calls
   - new_object.existing_method("foo.bar", *args)

I believe I'll need to use metaclasses and have an idea that
types.MethodType will help but I keep getting stuck. Any pointers would be
greatly appreciated.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bad Code Snippet of the Day

2014-02-18 Thread Terry Reedy

On 2/18/2014 11:47 AM, Chris Angelico wrote:

I call this "Russian Exception Roulette". It came about because of
some discussions on python-ideas regarding the new PEP 463 and
exception handling.

try:
 exc = getattr(__builtins__,random.choice(list(filter(lambda x:
x.endswith("Error"),dir(__builtins__)
 f()
except exc:
 print("You win!")

Given a function f(), defined elsewhere, what will this do?


I am not sure what you are asking or what your point is. If f happens to 
raise the randomly selected exception, it prints 'You win!', otherwise 
it does nothing.



Note that this was developed on Python 3.4, and some of the details
may be different on other versions (especially 2.x).




--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Rick Johnson
On Monday, February 17, 2014 1:40:41 PM UTC-6, Ben Finney wrote:
> Nagy László Zsolt ... writes:
> > > Use modules to group your class definitions conceptually. There is
> > > no need whatever to separate every class into a different module.
> > If there is a consensus, and it is really desireable to put all these
> > related classes into the same module, then this is what I'm going to
> > do.

It is not desirable to me, and i would argue truthfully,
to many others either.

> You should use multiple modules to separate the code where it makes
> sense, along *conceptual* lines. Make separate modules that each
> represent a conceptually-separate area of functionality in your
> application, and put the classes which implement that functionality in
> that module.

Classes with an "s"? As in many classes in one source file?
Are you insane man? Why oh why would you torture yourself
and others with such advice? Are you some sort of hard disc
neat freak? Do you fear cluttering your hard-drive with too
many files will overwork it? What of yourself?

I'm continually amazed by you "Java haters" who will
willingly place burdens on yourself just to spite that "mean
old Java". Splitting code into small source files is wise,
whereas, creating single monolithic monstrosities like
Tkinter should be a sin! A sin that should be punishable by
the Exception!

As the lines of code increase, so does the complexity of
navigating and maintaining large modules. Classes should
naturally exist in their own module with the exception of
small utility or special use classes that are not exposed
publicly.

Then you go and intermix the areas of "module source code"
and "module API". These are two distinct areas that need not
follow the same patterns. You can have 20 classes contained
in 20 different source files and then combine them
transparently at run-time so that as far as the client is
concerned, all the classes exist under one namespace.

# ui_mod1.py
class One():pass

# ui_mod2.py
class Two():pass

# ui_mod3.py
class Three():pass

# ui_mod4.py
class Four():pass

# ui_main.py
from ui_mod1 import *
from ui_mod2 import *
from ui_mod3 import *
from ui_mod4 import *

At least by this method i can maintain the code base without
wearing-out my scroll finger and eventually loosing my mind.
THE MORAL: With very few exceptions, please put EVERY class
in it's own module.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help creating new module which inherits existing class from another module.

2014-02-18 Thread Ben Finney
Jonno  writes:

> I'm not sure if this list is a suitable place to ask for this kind of
> help so if it's not please just suggest another forum which might be
> more suitable.

Welcome! Asking for help with writing Python code is definitely suitable
here.

> I'm looking for help/suggestions how to architect a module (perhaps
> just a class).

Right, I don't see anything in your request that indicates why a new
module would be needed.

> There is an existing module I want to use which has a class we'll call
> *Existing Class*.
>
> I want to create a python module which allows me to create
> *new_objects*

This is all rather abstract. Can you explain what the existing class is
for? What the new class is for?

> with the following properties:
>
>- The new_objects have all the attributes of the Existing_Class (simply
>create a class that inherits from Existing_Class)

The syntax for that is::

class Bar(Foo):
…

where “Foo” is the existing class, “Bar” is the class you're defining.

It's not strictly true to say that Bar will thereby “have all the
attributes of” the existing class. Rather, the resolution chain will
mean that accessing attributes on Bar will fall-back to looking at Foo
for attributes not found in Bar.

>- I then want to create a nested structure under the new_objects
>something like:
>
> new_object.foo
> new_object.foo.bar
> new_object.foo.bar.baz

Again, it's not clear why you're doing this. What are these attributes for?

> Where foo, bar, baz have the following properties:
>
>- All have *docstrings*

Docstrings are only for code objects: modules, classes, functions. Will
each of those attributes be one of those?

>- All are available for *tab completion* tools upon new_object creation.

Tab completion is up to the interactive tool you're using. Which tool is that?

>-
>Some of which will have *new methods* which act in the following way:
>- new_object.foo.bar()
>
>calls
>- new_object.existing_method("foo.bar", *args)

This would be an unusual semantic. Why not call the existing method?

> Any pointers would be greatly appreciated.

I am smelling the likelihood that you have a strange design that needs
to be examined and changed. Can you describe what your purpose is that
you think needs this strange architecture?

-- 
 \ “Anyone can do any amount of work provided it isn't the work he |
  `\  is supposed to be doing at the moment.” —Robert Benchley |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Chris Angelico
On Wed, Feb 19, 2014 at 7:41 AM, Rick Johnson
 wrote:
> # ui_main.py
> from ui_mod1 import *
> from ui_mod2 import *
> from ui_mod3 import *
> from ui_mod4 import *
>
> At least by this method i can maintain the code base without
> wearing-out my scroll finger and eventually loosing my mind.
> THE MORAL: With very few exceptions, please put EVERY class
> in it's own module.

Absolutely definitely not. If you're going to import * into every
module, just write it all in a single source file. Otherwise, when
someone tries to find the source code for some particular class or
function, s/he has to go digging through all five source files - first
the utterly useless merge-point, then the four others, because there's
no way to know which one has it.

Python could make this easier for us, by retaining the origin of every
function and class. And maybe it's already there, but I don't know
about it. But even if it did exist (by the way, it would be useful for
other things than just taming a mad layout like this), it'd still be
better to keep everything combined, because the origin of a
function/class could just as easily go to the exact line as to the
file.

A module is a namespace. It should be used as such. If you want a
package, use a package. There's no point putting each class out
separate unless you really need that.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bad Code Snippet of the Day

2014-02-18 Thread Chris Angelico
On Wed, Feb 19, 2014 at 7:41 AM, Terry Reedy  wrote:
> On 2/18/2014 11:47 AM, Chris Angelico wrote:
>>
>> I call this "Russian Exception Roulette". It came about because of
>> some discussions on python-ideas regarding the new PEP 463 and
>> exception handling.
>>
>> try:
>>  exc = getattr(__builtins__,random.choice(list(filter(lambda x:
>> x.endswith("Error"),dir(__builtins__)
>>  f()
>> except exc:
>>  print("You win!")
>>
>> Given a function f(), defined elsewhere, what will this do?
>
>
> I am not sure what you are asking or what your point is. If f happens to
> raise the randomly selected exception, it prints 'You win!', otherwise it
> does nothing.

My point is that this is a piece of obscure code: the try block
affects the interpretation of the except that's associated with it.
Just playing around with obfuscated Python, for amusement value.

The rules of Python are so simple that they allow stupidity like this,
and the interpreter just goes, "So? Of course that's how it is!". I
like it. :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bad Code Snippet of the Day

2014-02-18 Thread Rick Johnson
On Tuesday, February 18, 2014 10:47:15 AM UTC-6, Chris Angelico wrote:
> I call this "Russian Exception Roulette". It came about because of
> some discussions on python-ideas regarding the new PEP 463 and
> exception handling.
> try:
> 
> exc = getattr(__builtins__,random.choice(list(filter(lambda x:
> x.endswith("Error"),dir(__builtins__)
> f()
> except exc:
> print("You win!")
> Given a function f(), defined elsewhere, what will this do?

For get about "f()", it will throw a NameError since "random" 
was not imported. 

Beyond that this code (either conscientiously or unconsciously)
exposes the onerous and obfuscation of a language design
that coddles a global function nightmare paradigm over the
elegance of true OOP -- talk about cutting off your nose
just to spite your face!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Google Cloud Platform and GlassSolver Project

2014-02-18 Thread Chris Angelico
On Tue, Feb 18, 2014 at 11:35 PM, MRAB  wrote:
> Where I'm from, Rubik's Cubes are, well, cubes, thus 3x3x3,
> etc.

For some reason, they're often referred to in just two dimensions. I
have no idea why. A so-called "3x3" cube is standard, and has 3x3x3
small cubes (well, actually, the standard engineering form of it has
eight corner cubes, twelve edge cubes, and six center cubes, not one
of which is actually a cube, so that's 26 non-cubes and nothing in the
middle), and analogously the others. I suppose calling it a "Three
Cube" or a "Four Cube" isn't clear, and certainly "3x3x3" is
redundant.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bad Code Snippet of the Day

2014-02-18 Thread Chris Angelico
On Wed, Feb 19, 2014 at 8:10 AM, Rick Johnson
 wrote:
> Beyond that this code (either conscientiously or unconsciously)
> exposes the onerous and obfuscation of a language design
> that coddles a global function nightmare paradigm over the
> elegance of true OOP -- talk about cutting off your nose
> just to spite your face!

Humour me, Rick. Pretend I've been awake for 22 hours straight, am
wired on sleep-deprivation and energy drinks, and have no idea what
you're talking about. How exactly does the ability to dynamically
determine which exception to catch coddle a functional paradigm, and
how is it not object oriented?

Also, my face doesn't much care for my nose. It gets in the way. If I
cut my nose off, my face would be happy with me.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Rick Johnson
On Tuesday, February 18, 2014 3:02:26 PM UTC-6, Chris Angelico wrote:
> On Wed, Feb 19, 2014 at 7:41 AM, Rick Johnson wrote:
> > # ui_main.py
> > from ui_mod1 import *
> > from ui_mod2 import *
> > from ui_mod3 import *
> > from ui_mod4 import *
> > At least by this method i can maintain the code base without
> > wearing-out my scroll finger and eventually loosing my mind.
> > THE MORAL: With very few exceptions, please put EVERY class
> > in it's own module.
> Absolutely definitely not. If you're going to import * into every
> module, just write it all in a single source file.

Writing multiple individual classes in multiple individual
modules, and then importing those individual classes under a
single namespace at run-time is key to exposing a monolithic
API to a client without storing all the source code in a
monolithic file. The "Tkinter" folks would be wise to follow
my advise!

But I'm not suggesting this is the solution to EVERY
problem, or even that this is the solution to the OP's
current problem, what i am suggesting is that source files
should be kept as short as possible so as to accommodate easy
maintenance.

You see, unlike other languages, Python does not give us a
choice of the start and end of a Python module, there is no
keyword or delimiting chars that we can use to EXPLICITLY
define the start and end of a Python module. No, EVERY
Python script IS a module by default, and that is the law of
the land.

> Otherwise, when
> someone tries to find the source code for some particular class or
> function, s/he has to go digging through all five source files - first
> the utterly useless merge-point, then the four others, because there's
> no way to know which one has it.

Only if you're blind, or your source code was written by
people lacking even a modicum of common sense about how to
name a module. Most modules can simply be the name of the
containing class. Heck, even an idiot can manage that!

> Python could make this easier for us, by retaining the origin of every
> function and class. And maybe it's already there, but I don't know
> about it.

Google "inspect" and be enlightened. But Chris, if you have
to use the inspect module to find a class then sir, you need
lack: simple search tools, and/or motivation.

Are you telling me you're willing to search through a single
file containing 3,734 lines of code (yes, Tkinter) looking
for a method named "destroy" of a class named "OptionMenu"
(of which three other classes contain a method of the same
exact name!), when all you needed to do was open one single
module named "tk_optionmenu.py" and do a single search for
"def destroy"?

You must be trolling!

> But even if it did exist (by the way, it would be useful for
> other things than just taming a mad layout like this), it'd still be
> better to keep everything combined, because the origin of a
> function/class could just as easily go to the exact line as to the
> file.
> A module is a namespace. It should be used as such. If you want a
> package, use a package. There's no point putting each class out
> separate unless you really need that.

But in many cases you do! Chris, i think you missed the
entire crux of this thread. The OP is not writing a single
monolithic program where the code will ONLY be investigated
by the developers, no, he's creating an API, and API's
require structure.

But even if this were not an API, breaking large chunks of
code up and spreading them across individual files is the
key to managing code bases.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Chris Angelico
On Wed, Feb 19, 2014 at 8:44 AM, Rick Johnson
 wrote:
> Are you telling me you're willing to search through a single
> file containing 3,734 lines of code (yes, Tkinter) looking
> for a method named "destroy" of a class named "OptionMenu"

Yeah, actually I am. At my last job, I had a single C++ file of
roughly 5K lines, and it wasn't at all unmanageable. Probably wouldn't
have been a problem to have another order of magnitude on that. What
sort of wimpy text editor are you using that you can't find what
you're looking for in a single large file? Less steps to get to the
file, more searching within the file. Much easier.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Michael Torrie
On 02/17/2014 06:01 AM, Nagy László Zsolt wrote:
> I have a class hierarchy like this:
> 
> Widget <- VisualWidget <- BsWidget
> 
> and then BsWidget has many descendants: Desktop, Row, Column, Navbar etc.
> 
> Widgets can have children. They are stored in a tree. In order to manage 
> the order of widgets, I need methods to append children. (And later: 
> insert or prepend because they also have an order). So I would like to 
> have methods like this:
> 
> BsWidget.AppendNavbar()
> BsWidget.AppendRow(...)

Why not just take advantage of duck typing and have a generic append()
method that takes any kind of widget.  As long as the widget supports
the method calls that BsWidget needs to make on it, you have zero need
of imports in BsWidget.  There's really no need to import other parts of
your widget hierarchy. That is only necessary for the module that
instantiates the objects.

This is one feature of Python I really like and use a lot.  The ability
to completely decouple code units.  Of course you can do similar things
in Java and C++ by using abstract base classes and interfaces.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Tim Chase
On 2014-02-19 08:49, Chris Angelico wrote:
> > Are you telling me you're willing to search through a single
> > file containing 3,734 lines of code (yes, Tkinter) looking
> > for a method named "destroy" of a class named "OptionMenu"  
> 
> At my last job, I had a single C++ file of roughly 5K lines, and
> it wasn't at all unmanageable. Probably wouldn't have been a
> problem to have another order of magnitude on that. What sort of
> wimpy text editor are you using that you can't find what you're
> looking for in a single large file?

Even the venerable "ed" handles files of those sizes without batting
an eye.  I just opened a 2MB XML file (50k lines) in ed and jumped
all around in it with no trouble at all.  It's as simple as

  1;/class OptionMenu/;/def destroy/

in most cases.  If your editor can't help you do simple things like
that, I recommend you find an editor that is at least as good as
ed. :-)

-tkc



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Grant Edwards
On 2014-02-18, Chris Angelico  wrote:
> On Wed, Feb 19, 2014 at 8:44 AM, Rick Johnson
> wrote:
>> Are you telling me you're willing to search through a single
>> file containing 3,734 lines of code (yes, Tkinter) looking
>> for a method named "destroy" of a class named "OptionMenu"
>
> Yeah, actually I am.

Yup.  And there are new-fangled tools like grep and vi/emacs that even
make it easy!

> At my last job, I had a single C++ file of roughly 5K lines, and it
> wasn't at all unmanageable. Probably wouldn't have been a problem to
> have another order of magnitude on that. What sort of wimpy text
> editor are you using that you can't find what you're looking for in a
> single large file? Less steps to get to the file, more searching
> within the file. Much easier.

Definitely.  I've worked on a number C projects where the source code
was pointlessly split up into a whole slew of files.  AFAICT, it
wasn't done to provide separate namespaces or for information hiding
or code reuse. It was just done to piss me off when I'm trying to find
something...

-- 
Grant Edwards   grant.b.edwardsYow! Maybe I should have
  at   asked for my Neutron Bomb
  gmail.comin PAISLEY --
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Grant Edwards
On 2014-02-18, Tim Chase  wrote:
> On 2014-02-19 08:49, Chris Angelico wrote:
>> > Are you telling me you're willing to search through a single
>> > file containing 3,734 lines of code (yes, Tkinter) looking
>> > for a method named "destroy" of a class named "OptionMenu"  
>> 
>> At my last job, I had a single C++ file of roughly 5K lines, and
>> it wasn't at all unmanageable. Probably wouldn't have been a
>> problem to have another order of magnitude on that. What sort of
>> wimpy text editor are you using that you can't find what you're
>> looking for in a single large file?
>
> Even the venerable "ed" handles files of those sizes without batting
> an eye.  I just opened a 2MB XML file (50k lines) in ed and jumped
> all around in it with no trouble at all.  It's as simple as
>
>   1;/class OptionMenu/;/def destroy/
>
> in most cases.  If your editor can't help you do simple things like
> that, I recommend you find an editor that is at least as good as
> ed. :-)

You think you're joking, but there are lot of editors that aren't.

-- 
Grant Edwards   grant.b.edwardsYow! RELATIVES!!
  at   
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Rick Johnson
On Tuesday, February 18, 2014 4:17:48 PM UTC-6, Tim Chase wrote:
> On 2014-02-19 08:49, Chris Angelico wrote:
> > At my last job, I had a single C++ file of roughly 5K lines, and
> > it wasn't at all unmanageable. Probably wouldn't have been a
> > problem to have another order of magnitude on that. What sort of
> > wimpy text editor are you using that you can't find what you're
> > looking for in a single large file?
> Even the venerable "ed" handles files of those sizes without batting
> an eye.  I just opened a 2MB XML file (50k lines) in ed and jumped
> all around in it with no trouble at all.  It's as simple as
>   1;/class OptionMenu/;/def destroy/
> in most cases.  If your editor can't help you do simple things like
> that, I recommend you find an editor that is at least as good as
> ed. :-)

SarcasticSam: Who needs directories anyway when the
hard-drive is already one gigantic directory... THOSE IDIOTS!

Yes Sam, it seems this thread has degenerated into a testosterone
induced contest to determine who can open the largest file,
climb inside, and then jump around the fastest -- MAY THE
BEST MEAT-HEAD WIN!

For the rest of us --of which who respect brains over
brawn-- we'll swallow our foolish pride and wield the
technology of sane structures.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Rotwang

On 18/02/2014 21:44, Rick Johnson wrote:

[...]

Are you telling me you're willing to search through a single
file containing 3,734 lines of code (yes, Tkinter) looking
for a method named "destroy" of a class named "OptionMenu"
(of which three other classes contain a method of the same
exact name!), when all you needed to do was open one single
module named "tk_optionmenu.py" and do a single search for
"def destroy"?

You must be trolling!


I have music software that's a single 9K-line Python module, which I 
edit using Notepad++ or gedit. If I wish to find e.g. the method "edit" 
of class "sequence" I can type


class seqdef edit(
--
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Rick Johnson
On Tuesday, February 18, 2014 5:28:21 PM UTC-6, Rotwang wrote:
> I have music software that's a single 9K-line Python module, which I 
> edit using Notepad++ or gedit. If I wish to find e.g. the method "edit" 
> of class "sequence" I can type
>  class seqdef edit(https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread MRAB

On 2014-02-18 23:28, Rotwang wrote:

On 18/02/2014 21:44, Rick Johnson wrote:

[...]

Are you telling me you're willing to search through a single
file containing 3,734 lines of code (yes, Tkinter) looking
for a method named "destroy" of a class named "OptionMenu"
(of which three other classes contain a method of the same
exact name!), when all you needed to do was open one single
module named "tk_optionmenu.py" and do a single search for
"def destroy"?

You must be trolling!


I have music software that's a single 9K-line Python module, which I
edit using Notepad++ or gedit. If I wish to find e.g. the method "edit"
of class "sequence" I can type

  class seqdef edit(


I use EditPad Pro. It has a File Navigator, which gives a hierarchical
view of functions, classes and methods.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Rotwang

On 18/02/2014 23:41, Rick Johnson wrote:

On Tuesday, February 18, 2014 5:28:21 PM UTC-6, Rotwang wrote:


[snipped material restored for context]


On 18/02/2014 21:44, Rick Johnson wrote:

[...]

Are you telling me you're willing to search through a single
file containing 3,734 lines of code (yes, Tkinter) looking
for a method named "destroy" of a class named "OptionMenu"
(of which three other classes contain a method of the same
exact name!), when all you needed to do was open one single
module named "tk_optionmenu.py" and do a single search for
"def destroy"?

You must be trolling!


I have music software that's a single 9K-line Python module, which I
edit using Notepad++ or gedit. If I wish to find e.g. the method "edit"
of class "sequence" I can type
  class seqdef edit(

This is not about "how to use a search function"


No, it's about your incredulity that someone would search for a method 
in a large file that contains several methods of the same name. However, 
the existence of search functions makes this completely trivial.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Bad Code Snippet of the Day

2014-02-18 Thread Roy Smith
In article ,
 Terry Reedy  wrote:

> On 2/18/2014 11:47 AM, Chris Angelico wrote:
> > I call this "Russian Exception Roulette". It came about because of
> > some discussions on python-ideas regarding the new PEP 463 and
> > exception handling.
> >
> > try:
> >  exc = getattr(__builtins__,random.choice(list(filter(lambda x:
> > x.endswith("Error"),dir(__builtins__)
> >  f()
> > except exc:
> >  print("You win!")
> >
> > Given a function f(), defined elsewhere, what will this do?
> 
> I am not sure what you are asking or what your point is. If f happens to 
> raise the randomly selected exception, it prints 'You win!', otherwise 
> it does nothing.

def f():
   print("You win!")

problem solved :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Chris Angelico
On Wed, Feb 19, 2014 at 9:17 AM, Tim Chase
 wrote:
> On 2014-02-19 08:49, Chris Angelico wrote:
>> > Are you telling me you're willing to search through a single
>> > file containing 3,734 lines of code (yes, Tkinter) looking
>> > for a method named "destroy" of a class named "OptionMenu"
>>
>> At my last job, I had a single C++ file of roughly 5K lines, and
>> it wasn't at all unmanageable. Probably wouldn't have been a
>> problem to have another order of magnitude on that. What sort of
>> wimpy text editor are you using that you can't find what you're
>> looking for in a single large file?
>
> Even the venerable "ed" handles files of those sizes without batting
> an eye.  I just opened a 2MB XML file (50k lines) in ed and jumped
> all around in it with no trouble at all.

It's not just about whether your editor can handle a file of that
size, of course [1], but how well they help you find your way around
the codebase.

But ultimately, you're going to have those KLOC somewhere. Whether
they're in one file, a small handful of files, or eight hundred
separate tiny .PHP files (UGH UGH UGH UGH! and yes that was a real
thing and yes I had to search through it wince wince!), you somehow
need to find the one line you want out of, let's say, 50K. That's a
fairly small project by a lot of standards. Somehow, you need to find
one particular function. It might be named beautifully, in which case
a grep-across-files will do the job, or it might not. Maybe you can
see, as a human, that one of the subbranches MUST contain what you're
looking for (one file, or one directory, or something); but that often
requires knowledge of the codebase, which you mightn't have. So
splitting into files doesn't solve anything, and it introduces its own
set of problems.

Just for reference, here are a few line counts. They're based on "find
-name \*.FILE_EXT|xargs wc -l" in the base directories of several
projects (using an appropriate extension, as listed).

Small projects:
Proprietary project at my last job, *.cpp: 4782 (one file)
Same project, *.pike: 6559
Gypsum (open source MUD client), *.pike: 5083

Medium size projects:
CPython/Python, *.c: 55329
alsa-lib, *.c: 91131
SciTE, *.cxx: 114785 (34876 + Scintilla's 79909)
Pike, *.pike: 138705

Large projects:
Pike, *.c: 298773
CPython/Lib, *.py: 318232

(See how much of Python is written in Python? Although I can't help
feeling that my figures are wrong somehow. And that figure is ignoring
the test/ subdirectory with another 267872 lines for a total of
586104.)

I've done "search across files" in all of these, bar alsa-lib which I
line-counted just because it happened to be there. (Incidentally, I'm
fully aware that some of those figures are unfair. overall, I'd say
Pike and Python are comparable-sized projects, but Python's more
heavily written in Python and Pike's more heavily written in C, partly
by using a precompiler that's somewhat along the lines of Cython.
Scintilla includes a whole bunch of individual language lexers, and
it's usually pretty clear that you don't need to look in any of those.
Etc, etc.) It's usually been easy enough to find what I want; in fact,
the few times when it _hasn't_ have generally turned out to be because
of bugs (something had "desrtuct" instead of "destruct" in its name
and I of course couldn't find it). SciTE's search-across-files isn't
the best, but it covers 99%+ of my use cases. For anything else, well,
there's always popping up a terminal and using primitives like grep,
find, and so on.

ChrisA

[1] But as Grant hinted, some do have issues.
-- 
https://mail.python.org/mailman/listinfo/python-list


SMITHSONIAN DOWN AND BLEEDING -- THE THRINAXODON TIMES

2014-02-18 Thread SAINT THRINAXODON
==
>BREAKING NEWS
==
>
SMITHSONIAN FINALLY SHUT DOWN AFTER YEARS OF CENSORSHIP, SCAMS AND CON ARTISTRY.
>
THRINAXODON BLEW DOWN THE BUILDINGS, LIT IT ON FIRE AND HAD THE ASSHOLES 
ARRESTED.
>
R. DAWKINS WAS THROWN IN THE DOGHOUSE, ONLY TO GET KILLED BY ANGRY FELONS WHO 
WANTED PAYBACK FOR FRAMING THEM.
>
THRINAXODON DANCED ON DAWKINS' GRAVE, AND BURNED A FEW SMITHSONIAN MAGAZINES.
>
=
EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN:

https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f#

https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82#



http://thrinaxodon.wordpress.com/

===

THRINAXODON ONLY HAD THIS TO SAY:

"I..I...I...Can't believe it. This completely disproved Darwinian
orthodoxy."

===

THE BASTARDS AT THE SMITHSONIAN, AND THE LEAKEY FOUNDATION ARE ERODING
WITH FEAR.

===
THESE ASSHOLES ARE GOING TO DIE:
THOMAS AQUINAS;
ALDOUS HUXLEY;
BOB CASANVOVA;
SkyEyes;
DAVID IAIN GRIEG;
MARK ISAAK;
JOHN HARSHAM;
RICHARD NORMAN;
DR. DOOLITTLE;
CHARLES DARWIN;
MARK HORTON;
ERIK SIMPSON;
HYPATIAB7;
PAUL J. GANS;
JILLERY;
WIKI TRIK;
THRINAXODON;
PETER NYIKOS;
RON OKIMOTO;
JOHN S. WILKINS
===

THRINAXODON WAS SCOURING ANOTHER DEVONIAN FOSSIL BED, AND FOUND A
HUMAN SKULL, AND A HUMAN FEMUR. HE ANALYSED THE FINDS, AND SAW THAT
THEY WERE NOT NORMAL ROCKS. THESE WERE FOSSILIZED BONES. THEY EVEN HAD
TOOTH MARKS ON THEM. SO, THRINAXODON BROUGHT THEM TO THE LEAKEY
FOUNDATION, THEY UTTERLY DISMISSED IT, AND SAID, "We want to keep
people thinking that humans evolved 2 Ma." THRINAXODON BROUGHT HIS
SWORD, AND SAID, "SCIENCE CORRECTS ITSELF." RICHARD LEAKEY SAID, "That
is a myth, for people to believe in science." THRINAXODON PLANS TO
BRING DOOM TO SCIENCE, ITSELF.



THRINAXODON IS NOW ON TWITTER.

==
>
THRINAXODON WAS AWARDED 
US$100,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 
DOLLARS FOR HIS BRAVE EFFORTS IN SHUTTING DOWN THE EVOLUTIONARY SCAMS. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Wheezy.web - is it been developed?

2014-02-18 Thread Marcio Andrey Oliveira
Hi.

I stumbled upon Wheezy.web and I got interested into learn more about it.

After googling I didn't find that many information about it: only docs and
samples from its web site.

I didn't find a mailing list nor user groups and no tutorials from its
users.

Is Wheezy.web been actively developed? Does it have any user base community
that I could get in touch with? Or should I forget about it and stick to
say flask or pyramid?

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Turning an AST node / subnodes into something human-readable

2014-02-18 Thread Chris Angelico
I'm working with the ast module to do some analysis on Python
codebases, and once I've found what I'm looking for, I want to print
something out. The file name I'm hanging onto externally, so that
works; and the nodes all have a lineno. So far so good. But how do I
"reconstitute" a subtree into something fit for human consumption?

Take this cut-down example:

module = ast.parse("x[1] = 345+456")
assign = list(ast.walk(module))[1]
destination = assign.targets[0]

At this point, destination is the subtree representing what's being
assigned to. I can get a verbose dump of that:

>>> print(ast.dump(destination))
Subscript(value=Name(id='x', ctx=Load()), slice=Index(value=Num(n=1)),
ctx=Store())

but what I'd really like to do is get something that looks
approximately like "x[1]". Is there an easy way to do that? Its str
and repr aren't useful, and I can't see a "reconstitute" method on the
node, nor a function in ast itself for the job. In theory I could
write one, but it'd need to understand every node type, so it seems
the most logical place would be on the node itself - maybe in __str__.

Is there anything nice and easy? I don't care if it's not perfect, as
long as it's more readable than ast.dump(). :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help creating new module which inherits existing class from another module.

2014-02-18 Thread Jonno
Ben,

Thanks for your reply. I'll try to ellaborate a little more in the comments
below.


On Tue, Feb 18, 2014 at 2:47 PM, Ben Finney wrote:

> Jonno  writes:
>
> > I'm not sure if this list is a suitable place to ask for this kind of
> > help so if it's not please just suggest another forum which might be
> > more suitable.
>
> Welcome! Asking for help with writing Python code is definitely suitable
> here.
>
> > I'm looking for help/suggestions how to architect a module (perhaps
> > just a class).
>
> Right, I don't see anything in your request that indicates why a new
> module would be needed.
>

Only that eventually I might want to distribute this and include some other
features.

>
> > There is an existing module I want to use which has a class we'll call
> > *Existing Class*.
> >
> > I want to create a python module which allows me to create
> > *new_objects*
>
> This is all rather abstract. Can you explain what the existing class is
> for? What the new class is for?
>
> Well I was trying to keep it as generic as possible and only introduce the
necessary features. It's possible I've left out something important though.


> > with the following properties:
> >
> >- The new_objects have all the attributes of the Existing_Class
> (simply
> >create a class that inherits from Existing_Class)
>
> The syntax for that is::
>
> class Bar(Foo):
> ...
>
> where "Foo" is the existing class, "Bar" is the class you're defining.
>
> It's not strictly true to say that Bar will thereby "have all the
> attributes of" the existing class. Rather, the resolution chain will
> mean that accessing attributes on Bar will fall-back to looking at Foo
> for attributes not found in Bar.
>
> Point taken.


> >- I then want to create a nested structure under the new_objects
> >something like:
> >
> > new_object.foo
> > new_object.foo.bar
> > new_object.foo.bar.baz
>
> Again, it's not clear why you're doing this. What are these attributes for?
>

I tried to explain the necessary properties in the requirements below.
Really the main function of creating this new module is to add the
docstring & tab completion capabilities. Essentially it's a way to create
an explorable structure of elements with documentation. If you have other
suggestions how to achieve that I'd be interested.
.

>
> > Where foo, bar, baz have the following properties:
> >
> >- All have *docstrings*
>
> Docstrings are only for code objects: modules, classes, functions. Will
> each of those attributes be one of those?
>
> Only because I'd like them to have docstring attributes.


> >- All are available for *tab completion* tools upon new_object
> creation.
>
> Tab completion is up to the interactive tool you're using. Which tool is
> that?
>
>
For me ipython but I'd like it to work in other tools so the more general
the better.


> >-
> >Some of which will have *new methods* which act in the following way:
> >- new_object.foo.bar()
> >
> >calls
> >- new_object.existing_method("foo.bar", *args)
>
> This would be an unusual semantic. Why not call the existing method?
>
> Basically right now the user has to look up external documentation to
figure out which arguments (foo, bar etc) are necessary and there are many
of them in a nested structure. I'd like to create a module that they can
explore within an enhanced python editor/interpreter.


> > Any pointers would be greatly appreciated.
>
> I am smelling the likelihood that you have a strange design that needs
> to be examined and changed. Can you describe what your purpose is that
> you think needs this strange architecture?
>
>
Hopefully my comments help some.
I'm definitely not opposed to changing the architecture but the main
objectives of documentation & explorability (yes I know that's not a real
word) are top priority.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help creating new module which inherits existing class from another module.

2014-02-18 Thread Ben Finney
Jonno  writes:

> I tried to explain the necessary properties in the requirements below.

What you've described is a bunch of abstract behaviour.

But as I said, I'm suspecting this is a poor design; and I can't know
better until you explain what all this is *for*.

What is the purpose of the code you're writing? What is special about it
that makes you think it needs the specific properties you've described?

I ask all this because I suspect there are better and/or simpler ways to
achieve your *actual* goals. Maybe not; but to rule that out, I'd need
to know more about the purpose.

-- 
 \  “It is the integrity of each individual human that is in final |
  `\examination. On personal integrity hangs humanity's fate.” |
_o__)   —Richard Buckminster Fuller, _Critical Path_, 1981 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a question about list as an element in a tuple

2014-02-18 Thread John O'Hagan
On Mon, 16 Dec 2013 11:30:13 +0800
liuerfire Wang  wrote:

> Just like below:
> 
> In [1]: a = ([], [])
> 
> In [2]: a[0].append(1)
> 
> In [3]: a
> Out[3]: ([1], [])
> 
> In [4]: a[0] += [1]
> ---
> TypeError Traceback (most recent call
> last)  in ()
> > 1 a[0] += [1]
> 
> TypeError: 'tuple' object does not support item assignment
> 
> In [5]: a
> Out[5]: ([1, 1], [])
> 
> no problem, there is an exception. But a is still changed.
> 
> is this a bug, or could anyone explain it?
> 
> thanks.
> 

This thread from two years ago deals with this in some detail:

https://mail.python.org/pipermail/python-list/2012-February/619265.html

It's one of those things that is hard to resolve in a way that makes
sense in every situation. The weirdest part for me is this:

>>> t = ([],)
>>> l = t[0]
>>> l is t[0]
True
>>> l += [1]
>>> t[0] += [1]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'tuple' object does not support item assignment

Whether there is an error or not depends on the name used for the
object!

--

John


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wheezy.web - is it been developed?

2014-02-18 Thread Andriy Kornatskyy
Marcio,

The wheezy.web framework (http://bitbucket.org/akorn/wheezy.web) supplies 
documentation, tutorials, quick starts and benchmark for you. Due to modular 
architecture, it is being developed in several independent loosely coupled 
libraries under wheezy.*. The source code is easy to read, there is 100% test 
coverage.

No bells and whistles.

I believe the web framework should not be something cryptic (requiring 
community to exchange ideas about workarounds) nor something that involves 
infinitive development cycle.

If you have any questions I will be happy to answer in this mailing list or 
personally.

Thanks.

Andriy Kornatskyy

On Feb 19, 2014, at 1:48 AM, Marcio Andrey Oliveira  wrote:

> Hi.
> 
> I stumbled upon Wheezy.web and I got interested into learn more about it.
> 
> After googling I didn't find that many information about it: only docs and 
> samples from its web site.
> 
> I didn't find a mailing list nor user groups and no tutorials from its users.
> 
> Is Wheezy.web been actively developed? Does it have any user base community 
> that I could get in touch with? Or should I forget about it and stick to say 
> flask or pyramid?
> 
> Thank you.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Steven D'Aprano
On Tue, 18 Feb 2014 15:41:32 -0800, Rick Johnson wrote:

> Heck, when a class gets too big i even export some of the methods to
> outside modules and load the methods dynamically at run-time just to cut
> down on the length. I suppose my detractors would find that surprising
> also!

Not in the least bit surprising. I expected nothing less from you.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import order question

2014-02-18 Thread Steven D'Aprano
On Tue, 18 Feb 2014 13:44:47 -0800, Rick Johnson wrote:

> Are you telling me you're willing to search through a single file
> containing 3,734 lines of code (yes, Tkinter) looking for a method named
> "destroy" of a class named "OptionMenu" (of which three other classes
> contain a method of the same exact name!), when all you needed to do was
> open one single module named "tk_optionmenu.py" and do a single search
> for "def destroy"?

How do you know that the module tk_optionmenu.py contains the class 
OptionMenu? Perhaps it contains the function optionmenu. Or the class 
TK_OptionMenu. 

For a mere 4000 lines of code, yes, I'd rather have it all in the one 
file, presuming that they are all related pieces of code. Much, much, 
much easier to search, edit and maintain; avoids circular imports and 
other dependency problems.

If there are parts of that module that stand alone, then arguably they 
ought to be extracted out into a separate module. But other than that, 
4000 lines of code isn't so big that we should be splitting the file 
apart merely for the size.


[...]
> But even if this were not an API, breaking large chunks of code up and
> spreading them across individual files is the key to managing code
> bases.

You left out the word "badly".


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help creating new module which inherits existing class from another module.

2014-02-18 Thread Steven D'Aprano
On Tue, 18 Feb 2014 14:34:51 -0600, Jonno wrote:

> There is an existing module I want to use which has a class we'll call
> *Existing Class*.
> 
> I want to create a python module which allows me to create *new_objects*
> with the following properties:
> 
>- The new_objects have all the attributes of the Existing_Class
>(simply create a class that inherits from Existing_Class) 

That part is easy:

from some_module import ExistingClass

class NewClass(ExistingClass):
pass

newobject = NewClass()


>- I then
>want to create a nested structure under the new_objects something
>like:
> 
> new_object.foo
> 
> new_object.foo.bar
> 
> new_object.foo.bar.baz
> 
> Where foo, bar, baz have the following properties:
> 
>- All have *docstrings*
>- All are available for *tab completion* tools upon new_object
>creation. 

Well, that depends on the tab completion tools you are using.


>- Some of which will have *new methods* which act in the following
>way:
>- new_object.foo.bar()
> 
>calls
>- new_object.existing_method("foo.bar", *args)


Seems awfully complicated, and I don't understand what you would do with 
these strange things, but okay.

Start by ignoring the "existing class" and concentrated on these foo, 
foo.bar, foo.bar.baz things. It isn't clear to me what they are, but I 
think that you want foo to be an object which is callable, as well as 
having an attribute bar (which itself is callable, etc.). The way to do 
that is with a class:

class FooClass:
def __init__(self, parent):
self.parent = parent

def __call__(self):
return self.parent.existing_method("something")

Add your foo, bar and baz methods as needed, and we'll look for a way to 
calculate "something" on the fly later.


Now remember your NewClass definition above? What we'd like to do is this:

class NewClass(ExistingClass):
foo = FooClass(self)

but of course you can't, because self doesn't exist until the class is 
instantiated! So what we need if for foo to be a descriptor. I don't 
quite remember the descriptor syntax, so this may be wrong, but I think 
you want something like this:

# This is probably wrong.
class FooDescriptor(object):
def __get__(self, cls, obj):
return FooClass(obj)

and then in NewClass you put in:

foo = FooDescriptor()


The idea is that when you have a NewClass instance, calling 
"newobject.foo" will automatically call the descriptor's __getmethod__, 
passing it the class and instance. That descriptor will create and 
populate the FooClass instance, which does the real work.

Descriptors are how methods, classmethods, staticmethods and properties 
work, so they are a fundamental, powerful way of implementing things like 
this.

-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list