What is the pattern for this number set?

2018-07-18 Thread no
This is a chart I made using BASIC back in the 90s when I could still
do math and programming.
I would like to have a new print out of this chart but I no longer can
figure out programming or math.
Anyone care to figure out the pattern and make a new copy of the
chart?

https://imgur.com/a/thF6U43
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the pattern for this number set?

2018-07-18 Thread no
On Wed, 18 Jul 2018 18:43:18 -0400, no@none.invalid wrote:

>On Wed, 18 Jul 2018 17:16:21 -0400, no@none.invalid wrote:
>
>>This is a chart I made using BASIC back in the 90s when I could still
>>do math and programming.
>>I would like to have a new print out of this chart but I no longer can
>>figure out programming or math.
>>Anyone care to figure out the pattern and make a new copy of the
>>chart?
>>
>>https://imgur.com/a/thF6U43
>
>
>I don't remember how I did it.
>It is from the game Empire.  There is a new version of it on Steam
>called Empire Deluxe Combined Edition.
>I played the game relentlessly from the 90s until I upgraded to Win7.
>The Windows version would not run on Win7.
>The cities have production times in multiples of 3 and then you get a
>10% bonus if you keep building the same type unit.  100 percent is
>never the optimal number but that was a base amount.
>
>If you are bored the game cost about 18 bucks on Steam and I like to
>play multi player.
>
>
>The cities start at a random efficiency amount.  If you chose not to
>build anything the city efficiency goes up by 1 per turn (until 100;
>after 100 city's efficiency takes more than one turn) so you can
>prolong production to get a faster build unit later.
>
>The chart is what turn is the best city amount after the 10% bonus. 
>
>So at a 100 percent the armor takes 12 to build and it drops to 10
>after the first unit is built.  So a city at 85% will yield it's
>second unit at 12 turns.  If you wait until the city is at 87% the
>second unit will be built at 11 turns.  You have to pump production up
>to 96% to get the second unit at 10 turns.
>
>An infantry takes 6 @ 100%
>A destroyer takes 24 @ 100%
>A cruiser takes 36 @ 100%
>A battleship takes 53 @ 100% <  not multiple of 3 ?

Bad number, but they are not all multiples of 3

>A carrier takes 48 @ 100%
> 
>
>That is about all I can remember.

Here are all the old units and new units from the new game.
The chart would be much larger with the new units but I would be happy
with just the old numbers.

https://imgur.com/a/6mFRaNc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the pattern for this number set?

2018-07-18 Thread no
On Wed, 18 Jul 2018 17:16:21 -0400, no@none.invalid wrote:

>This is a chart I made using BASIC back in the 90s when I could still
>do math and programming.
>I would like to have a new print out of this chart but I no longer can
>figure out programming or math.
>Anyone care to figure out the pattern and make a new copy of the
>chart?
>
>https://imgur.com/a/thF6U43


I don't remember how I did it.
It is from the game Empire.  There is a new version of it on Steam
called Empire Deluxe Combined Edition.
I played the game relentlessly from the 90s until I upgraded to Win7.
The Windows version would not run on Win7.
The cities have production times in multiples of 3 and then you get a
10% bonus if you keep building the same type unit.  100 percent is
never the optimal number but that was a base amount.

If you are bored the game cost about 18 bucks on Steam and I like to
play multi player.


The cities start at a random efficiency amount.  If you chose not to
build anything the city efficiency goes up by 1 per turn (until 100;
after 100 city's efficiency takes more than one turn) so you can
prolong production to get a faster build unit later.

The chart is what turn is the best city amount after the 10% bonus. 

So at a 100 percent the armor takes 12 to build and it drops to 10
after the first unit is built.  So a city at 85% will yield it's
second unit at 12 turns.  If you wait until the city is at 87% the
second unit will be built at 11 turns.  You have to pump production up
to 96% to get the second unit at 10 turns.

An infantry takes 6 @ 100%
A destroyer takes 24 @ 100%
A cruiser takes 36 @ 100%
A battleship takes 53 @ 100% <  not multiple of 3 ?
A carrier takes 48 @ 100%
 

That is about all I can remember.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the pattern for this number set?

2018-07-18 Thread no
On Wed, 18 Jul 2018 18:43:18 -0400, no@none.invalid wrote:

>On Wed, 18 Jul 2018 17:16:21 -0400, no@none.invalid wrote:
>
>>This is a chart I made using BASIC back in the 90s when I could still
>>do math and programming.
>>I would like to have a new print out of this chart but I no longer can
>>figure out programming or math.
>>Anyone care to figure out the pattern and make a new copy of the
>>chart?
>>
>>https://imgur.com/a/thF6U43
>
>
>I don't remember how I did it.
>It is from the game Empire.  There is a new version of it on Steam
>called Empire Deluxe Combined Edition.
>I played the game relentlessly from the 90s until I upgraded to Win7.
>The Windows version would not run on Win7.
>The cities have production times in multiples of 3 and then you get a
>10% bonus if you keep building the same type unit.  100 percent is
>never the optimal number but that was a base amount.
>
>If you are bored the game cost about 18 bucks on Steam and I like to
>play multi player.
>
>
>The cities start at a random efficiency amount.  If you chose not to
>build anything the city efficiency goes up by 1 per turn (until 100;
>after 100 city's efficiency takes more than one turn) so you can
>prolong production to get a faster build unit later.
>
>The chart is what turn is the best city amount after the 10% bonus. 
>
>So at a 100 percent the armor takes 12 to build and it drops to 10
>after the first unit is built.  So a city at 85% will yield it's
>second unit at 12 turns.  If you wait until the city is at 87% the
>second unit will be built at 11 turns.  You have to pump production up
>to 96% to get the second unit at 10 turns.
>
>An infantry takes 6 @ 100%
>A destroyer takes 24 @ 100%
>A cruiser takes 36 @ 100%
>A battleship takes 53 @ 100% <  not multiple of 3 ?
>A carrier takes 48 @ 100%
> 
>
>That is about all I can remember.

I think I was wrong about the 10%  The instructions say..

Continue Production Reduction – For every unit produced in a city
there is a timed production cost in turns. With this rule enabled,
after the first unit has been produced, if the type remains the same,
each additional unit of this type will be produced at a different
(traditionally one-sixth lower) rate
-- 
https://mail.python.org/mailman/listinfo/python-list


copy and paste with a program called clipboard

2018-07-19 Thread no
I just installed Python 3.7
The instructions say to highlight some text and press enter to copy
text.
You are supposed to just right click with the mouse to paste text.

I use a very useful program called Clipmate that captures from the
clipboard and keeps a list of clipboard captures and I can menu pick
what I want to paste from the clipboard.

This doesn't not seem to be working as nothing happens when I try to
select text and right click in the command window with the mouse.

Ctrl V doesn't work either.

Is this a bug?  Is there a workaround?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: copy and paste with a program called clipboard

2018-07-19 Thread no
On Thu, 19 Jul 2018 17:35:24 +0100, MRAB 
wrote:

>On 2018-07-19 16:47, no@none.invalid wrote:
>> I just installed Python 3.7
>> The instructions say to highlight some text and press enter to copy
>> text.
>> You are supposed to just right click with the mouse to paste text.
>> 
>> I use a very useful program called Clipmate that captures from the
>> clipboard and keeps a list of clipboard captures and I can menu pick
>> what I want to paste from the clipboard.
>> 
>> This doesn't not seem to be working as nothing happens when I try to
>> select text and right click in the command window with the mouse.
>> 
>> Ctrl V doesn't work either.
>> 
>> Is this a bug?  Is there a workaround?
>> 
>I'm assuming you're using Windows.
>
>It might be that the console window's properties need changing:
>
>1. Right-click on the title bar.
>
>2. Click on Properties.
>
>3. In the Options tab, turn on QuickEdit Mode.
>
>4. Click OK.

I am using Windows7.  When I run the command line thingy it
says...Python 3.7.0 64 bit.

When I try to turn on QuickEdit I get this error message.

https://imgur.com/a/kuxiNHv

When I installed Python, I picked integrate with shell and add to
path.
-- 
https://mail.python.org/mailman/listinfo/python-list


Edit with IDLE pull down menu

2018-07-19 Thread no
Edit with IDLE pull down menu has one item.
Why would you have nested menu with only one choice?

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


Re: Edit with IDLE pull down menu

2018-07-19 Thread no
On Thu, 19 Jul 2018 13:15:23 -0700 (PDT), Rick Johnson
 wrote:

>n...@none.invalid wrote:
>> Edit with IDLE pull down menu has one item.
>> Why would you have nested menu with only one choice?
>
>Oh, i dunno, i'm just riffing here, but... perhaps because the menu's 
>_contents_ depend on _context_???

It says...Edit with IDLE and the pull down choice is Edit with
IDLE.
Do you have an example of what else might be in the Edit with IDLE
menu?

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


Re: Edit with IDLE pull down menu

2018-07-19 Thread no
On Thu, 19 Jul 2018 14:00:39 -0700 (PDT), Rick Johnson
 wrote:

>n...@none.invalid wrote:
>> Rick Johnson wrote:
>> >n...@none.invalid wrote:
>> > >
>> > > Edit with IDLE pull down menu has one item. Why would you
>> > > have nested menu with only one choice?
>> >
>> > Oh, i dunno, i'm just riffing here, but... perhaps because
>> > the menu's _contents_ depend on _context_???
>> 
>> It says...Edit with IDLE and the pull down choice is
>> Edit with IDLE. Do you have an example of what else might
>> be in the Edit with IDLE menu?
>
>I dunno, as usual you don't offer enough _context_.
>
>
>WORD OF THE DAY, KIDS: "Context".
>
>
>Now, where is this offending "pull-down menu" located? 
>
> * As a "me-right-clicks-a-file-icon" OS menu?
> 
> * An a menu of a specific program like IDLE?
> 
> * On a moon made from blue cheese?
> 
>Can you help us out here?
>
I keep forgetting that Python is cross platform.
I use Windows 7.
After installing Python you can right click on a .py file and you get
a pull down menu.
The option for Edit with IDLE has an expanding menu.  The only item in
the pull down menu is..Edit with IDLE.

So to run a .py program, you have to right click and select the pull
down menu Edit with IDLE and then inside that menu you pick Edit with
IDLE.  Seems a little redundant.
-- 
https://mail.python.org/mailman/listinfo/python-list


CASESOLUTIONSCENTRE (AT) GMAIL (DOT) COM

2018-07-19 Thread no
Gee.   If those spams keep up, you would think that someone might try
to turn the tables on the spammer.

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


Re: Edit with IDLE pull down menu

2018-07-19 Thread no
On Thu, 19 Jul 2018 18:25:41 -0400, Dennis Lee Bieber
 wrote:

>On Thu, 19 Jul 2018 17:40:16 -0400, no@none.invalid declaimed the
>following:
>
>>
>>So to run a .py program, you have to right click and select the pull
>>down menu Edit with IDLE and then inside that menu you pick Edit with
>>IDLE.  Seems a little redundant.
>
>   No... In a properly configured system, to RUN a .py program, you just
>double-click it. It will likely open a system console for stdout (a .pyw
>file is commonly used for Python scripts that do not make use of
>stdin/stdout/stderr -- ie; a program written using one of the graphical
>toolkits).
>
>   Since I have always used ActiveState builds, my context menu has "Edit
>with PythonWin" and does NOT have any mention of IDLE.

I wasn't trying to run a Python program.  I wanted to Edit it with
IDLE.

When I said "run the program" I was talking about IDLE.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: copy and paste with a program called clipboard

2018-07-19 Thread no
On Thu, 19 Jul 2018 23:35:05 +, eryk sun 
wrote:

>On Thu, Jul 19, 2018 at 6:49 PM,   wrote:
>> On Thu, 19 Jul 2018 17:35:24 +0100, MRAB 
>> wrote:
>>
>>>I'm assuming you're using Windows.
>>>
>>>It might be that the console window's properties need changing:
>>>
>>>1. Right-click on the title bar.
>>>
>>>2. Click on Properties.
>>>
>>>3. In the Options tab, turn on QuickEdit Mode.
>>>
>>>4. Click OK.
>>
>> I am using Windows7.  When I run the command line thingy
>
>It's called a console, which is a special window for command-line and
>text-interface applications. The Windows API includes functions that
>allow a process to attach to or allocate a console, read from and
>write to it for standard input & output (i.e. stdin, stdout, stderr),
>and low-level functions that allow creating complex text interfaces
>such as text editors (e.g. nano) and file managers (e.g. Far Manager).
>In Windows 7+, each console is hosted by an instance of conhost.exe.
>The console host process runs in the same security context (i.e. user,
>groups, integrity level, and privileges) as the process that allocates
>the console.
>
>python.exe is a console application, which means that it automatically
>attaches to the console of the parent process or allocates a new
>console if the parent doesn't have one.
>
>> When I try to turn on QuickEdit I get this error message.
>
>The console host failed to modify the shortcut. This is probably
>because the .LNK file was installed for all users, and the current
>user only has read & execute access. Administrators should have full
>access to this file. To run with administrator access, right-click the
>shortcut and choose "Run as administrator".
>
>FYI, the console's default settings for the current user are in the
>registry key "HKCU\Console". On the control menu, this is what the
>"Defaults" dialog modifies. The "Properties" dialog modifies the
>settings for the current window, which override the default settings.
>The current-window settings are stored based on the initial window
>title. If an application is run from a .LNK shortcut, the Windows
>shell sets the initial title in the process startup info as the
>fully-qualified path to the .LNK file and sets a flag that indicates
>this. In this case, the console knows that the current properties
>should be read from and written to the .LNK file. If the application
>is run directly instead of using a shortcut, then the console stores
>the properties in the registry key "HKCU\Console\[window title]". A
>custom window title can be set using CMD's `start` command. If no
>custom title is set, the default title is the fully-qualified path of
>the executable, which the console normalizes to make it suitable for
>use as a registry key (e.g. replace backslash with underscore).

I was able to run the program as administrator I changed the setting
so I can now copy and paste.

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


Re: Edit with IDLE pull down menu

2018-07-20 Thread no
On Fri, 20 Jul 2018 03:19:16 -0400, Terry Reedy 
wrote:

>On 7/19/2018 5:40 PM, no@none.invalid wrote:
>
>> The option for Edit with IDLE has an expanding menu.  The only item in
>> the pull down menu is..Edit with IDLE.
>
>What I see is Edit with IDLE 3.7.  There should be an entry for each 
>Python installed.  Since that is the reason for the 2nd menu, and used 
>to be the case, it is a bug that there is not.  I will later check the 
>tracker and maybe open an issue.
>
>> So to run a .py program, you have to right click and select the pull
>> down menu Edit with IDLE and then inside that menu you pick Edit with
>> IDLE.  Seems a little redundant.

You seem to be able to directly affect Python development.  If that is
true, maybe you could remove the pull down redundancy from one menu
and add a pull down option to another pull down menu.

If Python can modify the pull down menus, it would be nice to be able
to right click in a folder (Windows) and have an option to create a
new python file with a .py extension like you can create a new text
document with a .txt extension.

OpenOffice adds this option to create new OO files.

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


PyCharm

2018-07-20 Thread no
Win7

I was watching some tutorial videos on Python that recommended I use
PyCharm and it worked pretty well until I tried to use input.

I found this:
https://youtrack.jetbrains.com/issue/PY-27891

It says..
Pavel Karateev   commented 10 Jan 2018 11:57
Hi Calvin Broadus! I am sorry for the inconvenience, this is the
problem on PyCharm side, the fix is in progress, should be included in
the next minor update 2017.3.3, release candidate build is planned on
this week.

Since I just installed the program yesterday, I assume that the fix
has not been implemented yet.

Most of my practice programs I always just enter a set value for
inputs instead of taking inputs from the keyboard, but I would like to
pause so find out why my program is broken.

Is there another way to insert a pause that will work with PyCharm?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Edit with IDLE pull down menu

2018-07-21 Thread no
On Sat, 21 Jul 2018 08:52:45 -0700 (PDT), Rick Johnson
 wrote:

>n...@none.invalid wrote:
>> Terry Reedy wrote:
>
>[...]
>
>> You seem to be able to directly affect Python development.
>> If that is true, maybe you could remove the pull down
>> redundancy from one menu and add a pull down option to
>> another pull down menu.  If Python can modify the pull down
>> menus, it would be nice to be able to right click in a
>> folder (Windows) and have an option to create a new python
>> file with a .py extension like you can create a new text
>> document with a .txt extension.  OpenOffice adds this
>> option to create new OO files.
>
>Hmm, your idea is not terribly awful, but, you should
>consider that if a "Make New file.XXX" command was added to
>the file system context menu for _every_ possible file-type,
>*ZOINKS*, that'd be a frighteningly long list of commands to
>scroll through! And then, after creating the empty file in
>this manner, you'd still have to open the file for editing.
>Thus, a two step process.
>
>A better solution is to use an IDE. Sure, you may have to
>navigate to the appropriate directory, but once you're
>there, any new documents created from the interface (aka:
>"File->New") will default to the current working directory.

I don't remember if OO ever asked for permission, but Winrar did.

I would hope that install programs asked for permission before adding
something like this.  And take it with them when they leave.


The reason I find this useful is because most of my practice programs
so far "import random".  I have a shell file that I keep and I copy it
to a blank file to start another practice problem.  If I try to just
"save as" something else, I forget sometimes.


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


Re: Edit with IDLE pull down menu

2018-07-21 Thread no
On Sat, 21 Jul 2018 14:34:15 -0700 (PDT), Rick Johnson
 wrote:

This is really the code I keep copying.

import random
from random import randint
a = [5, 10, 15, 20, 25, 30, 35, 40]
b = ["Rock","Paper","Scissors","Lizard ","Spock"]


I am lazy and don't type well, so I leave out some details when
posting.

I don't know why the program I needed randint for didn't work with
just import random, but I moved on without lingering on it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyCharm

2018-07-22 Thread no
On Sun, 22 Jul 2018 11:51:51 +0200, Chris Warrick 
wrote:

>On Sat, 21 Jul 2018 at 05:17,  wrote:
>>
>> Win7
>>
>> I was watching some tutorial videos on Python that recommended I use
>> PyCharm and it worked pretty well until I tried to use input.
>>
>> I found this:
>> https://youtrack.jetbrains.com/issue/PY-27891
>>
>> It says..
>> Pavel Karateev   commented 10 Jan 2018 11:57
>> Hi Calvin Broadus! I am sorry for the inconvenience, this is the
>> problem on PyCharm side, the fix is in progress, should be included in
>> the next minor update 2017.3.3, release candidate build is planned on
>> this week.
>>
>> Since I just installed the program yesterday, I assume that the fix
>> has not been implemented yet.
>>
>> Most of my practice programs I always just enter a set value for
>> inputs instead of taking inputs from the keyboard, but I would like to
>> pause so find out why my program is broken.
>>
>> Is there another way to insert a pause that will work with PyCharm?
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>
>How does it fail? What PyCharm version are you on?

I have learned that it is not failing, but it doesn't do what I
expected.

When I run a program that has an input statement, the cursor doesn't
move from the edit code to the place in Pycharm where the input
statement is.  I have to click my mouse on the end of the input line
before entering a value.  If I just start typing, the text is inserted
in the code and not in the running part of the program.

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


Re: PyCharm

2018-07-22 Thread no
On Fri, 20 Jul 2018 20:56:41 -0700, Michael Vilain
 wrote:

>I'm running PyCharm Edu (to go through their great tutorial). It's version is 
>2018.1.3, which I got from the web site.  Unless you mistyped the version, 
>this is the current release and yours is very old.

The date was just from a message posted back in Jan.

My version  says:
PyCharm 2018.1.4 (Community Edition)
Build #PC-181.5087.37, built on May 24, 2018
JRE: 1.8.0_152-release-1136-b39 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1

When I try to use an input statment, the program freezes.  I have to
terminate it.

What happens when you try to run code with an input statment?

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


Re: For next loops

2018-07-22 Thread no
never mind.
x = range (5)
y = range (5)
for ply in x:

for com in y:
if ply==com:
result="Tie"

print(ply,com,result)
result = ""


On Sun, 22 Jul 2018 23:17:24 -0400, no@none.invalid wrote:

>x = range (5)
>y = range (5)
>for ply in x:
>for com in y:
>if ply==com:
>result="Tie"
>print(ply,com,result)
>
>Why is ply always equal to com?
>0 0 Tie
>0 1 Tie
>0 2 Tie
>0 3 Tie
>0 4 Tie
>1 0 Tie
>1 1 Tie
>1 2 Tie
>1 3 Tie
>1 4 Tie
>2 0 Tie
>2 1 Tie
>2 2 Tie
>2 3 Tie
>2 4 Tie
>3 0 Tie
>3 1 Tie
>3 2 Tie
>3 3 Tie
>3 4 Tie
>4 0 Tie
>4 1 Tie
>4 2 Tie
>4 3 Tie
>4 4 Tie
-- 
https://mail.python.org/mailman/listinfo/python-list


For next loops

2018-07-22 Thread no
x = range (5)
y = range (5)
for ply in x:
for com in y:
if ply==com:
result="Tie"
print(ply,com,result)

Why is ply always equal to com?
0 0 Tie
0 1 Tie
0 2 Tie
0 3 Tie
0 4 Tie
1 0 Tie
1 1 Tie
1 2 Tie
1 3 Tie
1 4 Tie
2 0 Tie
2 1 Tie
2 2 Tie
2 3 Tie
2 4 Tie
3 0 Tie
3 1 Tie
3 2 Tie
3 3 Tie
3 4 Tie
4 0 Tie
4 1 Tie
4 2 Tie
4 3 Tie
4 4 Tie
-- 
https://mail.python.org/mailman/listinfo/python-list


What is the pattern?

2018-08-22 Thread no
I asked this before but my Usenet reader only saves messages for 30
days.  I still can't get the pattern for this chart.
I started working on the code that should print it, but I never
remembered how to do it.

empire={6:"Infantry",12:"Armor/Fighter",30:"Transport"}
for x in range (6,120,6):
print(x,x - x / 6)

Anyone want to fill in the blanks to give this chart?
https://imgur.com/a/OR0WKsv
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UltraEdit and Python

2006-06-09 Thread No
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says...
> How do I sent up Ultra Edit to work w/ Python?
> 
> How do I get Ultra Edit to run a Python script currently in the edit window 
> and supply results?
> 
> I can't figure out how to get Ultra Edit to invoke the Python debugger to 
> allow stepping through a Python script and view each line reults?

Menu/Advanced/Tool Configuration: (Command tab)

Menu Item Name: Python
Command Line: "C:\Program Files\python24\python.exe" %F
Working Directory: C:\ 


Menu/Advanced/Tool Configuration: (Options tab)

Program Type: Dos Program


Menu/Advanced/Tool Configuration: (Output tab)

Command Output (DOC Commands): Output to List Box, Capture Output
Replace selected text with: No Replace


(This is with UltraStudio. Should be the same/similar in UltraEdit.)


> 
> How do I set pause / break points  in Ultra Edit for a Python script?
> 
 
If you find out, let me know by posting here...

-Rob

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


Re: UltraEdit and Python

2006-06-09 Thread No


I'm replying to me...

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
says...
> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says...
> > How do I sent up Ultra Edit to work w/ Python?
> > 
> > How do I get Ultra Edit to run a Python script currently in the edit window 
> > and supply results?
> > 



> > I can't figure out how to get Ultra Edit to invoke the Python debugger to 
> > allow stepping through a Python script and view each line reults?

I had intended to insert my reply above this paragraph. My reply below 
DOESN'T allow stepping, just "run and view results".


> 
> Menu/Advanced/Tool Configuration: (Command tab)
> 
> Menu Item Name: Python
> Command Line: "C:\Program Files\python24\python.exe" %F
> Working Directory: C:\ 
> 
> 
> Menu/Advanced/Tool Configuration: (Options tab)
> 
> Program Type: Dos Program
> 
> 
> Menu/Advanced/Tool Configuration: (Output tab)
> 
> Command Output (DOC Commands): Output to List Box, Capture Output
> Replace selected text with: No Replace
> 
> 
> (This is with UltraStudio. Should be the same/similar in UltraEdit.)
> 
> 
> > 
> > How do I set pause / break points  in Ultra Edit for a Python script?
> > 
>  
> If you find out, let me know by posting here...
> 
> -Rob
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, email temperature

2012-12-22 Thread No One
On 2012-12-22, KarlE  wrote:
> On Saturday, December 22, 2012 9:44:39 PM UTC+1, Joel Goldstick wrote:
>> On Sat, Dec 22, 2012 at 3:36 PM, Alexander Ranstam  wrote:
>> 
>> Hi!
>> 
>> 
>> 
>> Im totally new to Python, and im using it on my Raspberry pi. I found a 
>> program that sends an email, and one that checks the temperature of my CPU, 
>> but i cant seem to combine the to into the funktion that i want, sending me 
>> the CPU temp via Email.
>> 
>> 
>> 
>> 
>> The two programs work very well on their own, but this doesnt work.
>> 
>> 
>> 
>> this works: server.sendmail(fromaddr, toaddrs, msg)
>> 
>> but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)
>> 
>> 
>> 
>> despite the command "print cputemp" working in the same program.
>> 
>> 
>> 
>> When i run the program i get the error:
>> 
>> 
>> 
>> Traceback (most recent call last):
>> 
>> ? File "sendcpu.py", line 36, in 
>> 
>> ? ? msg = cpu_temperature
>> 
>> NameError: name 'cpu_temperature' is not defined
>> 
>> 
>> 
>> Does anyone know why the program claims that cpu_temperature isnt defined, 
>> when it is?
>> 
>> 
>> 
>> You should copy and paste the code here including the context around the 
>> error.? You say print cputemp works, but cpu_temperature is not defined.? 
>> They are spelled differently.? Start there 
>> 
>> 
>> 
>> 
>> Thanx!
>> 
>> 
>> 
>> //Alexander
>> 
>> 
>> 
>> --
>> 
>> http://mail.python.org/mailman/listinfo/python-list
>> 
>> 
>> 
>> 
>> -- 
>> Joel Goldstick
>
> Hi!
>
> I made a typing error, and couldnt edit the post :( this is the code:
>
>
> #!/usr/bin/env python
> from __future__ import division
> from subprocess import PIPE, Popen
> import psutil
> import smtplib
>
> def get_cpu_temperature():
> process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
> output, _error = process.communicate()
> return float(output[output.index('=') + 1:output.rindex("'")])
>
>
> def main():
> cpu_temperature = get_cpu_temperature()
> cpu_usage = psutil.cpu_percent()
>
> ram = psutil.phymem_usage()
> ram_total = ram.total / 2**20   # MiB.
> ram_used = ram.used / 2**20
> ram_free = ram.free / 2**20
> ram_percent_used = ram.percent
>
> disk = psutil.disk_usage('/')
> disk_total = disk.total / 2**30 # GiB.
> disk_used = disk.used / 2**30
> disk_free = disk.free / 2**30
> disk_percent_used = disk.percent
> #
> # Print top five processes in terms of virtual memory usage.
> #
> print 'CPU temperature is: ',  cpu_temperature
>
> fromaddr = 'myemailadress'
> toaddrs  = 'myemailadress'
> #msg = 'There was a terrible error that occured and I wanted you to know!'
> msg = cpu_temperature
>
> # Credentials (if needed)
> username = 'myusername'
> password = 'mypassword'
>
> # The actual mail send
> server = smtplib.SMTP('smtp.gmail.com:587')
> server.starttls()
> server.login(username,password)
> server.sendmail(fromaddr, toaddrs, cpu_temperature)
> server.quit()
>
>
>
>
> if __name__ == '__main__':
> main()
>
> running it gives the following error:
>
> pi@raspberrypi /home/python $ python sendcpu.py
> Traceback (most recent call last):
>   File "sendcpu.py", line 36, in 
> msg = cpu_temperature
> NameError: name 'cpu_temperature' is not defined
> pi@raspberrypi /home/python $
>
>
> isnt cpu_temperature defined?
>
>

You might have a look at the indentation, as well. At least on my reader, the 
lines from "fromaddr =" to "server.quit()" are in a left indented block from 
the main function. You probably want to get them all in the same indentation 
level to solve the scope issue. Also, on the code as it copies to my editor 
there are mixed tabs and spaces. If your code also mixes tabs and spaces, pick 
one (spaces preferred over tabs) and make sure to eliminate the other. 

Norm.
-- 
http://mail.python.org/mailman/listinfo/python-list


VBR mp3 length

2005-07-05 Thread No One
Hello all,
If this isn't the correct newsgroup, please redirect me.

I'm trying to extract the song length from variable bit rate mp3's.
Does anyone know of a library or bit of code that will do this?  I've
tried pymad, but it seems to grab the bitrate of the first frame and
then apply that to the the file length to come up with a total length.
Needless to say, if the bitrate of the first frame isn't close to the
overall average, it's wildly off.

Thanks,
-Steve
-- 
http://mail.python.org/mailman/listinfo/python-list


Compiling multiple python scripts into an exe file

2015-01-13 Thread no nein
Basically, is it possible to compile multiple unrelated python scripts into a 
single exe file, so when execute it several python programs are run at once.
In order to use this on another machine without python installed and only by 
using one single file.
-- 
https://mail.python.org/mailman/listinfo/python-list


Connection acception with confirmation

2007-05-29 Thread no`name`

Hi, i'm new in Python and i'm trying to write some server which can
confirm connection from client.
Here is a part of code:

import sys
import threading
from socket import *

class TelGUI(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)

def run(self):
s = socket(AF_INET, SOCK_STREAM)
s.bind(('',8900))
s.listen(5)
while 1:
client,addr = s.accept()
print addr
print "Or u want to accept connection from this host? 
[y/n]"
opt = sys.stdin.read(1)
if opt == 'y':
#establish
else: s.close() #reject

def main():
app = TelGUI()
app.start()

print "Menu"
while 1:
#some menu operations
op = sys.stdin.read(1)
if op == 'x':
break

if __name__ == "__main__":
main()

maybe someone have some ideas how to block first stdin in main
function and get stdin from the thread when here is a new connection?
Thanks

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


Ligmail bug?

2007-08-11 Thread No.23

#!/usr/bin/env python

import libgmail
from time import gmtime, strftime

fp = open('/tmp/python.list', 'w')
ga = libgmail.GmailAccount("[EMAIL PROTECTED]", "mypass")
ga.login()

result = self.ga.getMessagesByLabel('python.list', True)
result_len = len(result)
cnt = 0
if result_len:
for thread in result:
cnt += 1
thread_len = len(thread)
print 'Thread: %d/%d Msg: %d %s' % (cnt,
result_len,
thread_len, 
thread.subject)
for msg in thread:
print '  Msg: %d/%d %s' % (msg.number, 
   thread_len, 
   msg.subject)
source = msg.source.replace('\r','').lstrip()
fp.write('From - ' + \
  strftime("%a %b %d %H:%M:%S %Y", 
  gmtime()) + '\n')
fp.write(source)
fp.write('\n\n')

Thread: 1/1244 Msg: 7 \u003cb\>Deleting objects on the fly\u003c/b\>
  Msg: 1/7 Deleting objects on the fly
  Msg: 2/7 Re: Deleting objects on the fly
  Msg: 3/7 Re: Deleting objects on the fly
  Msg: 4/7 Re: Deleting objects on the fly
  Msg: 5/7 Re: Deleting objects on the fly
  Msg: 6/7 Re: Deleting objects on the fly
  Msg: 7/7 Re: Deleting objects on the fly
Thread: 2/1244 Msg: 1 \u003cb\>A new french book on Python\u003c/b\>
  Msg: 1/1 A new french book on Python
Thread: 3/1244 Msg: 14 \u003cb\>Destruction of generator objects\u003c/b\>
  Msg: 1/14 Destruction of generator objects
  Msg: 2/14 Re: Destruction of generator objects
  Msg: 3/14 Re: Destruction of generator objects
  Msg: 4/14 Re: Destruction of generator objects
  Msg: 5/14 Re: Destruction of generator objects
  Msg: 6/14 Re: Destruction of generator objects
  Msg: 7/14 Re: Destruction of generator objects
  Msg: 8/14 Re: Destruction of generator objects
  Msg: 9/14 Re: Destruction of generator objects
  Msg: 10/14 Re: Destruction of generator objects
  Msg: 11/14 Re: Destruction of generator objects
  Msg: 12/14 Re: Destruction of generator objects
  Msg: 13/14 Re: Destruction of generator objects
  Msg: 14/14 Re: Destruction of generator objects
..
Thread: 307/1244 Msg: 1 MailingLogger 3.2.0 Released!
   Msg: 1/1 MailingLogger 3.2.0 Released!
 Thread: 308/1244 Msg: 13 Why no maintained wrapper to Win32?
   Msg: 1/13 Why no maintained wrapper to Win32?
   Msg: 2/13 Re: Why no maintained wrapper to Win32?
   Msg: 3/13 Re: Why no maintained wrapper to Win32?
   Msg: 4/13 Re: Why no maintained wrapper to Win32?
   Msg: 5/13 Re: Why no maintained wrapper to Win32?
   Msg: 6/13 Re: Why no maintained wrapper to Win32?
   Msg: 7/13 Re: Why no maintained wrapper to Win32?
   Msg: 8/13 Re: Why no maintained wrapper to Win32?
   Msg: 9/13 Re: Why no maintained wrapper to Win32?
   Msg: 10/13 Re: Why no maintained wrapper to Win32?
   Msg: 11/13 Re: Why no maintained wrapper to Win32?
   Msg: 12/13 Re: Why no maintained wrapper to Win32?
   Msg: 13/13 Re: Why no maintained wrapper to Win32?
 Thread: 309/1244 Msg: 5 Encryption recommendation
   Msg: 1/5 Encryption recommendation
   Msg: 2/5 Re: Encryption recommendation
   Msg: 3/5 Re: Encryption recommendation
   Msg: 4/5 Re: Encryption recommendation
   Msg: 5/5 Re: Encryption recommendation
 Thread: 310/1244 Msg: 3 Simple question about logging module.
   Msg: 1/3 Simple question about logging module.
   Msg: 2/3 Re: Simple question about logging module.
   Msg: 3/3 Re: Simple question about logging module.
 Thread: 311/1244 Msg: 5 Plotting Images
   Msg: 1/5 Plotting Images
   Msg: 2/5 Re: Plotting Images
   Msg: 3/5 Re: Plotting Images
   Msg: 4/5 Re: Plotting Images
   Msg: 5/5 Re: Plotting Images
 Thread: 312/1244 Msg: 33 From D
 Thread: 313/1244 Msg: 4 get directory and file names
 Thread: 314/1244 Msg: 7 Compiling 2.5.1 on OpenBSD 4.1
 Thread: 315/1244 Msg: 2 how to add a toolbar to a Frame using wxpython
 Thread: 316/1244 Msg: 1 create a toolbar + images using wxpython for windows
 Thread: 317/1244 Msg: 4 Pysqlite storing file as blob example
 Thread: 318/1244 Msg: 1 Nasm_with_C++_with_Python
 Thread: 319/1244 Msg: 2 interaction of 'with' and 'yield'
 Thread: 320/1244 Msg: 5 problems with logging module
 Thread: 321/1244 Msg: 5 win32 question in Python
 Thread: 322/1244 Msg: 6 File handle not being released by close
 Thread: 323/1244 Msg: 6 Replacing overloaded functions with closures.
 Thread: 324/1244 Msg: 1 Where can I get a complete user interface about 
pylibpcap?
 Thread: 325/1244 Msg: 7 making a variable available in a function from 
decoratorThread: 326/1244 Msg: 1 www.cerocom.com
 Thread: 327/1244 Msg: 6 OOP in Python book?
 Thread: 328/1244 Msg: 3 Help text embedding in C code?
 Thread: 329/1244 Msg: 16 128 or 96

Re: newbie qns : how do i use xmldiff?

2010-11-05 Thread No Name
I had to do some fishing around to figure this much out. Hope it helps.

from input import * # From the xmldiff directory
from fmes import *  # From the xmldiff directory
from format import *# From the xmldiff directory
from StringIO import *

# Build your original tree
text1 = '123'
stream1 = StringIO(text)
tree1 = tree_from_stream(stream)

# Build your modified tree
text2 = '223'
stream2 = StringIO(text2)
tree2 = tree_from_stream(stream2)

# Compare the trees
formatter = InternalPrinter()
corrector = FmesCorrector(formatter)
corrector.process_trees(tree, tree2)

## OUTPUT: 
## Instructions for modifying original to modified
#  [rename, /point[1]/y[1], x]
#  [insert-after, /point[1]/x[2],
#  
#  2
#  
#  ]
#  [remove, /point[1]/x[1]]

> On Wednesday, February 03, 2010 1:38 AM sWrath swrath wrote:

> Hi ,
> 
> I am pretty new to python , and reading up on it.
> 
> Basically I am trying to compare xml files . I know difflib have it
> but it does not work out as expected. I was looking at xmldiff ,
> unfortunately I am not able to find documentation how to call it from
> python. Anyone knows a link or doc to it as I have been looking high
> and low for few days?
> 
> lastly , is there a py (or algorithm) where it behaves exactly like
> diff ? Greatly appreciated.
> 
> Thanks
> john


>> On Wednesday, February 03, 2010 3:34 PM Terry Reedy wrote:

>> On 2/3/2010 1:38 AM, sWrath swrath wrote:
>> 
>> When asking such a question, it is good to explain what sort of thing,
>> in this case, 'xmldiff' is and where it is is from. Let us assume you
>> meant xmldiff from
>> 
>> http://www.logilab.org/859
>> 
>> It says it is a python tool that can "be used be used as a library or as
>> a command line tool." It includes a README file. Have you read that?
>> That says "USAGE ... Read the HELP.txt file.". Have you read *that*?
>> HELP.txt seems to focus on command line usage. I would start with that.
>> To use it as a library (via import ...), you might have to look at the
>> source code as I did not see importing covered in my quick look at that
>> file.
>> 
>> Terry Jan Reedy


>> Submitted via EggHeadCafe - Software Developer Portal of Choice 
>> FireAndForget Asynchronous Utility Class for SQL Server Inserts and Updates
>> http://www.eggheadcafe.com/tutorials/aspnet/7a22d9a4-59fc-40b0-8337-75c76f14fb3b/fireandforget-asynchronous-utility-class-for-sql-server-inserts-and-updates.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


Python component model

2006-10-09 Thread Edward Diener No Spam
The definition of a component model I use below is a class which allows 
properties, methods, and events in a structured way which can be 
recognized, usually through some form of introspection outside of that 
class. This structured way allows visual tools to host components, and 
allows programmers to build applications and libraries visually in a RAD 
environment.

The Java language has JavaBeans as its component model which allows Java 
applications to be built in a visual RAD way. Microsoft's .Net has a 
component model built-in to its .Net class libraries as well as 
supported by CLR which allows .Net applications to be built visually 
using components created in any .Net supported language.

With Python things are different. There is no single component model 
which allows Python developers to build components which will be used 
and recognized by the various RAD Python tools on the market. Instead a 
developer must create a slightly different set of Python classes for 
each RAD Python tool. This is the situation despite Python's having 
easily as much functionality, if not much more, as Java or .Net 
languages such as C#, VB, or C++/CLI for creating components, and for 
allowing visual tools to introspect the properties, methods, and events 
of Python classes.

I believe that Python should have a common components model for all RAD 
development environments, as that would allow the Python programmer to 
create a set of classes representing components which would work in any 
environment. I want to immediately point out that components do not 
simply mean visual GUI components but what may be even more important, 
non-visual components. Having used RAD development environments to 
create applications, I have found such environments almost always much 
better than coding complex interactions manually, and I believe that 
visual development environments are almost a necessity in today's world 
of large-scale, multi-tier, and enterprise applications.

Has there ever been, or is there presently anybody, in the Python 
developer community who sees the same need and is working toward that 
goal of a common component model in Python, blessed and encouraged by 
those who maintain the Python language and standard modules themselves ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-09 Thread Edward Diener No Spam
 Studio for .Net, one 
knows what I mean as far as a visual RAD environment. All of these are 
made possible by a common component model which different development 
environments can use.

There's nothing wrong with Python's introspection. In fact Python's 
facilities in this area and its support for metadata are stronger than 
any of these other languages ! However there is no common component 
model which specifies that X is a "property" or Y is an "event" of a 
Python class which can be visually manipulated at design-time and 
automagically set at run-time, so that any given Python RAD visual 
environment will treat a Python class, specified as a component, in 
exactly the same way. Also in these other languages, a component is 
different from a class in that a component is recognized in a particular 
way, often so that the component can interact if necessary with its 
container and/or visual site.

OK, I have proselytized enough . Python is a great language and I 
truly love it and its flexibility and ease of programming use. If there 
is no impetus to create a component model for re-usable components for 
visual RAD environments in Python, that's fine with me. But I thought 
someone from the Python development community, given the use of visual 
RAD environments for other languages as mentioned above, to create GUI 
and large-scale applications, would have considered it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Echo wrote:
> On 10/9/06, Edward Diener No Spam <[EMAIL PROTECTED]> 
> wrote:
>> The definition of a component model I use below is a class which allows
>> properties, methods, and events in a structured way which can be
>> recognized, usually through some form of introspection outside of that
>> class. This structured way allows visual tools to host components, and
>> allows programmers to build applications and libraries visually in a RAD
>> environment.
>>
>> The Java language has JavaBeans as its component model which allows Java
>> applications to be built in a visual RAD way. Microsoft's .Net has a
>> component model built-in to its .Net class libraries as well as
>> supported by CLR which allows .Net applications to be built visually
>> using components created in any .Net supported language.
>>
>> With Python things are different. There is no single component model
>> which allows Python developers to build components which will be used
>> and recognized by the various RAD Python tools on the market. Instead a
>> developer must create a slightly different set of Python classes for
>> each RAD Python tool. This is the situation despite Python's having
>> easily as much functionality, if not much more, as Java or .Net
>> languages such as C#, VB, or C++/CLI for creating components, and for
>> allowing visual tools to introspect the properties, methods, and events
>> of Python classes.
>>
>> I believe that Python should have a common components model for all RAD
>> development environments, as that would allow the Python programmer to
>> create a set of classes representing components which would work in any
>> environment. I want to immediately point out that components do not
>> simply mean visual GUI components but what may be even more important,
>> non-visual components. Having used RAD development environments to
>> create applications, I have found such environments almost always much
>> better than coding complex interactions manually, and I believe that
>> visual development environments are almost a necessity in today's world
>> of large-scale, multi-tier, and enterprise applications.
>>
>> Has there ever been, or is there presently anybody, in the Python
>> developer community who sees the same need and is working toward that
>> goal of a common component model in Python, blessed and encouraged by
>> those who maintain the Python language and standard modules themselves ?
>> -- 
>> http://mail.python.org/mailman/listinfo/python-list
>>
> 
> 
> If you are talking about about creating a GUI and having be able to
> run using different GUI libraries like Tkinter, wxPython, wxgtk, ect.
> You could look into Dabo(http://dabodev.com/). It is designed so that
> you can design your GUI and have it run with what ever GUI library you
> want(only wxPython is supported at the moment. And I think that
> Tkinter works somewhat.)

It's not just for GUI controls that a component model exists in the 
other environments I mentioned. Non-GUI components are intrinsically as 
important, if not more so, to a component model architecture. Also, 
quite honestly, I think a component model would have to be specified by 
the core Python developers instead of retrofitted against the popular 
GUI environments for Python which currently exist. Also I admit I am no 
fan of wx-you-name-it, whose "event" model especially I find way too 
limiting and ineffective in relation to the entire area of 
component-based programming and events.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Chaz Ginger wrote:
> Edward Diener No Spam wrote:
>> [EMAIL PROTECTED] wrote:
>>> Edward> The definition of a component model I use below is a class
>>> which
>>> Edward> allows properties, methods, and events in a structured way
>>> which
>>> Edward> can be recognized, usually through some form of introspection
>>> Edward> outside of that class. This structured way allows visual
>>> tools
>>> Edward> to host components, and allows programmers to build
>>> applications
>>> Edward> and libraries visually in a RAD environment.
>>>
>>> ...
>>> Edward> I believe that Python should have a common components
>>> model for
>>> Edward> all RAD development environments, as that would allow the
>>> Python
>>> Edward> programmer to create a set of classes representing components
>>> Edward> which would work in any environment.
>>>
>>> Having never used java or .NET I'm not sure what you're looking for. 
>>> Does
>>> Python's current introspection not work?  Is it someone too unstructured
>>> (whatever "structured" means)?  Can you give a simple example?
>> In the typical RAD development environment, a particular component model
>> allows one to drop components, which are classes corresponding to a
>> particular inner representation which tells the development environment
>> what are the "properties" and "events" of that component, and
>> subsequently set "properties" for that component and add handlers for
>> its "events" visually. snip...
>>
> 
> Why not propose something. That is the easiest way to get things moving.

How does one do that ? Propose something here on this NG or is there 
some other official way ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Robert Kern wrote:
> Edward Diener No Spam wrote:
> 
>> There's nothing wrong with Python's introspection. In fact Python's 
>> facilities in this area and its support for metadata are stronger than 
>> any of these other languages ! However there is no common component 
>> model which specifies that X is a "property" or Y is an "event" of a 
>> Python class which can be visually manipulated at design-time and 
>> automagically set at run-time, so that any given Python RAD visual 
>> environment will treat a Python class, specified as a component, in 
>> exactly the same way. Also in these other languages, a component is 
>> different from a class in that a component is recognized in a 
>> particular way, often so that the component can interact if necessary 
>> with its container and/or visual site.
> 
> You'll definitely want to take a look at Enthought's Traits (disclaimer: 
> I work for Enthought). I'm supposed to be on vacation now, so I'm not 
> going to give you the full rundown of Traits and Traits UI, so I'm 
> simply going to point you to the page we have about it:
> 
>   http://code.enthought.com/traits/

It looks as if traits is an attempt to create a "property" in the 
component terminology which I originally specified. I will take a look 
at it.

> 
> You can talk to the rest of the Enthought crew on the enthought-dev 
> mailing list if you have any questions:
> 
>   https://mail.enthought.com/mailman/listinfo/enthought-dev

Already subscribed. Thanks !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-09 Thread Edward Diener No Spam
goon wrote:
>>  or IBM's Eclipse for Java
> 
> Or Eclipse for Python using PyDev? [0]

Those are very nice features but there is no re-usable Python bean 
support like there is a Java bean. That was my initial point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Michael wrote:
> Edward Diener No Spam wrote:
> 
>> Has there ever been, or is there presently anybody, in the Python
>> developer community who sees the same need and is working toward that
>> goal of a common component model in Python, blessed and encouraged by
>> those who maintain the Python language and standard modules themselves ?
> 
> Someone aiming towards a standard to /replace/ everyone else's? That
> presupposes a level of arrogance that seems unusual in the python world.
> (whilst everyone's proud of their own code and they _generally_ respect
> other people's even if it's not their cup of tea).

The reason I would like to see a standard component model for Python is 
so 3rd party developers could create their classes to conform to this 
model and work in any RAD IDE environment which adapts it. That's the 
way JavaBeans work, that the way Borland's VCL component model works, 
and that's the way .Net works. When there are many different component 
models, the 3rd party developer must adapt their components to each 
model for a particular environment.

But far be it from me to want to replace everybody else's model .

By your reasoning above, standardizing anything in software is an 
arrogant proposition. Whereas I look at standardization, when it is well 
done, as a boon to programmers.

> 
> The WSGI standard could be a form of component model, and has gone through
> the PEP process so that might match your criterion.

I do not know what it is but I will look it up.

> As for component
> models, they do exist.
> 
> Our component model on the Kamaelia project [1] is one that's heavily
> designed around the idea of composition and independent execution of
> components and message passing (message passing maps to events for some
> sorts of message), 
>[1] http://kamaelia.sourceforge.net/Home

I will look at kamaelia. Thanks !

> 
> I wouldn't think of proposing it as the single standard to rule them all
> though, for the simple reason every approach has its own strengths. (We do
> find the approach extremely useful though)
> 
> If you want a quick example of the core ideas, a tutorial aimed around
> building a massively simplified core is here:
>http://kamaelia.sourceforge.net/MiniAxon/
> 
> If you want to see a substantial example, you can look here:
>* http://tinyurl.com/oqjfb - whiteboarding with audio where every client
>  is a server. The entire resulting system is also a component.
> 
> For something more simplistic:
>* http://kamaelia.sourceforge.net/Examples/SimplestPresentationTool.html
> 
> Something halfway in terms of complexity (a PVR for transcoding everything
> broadcast on digital TV):
>* http://tinyurl.com/lvygq
>  (OK, you need to add more channels, but you'd need more CPU's too)
> 
> We also have tools for introspecting a running system, and also a visual
> composition tool (called Compose) [2] for creating simple systems
> graphically, and that, as you say, handles a significant chunk of
> dreariness. Suggestions on improving the model and composition tool are
> very welcome, code is even more welcome :)
> 
>[2] Sample system created with the newest version of Compose:
>   http://tinyurl.com/numwk
>Compose is also a Kamaelia system, and can be found here:
>   http://tinyurl.com/p7z76
>(bulk of the wiring up is in the bottom of the file - this is an
>interesting example because of the use of Pygame and Tk for different
>parts of the interface where appropriate)
> 
> 
> However, off the top of my head, you should also look at Zope's component
> model, Trac's component model, Twisted's model & PEAK, and any proposal
> to say "this is the solution", needs to be compelling for all of these
> projects. 

A standard component model could be used as a base for other more 
advanced needs. Most of those mentioned above seem to involve web 
application frameworks whereas my idea of a component model just assumes 
  the paradigms of properties, methods, and events which may allow 
re-usable components at a base level in any environment.

A particular implementation is certainly allowed to build a more 
complicated idea of a component, through inheritance, from a base level 
component, and this is in fact the way that most components work in 
current component model environments I have mentioned. For instance in 
.Net a control is a component with other added qualities. So while one 
could build components which are not controls, it is necessary to add 
functionality to the base level idea of a component in order to create a 
control.

> 
> Note, they do change where there's a benefit - twisted adopted some
> int

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Nick Vatamaniuc wrote:
> Edward Diener No Spam wrote:
>> Michael wrote:
> 
> Python does not _need_ a component model just as you don't _need_ a RAD
> IDE tool to write Python code. The reason for having a component model
> or a RAD IDE tool is to avoid writing a lot of boiler plate code.
> Python is terse enough that boiler plate code is not needed, just type
> what you need into an editor. It seems that you talk about Python but
> you are still thinking in Java or C++.

A RAD IDE tool to hook up components into an application or library ( 
module in Python ) has nothing to do with terseness and everything to do 
with ease of programming. All you are saying is that you don't have a 
need for this, but perhaps others do. I don't mind others saying they 
have no need or seeing no benefit. But if you have ever used a visual 
design-time environment for creating applications you might feel 
differently.

"Thinking in Java or C++" as opposed to Python does not mean anything to 
me as a general statement. I am well aware of the difference between 
statically and dynamically typed languages but why this should have 
anything to do with RAD programming is beyond me. Do you care to 
elucidate this distinction ?

> 
> At the same time one could claim that Python already has certain
> policies that makes it seem as if it has a component model. Take a look
> at the "magic methods". For example if a class has a __len__ method, it
> is possible to use the len() function on an instance of that class. If
> a class has the  __getitem__ then indexing can be used on that class's
> insance. Then Python has properties (see
> http://www.python.org/doc/2.2.3/whatsnew/sect-rellinks.html).  Just by
> inspecting the object one can tell a great deal about them (even read
> the documentation if needed, by using the __doc__ attribute).   What
> other standards would you propose for the core language?

Python has great facilities for a component model, much better than the 
other languages I use regularly ( C++, C#, Java ). I am not arguing 
against that. A component model for RAD tools allows the tool to expose 
properties and events to the end-user at design time so that at run-time 
the properties and events are automatically setup once an object is 
instantiated. The essence of a component model for RAD programming is 
how one specifies properties and events for a class to be manipulated by 
the RAD tool at design time. Another obvious part of the component model 
is how one specifies that the properties and events one sets up at 
design-time are serialized so that at run-time they are properly set. A 
final element of a component model is the ability of a component to 
interact with the environment in which it exists at design time, through 
property editors, and at run-time, the latter being obviously more 
important for visual controls than non-visual components.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Paul Rubin wrote:
> "Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
>> Python does not _need_ a component model just as you don't _need_ a RAD
>> IDE tool to write Python code. The reason for having a component model
>> or a RAD IDE tool is to avoid writing a lot of boiler plate code.
> 
> It's also so that applications written in differing languages can call
> each other.

That's a possible reason, but with JavaBeans and EJBs for Java there is 
just a single language and I am sure there are many Java programmers who 
enjoy using Eclipse, NetBeans, or JBuilder to name a few RAD IDEs which 
allow them to create their applications using a design-time visual 
environment.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Diez B. Roggisch wrote:
> Paul Rubin schrieb:
>> "Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
>>> Python does not _need_ a component model just as you don't _need_ a RAD
>>> IDE tool to write Python code. The reason for having a component model
>>> or a RAD IDE tool is to avoid writing a lot of boiler plate code.
>>
>> It's also so that applications written in differing languages can call
>> each other.
> 
> Nope. Things like CORBA and COM do have that property, but e.g. the Java 
> beans spec has only a meaning inside the VM. Not sure about .NET, but I 
> can imagine there it's the same thing.
> 
> All the languages he mentioned are statically typed, or the component 
> models themselves are. So the component model is basically needed (as 
> others also mentioned) to glue things together, to dynamize that - 
> whereas python is dynamic on the first hand, and actually lacks static 
> typing to infer component properties...

While I understand dynamic typing, I still think it is possible to 
create attributes in a Python component model which could tell a RAD 
tool what type the attribute will encompass for the purpose of 
properties and events. Obviously a "name, type" tuple, among other 
possible information would have to be used. But given Python's amazingly 
flexible type and introspection system, this should be possible.

Of course I am not trying to change the nature of normal Python 
attributes per se at all, and one of the most important things in a 
property-method-event component model is to be able to specify 
properties that are distinct from just normal object data members. So 
one of the most important things in a Python component model would be 
the ability to tag component properties as totally distinct from normal 
Python class attributes or property attributes.

Given that Python already has new-style class properties, maybe another 
name for the component properties I envision is needed to avoid confusion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Steve Holden wrote:
> Diez B. Roggisch wrote:
> [...]
>>> Just the same, one can use IronPython to call components written in
>>> other languages. And, I believe, vice versa.
>>
>>
>> Sure, as I can do it in jython. But the key point is: can your ordinary
>> python-object be published as a component? At least for jython I can
>> say "no", you will have to subclass an already existing
>> java-object/interface. And I have difficulties imagining that it is any
>> different in .NET - because I've read statements that claimed that the
>> structure of the VM/runtime is orientied towards single-inheritance
>> statically typed languages as C#/java.
>>
> The answer to this question is currently beyond me. Maybe someone who 
> knows more about IronPython can elucidate. I do know (as you probably do 
> also) that Python generates code for the .NET CLR, however.

I am not sure about current IronPython functionality but the end result 
is that one should be able to create .Net components and classes using 
Python with IronPython just as one does in C#, C++/CLI, or VB .NET.

But this is not creating a component model for Python except in the .Net 
environment, which essentially means Windows unless IronPython will work 
under Mono, and Microsoft does not kill Mono. I don't think all those 
"ifs" is something a Python programmer wants to deal with in possible 
RAD component development.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote:
> Nick Vatamaniuc wrote:
> 
>> At the same time one could claim that Python already has certain
>> policies that makes it seem as if it has a component model.
> 
> every Python object surely qualifies as a component, for any non-myopic 
> definition of that word, and everything inside a Python program is an 
> object.  so yes, Python has a component model, and Python programmers 
> are using that model all over the place.
> 
> what might be missing is support for publishing additional metadata 
> using a standardized vocabulary, and a way to access that data with-
> out having to actually create the object.
> 
> implementing this using existing mechanisms is trivial (as the endless 
> stream of interface/component/adapter/trait implementations have shown 
> us); coming up with a good-enough-to-be-useful-for-enough-people 
> vocabulary is a lot harder.

There's no doubt that Python's excellent introspection mechanism allows 
an outside RAD-like tool to inspect the workings of any Python object. 
But that does not make it a component model in my original use of the 
term on this thread. A RAD tool needs to know what properties and events 
within a class can be manipulated visually, and it needs to be able to 
serialize those properties and events so that they are set at run-time 
automatically once an object is created.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Michael Sparks wrote:
> Edward Diener No Spam wrote:
>> Michael wrote:
>>> Edward Diener No Spam wrote:
>>>
>>>> Has there ever been, or is there presently anybody, in the Python
>>>> developer community who sees the same need and is working toward that
>>>> goal of a common component model in Python, blessed and encouraged by
>>>> those who maintain the Python language and standard modules themselves ?
>>> Someone aiming towards a standard to /replace/ everyone else's? That
>>> presupposes a level of arrogance that seems unusual in the python world.
>>> (whilst everyone's proud of their own code and they _generally_ respect
>>> other people's even if it's not their cup of tea).
>> The reason I would like to see a standard component model for Python is
>> so 3rd party developers could create their classes to conform to this
>> model and work in any RAD IDE environment which adapts it. That's the
>> way JavaBeans work, that the way Borland's VCL component model works,
>> and that's the way .Net works. When there are many different component
>> models, the 3rd party developer must adapt their components to each
>> model for a particular environment.
>>
>> But far be it from me to want to replace everybody else's model .
> 
> Well that's the thing you *do* want since you want the previous
> paragraph ;-)
> (Or at least a way to adapt component models.)

I was being funny above. Yes I would like to establish a basic component 
model for RAD development in Python. But surely it need not replace all 
others but could serve at least as a base class for other derived models 
for various environments. That way a developer writing a Python 
component could have it work in these environments as a simple component 
and more complex components, tailored to that environment could be 
created as necessary through inheritance.

> 
>> By your reasoning above, standardizing anything in software is an
>> arrogant proposition. Whereas I look at standardization, when it is well
>> done, as a boon to programmers.
> 
> OK, maybe I was being a bit strong - I was merely thinking "lots of
> people have something like this already, and I've not seen anyone push
> their model as THE model", (even if lots of people like *their* model
> :-)
> 
> However, I was also being a bit tongue in cheek, though I should have
> said unreasonable, not arrogant:
>"...all progress depends on the unreasonable man." -- Bernard Shaw.

Bravo, Shaw. Of course by unreasonable I assume Shaw meant those using 
imagination and inspiration along with logic and reason.

> 
> What could have some mileage though is proposing a standard way for
> these component models to interoperate. What that would look like
> (given the wildly different models :), is another matter and an
> exercise for the interested reader ;-)
> 
>>> The WSGI standard could be a form of component model, and has gone through
>>> the PEP process so that might match your criterion.
>> I do not know what it is but I will look it up.
> 
> NB, I'm using component model in it's loosest form there.
> 
>>> As for component
>>> models, they do exist.
>>>
>>> Our component model on the Kamaelia project [1] is one that's heavily
>>> designed around the idea of composition and independent execution of
>>> components and message passing (message passing maps to events for some
>>> sorts of message),
>>>[1] http://kamaelia.sourceforge.net/Home
>> I will look at kamaelia. Thanks !
> 
> You're welcome. Any deficiencies or improvements or suggestions you've
> got would be very welcome (I can see some which we're planning on
> addressing at some point, but fresh critical eyes are always welcome).
> 
>>> However, off the top of my head, you should also look at Zope's component
>>> model, Trac's component model, Twisted's model & PEAK, and any proposal
>>> to say "this is the solution", needs to be compelling for all of these
>>> projects.
>> A standard component model could be used as a base for other more
>> advanced needs. Most of those mentioned above seem to involve web
>> application frameworks whereas my idea of a component model just assumes
>>   the paradigms of properties, methods, and events which may allow
>> re-usable components at a base level in any environment.
> 
> They do, however in particular, Trac's model whilst web oriented
> strikes me personally as interesting and PEAK's is applicable, as I
> understa

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Richard Brodie wrote:
> "Edward Diener No Spam" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>> "Thinking in Java or C++" as opposed to Python does not mean anything to me 
>> as a general 
>> statement. I am well aware of the difference between statically and 
>> dynamically typed 
>> languages but why this should have anything to do with RAD programming is 
>> beyond me. Do 
>> you care to elucidate this distinction ?
> 
> I think this blog entry http://osteele.com/archives/2004/11/ides
> provides some insight into the point of view expressed. 

I think that one can easily be both, someone who is good at using a 
language and someone who is good at using a visual tool. The dichotomy 
presented in the article exists only for a small number of people.

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


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote:
> "Edward Diener No Spam" wrote:
> 
>> A RAD IDE tool to hook up components into an application or library (
>> module in Python ) has nothing to do with terseness and everything to do
>> with ease of programming.
> 
> python already has excellent and ridiculously easy-to-program ways to hook
> things up.  after all, hooking things up is what python programmers tend to 
> do,
> most of their time.

I agree.

> 
> if you want better support for more precise hooking, post some examples.

I want a design-time environment to hook up my objects in a visual way. 
I think it is easier than doing it manually, even in Python.

> 
>> All you are saying is that you don't have a need for this, but perhaps 
>> others do.
> 
> handwavy references to what "other may need" is another thing you should
> avoid if you want your Python change proposal to be successful.

I did not say what "others may need".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Diez B. Roggisch wrote:
>> While I understand dynamic typing, I still think it is possible to
>> create attributes in a Python component model which could tell a RAD
>> tool what type the attribute will encompass for the purpose of
>> properties and events. Obviously a "name, type" tuple, among other
>> possible information would have to be used. But given Python's amazingly
>> flexible type and introspection system, this should be possible.
> 
> The amazing flexibility stems from the fact that it is _runtime_. This is
> _exactly_ the difference between static and dynamic typing.
> 
> If a static analysis (_not_ importing the module, which can trigger
> arbitrary code being run!!!) is supposed to deliver the component
> architecture, you are either introducing static typing, or get into the
> danger of lose coupling between declaration and implementation, rendering
> the whole thing pretty useless.

Yes, I am suggesting static typing functionality for a subset of Python 
attributes. How this can be done I am still investigating on my own.

> 
> Of course, with a bit of discipline, you can create such a introspection
> facility that offers its properties after a mere import, see ZOPE
> interfaces for example. 
> 
> But in the end, it boils down to declaring stuff for that purpose alone, and
> introducing static typing, whereas other languages declare typing for their
> own needs, and add the component model upon that. 
> 
> And then you lose a _lot_ of what python makes powerful, for a very doubtful
> benefit IMHO.

Adding a feature, such as static typing functionality for the situation 
of doing visual RAD programming, does not "lose a _lot_ of what makes 
python powerful".

My idea of adding static typing is not an attempt to change the language 
but rather to develop Python classes which encapsulate the idea of a 
variable and a type for the purposes of emulating component properties 
and component events. If a language addition is needed instead I will 
investigate how to propose it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Tim Chase wrote:
>> There's no doubt that Python's excellent introspection mechanism 
>> allows an outside RAD-like tool to inspect the workings of any Python 
>> object. But that does not make it a component model in my original use 
>> of the term on this thread. A RAD tool needs to know what properties 
>> and events within a class can be manipulated visually, and it needs to 
>> be able to serialize those properties and events so that they are set 
>> at run-time automatically once an object is created.
> 
> A little visual inspection of some objects:
> 
> [EMAIL PROTECTED]:~$ python
> Python 2.3.5 (#2, Sep  4 2005, 22:01:42)
> [GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> class Person(object):
> ... def __init__(self, name, age=None):
> ... self.name = name
> ... self.age = age
> ... def whoami(self):
> ... if self.age is not None:
> ...return "%s (%i)" % (
> ...self.name,
> ...self.age)
> ... return self.name
> ...
>  >>> p = Person("Sandy")
>  >>> [s for s in dir(p) if not s.startswith('_') and 
> callable(eval('p.%s' % s))]
> ['whoami']
>  >>> [s for s in dir(p) if not s.startswith('_') and not 
> callable(eval('p.%s' % s))]
> ['age', 'name']
> 
> Thus, you have the ability to find an object's methods/events (things 
> that are callable()), and its properties (things that are not 
> callable()).  Any "RAD" tool that wants can pull these properties, just 
> as my command-line RAD tool can ;)

Not all attributes are component properties in typical Visual RAD tool. 
In most visual RAD tools which I have used a component property is a 
publicly exposed type/name which may or may not have the backing of an 
actual data member and does have a function to get the type's value if 
the property is readable and does have a function associated with it to 
set the type's value if the property is writable. This is very close to 
the class properties in Python. The difference is that normally a type 
must be associated with a property whereas in Python, as I understand 
it, the type of a class property is unknown.

Furthermore by a component event I do not mean methods on the event 
creator's side but rather an event source. This would look something 
like a tuple of callable functions of a particular signature to which an 
event sink could add an event handler so that when a particular event 
occurred on the event source the event handlers added to the event 
source would each be called.

> 
> As for serializing them,
> 
>  >>> import shelve
>  >>> d = shelve.open('tmp/stuff.shlv')
>  >>> d['person'] = p
>  >>> p = 'hello'
>  >>> p
> 'hello'
>  >>> p = d['person']
>  >>> p.whoami()
> 'Sandy'
>  >>> p.age = 42
>  >>> p.whoami()
> 'Sandy (42)'
>  >>> d['person'] = p
>  >>> d.close()
>  >>> p = 'hello2'
>  >>> p
> 'hello2'
>  >>> d = shelve.open('tmp/stuff.shlv')
>  >>> p = d['person']
>  >>> p.whoami()
> 'Sandy (42)'
> 
> which seems to work fine for me.  This can be used for creating all 
> sorts of flavors of objects at design time, storing them, and then 
> restoring them at runtime.

I realize that Python has excellent abilities in all these areas, 
including serialization. But a component model for serialization must 
not only have the ability of serializing and deserializing all of the 
component's data, as well as any base classes, it must also have a means 
of allowing the class itself to specify which data needs to be 
serialized and which not, as well as allow for the class to seriliaze 
all or part of its own data.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote:
> Edward Diener No Spam wrote:
> 
>> There's no doubt that Python's excellent introspection mechanism allows
>> an outside RAD-like tool to inspect the workings of any Python object.
>> But that does not make it a component model in my original use of the
>> term on this thread. A RAD tool needs to know what properties and events
>> within a class can be manipulated visually, and it needs to be able to
>> serialize those properties and events so that they are set at run-time
>> automatically once an object is created.
> 
> external serialization was not part of your original definition.

Well, knock me over.

> 
> I think you have to be a *lot* more concrete here.  repeatedly referring to
> "some kind of hypothetical property (that isn't a property)" and "some kind
> of hypothetical event (that isn't a public method)" and "some kind of hypo-
> thetical RAD tool" won't get you anywhere.

My OP was just to query whether a component model existed for Python, 
like JavaBeans for Java or .Net for C#, C++/CLI etc. After that came 
suggestions of what I thought such a component model was about, which I 
thought I answered generally. Not you want details. No doubt next will 
come a demand for code.

OK, here is my idea of what such a component model envisages as a list 
of items. After this, unless I get some intelligent comments from people 
who might be interested in what I envision, or something very similar, I 
will be off to investigate it myself rather than do battle with the 
horde of people who will just tell me that Python, being a great 
language, does not need what I have suggested.

1) Component property: This is a glorified attribute with a type that 
can either be specified in a "static" manner, or always be discovered 
dynamically, or have converters back and forth between a string and the 
actual value represented by the component property. A component property 
has a getter function to retrieve the value if it is readable and a 
setter function to set the value if it is writable. It must be either 
readable or writable or both. A component property is not any Python 
class attribute since a component has the right to specify only certain 
values as manipulatable in a design-time RAD environment.

2) Component event: This is an type which encapsulates an array, or a 
list of callable objects with the same function signature, along with 
the functionality to add and remove elements from the array, as well as 
cycle through the array calling the callable objects as a particular 
event is triggered. A component event is an event source for a 
particular event. Component events have to be dicoverable by the Visual 
RAD system so that an object's appropriate event handler, an event sink, 
can be hooked to the component event itself, an event source, through a 
design time interface which propagates the connection at run-time.

3: Component serialization: A component which has its properties and 
events set by a visual design-time RAD environment needs to be 
serialized at design time and deserialized at run-time. This can be a 
default serialization of all component properties and events, or the 
component itself can participate in the serilization effort either 
wholly or partly.

4) Custom property and component editors: A component editor can present 
a property editor or an editor for an entire component which the visual 
design-time RAD environment can use to allow the programmer end-user of 
the component to set or get component property values. Normally a design 
time environment will present default property editors for each 
component property type, but a component can override this.

