Re: the python shell window is already executing a command

2014-09-19 Thread Terry Reedy

On 9/18/2014 10:51 PM, Chris Angelico wrote:

On Fri, Sep 19, 2014 at 5:05 AM, Terry Reedy tjre...@udel.edu wrote:

A couple more questions; after you run the file once, is there a warning
above the first  prompt?  If, after the program stop and you see a second

prompt and run
import sys; len(sys.modules), 'array' in sys.modules

what is the result?


What's significant about the array module here? I'm a little puzzled.


'array' is alphabetically the first module imported in the default 
two-process mode but not in the one-process mode selected by a command 
line '-n'.  To the best of my understanding, the message reported, which 
I found in the code, should only appear in one-process mode.


Seymour reported that he started Idle by right-clicking on the file and 
selecting 'Edit with Idle'. Asking the above question is easier then 
trying to get him to directly determine what command line is associated 
with 'Edit with Idle' on his particular machine.


--
Terry Jan Reedy

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


Re: the python shell window is already executing a command

2014-09-19 Thread Chris Angelico
On Sat, Sep 20, 2014 at 5:43 AM, Terry Reedy tjre...@udel.edu wrote:
 On 9/18/2014 10:51 PM, Chris Angelico wrote:

 On Fri, Sep 19, 2014 at 5:05 AM, Terry Reedy tjre...@udel.edu wrote:

 A couple more questions; after you run the file once, is there a warning
 above the first  prompt?  If, after the program stop and you see a
 second

 prompt and run
 import sys; len(sys.modules), 'array' in sys.modules

 what is the result?


 What's significant about the array module here? I'm a little puzzled.


 'array' is alphabetically the first module imported in the default
 two-process mode but not in the one-process mode selected by a command line
 '-n'.  To the best of my understanding, the message reported, which I found
 in the code, should only appear in one-process mode.

 Seymour reported that he started Idle by right-clicking on the file and
 selecting 'Edit with Idle'. Asking the above question is easier then trying
 to get him to directly determine what command line is associated with 'Edit
 with Idle' on his particular machine.

Ah! Nice one. :) Get the info you want with a very simple copy/paste
line of code. Cryptic, but effective.

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


Re: the python shell window is already executing a command

2014-09-18 Thread Seymore4Head
On Wed, 17 Sep 2014 23:50:56 -0400, Terry Reedy tjre...@udel.edu
wrote:

On 9/17/2014 9:34 PM, Seymore4Head wrote:
 On Wed, 17 Sep 2014 18:56:47 -0400, Terry Reedy tjre...@udel.edu

 A little digging with Idle's grep (Find in Files) shows that the message
 is produced by this code in idlelib/PyShell.py, about 825.

  def display_executing_dialog(self):
  tkMessageBox.showerror(
  Already executing,
  The Python Shell window is already executing a command; 
  please wait until it is finished.,
  master=self.tkconsole.text)

 This function is only called here (about line 735)
  def runcommand(self, code):
  Run the code without invoking the debugger
  # The code better not raise an exception!
  if self.tkconsole.executing:
  self.display_executing_dialog()
  else run idle code in user process output view user

 How is this run?  Run-Module F5 invokes
 ScriptBinding.run_module_event(116) and thence _run_module_event (129).
 This methods includes this.
  if PyShell.use_subprocess:
  interp.restart_subprocess(with_cwd=False)

 restart_subprocess includes these lines (starting at 470):
  # Kill subprocess, spawn a new one, accept connection.
  self.rpcclt.close()
  self.terminate_subprocess()
  console = self.tkconsole
  ...
  console.executing = False  # == self.tkconsole
  ...
  self.transfer_path(with_cwd=with_cwd)

 transfer_path calls runcommand but only after tkconsole.executing has
 been set to False.  But this only happens if PyShell.use_subprocess is
 True, which it normally is, but not if one starts Idle with the -n option.

 After conditionally calling interp.restart_subprocess, _run_module_event
 directly calls interp.runcommand, which can fail when running with -n.
 Are you?  This is the only way I know to get the error message.  Is so,
 the second way to not get the error message is to not use -n and run
 normally.

 Sorry.  I don't speak python yet.  Quite a few of the above terms are
 new to me.

 It may be that was trying to run the program again before the current
 one was finished.  In the past I was getting the error when I was
 (almost) sure the program had finished.  I will be more careful in the
 future, but I will also keep an eye out for the problem to repeat.
 I just tried to run the above program again and gave it more time to
 finish and I did not get the error, so it could well be I was jumping
 the gun.

My question was How do you start Idle?
(I can make a difference.)

The way I start IDLE is to go to my programs folder and right click on
file.py in the directory and select edit with IDLE.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: the python shell window is already executing a command

2014-09-18 Thread Terry Reedy

On 9/18/2014 11:24 AM, Seymore4Head wrote:

On Wed, 17 Sep 2014 23:50:56 -0400, Terry Reedy tjre...@udel.edu
wrote:



My question was How do you start Idle?
(I can make a difference.)


The way I start IDLE is to go to my programs folder and right click on
file.py in the directory and select edit with IDLE.


A couple more questions; after you run the file once, is there a warning 
above the first  prompt?  If, after the program stop and you see a 
second  prompt and run

 import sys; len(sys.modules), 'array' in sys.modules
what is the result?

If you run the program multiple times and get the error message, please 
cut and paste the whole message and the lines above, up to 10 or 15.


--
Terry Jan Reedy

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


Re: the python shell window is already executing a command

2014-09-18 Thread Seymore4Head
On Thu, 18 Sep 2014 15:05:53 -0400, Terry Reedy tjre...@udel.edu
wrote:

On 9/18/2014 11:24 AM, Seymore4Head wrote:
 On Wed, 17 Sep 2014 23:50:56 -0400, Terry Reedy tjre...@udel.edu
 wrote:

 My question was How do you start Idle?
 (I can make a difference.)

 The way I start IDLE is to go to my programs folder and right click on
 file.py in the directory and select edit with IDLE.

A couple more questions; after you run the file once, is there a warning 
above the first  prompt?  If, after the program stop and you see a 
second  prompt and run
  import sys; len(sys.modules), 'array' in sys.modules
what is the result?

If you run the program multiple times and get the error message, please 
cut and paste the whole message and the lines above, up to 10 or 15.

I think it might be that I was trying to re run the program too soon.
I haven't messed with any programming too much, but I did re run the
program I posted and gave it more time to finish.  That seems to have
been the problem.

If I run into the problem again after making sure the program has
finished, I will update.

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


Re: the python shell window is already executing a command

2014-09-18 Thread Chris Angelico
On Fri, Sep 19, 2014 at 5:05 AM, Terry Reedy tjre...@udel.edu wrote:
 A couple more questions; after you run the file once, is there a warning
 above the first  prompt?  If, after the program stop and you see a second
 prompt and run
 import sys; len(sys.modules), 'array' in sys.modules
 what is the result?

What's significant about the array module here? I'm a little puzzled.

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


Re: the python shell window is already executing a command

2014-09-17 Thread Terry Reedy

On 9/16/2014 10:17 PM, Seymore4Head wrote:

I have googled for a solution to this problem.  None I have tried
worked.