5) Custom type converters: A component should be able to specify a 
custom converter for any property to convert, in both directions or 
either direction, between the property's string value as seen by a 
property editor and the actual value of the component property's type.

This is the general gist of those things which are needed in a visual 
Design-time RAD environment.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Paul Boddie wrote:
> [EMAIL PROTECTED] wrote:
>> Edward> My OP was just to query whether a component model existed for
>> Edward> Python, like JavaBeans for Java or .Net for C#, C++/CLI
>> Edward> etc.
>>
>> For those of us who've never used Java, .Net or C++/CLI, a more concrete
>> description of what you were after from the beginning would have been
>> helpful.
> 
>>From vague recollections of the original Java Beans technology, the
> primary "innovation" was to have getProperty and setProperty methods,
> along with things like isCapability and hasProperty, if I remember
> correctly. None of this was really shocking to anyone using Python,
> mostly because Python had __getattr__ and __setattr__ even back then
> for customising real property/attribute access, and Python's run-time
> introspection capabilities were superior to Java's (and probably still
> are).

There is no argument on my part that Python's introspection and metadata 
  capabilities are superior to Java, as well as its potential attribute 
as component property model. In the theoretical Python model I proposed, 
the designer of the component must have the ability to specify which of 
the component's attributes are properties and how this is controlled ( 
via __getattr__ and __setattr__ ? descriptors as someone else suggested 
? other ideas ? ). Merely saying that all of an object's attributes are 
component properties for the purposes of a visual RAD designer can not 
be correct.