I have a very short program that runs for a count of 20 and ends.
What I do is click on the IDLE window and without making any changes I
just hit f5 to rerun the program.


Do you mean click on the Idle editor window?


Sometimes I get the error the python shell window is already
executing a command and sometimes not.

I am using XP and Python 3.4.1.

Is there a way to rerun a program without getting this error?


Normally, hitting f5 kills the previous process if it is still running 
and starts the one in the editor.  Please post a minimal program that 
exhibits the problem.


--
Terry Jan Reedy

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


Re: the python shell window is already executing a command

2014-09-17 Thread Seymore4Head
On Wed, 17 Sep 2014 04:02:16 -0400, Terry Reedy tjre...@udel.edu
wrote:

On 9/16/2014 10:17 PM, Seymore4Head wrote:
 I have googled for a solution to this problem.  None I have tried
 worked.

 I have a very short program that runs for a count of 20 and ends.
 What I do is click on the IDLE window and without making any changes I
 just hit f5 to rerun the program.

Do you mean click on the Idle editor window?

 Sometimes I get the error the python shell window is already
 executing a command and sometimes not.

 I am using XP and Python 3.4.1.

 Is there a way to rerun a program without getting this error?

Normally, hitting f5 kills the previous process if it is still running 
and starts the one in the editor.  Please post a minimal program that 
exhibits the problem.

It happens in almost every program I have written.  I just tried this
one again.  I could run the program by pushing f5.  The first couple
of times it would run again by switching back to IDLE and pressing f5,
but after the second or third time, it gives an error that the python
shell window is already executing a command.

If I make a change to the program, like adding or deleting a 0 from
rounds the program will run without generating an error, but if I
try to re run the program without changing anything, I get the error
almost every time.


Here is one.

import random
count =0
rounds=1000
heads=0
tails=0
ht=[0,1]
while countrounds:
coin=random.choice(ht)
if coin == 0:
heads=heads+1
elif coin == 1:
tails=tails+1
count = count + 1
print (heads,tails)
print ('Heads {:.2%} Tails {:.2%} '.format(heads/rounds,
tails/rounds))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: the python shell window is already executing a command

2014-09-17 Thread Terry Reedy

On 9/17/2014 11:55 AM, Seymore4Head wrote:

On Wed, 17 Sep 2014 04:02:16 -0400, Terry Reedy tjre...@udel.edu
wrote:

On 9/16/2014 10:17 PM, Seymore4Head wrote:

What I do is click on the IDLE window and without making any changes I
just hit f5 to rerun the program.
Sometimes I get the error the python shell window is already
executing a command and sometimes not.


You left out an important part of the error message please wait until 
it is finished.



I am using XP and Python 3.4.1.


I am using 3.4.1 on Win 7.


Is there a way to rerun a program without getting this error?


Follow the instruction you were given, but omitted, or see below.


Normally, hitting f5 kills the previous process if it is still running
and starts the one in the editor.  Please post a minimal program that
exhibits the problem.


It happens in almost every program I have written.  I just tried this
one again.  I could run the program by pushing f5.  The first couple
of times it would run again by switching back to IDLE and pressing f5,
but after the second or third time, it gives an error that the python
shell window is already executing a command.

If I make a change to the program, like adding or deleting a 0 from
rounds the program will run without generating an error, but if I
try to re run the program without changing anything, I get the error
almost every time.


Here is one.

import random
count =0
rounds=1000
heads=0
tails=0
ht=[0,1]
while countrounds:
 coin=random.choice(ht)
 if coin == 0:
 heads=heads+1
 elif coin == 1:
 tails=tails+1
 count = count + 1
print (heads,tails)
print ('Heads {:.2%} Tails {:.2%} '.format(heads/rounds,
tails/rounds))


I am unable to reproduce the problem. When I run this program from an 
Idle editor, it finished before I can click on the Editor window and hit 
F5 again.  The same remains true with 1 or 2 zeros added.  With 100 
rounds, I get the expected behavior, which is no ouput from the 
cancelled process and a clean restart.


A little digging with Idle's grep (Find in Files) shows that the message 
is produced by this code in idlelib/PyShell.py, about 825.


def display_executing_dialog(self):
tkMessageBox.showerror(
Already executing,
The Python Shell window is already executing a command; 
please wait until it is finished.,
master=self.tkconsole.text)

This function is only called here (about line 735)
def runcommand(self, code):
Run the code without invoking the debugger
# The code better not raise an exception!
if self.tkconsole.executing:
self.display_executing_dialog()
else run idle code in user process output view user

How is this run?  Run-Module F5 invokes 
ScriptBinding.run_module_event(116) and thence _run_module_event (129). 
This methods includes this.

if PyShell.use_subprocess:
interp.restart_subprocess(with_cwd=False)

restart_subprocess includes these lines (starting at 470):
# Kill subprocess, spawn a new one, accept connection.
self.rpcclt.close()
self.terminate_subprocess()
console = self.tkconsole
...
console.executing = False  # == self.tkconsole
...
self.transfer_path(with_cwd=with_cwd)

transfer_path calls runcommand but only after tkconsole.executing has 
been set to False.  But this only happens if PyShell.use_subprocess is 
True, which it normally is, but not if one starts Idle with the -n option.


After conditionally calling interp.restart_subprocess, _run_module_event 
directly calls interp.runcommand, which can fail when running with -n. 
Are you?  This is the only way I know to get the error message.  Is so, 
the second way to not get the error message is to not use -n and run 
normally.


--
Terry Jan Reedy


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


Re: the python shell window is already executing a command

2014-09-17 Thread Seymore4Head
On Wed, 17 Sep 2014 18:56:47 -0400, Terry Reedy tjre...@udel.edu
wrote:

On 9/17/2014 11:55 AM, Seymore4Head wrote:
 On Wed, 17 Sep 2014 04:02:16 -0400, Terry Reedy tjre...@udel.edu
 wrote:
 On 9/16/2014 10:17 PM, Seymore4Head wrote:
 What I do is click on the IDLE window and without making any changes I
 just hit f5 to rerun the program.
 Sometimes I get the error the python shell window is already
 executing a command and sometimes not.

You left out an important part of the error message please wait until 
it is finished.

 I am using XP and Python 3.4.1.

I am using 3.4.1 on Win 7.

 Is there a way to rerun a program without getting this error?

Follow the instruction you were given, but omitted, or see below.

 Normally, hitting f5 kills the previous process if it is still running
 and starts the one in the editor.  Please post a minimal program that
 exhibits the problem.

 It happens in almost every program I have written.  I just tried this
 one again.  I could run the program by pushing f5.  The first couple
 of times it would run again by switching back to IDLE and pressing f5,
 but after the second or third time, it gives an error that the python
 shell window is already executing a command.

 If I make a change to the program, like adding or deleting a 0 from
 rounds the program will run without generating an error, but if I
 try to re run the program without changing anything, I get the error
 almost every time.


 Here is one.

 import random
 count =0
 rounds=1000
 heads=0
 tails=0
 ht=[0,1]
 while countrounds:
  coin=random.choice(ht)
  if coin == 0:
  heads=heads+1
  elif coin == 1:
  tails=tails+1
  count = count + 1
 print (heads,tails)
 print ('Heads {:.2%} Tails {:.2%} '.format(heads/rounds,
 tails/rounds))