I actually think that Java's notion of preoperties in JavaBeans, which 
are just getter and setter functions with a particular naming 
convention, determined by Java as a default, or through an associated 
BeanInfo class, is rather klutzy and much prefer that of .Net or 
Borland's VCL where a particular language construct is used for 
properties instead. Of course with Python's superior metadata abilities, 
a particular new language construct shouldn't be necessary.

> 
> The other innovation was the introduction of standard interfaces for
> listening to and dispatching events, where you implement some listener
> interface and respond to events in order to "care about" those events.
> I don't recall any particularly good mechanisms for connecting beans to
> each other in order to fire off events, although the beanbox (or
> whatever the graphical tool originally promoted was called) and/or the
> IDE is supposed to help you with that part of the work.

The beanbox did nothing to help setup events, event sources, or event 
listeners. It just presented a graphical example of a visual RAD tool 
which could tie event sources to event listeners. It is onerous in 
JavaBeans to connect event sources to event listeners, and takes a good 
deal of manual coding although doing it is easy to understand.

> 
> The groovy 1990s API

1997.

Again Borland's VCL or .Net have much better solutions for events but 
again require language constructs which Python ought not need given its 
strong metadata possibilities to supply a component event model.

> is actually viewable in various places; here, for
> example:
> 
> http://www.doc.ic.ac.uk/~jpc1/linux/bdk-doc-1.0/apis.html

The BDK is no longer supported in the latest version of Java and 
JavaBeans. Instead there is a Bean Builder at 
https://bean-builder.dev.java.net/ .

> 
> Despite the supposedly exciting advances heralded by Java Beans, a
> large part of the technology was just codifying existing practices and
> techniques, but it could be argued that such techniques have been
> superseded by signal/slot mechanisms and more advanced event
> architectures (pioneered by frameworks like Qt and since adopted by
> Gtk, I believe).

I agree and I would want to have a component event model for Python that 
is much superior to the JavaBeans event model in ease of use. A much 
better ideal for component properties and component events is presented 
by .Net, where there are actual language keywords which perform the 
magic. I would guess that Qt and Gtk also follow a better ease of use 
path, perhaps with macros in C++. But Python should be able to do as 
good or better than any of these environments.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
fumanchu wrote:
> Edward Diener No Spam wrote:
>> OK, here is my idea of what such a component model envisages as a list
>> of items. After this, unless I get some intelligent comments from people
>> who might be interested in what I envision, or something very similar, I
>> will be off to investigate it myself rather than do battle with the
>> horde of people who will just tell me that Python, being a great
>> language, does not need what I have suggested.
> 
> [This quote hacked up by me:]
>> 1) Component property: This is a glorified attribute with a type that
>> a) can be specified in a "static" manner, or discovered dynamically,
>> b) has converters between a string and the actual value
>> c) has a getter function to retrieve the value if it is readable and a
>> setter function to set the value if it is writable.
>> d) be either readable or writable or both.
>> e) not any Python class attribute since a component has the right
>> to specify only certain values as manipulatable in a design-time
>> RAD environment.
> 
> Whenever you say "glorified attribute", your first thought should be
> "Python descriptor" (but not your last--it's not a cure-all). They are
> able to do all of (a, b, c, d, e) which I marked in your text above.
> For example, here's a descriptor for
> attributes-you-want-to-persist-in-a-database from my ORM, Dejavu (see
> http://projects.amor.org/dejavu/browser/trunk/units.py#l290):
> 
> 
> class UnitProperty(object):
> """Data descriptor for Unit data which will persist in storage."""
> 
> def __init__(self, type=unicode, index=False, hints=None, key=None,
> default=None):
> self.type = type
> self.index = index
> if hints is None: hints = {}
> self.hints = hints
> self.key = key
> self.default = default
> 
> def __get__(self, unit, unitclass=None):
> if unit is None:
> # When calling on the class instead of an instance...
> return self
> else:
> return unit._properties[self.key]
> 
> def __set__(self, unit, value):
> if self.coerce:
> value = self.coerce(unit, value)
> oldvalue = unit._properties[self.key]
> if oldvalue != value:
> unit._properties[self.key] = value
> 
> def coerce(self, unit, value):
> if value is not None and not isinstance(value, self.type):
> # Try to cast the value to self.type.
> try:
> value = self.type(value)
> except Exception, x:
> x.args += (value, type(value))
> raise
> return value
> 
> def __delete__(self, unit):
> raise AttributeError("Unit Properties may not be deleted.")
> 
>> a) can be specified in a "static" manner, or discovered dynamically,
> 
> The "component model" can either scan a class for instances of
> UnitProperty or keep a registry of them in the class or elsewhere (via
> a metaclass + add_property functions).
> 
>> b) has converters between a string and the actual value
> 
> Note the "coerce" function above. Something similar could be done for
> serialization (which I can prove in my case because I use UnitProperty
> to help produce SQL ;) but you could just as easily pickle
> unit._properties and be done with it.
> 
>> c) has a getter function to retrieve the value if it is readable and a
>> setter function to set the value if it is writable.
>> d) be either readable or writable or both.
> 
> Descriptors that only have __get__ are read-only; if they have __set__
> they are read-write.
> 
>> e) not any Python class attribute since a component has the right
>> to specify only certain values as manipulatable in a design-time
>> RAD environment.
> 
> Right. Descriptors allow the creator of a class to use "normal"
> attributes (including functions) which don't participate in the
> component model.
> 
>> 2) Component event: This is an type which encapsulates an array, or a
>> list of callable objects with the same function signature, along with
>> the functionality to add and remove elements from the array, as well as
>> cycle through the array calling the callable objects as a particular
>> event is triggered. A component event is an event source for a
>> particular event. Component events have to be dicoverable by the Visual
>> RAD system so that an object's appropriate event handler, an event sink,
>> can be hooked to the component event its

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Kay Schluehr wrote:
> fumanchu wrote:
> 
>>> 4) Custom property and component editors: A component editor can present
>>> a property editor or an editor for an entire component which the visual
>>> design-time RAD environment can use to allow the programmer end-user of
>>> the component to set or get component property values. Normally a design
>>> time environment will present default property editors for each
>>> component property type, but a component can override this.
>> This is the hard part. I believe Dabo has done some work in this space,
>> but this is where the tight coupling comes in between code and tool, a
>> coupling which Python has traditionally resisted.
> 
> I do think it's just about presenting component properties and their
> types / value ranges. I do think this can be easily achieved using
> decorators that might also add the right kind of token for
> introspection purposes to the function/method attributes. Descriptors
> i.e. customized binding semantics might cover one aspect of
> componentization but as I understood Edward he asked for uniform
> declarative semantics. 