I am unable to reproduce the problem. When I run this program from an 
Idle editor, it finished before I can click on the Editor window and hit 
F5 again.  The same remains true with 1 or 2 zeros added.  With 100 
rounds, I get the expected behavior, which is no ouput from the 
cancelled process and a clean restart.

A little digging with Idle's grep (Find in Files) shows that the message 
is produced by this code in idlelib/PyShell.py, about 825.

 def display_executing_dialog(self):
 tkMessageBox.showerror(
 Already executing,
 The Python Shell window is already executing a command; 
 please wait until it is finished.,
 master=self.tkconsole.text)

This function is only called here (about line 735)
 def runcommand(self, code):
 Run the code without invoking the debugger
 # The code better not raise an exception!
 if self.tkconsole.executing:
 self.display_executing_dialog()
 else run idle code in user process output view user

How is this run?  Run-Module F5 invokes 
ScriptBinding.run_module_event(116) and thence _run_module_event (129). 
This methods includes this.
 if PyShell.use_subprocess:
 interp.restart_subprocess(with_cwd=False)

restart_subprocess includes these lines (starting at 470):
 # Kill subprocess, spawn a new one, accept connection.
 self.rpcclt.close()
 self.terminate_subprocess()
 console = self.tkconsole
 ...
 console.executing = False  # == self.tkconsole
 ...
 self.transfer_path(with_cwd=with_cwd)

transfer_path calls runcommand but only after tkconsole.executing has 
been set to False.  But this only happens if PyShell.use_subprocess is 
True, which it normally is, but not if one starts Idle with the -n option.

After conditionally calling interp.restart_subprocess, _run_module_event 
directly calls interp.runcommand, which can fail when running with -n. 
Are you?  This is the only way I know to get the error message.  Is so, 
the second way to not get the error message is to not use -n and run 
normally.

Sorry.  I don't speak python yet.  Quite a few of the above terms are
new to me.

It may be that was trying to run the program again before the current
one was finished.  In the past I was getting the error when I was
(almost) sure the program had finished.  I will be more careful in the
future, but I will also keep an eye out for the problem to repeat.
I just tried to run the above program again and gave it more time to
finish and I did not get the error, so it could well be I was jumping
the gun.

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


Re: the python shell window is already executing a command

2014-09-17 Thread Terry Reedy

On 9/17/2014 9:34 PM, Seymore4Head wrote:

On Wed, 17 Sep 2014 18:56:47 -0400, Terry Reedy tjre...@udel.edu



A little digging with Idle's grep (Find in Files) shows that the message
is produced by this code in idlelib/PyShell.py, about 825.

 def display_executing_dialog(self):
 tkMessageBox.showerror(
 Already executing,
 The Python Shell window is already executing a command; 
 please wait until it is finished.,
 master=self.tkconsole.text)

This function is only called here (about line 735)
 def runcommand(self, code):
 Run the code without invoking the debugger
 # The code better not raise an exception!
 if self.tkconsole.executing:
 self.display_executing_dialog()
 else run idle code in user process output view user

How is this run?  Run-Module F5 invokes
ScriptBinding.run_module_event(116) and thence _run_module_event (129).
This methods includes this.
 if PyShell.use_subprocess:
 interp.restart_subprocess(with_cwd=False)

restart_subprocess includes these lines (starting at 470):
 # Kill subprocess, spawn a new one, accept connection.
 self.rpcclt.close()
 self.terminate_subprocess()
 console = self.tkconsole
 ...
 console.executing = False  # == self.tkconsole
 ...
 self.transfer_path(with_cwd=with_cwd)

transfer_path calls runcommand but only after tkconsole.executing has
been set to False.  But this only happens if PyShell.use_subprocess is
True, which it normally is, but not if one starts Idle with the -n option.

After conditionally calling interp.restart_subprocess, _run_module_event
directly calls interp.runcommand, which can fail when running with -n.
Are you?  This is the only way I know to get the error message.  Is so,
the second way to not get the error message is to not use -n and run
normally.


Sorry.  I don't speak python yet.  Quite a few of the above terms are
new to me.

It may be that was trying to run the program again before the current
one was finished.  In the past I was getting the error when I was
(almost) sure the program had finished.  I will be more careful in the
future, but I will also keep an eye out for the problem to repeat.
I just tried to run the above program again and gave it more time to
finish and I did not get the error, so it could well be I was jumping
the gun.


My question was How do you start Idle?
(I can make a difference.)

--
Terry Jan Reedy

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


the python shell window is already executing a command

2014-09-16 Thread Seymore4Head
I have googled for a solution to this problem.  None I have tried
worked.

I have a very short program that runs for a count of 20 and ends.
What I do is click on the IDLE window and without making any changes I
just hit f5 to rerun the program.

Sometimes I get the error the python shell window is already
executing a command and sometimes not.

I am using XP and Python 3.4.1.

Is there a way to rerun a program without getting this error?

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


did anybody play with python and window mobile broadband?

2010-03-18 Thread News123
Hi,


I'd like to use a mobile broadband device with a windows python app.
Did anybody play already with python and the window mobile broadband
interface?