Uniform in the sense that a visual RAD tool introspecting a Python class 
would be able to say that s type X is a component property and type Y is 
a component event, and everything is is just normal Python code which 
the RAD tool can ignore.

> Components in this sense are just specialized
> objects such as TestCase classes in the PyUnit framework.

Totally agreed. But the common functionality they add is valuable to 
visual RAD tools.

> What I still
> do not understand is the reference to "many RAD" tools which is
> completely hypothetical to me.

You are right that I should not have mentioned this without experience 
with the many Python tools, notable Python web page development 
environments, which are out there.

> The portability of components across
> different GUI designers for the same underlying toolkit is a quite
> speculative future requirement to say the least.

It's been a success in the Java world with JavaBeans and EJBs within 
environments like Eclipse, NetBeans, JBuilder, and others; and its been 
a success in the .Net world with .Net components within Visual Studio, 
Borland Development Studio, and potentially others, so ideally it could 
be a success in the Python world.

I believe the only knock against Python, as opposed to Java or .Net, is 
that it does not present enough ease of use environments to creating 
large scale applications, whether Linux, Windows, or Web applications. I 
believe part of that reason is because Python developers who, whether 
they wanted to distribute their classes for free or want to sell them 
for a profit, are presented with endless technologies built with Python, 
each one demanding a slightly different approach to class reusability, 
are reticent to develop their ideas for many different environments.

Wanting a common PME component model is a way of saying that Python 
class developers can develop their classes as components and at least at 
the base level can expect them to work flawlessly in any Python 
environment. I am NOT against a particular environment building further 
requirements on top of a common Python component model, and in fact 
would expect it in many cases. But given inheritance in OOP, and in 
Python of course, this might be as easy for me as deriving a new class 
from my particular base class component for a particular visual RAD 
development environment, adding the extra function needed onto my 
derived class, and away we go.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote:
> fumanchu wrote:
> 
>>> 4) Custom property and component editors: A component editor can present
>>> a property editor or an editor for an entire component which the visual
>>> design-time RAD environment can use to allow the programmer end-user of
>>> the component to set or get component property values. Normally a design
>>> time environment will present default property editors for each
>>> component property type, but a component can override this.
>>
>> This is the hard part. I believe Dabo has done some work in this space,
>> but this is where the tight coupling comes in between code and tool, a
>> coupling which Python has traditionally resisted.
> 
> that's not that hard on a pure technical level; even a "basic" tool
> like IDLE can hook itself into an executing Python process.  once you're 
> hooked up, you can inspect and modify most about everything.
> 
> for example, doing remote tweaking of live Tkinter widget trees is 
> pretty straight-forward.
> 
> coming up with a good way to capture the modifications, and use them in 
> your actual application, is a bit harder.  do you really want to replace 
> plain old source code with some kind of more or less obscure resource 
> files?