I'm looking for examples:
- how to connect/disconnect  a mobile broadband device (currently I use
rasdial. not sure it's the best solution)
- to obtain the device's current mode (GPRS / EDGE / . . . )
- to obtain the current signal level

Thanks a lot for any pointers



N

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


Re: did anybody play with python and window mobile broadband?

2010-03-18 Thread Sanjiva P.
On 03/18/2010 10:20 AM, News123 wrote:
 I'm looking for examples:
 - how to connect/disconnect  a mobile broadband device (currently I use
 rasdial. not sure it's the best solution)
 - to obtain the device's current mode (GPRS / EDGE / . . . )
 - to obtain the current signal level
 
 Thanks a lot for any pointers

Well no examples,but most or all of it should work through AT commands.

Did you try plugging the mobile broadband interface in?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: did anybody play with python and window mobile broadband?

2010-03-18 Thread egl...@gmail.com
On 18 мар, 11:20, News123 news1...@free.fr wrote:
 I'd like to use a mobile broadband device with a windows python app.
 Did anybody play already with python and the window mobile broadband
 interface?


There was a discussion on this subject in some local forum recently. I
assume you're using PythonCE, right?

The best solution proposed there was to use ctypes and WinAPI. You can
find a relatively high level APIs to set up a connection (without need
to go too low level with AT commands) and make your own wrapper.

A good starting point can be found here: 
http://msdn.microsoft.com/en-us/library/bb416346.aspx
(it's not the only way to to things, btw).

--
regards,
eGlyph
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: did anybody play with python and window mobile broadband?

2010-03-18 Thread News123
Hi Sanjiva,


Sanjiva P. wrote:
 On 03/18/2010 10:20 AM, News123 wrote:
 I'm looking for examples:
 - how to connect/disconnect  a mobile broadband device (currently I use
 rasdial. not sure it's the best solution)
 - to obtain the device's current mode (GPRS / EDGE / . . . )
 - to obtain the current signal level

 Thanks a lot for any pointers
 
 Well no examples,but most or all of it should work through AT commands.
Thanks, yes AT commands would be fine.
How can I send AT commands, while another application / connection
mnager is using the modem?


I just don't know how to send AT commands to a connected modem.


 
 Did you try plugging the mobile broadband interface in?

What do you mean with pluggging in?

ctypes?
or something else?




bye


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


Re: did anybody play with python and window mobile broadband?

2010-03-18 Thread News123
Hy Eglyph,

egl...@gmail.com wrote:
 On 18 мар, 11:20, News123 news1...@free.fr wrote:
 I'd like to use a mobile broadband device with a windows python app.
 Did anybody play already with python and the window mobile broadband
 interface?

 
 There was a discussion on this subject in some local forum recently. I
 assume you're using PythonCE, right?

No I'm using C-Python on a small windows PC (Atom) with a USB Boradband
modem.

Could you forward me the discussion in case you remember the forum?


 
 The best solution proposed there was to use ctypes and WinAPI. You can
 find a relatively high level APIs to set up a connection (without need
 to go too low level with AT commands) and make your own wrapper.
 
 A good starting point can be found here: 
 http://msdn.microsoft.com/en-us/library/bb416346.aspx
 (it's not the only way to to things, btw).

Thanks, I'll read into it.

bye

N


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


Re: Porting VB apps to Python for Window / Linux use

2008-10-27 Thread Steven D'Aprano
On Mon, 27 Oct 2008 12:31:06 +1100, Ben Finney wrote:

 Lawrence D'Oliveiro [EMAIL PROTECTED] writes:
 
 Software has no market value. Business models that try to assign it one
 are doomed to fight an uphill battle against market forces.
 
 +1 QOTW.

-1

That quote confuses the *cost* of duplicating software (which is close 
enough to zero) with the *value* put on the software by the market (the 
users). We can see that, for example, Ben Finney himself puts quite a lot 
of value on software such as emacs. Just recently Ben wrote (paraphrased) 
that he valued emacs because although he wasn't a Lisp programmer, other 
programmers had already produced many fine emacs tools that let him be a 
more productive developer. Now Ben is agreeing with the statement that he 
doesn't value software, that he considers emacs and other such tools mere 
commodities and is indifferent to which he uses, or even whether he uses 
any at all. That's clearly untrue, and I can only imagine it is because 
Ben doesn't understand what it means for a product, service or thing to 
have no market value. No value is not the same as priceless, and I 
imagine Ben would agree that freedom to modify the source code of emacs 
is virtually priceless.

Should distribution costs rise (say, because the Australian government's 
compulsory web censorship plan accidentally block all free software -- 
it must be warez if it's free, right?) then would it really be 
inconceivable that people in Australia who valued emacs over (say) 
Microsoft Notepad would be willing to pay for reliable, uncensored copies 
of the software?

Plenty of people pay for free software. Some of them pay with money, some 
of them pay with development effort, some of them with both. Unless my 
memory is playing tricks on me, I believe that Ben himself has purchased 
Ubuntu CDs with real money; and if he hasn't, I can assure you that his 
employer has.

I can only imagine that what Lawrence was trying to say was something on 
the lines of this: open source software reduces the ability of vendors to 
extract monopoly rents from software by turning each software application 
itself into a commodity. It's not just that there are a thousand 
different text editors from a thousand suppliers that Ben could use, but 
that there are a thousand suppliers entitled to distribute emacs itself, 
and competition between those suppliers ensure that the cost of emacs 
approaches the marginal cost of duplication and distribution, which is 
essentially zero.

(The corollary of this is that to avoid such commoditization, software 
vendors need the government to enforce an artificial monopoly on each 
product. That's not necessarily a bad thing, although it often is.)

It's not as snappy as saying that Ben and others like him don't value 
software, but it's more accurate.



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


Re: Porting VB apps to Python for Window / Linux use

2008-10-26 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Stef
Mientki wrote:

 ... although I realize closed source is not completely possibly in Python,
 but that's no problem if the program is large/complex enough compared to
 it's market value ;-)

Software has no market value. Business models that try to assign it one are
doomed to fight an uphill battle against market forces.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-26 Thread Ben Finney
Lawrence D'Oliveiro [EMAIL PROTECTED] writes:

 Software has no market value. Business models that try to assign it
 one are doomed to fight an uphill battle against market forces.

+1 QOTW.

-- 
 \   “Yesterday I told a chicken to cross the road. It said, ‘What |
  `\ for?’” —Steven Wright |
_o__)  |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-24 Thread Ed Leafe

On Oct 18, 2008, at 8:12 AM, Dotan Cohen wrote:


I often see mention of SMBs that either want to upgrade their Windows
installations, or move to Linux, but cannot because of inhouse VB
apps. Are there any Python experts who I can reference them to for
porting? I have nothing on hand at the moment, but I see this as a
need without an obvious answer.


	Sorry for the delay in responding, but someone just pointed out this  
post to me.


	You might want to take a look at Dabo, which is an integrated desktop  
application framework for Python (disclosure: I'm one of the authors).  
It allows you to visually create UIs that run unmodified on Windows,  
Linux and OS X.


You can learn about it at http://dabodev.com


-- Ed Leafe



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


Re: Porting VB apps to Python for Window / Linux use

2008-10-21 Thread Stef Mientki

Grant Edwards wrote:

On 2008-10-20, Stef Mientki [EMAIL PROTECTED] wrote:

  

I don't think I'm feeding the troll, but - ever took a look at
PyQt?
  

I wanted to go from Delphi to a free / open source
environment, for both open source and commercial applications.

So the Qt license stopped me from looking any further.



The Qt license is still free/open-source for commercial
applications as long as you license your app under the GPL.

Did you mean to say for both open source and closed source
applications?

  

Yes,
although I realize closed source is not completely possibly in Python,
but that's no problem if the program is large/complex enough compared to 
it's market value ;-)


cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Bruno Desthuilliers

Stef Mientki a écrit :

Lawrence D'Oliveiro wrote:

In message [EMAIL PROTECTED], Dotan
Cohen wrote:

 

I often see mention of SMBs that either want to upgrade their Windows
installations, or move to Linux, but cannot because of inhouse VB
apps.



Probably best to leave those legacy VB apps alone and develop new
replacements in a more open, cross-platform language, like Python.
  

Sorry but for GUI design, Python is pre-historic ;-)


Time to show the don't feed the troll sign, I guess.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Bruno Desthuilliers

Stef Mientki a écrit :
(snip)
I'm very satisfied with Python, and  must say it's much more beautiful 
language than Delphi, seen over the full width of programming.

Although both languages are Object Oriented,


I think you can lowercase those two last words - it's not a religion, 
you know ?-)


for some (unknown) reason it's 10 times easier to maintain and extend 
libraries in Python than in Delphi.

I WOULD BE MUCH OBLIGED, IF SOMEONE CAN EXPLAIN THAT DIFFERENCE !


Err... Dynamism ?-)

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


Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Stef Mientki

Bruno Desthuilliers wrote:

Stef Mientki a écrit :

Lawrence D'Oliveiro wrote:

In message [EMAIL PROTECTED], Dotan
Cohen wrote:

 

I often see mention of SMBs that either want to upgrade their Windows
installations, or move to Linux, but cannot because of inhouse VB
apps.



Probably best to leave those legacy VB apps alone and develop new
replacements in a more open, cross-platform language, like Python.
  

Sorry but for GUI design, Python is pre-historic ;-)


Time to show the don't feed the troll sign, I guess.

Even without the smiley, I'm convinced of my statement.
cheers,
Stef

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


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


Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Ville M. Vainio
Stef Mientki [EMAIL PROTECTED] writes:


  Sorry but for GUI design, Python is pre-historic ;-)
 
  Time to show the don't feed the troll sign, I guess.
 Even without the smiley, I'm convinced of my statement.
 cheers,

I don't think I'm feeding the troll, but - ever took a look at PyQt?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Stef Mientki

Ville M. Vainio wrote:

Stef Mientki [EMAIL PROTECTED] writes:


  

Sorry but for GUI design, Python is pre-historic ;-)


Time to show the don't feed the troll sign, I guess.
  

Even without the smiley, I'm convinced of my statement.
cheers,



I don't think I'm feeding the troll, but - ever took a look at PyQt?
  

I wanted to go from Delphi to a free / open source environment,
for both open source and commercial applications.
So the Qt license stopped me from looking any further.

cheers,
stef

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


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


Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED],
[EMAIL PROTECTED] wrote:

 Still has some things that I would dearly love in python... like skinned
 gui applications.

That's a function of the GUI toolkit, not of the language. Python doesn't
make you use any GUI toolkit, nor does it prevent you from using any GUI
toolkit. It concentrates on the stuff a language should do, nothing more,
nothing less.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Grant Edwards
On 2008-10-20, Stef Mientki [EMAIL PROTECTED] wrote:

 I don't think I'm feeding the troll, but - ever took a look at
 PyQt?

 I wanted to go from Delphi to a free / open source
 environment, for both open source and commercial applications.

 So the Qt license stopped me from looking any further.

The Qt license is still free/open-source for commercial
applications as long as you license your app under the GPL.

Did you mean to say for both open source and closed source
applications?

-- 
Grant

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


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread Stef Mientki

Lawrence D'Oliveiro wrote:

In message [EMAIL PROTECTED], Dotan
Cohen wrote:

  

I often see mention of SMBs that either want to upgrade their Windows
installations, or move to Linux, but cannot because of inhouse VB
apps.



Probably best to leave those legacy VB apps alone and develop new
replacements in a more open, cross-platform language, like Python.
  

Sorry but for GUI design, Python is pre-historic ;-)
Stef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread Dotan Cohen
2008/10/19 Stef Mientki [EMAIL PROTECTED]:
 Sorry but for GUI design, Python is pre-historic ;-)
 Stef

Really, even with the cross-platform Qt bindings?

Can you recommend a better language? (not java no please not java)

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread Stef Mientki

Dotan Cohen wrote:

2008/10/19 Stef Mientki [EMAIL PROTECTED]:
  

Sorry but for GUI design, Python is pre-historic ;-)
Stef



Really, even with the cross-platform Qt bindings?
  

I skipped Qt because of the weird license
(I make both commercial and free-open software)

Can you recommend a better language? (not java no please not java)

  

As said VB or even much better Delphi !

But to be honest,
wanting the same language for commercial and open software,
I'm very satisfied with Python, and  must say it's much more beautiful 
language than Delphi, seen over the full width of programming.

Although both languages are Object Oriented,
for some (unknown) reason it's 10 times easier to maintain and extend 
libraries in Python than in Delphi.

I WOULD BE MUCH OBLIGED, IF SOMEONE CAN EXPLAIN THAT DIFFERENCE !
And with wxPython and some tools I made, I almost have the same 
environment as Delphi.



cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread Dotan Cohen
2008/10/19 Stef Mientki [EMAIL PROTECTED]:
 Dotan Cohen wrote:

 2008/10/19 Stef Mientki [EMAIL PROTECTED]:


 Sorry but for GUI design, Python is pre-historic ;-)
 Stef


 Really, even with the cross-platform Qt bindings?


 I skipped Qt because of the weird license
 (I make both commercial and free-open software)

 Can you recommend a better language? (not java no please not java)



 As said VB or even much better Delphi !

 But to be honest,
 wanting the same language for commercial and open software,
 I'm very satisfied with Python, and  must say it's much more beautiful
 language than Delphi, seen over the full width of programming.
 Although both languages are Object Oriented,
 for some (unknown) reason it's 10 times easier to maintain and extend
 libraries in Python than in Delphi.
 I WOULD BE MUCH OBLIGED, IF SOMEONE CAN EXPLAIN THAT DIFFERENCE !
 And with wxPython and some tools I made, I almost have the same environment
 as Delphi.


Really, you recommend that VB apps destined for migration be recoded
in Delphi, as opposed to Python? I will look further into that
language.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread Francesco Bochicchio
Il Sun, 19 Oct 2008 10:34:23 +0200, Stef Mientki ha scritto:

...

 I'm very
 satisfied with Python, and  must say it's much more beautiful language
 than Delphi, seen over the full width of programming. Although both
 languages are Object Oriented, for some (unknown) reason it's 10 times
 easier to maintain and extend libraries in Python than in Delphi.
 I WOULD BE MUCH OBLIGED, IF SOMEONE CAN EXPLAIN THAT DIFFERENCE ! And
 with wxPython and some tools I made, I almost have the same environment
 as Delphi.
 

IMO:
- dynamic typing
- powerful built-in types like lists, sets and dictionaries
- very rich function definition syntax, with multiple returns,
  yield, values passed by position and by name, automatic
  grouping of parameters in list/dictionaries
- rich standard library, which becomes impressive if you accound for all
  the non standard modules that you find in internet. And, unlike another
  language wich shall remain unnamed (starts with J), most of python
  library modules have the same pratical approach of C standard
  library. 

Never used seriously delphi, but played a little with it: IIRC, under the 
nice IDE and GUI toolkit, the language itself is a kind of object-pascal.
This would place it more or less at the same level of abstraction of 
Java,  way below  languages like python and ruby, 


Ciao
-
FB

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


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread Stef Mientki

Dotan Cohen wrote:

2008/10/19 Stef Mientki [EMAIL PROTECTED]:
  

Dotan Cohen wrote:


2008/10/19 Stef Mientki [EMAIL PROTECTED]:

  

Sorry but for GUI design, Python is pre-historic ;-)
Stef



Really, even with the cross-platform Qt bindings?

  

I skipped Qt because of the weird license
(I make both commercial and free-open software)


Can you recommend a better language? (not java no please not java)


  

As said VB or even much better Delphi !

But to be honest,
wanting the same language for commercial and open software,
I'm very satisfied with Python, and  must say it's much more beautiful
language than Delphi, seen over the full width of programming.
Although both languages are Object Oriented,
for some (unknown) reason it's 10 times easier to maintain and extend
libraries in Python than in Delphi.
I WOULD BE MUCH OBLIGED, IF SOMEONE CAN EXPLAIN THAT DIFFERENCE !
And with wxPython and some tools I made, I almost have the same environment
as Delphi.




Really, you recommend that VB apps destined for migration be recoded
in Delphi, as opposed to Python? 

Certainly not.
Delphi is windows only and as Francesco said,
it's just Object Pascal , which is inferior to Python.

Stef


I will look further into that
language.

  


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


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread Stef Mientki

Francesco Bochicchio wrote:

Il Sun, 19 Oct 2008 10:34:23 +0200, Stef Mientki ha scritto:

...

 I'm very
  

satisfied with Python, and  must say it's much more beautiful language
than Delphi, seen over the full width of programming. Although both
languages are Object Oriented, for some (unknown) reason it's 10 times
easier to maintain and extend libraries in Python than in Delphi.
I WOULD BE MUCH OBLIGED, IF SOMEONE CAN EXPLAIN THAT DIFFERENCE ! And
with wxPython and some tools I made, I almost have the same environment
as Delphi.




IMO:
- dynamic typing
- powerful built-in types like lists, sets and dictionaries
- very rich function definition syntax, with multiple returns,
  yield, values passed by position and by name, automatic
  grouping of parameters in list/dictionaries
- rich standard library, which becomes impressive if you accound for all
  the non standard modules that you find in internet. And, unlike another
  language wich shall remain unnamed (starts with J), most of python
  library modules have the same pratical approach of C standard
  library. 

Never used seriously delphi, but played a little with it: IIRC, under the 
nice IDE and GUI toolkit, the language itself is a kind of object-pascal.
This would place it more or less at the same level of abstraction of 
Java,  way below  languages like python and ruby, 
  

Thanks Francesco,
for these features and indeed the Object Pascal language is indeed 
inferior to Python.

Some of Python features that I find an enormous improvement over Delphi:
- extending functions and classes with keyword arguments, without 
affecting the previous use of these declarations

- array slicing
- having 1 procedure that can handle every type, opposed to the Delphi 
overload method


Some minor points of Python, compared to Delphi
- rich standard library is less than in Delphi. It might be just as 
large, but using it is a crime (Delphi libs always work because they are 
upwards compatible)

- GUI design
- deploying an application

cheers,
Stef



Ciao
-
FB

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


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


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread infixum
On Oct 19, 12:51 am, Stef Mientki [EMAIL PROTECTED] wrote:
 Lawrence D'Oliveiro wrote:
  In message [EMAIL PROTECTED], Dotan
  Cohen wrote:

  I often see mention of SMBs that either want to upgrade their Windows
  installations, or move to Linux, but cannot because of inhouse VB
  apps.

  Probably best to leave those legacy VB apps alone and develop new
  replacements in a more open, cross-platform language, like Python.

 Sorry but for GUI design, Python is pre-historic ;-)
 Stef

Some folks below mention wxPython, which (I think) works pretty
decently.

Another option is IronPython, the dot net based version of Python.
Much of it runs under Mono on Linux.  The dot Net Windows and controls
look decent in both environments (Windows and Linux), and aren't that
difficult to code.

IronPython has a mailing list; you might want to cross-post there.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread bearophileHUGS
Stef Mientki:
 it's just Object Pascal , which is inferior to Python.

They are quite different languages, you can't compare them in a simple
way.
Delphi is statically typed, and compiles very quickly producing
small exes; algorithmic code can run a hundred times faster than
Python code. There are lot of people still that think that a
statically typed language is safer.
Delphi is kinda old, so today there are better languages than Delphi
(like D), but when Delphi 2-3 was out, there weren't many other
languages with IDEs at its level, especially for programs with a nice
GUIs plus interfaces with DBMSs. Today you can write programs with
FreePascal, that is free. Bashing other languages doesn't make Python
any better.

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-19 Thread david . lyon

Quoting [EMAIL PROTECTED]:


Stef Mientki:

it's just Object Pascal , which is inferior to Python.


They are quite different languages, you can't compare them in a simple
way.
Delphi is kinda old, so today there are better languages than Delphi
(like D), but when Delphi 2-3 was out, there weren't many other
languages with IDEs at its level, especially for programs with a nice
GUIs plus interfaces with DBMSs.


I have programmed Delphi for years.. and was pretty much forced to  
move to python for different reasons.


I would go along best with the description of delphi being old. It  
was great in its time... and had many advancements over others. Still  
has some things that I would dearly love in python... like skinned  
gui applications.


As for porting... don't.

Just rewrite them

Shouldn't be so hard...

David






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


Porting VB apps to Python for Window / Linux use

2008-10-18 Thread Dotan Cohen
I often see mention of SMBs that either want to upgrade their Windows
installations, or move to Linux, but cannot because of inhouse VB
apps. Are there any Python experts who I can reference them to for
porting? I have nothing on hand at the moment, but I see this as a
need without an obvious answer.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-18 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Dotan
Cohen wrote:

 I often see mention of SMBs that either want to upgrade their Windows
 installations, or move to Linux, but cannot because of inhouse VB
 apps.

Probably best to leave those legacy VB apps alone and develop new
replacements in a more open, cross-platform language, like Python.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porting VB apps to Python for Window / Linux use

2008-10-18 Thread Dotan Cohen
2008/10/19 Lawrence D'Oliveiro [EMAIL PROTECTED]:
 In message [EMAIL PROTECTED], Dotan
 Cohen wrote:

 I often see mention of SMBs that either want to upgrade their Windows
 installations, or move to Linux, but cannot because of inhouse VB
 apps.

 Probably best to leave those legacy VB apps alone and develop new
 replacements in a more open, cross-platform language, like Python.

That is quite the reason why I asked here, so that I could find
someone who can port these things to Python.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


Re: python - stealth window

2007-11-09 Thread Gabriel Genellina
En Thu, 08 Nov 2007 03:23:27 -0300, Adam [EMAIL PROTECTED]  
escribió:

 I want create Windows console window in stealth with Python script. I  
 tried
 search on internet but I do not find anything. I want something like this
 just it is in C++:

 HWND stealth; /*creating stealth (window is not visible)*/
 AllocConsole();
stealth=FindWindowA(ConsoleWindowClass,NULL);
 ShowWindow(stealth,0);

 So I start my script and that is will be run in the background and I can
 trick with hotkeys in WINAMP. I do not worry for a new one window. :-)  
 I
 hope you understand me because my english is not perfect.

Using the pywin32 packages from Mark Hammond, this is a direct translation  
of the above:

code
import win32console, win32gui

win32console.AllocConsole()
stealth = win32gui.FindWindow(ConsoleWindowClass, None)
win32gui.ShowWindow(stealth, 0)
import time
time.sleep(5)
win32gui.ShowWindow(stealth, 1)
/code

You must either run it using pythonw.exe, or remove the AllocConsole call

-- 
Gabriel Genellina

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


python - stealth window

2007-11-07 Thread Adam
Hello,

I want create Windows console window in stealth with Python script. I tried
search on internet but I do not find anything. I want something like this
just it is in C++:

HWND stealth; /*creating stealth (window is not visible)*/
AllocConsole();
   stealth=FindWindowA(ConsoleWindowClass,NULL);
ShowWindow(stealth,0);

So I start my script and that is will be run in the background and I can
trick with hotkeys in WINAMP. I do not worry for a new one window. :-) I
hope you understand me because my english is not perfect.

Regards,

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

Re: python on window

2007-03-26 Thread sandeep patil
i have written this program but i have gott following error,
in anather proram indentation error sir how i will indent in my
editor

#test.py
 def invert(table):
index=()
for key in table:
value=table[key]
if not index.has_key(value):
index[value]=[]
index[value].append(key)
return index


 phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu': 9325}
 phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
 print phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
 inverted_phonebook = invert(phonebook)

Traceback (most recent call last):
  File pyshell#13, line 1, in module
inverted_phonebook = invert(phonebook)
  File pyshell#9, line 5, in invert
if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'
 interted_phonebook= invert(phonebook)

Traceback (most recent call last):
  File pyshell#14, line 1, in module
interted_phonebook= invert(phonebook)
  File pyshell#9, line 5, in invert
if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'


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


Re: python on window

2007-03-26 Thread Parthan SR

On 26 Mar 2007 05:00:54 -0700, sandeep patil [EMAIL PROTECTED] wrote:


i have written this program but i have gott following error,
in anather proram indentation error sir how i will indent in my
editor

#test.py
 def invert(table):
index=()
for key in table:
value=table[key]
if not index.has_key(value):
index[value]=[]
index[value].append(key)
return index


 phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu': 9325}
 phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
 print phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
 inverted_phonebook = invert(phonebook)

Traceback (most recent call last):
  File pyshell#13, line 1, in module
inverted_phonebook = invert(phonebook)
  File pyshell#9, line 5, in invert
if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'
 interted_phonebook= invert(phonebook)

Traceback (most recent call last):
  File pyshell#14, line 1, in module
interted_phonebook= invert(phonebook)
  File pyshell#9, line 5, in invert
if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'





In your code, index = () means it is a tuple. IIRC, it should be a
dictionary. For that, index = {}. This is the one causing the following
error in your code,

 if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'

You can not use has_key over a tuple object.

But where is the indentation error ? I see nothing like that in the error
message.


--
With Regards

---
Parthan.S.R.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python on window

2007-03-26 Thread Michael Bentley

On Mar 26, 2007, at 7:00 AM, sandeep patil wrote:
 i have written this program but i have gott following error,
 in anather proram indentation error sir how i will indent in my
 editor

 #test.py
 def invert(table):
   index=()
   for key in table:
   value=table[key]
   if not index.has_key(value):
   index[value]=[]
   index[value].append(key)
   return index


 phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu':  
 9325}
 phonebook
 {'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
 print phonebook
 {'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
 inverted_phonebook = invert(phonebook)

 Traceback (most recent call last):
   File pyshell#13, line 1, in module
 inverted_phonebook = invert(phonebook)
   File pyshell#9, line 5, in invert
 if not index.has_key(value):
 AttributeError: 'tuple' object has no attribute 'has_key'

If you define index as a dict instead of a tuple, you'll stop getting  
that error -- but I'm afraid it still won't do what you want.  Are  
you trying to get a phonebook in which the values of the original  
phonebook are the keys of the new one -- and the values are lists  
(both 'sandeep' and 'titu' have the same number)?  If so, try this:

def invert(table):
index=dict()
for k,v in table.items():
if index.has_key(v):
index[v].append(k)
else:
index[v] = [k]
return index

You had mentioned something about indentation error...  If you'll  
look at your definition of invert(), you can see that 'return index'  
is inside the for loop -- which would cause a return before the  
second time through the for loop.  By dedenting (is that a word?) so  
'return' falls directly below 'for', the for loop would have been  
able to run to completion before returning.

Hope this helps,
Michael

---

Our network was brought down by a biscuit??? --Steven D'Aprano



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


python on window

2007-03-23 Thread sandeep patil
i have install python on window xp os.
C:/program files/python

i have done print program it working but .py can't  working
 help me  to how i will execute this file this file where i will save
it.
path execution how .
tell me about any envorment veriable in python to set before python
editor run,it path. etc


 print ' sandeep patil'
 sandeep patil
 print ' sandeep bhagwan  patil ,msc. java j2ee developer
SyntaxError: EOL while scanning single-quoted string
 print ' sandeep bhagwan  patil ,msc. java j2ee developer'
 sandeep bhagwan  patil ,msc. java j2ee developer
 import posix

Traceback (most recent call last):
  File pyshell#4, line 1, in module
import posix
ImportError: No module named posix
 phonebook = {'sandeep':9325,'amit':9822,'anand':9890}
 phonebook = {'titu':9423,'dadu':9422,'giri':9326}
 inverted_phonebook=invert(phonebook)

Traceback (most recent call last):
  File pyshell#7, line 1, in module
inverted_phonebook=invert(phonebook)
NameError: name 'invert' is not defined
 def invert(table):
index={}
for key in table.key():
value=table[key]
if not index.has_key(value):
index[value]=[]
index[value].append(key)
return index


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


Re: python on window

2007-03-23 Thread Gabriel Genellina
En Fri, 23 Mar 2007 04:25:52 -0300, sandeep patil [EMAIL PROTECTED]  
escribió:

 i have install python on window xp os.
 C:/program files/python

 i have done print program it working but .py can't  working
  help me  to how i will execute this file this file where i will save
 it.
 path execution how .
 tell me about any envorment veriable in python to set before python
 editor run,it path. etc

You don't need to set any environment variable to run Python. (Perhaps  
PYTHONPATH, but *only* if you put modules into non standard places)

 import posix

 Traceback (most recent call last):
   File pyshell#4, line 1, in module
 import posix
 ImportError: No module named posix

That's ok: there is no module named posix on Windows, it is only  
available on Unix systems.

I've rearranged a bit your example. Write the following into a file named  
test.py - use whatever editor you like (even notepad):

---begin file test.py---
def invert(table):
 index = {}
 for key in table:
 value = table[key]
 if not index.has_key(value):
 index[value] = []
 index[value].append(key)
 return index

phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu': 9325}
print Phonebook, phonebook

inverted_phonebook = invert(phonebook)
print Inverted phonebook, inverted_phonebook
---end file test.py---

Then open a console window, change to the same directory where you saved  
test.py, and execute:

python test.py

You should get:

Phonebook {'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
Inverted phonebook {9890: ['anand'], 9325: ['titu', 'sandeep'], 9822:  
['amit']}

There are plenty of tutorials about Python. A good book -among others- is  
Dive into Python; you can buy the book, read it online, or even download  
it from http://www.diveintopython.org/

-- 
Gabriel Genellina

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


Re: python on window

2007-03-23 Thread jwelby
On Mar 23, 7:25 am, sandeep patil [EMAIL PROTECTED] wrote:
 i have install python on window xp os.
 C:/program files/python

 i have done print program it working but .py can't  working
  help me  to how i will execute this file this file where i will save
 it.
 path execution how .
 tell me about any envorment veriable in python to set before python
 editor run,it path. etc
 

  print ' sandeep patil'
  sandeep patil
  print ' sandeep bhagwan  patil ,msc. java j2ee developer

 SyntaxError: EOL while scanning single-quoted string print ' sandeep 
 bhagwan  patil ,msc. java j2ee developer'

  sandeep bhagwan  patil ,msc. java j2ee developer

  import posix

 Traceback (most recent call last):
   File pyshell#4, line 1, in module
 import posix
 ImportError: No module named posix

  phonebook = {'sandeep':9325,'amit':9822,'anand':9890}
  phonebook = {'titu':9423,'dadu':9422,'giri':9326}
  inverted_phonebook=invert(phonebook)

 Traceback (most recent call last):
   File pyshell#7, line 1, in module
 inverted_phonebook=invert(phonebook)
 NameError: name 'invert' is not defined def invert(table):

 index={}
 for key in table.key():
 value=table[key]
 if not index.has_key(value):
 index[value]=[]
 index[value].append(key)
 return index
 

Hi Sandeep.

As you are working with Python on Windows, I would suggest that you
install the Python for Windows extensions from here:

http://sourceforge.net/project/showfiles.php?group_id=78018

It includes a very good application called PythonWin. Once installed,
PythonWin will be available under Python in your Start menu.

If you run PythonWin, File/New gives you the option to create a new
Python script. To begin with, you can save into the Lib folder of your
Python installation (probably C:\Python25\Lib). I usually add my
initials at the front of the script name to differentiate my scripts
from the standard ones if I put stuff in Lib.

You should be able edit your PYTHONPATH variable in PythonWin - see
the Tools options (though, now I look, my installation actually has a
bug in this function), or alternatively, you can add a folder to your
PYTHONPATH environment variable in RegEdit (if you know what you're
doing).

I hope this helps.

J.

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


Re: python on window

2007-03-23 Thread jwelby
That should have been:

You should be able edit your PYTHONPATH variable (should you need
to)...

Gabiel is right, it's not usually required.

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


Python Shell window

2006-04-10 Thread Jay
Is their any way of setting wear the Python Shell window appears on the
screen when I run my program?

I am testing a full screen program with no Window Frame on a comp with
2 monitors and I have to keep pressing the Window Key to bring the
Shell to the front and then moving it manually to the other screen
every time I restart the program.

I would like it to just appear on the other screen from the start.

Any ideas

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


Re: Python Shell window

2006-04-10 Thread jay graves
Jay wrote:
 Is their any way of setting wear the Python Shell window appears on the
 screen when I run my program?

 I am testing a full screen program with no Window Frame on a comp with
 2 monitors and I have to keep pressing the Window Key to bring the
 Shell to the front and then moving it manually to the other screen
 every time I restart the program.

 I would like it to just appear on the other screen from the start.

 Any ideas

1.  Do you really want the CMD prompt to show up?  If not, rename your
file from .py to .pyw and it will be hidden.  You'll miss all of the
STD* streams though.

2.  Find the window and move it to the right place.  Here is a script I
use to launch PuTTY  (which has the unfortunate problem of 'hiding' its
title bar below my 'Start' bar which I keep at the top of my screen).
It's convient for me to launch PuTTY from this script but I don't see
any reason why you couldn't add this code to your main function and
find the errand CMD prompt and move it.

(For this you need the win32 extension installed)

import win32gui,os,sys,time

command = rstart putty -load %s

def moveWindow(hwnd, ignored):
x = win32gui.GetWindowText(hwnd)
if x.find('PuTTY') = 0:
left,top,right,bottom = win32gui.GetWindowRect(hwnd)
if top  30:
width = right - left
height = bottom - top
win32gui.MoveWindow(hwnd,left,top+30,width,height,1)

try:
p1 = sys.argv[1]
except IndexError:
#print you must provide a valid machine name
p1 = opus

os.system(command % (p1,))
time.sleep(1.0)
win32gui.EnumWindows(moveWindow, None)



HTH..

Jay

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


Re: Python Shell window

2006-04-10 Thread jay graves
 find the errand CMD prompt and move it.

errand - errant

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


python-text window vs. game/graphics window

2005-04-20 Thread D. Hartley
Hello, group!

I am asking anyone who is knowledgeable about entering text into the
text window while a game/graphics window is running (am using pygame).
 I have asked this on the 'tutor' mailing list and no one could/would
answer it.  I am making a space invaders clone for my Python Teacher's
birthday, and so obviously can not ask him for help! Even the debugger
wouldn't shed light on the situation, due to when it happens:

I am trying to make a high score list.  If you do not score high
enough, the list displays in the text window (fine), and you can type
y/n in the game window for a new game. If you DO make the high score
list, it prompts you to enter your name on the text window (and hit
enter), and displays the updated score list (great).  However, when I
click back to the graphics window, the whole thing closes/shuts
down/crashes.  For the life of me I cant figure it out.  I have looked
at the order of my steps, I've tried to follow it through piece by
piece, and like I said I tried to use the debugger to step through it
- but since the game just closes out, it doesnt tell me anything.

1. How can I stop this crash from happening? I have copied and pasted
the game over section of my code below, and am attaching the entire
code to the email, in case that would be helpful.

2. I'd REALLY like to make it display the high scores/prompt for user
name on the game/graphics window, not in the text window, anyway - and
that would eliminate the problem it seems to have when using
keystrokes in the text window and then trying to switch back to the
game window. (it's not a click-specific issue, alt-tab does it too).


I apologize for the newbie nature of this question to a more
advanced list, but I have tried everything else I can think of and am
at my wits' end.  The 'deadline' (birthday) is in a week and I'm
stuck.  I'd appreciate any comments or suggestions you might have, in
as simple of language as you can offer them, ha ha.  I *am* new to
python, and so my code may not be so elegant. But I hope you can read
it enough to see what I'm doing wrong or possibly just offer
suggestions for displaying it all in the graphics window and avoiding
the problem altogether.

Thank you so much for your time and ideas!

Sincerely,
Denise

#game over..
if lives == 0:

def add_score():
high_scores = pickle.load(file(scores.pik))
score = total_enemy_hits
if score  high_scores[-1][0]:
print Ta da! You got, total_enemy_hits,
Ranch Delivery Devices!
name = read_string(You made the high score
list! What's your name? )
user_score = (score,name)
high_scores.append(user_score)
high_scores.sort(reverse=True)
del high_scores[-1]
pickle.dump(high_scores, file(scores.pik, w))
for score, name in high_scores:
slip = 30 - len(name)
slip_amt = slip* 
prefix = 5* 
print prefix,name,slip_amt,score
else:
print Sorry, you only got, total_enemy_hits,
Ranch Delivery Devices.
print You didn't quite make the high score list!
for score, name in high_scores:
slip = 30 - len(name)
slip_amt = slip* 
prefix = 5* 
print prefix,name,slip_amt,score
print Better luck next time!

add_score()

end.play()
showGameOver(screen, background_image)
pygame.display.flip()


answer = 
while not answer in (y,n):
   for event in pygame.event.get():
  if event.type == KEYDOWN:
 if event.key == K_n:
answer = n
 elif event.key == K_y:
answer = y
if answer == n:
running = 0
else:
return 1

#refresh the display
pygame.event.pump()
pygame.display.flip()

#well, nice playing with you...
screen = pygame.display.set_mode((640, 480))
return 0
#!/usr/bin/env python

#--
# Spacin'Vaders 0.1
#
# Created by Rodrigo Vieira
# (icq, msn) = (9027513, [EMAIL PROTECTED])
# email = [EMAIL PROTECTED]
#
# License: GPL
#
# Have fun! Feel free to contact me for comments,
# questions or new features :)
#
# Check README.txt for more info
#--

#Import Modules
import os, pygame
import