The Visual Studio RAD IDE environment actually modifies source code 
constructors, via an InitializeComponent() function called from it, in 
order to set properties and events in components. It does mark the 
function as such with comments in the source code. OTOH Borland's VCL 
uses the resource file technique you scorn above, linking in the code 
via resources and automatically updating a component's properties and 
events from base class components constructors. I believe Java's JVM 
automatically deserializes .ser files at run-time saved by a RAD 
designer in order to set properties and events on an object of a class.

There are obviously numerous techniques, so one should theoretically 
work well with Python.

> 
> and designing a metadata vocabulary that's powerful enough to be useful 
> for more than just one or a few target domains might be really hard.

That's the are I am most interested in.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-14 Thread Edward Diener No Spam
Peter Wang wrote:
> Edward Diener wrote:
>> It looks as if traits is an attempt to create a "property" in the
>> component terminology which I originally specified. I will take a look
>> at it.
> 
> Traits is frighteningly similar to the requirements that you laid out
> in your post (the example for Skip), including delegates!  I would like
> to point out, however, that traits is a *general* component framework
> for python that facilitates implementing the observer pattern and a
> higher level of introspection.  It can be used to build applications
> that have no visual interfaces at all, but wish to benefit from the
> "reactive programming" style that componentized, event-based
> programming encourages.  (induces?)

Thanks for the explanation. I was too quick in seeing Traits as only a 
version of properties without realizing that it included much more.

> 
> Traits UI, which Robert only alluded to, is actually very much the sort
> of RAD environment you have described.  It builds upon the component
> model, and uses introspection to automagically create nice widgets for
> your model, but adds mechanisms for specifying controllers, customizing
> behavior, and generically composing complicated forms from simpler
> ones.  There is even a visual "builder" tool for it called VET that
> closely resembles Delphi/C++ Builder.  (The VET itself is, of course,
> written using Traits UI.)

I have downloaded both Traits and Traits UI and will look at both.

> 
> Envisage, the plugin application framework, can use the traits
> component models and the TraitsUI interfaces to roll out very dynamic
> applications, whose underlying models are all live components that can
> be scripted, twiddled with from an embedded Python shell, etc.
> 
>> Already subscribed. Thanks !
> 
> Please contribute ideas or ask conceptual questions!

It would be easier for me if you could get an NG somewhere for 
Enthought, perhaps on GMane, since I always find mailing lists much more 
clunky than a good NG. But that is up to Enthought.

> 
> Oh, and disclaimer: I also work at enthought. :)

That's fine. It is the ideas about a PME component model for Python in 
which I was interested, no matter where it originates. Thanks for the 
encouraging reply.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-14 Thread Edward Diener No Spam
Kay Schluehr wrote:
> val bykoski wrote:
>> Peter Wang wrote:
>>> Edward,
>>>
>>> This isn't in response to any specific one of the 100+ posts on this
>>> thread, but I justed wanted to encourage you to continue your
>>> investigation into Python component models and maybe looking for some
>>> common ground between them.  Frequently the individual developers are
>>> too heads-down on working on their own things to do a broad survey, so
>>> I think this would be very useful indeed.
>>>
>>> I wouldn't have felt it necessary to post this except for the large
>>> number of posts along the lines of "foo.dict is introspective enough
>>> for me!".  I think you might have an easier time evangelizing the
>>> principle of component-oriented programming (or "event-based", or
>>> "reactive", or whatever) if you separated it from the notions of RAD UI
>>> development.  There is a very large difference between writing
>>> components and writing objects, and it seems that most people arguing
>>> "python doesn't need components" don't see this distinction.
>>>
>>> For me, it's the difference between writing "live" objects and "dead"
>>> objects.  Live objects not only encapsulate implementations of an
>>> interface with some state, but they also encapsulate handling of
>>> events, i.e. responses to changes in their environment.  Dead objects
>>> have methods but there has to be a function somewhere that knows which
>>> dead object to call with what parameters at exactly the right time.
>>> (The only mechanism for managing this complexity is to create ever more
>>> functions at ever higher levels of abstraction, or to have a
>>> proliferation of nebulously-defined "manager" objects.)  IMHO once you
>>> cross this chasm and are able to model your problem domain with live
>>> objects that go off and automatically respond to the runtime
>>> environment and Do the Right Thing, it's very hard to go back to a dead
>>> object mindset.  I can understand, however, that until one makes this
>>> leap, it might seem like an academic and useless distinction.
>>>
>>> -peter
>>>
>> Excellent post, Peter.  Thanks for great clarification. Looking from a
>> physicist' perspective, im always trying to compare/evaluate languages
>> from "the physical reality/dynamics" angle.  So, the run-time
>> space/dynamics is the only one that matches the natural "always-runtime"
>> objects - atoms, molecules, EM fields, biological cells(?).  It is the
>> *reactive* world with event/forces-driven dynamics.  Seemingly, there is
>> nothing beyond that, including biology.
> 
> A more conventional notion is that of static/dynamic properties of a
> language. Component models that guarantee certain properties at compile
> time are easily checked for consistency but to many programmers ( I
> guess most of the programmers who attend to this list ) they are
> inflexible: you might change or adapt your components according to
> events, switch between entities, enable dynamic configuration etc. This
> can be achieved in C++, Java etc. as well but not without pain.

Having "static" properties and events is necessary for visual RAD 
programming environments, where connections are being setup between 
events and event handlers, and properties are being initialized, at 
design time. This does not preclude the normal "dynamic" attributes of 
Python. However if Python programmers reject such visual RAD programming 
environments as having any value, then they probably won't be interested 
in a common component model for them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lead Software Engineer

2006-10-19 Thread Edward Diener No Spam
Emma wrote:
> Successful candidates meet the following requirements:
> · A burning desire to build rock-solid apps that people will be
> unable
> to live without

I use to have a burning desire to cleverly answer questionnaires for 
companies which either don't exist or, if they do, don't tell you who 
they are, where they are located, or what they are offering, but I gave 
it up in infancy.
-- 
http://mail.python.org/mailman/listinfo/python-list


TypeError: unbound method must be called with class instance 1st argument

2006-12-20 Thread void . no . spam . com
I'm a novice at Python, and found some code samples on how to use
threads.  My script is being run by a product that contains a Jython
interpreter.  Can someone please explain why I get the following error:

Traceback (innermost last):
  File "/full/path/to/file/GenerateData.py", line 104, in ?
  File "/full/path/to/file/GenerateData.py", line 34, in __init__
TypeError: unbound method must be called with class instance 1st
argument


Here are the important pieces of my GenerateData.py script.  Note that
"scriptinterface" is something provided by the product to allow my
script to interface with it.  Line 104 is the last line -- the one that
creates a GenThread and calls start() on it.


import sys

# need this section otherwise the import random won't work
if sys.path.count('/usr/local/lib/python2.2/') == 0:
sys.path.append('/usr/local/lib/python2.2/')

import random
import time
import threading

from java.lang import String
from jarray import array

class GenThread(threading.Thread):
def __init__(self, ipAddress, port):
threading.Thread.__init__()
self.ipAddress = ipAddress
self.port = str(port)

def run(self):
#
# code
#

GenThread(scriptinterface.getSnmpIPAddress(),
scriptinterface.getSnmpPort()).start()

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


Re: TypeError: unbound method must be called with class instance 1st argument

2006-12-20 Thread void . no . spam . com

Matimus wrote:
> >  Can someone please explain why I get the following error:
>
> The following line:
>  threading.Thread.__init__()
> Should be written as:
>  threading.Thread.__init__(self)

Thank you!

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


Re: so funny...

2008-05-29 Thread Hung Well (no comma)

"John" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> http://sitscape.com/topic/funny
>
> Just keep hit the "Surprise->" button there for amazing fun.
> Click on "channel" will show you other topics, lots of fun!


You tickle easy.

--WH 


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


Re: Python 2.4 | 7.3 The for statement

2005-03-22 Thread he . dicho . que . no . quiero . spam
brainsucker wrote:

> Python 2.4 | 7.3 The for statement:
> ---
>
>  for_stmt ::= "for" target_list "in" expression_list ":"
>   suite ["else" ":" suite]
>
>
> New for statement:
> --
>
> for_stmt ::= "for" target_list "in" expression_list
>  [ "and" expression ] ":"
>   suite ["else" ":" suite]
>
>   ** If the expression evaluates to False before
>  entering the for, jump else.
>   ** If the expression is evaluated to False after
>  the first iteration, break.




I think that your idea is good but as others said the "and" literal
could be confusing. ¿Maybe we can use another word instead of "and"?

The for definition could be like this:

 for_stmt ::= "for" target_list "in" expression_list
 [ "until" expression ] ":"
  suite ["else" ":" suite]

or some other word that clarifies the work of the expression

 leave_cond_1 = False
 leave_cond_2 = False
 mylist = [1,2,3,4,5]
 for item in mylist until leave_cond_1 or leave_cond_2:
   print item

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