Re: Programming Idiomatic Code

2007-07-03 Thread Douglas Woodrow
On Tue, 3 Jul 2007 10:19:07, Nathan Harmston 
[EMAIL PROTECTED] wrote

i m in the UK and dont have the experience but hey 10 minutes of
programming python beats 12 hours of programming in Clipper-derived
unreadable drivel (you dont know how much I appreciate Python atm).

Clipper-derived unreadable drivel

I'm intrigued, what language are you working in?

Clipper v5 was a pretty impressive development language for 1990 - with 
code blocks, a flexible pre-processor, garbage collection, exception 
handling, decent speed and an API to allow easy integration with 
routines written in c.

It doesn't have to be unreadable at all (unless it's written by someone 
who thinks it is dBase).

-- 
Doug Woodrow

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


Re: Python's only one way to do it philosophy isn't good?

2007-06-27 Thread Douglas Woodrow
On Wed, 27 Jun 2007 01:45:44, Douglas Alan [EMAIL PROTECTED] wrote
A chaque son gout

I apologise for this irrelevant interruption to the conversation, but 
this isn't the first time you've written that.

The word chaque is not a pronoun.

http://grammaire.reverso.net/index_alpha/Fiches/Fiche220.htm
-- 
Doug Woodrow

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


Re: Strange behavior in Windows

2007-06-05 Thread Douglas Woodrow
On Mon, 4 Jun 2007 21:34:36, David Stockwell wxp [EMAIL PROTECTED] 
wrote

in DOS you can try this to see what your path is:

echo My path is %PATH%

or more simply:

,
| C: path
`
-- 
Doug Woodrow

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


Re: int vs long

2007-06-04 Thread Douglas Woodrow
On Mon, 4 Jun 2007 10:50:14, Peter Otten [EMAIL PROTECTED] wrote

 This is fixed in Python2.5:

 Hm, my test above was from 2.5!?

Then your installation is broken. What does

 import itertools
 itertools
module 'itertools' from
'/usr/local/lib/python2.5/lib-dynload/itertools.so'

print?


Maybe it's a problem with the Windows build of Python 2.5

,
| Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310
| 32 bit (Intel)] on win32
| Type help, copyright, credits or license for more information.
|  import sys
|  import itertools
|  itertools
| module 'itertools' (built-in)
|  c = itertools.count(sys.maxint)
|  c.next()
| Traceback (most recent call last):
|   File stdin, line 1, in module
| OverflowError: cannot count beyond LONG_MAX
| 
`

-- 
Doug Woodrow

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


Re: c[:]()

2007-06-01 Thread Douglas Woodrow
On Thu, 31 May 2007 18:42:05, Warren Stringer [EMAIL PROTECTED] wrote
They were copied from working code. Copied *badly*? Yes. Running python via:
   Windows - start - run - python
doesn't allow cut and paste

Hi Warren,

Actually you can copy and paste from a Windows cmd/command shell: 
right-click the title-bar of the window, select Edit from the pop-up 
menu, then Mark from the sub-menu to copy whatever you want to select 
into the Windows clipboard.

HTH,
-- 
Doug Woodrow

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


Re: c[:]()

2007-06-01 Thread Douglas Woodrow
On Fri, 1 Jun 2007 07:23:16, Steve Holden [EMAIL PROTECTED] wrote
  Actually you can copy and paste from a Windows cmd/command shell: 
right-click the title-bar of the window, select Edit from the pop-up 
menu, then Mark from the sub-menu to copy whatever you want to 
select  into the Windows clipboard.

Better still, modify your shortcut by bring up the command window's 
Properties page and setting Quick Edit Mode. Then you can select with 
the mouse and hit Enter to copy.

Cool, thanks Steve!

Newsgroups really are a good way of learning new things quickly.
-- 
Doug Woodrow

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


Re: c[:]()

2007-05-31 Thread Douglas Woodrow
On Wed, 30 May 2007 23:23:22, Warren Stringer [EMAIL PROTECTED] wrote

def a(): return 'b'
def b(): print 'polly! wakey wakey'
c = {}
c['a'] = b
c[a()]()  #works!


(typo correction for other easily-confused newbies like myself)

I think you mean
,
| c['a']()  #works!
`

-- 
Doug Woodrow

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


Re: c[:]()

2007-05-31 Thread Douglas Woodrow
On Thu, 31 May 2007 08:57:56, Douglas Woodrow 
[EMAIL PROTECTED] wrote
On Wed, 30 May 2007 23:23:22, Warren Stringer [EMAIL PROTECTED] wrote

def a(): return 'b'
def b(): print 'polly! wakey wakey'
c = {}
c['a'] = b
c[a()]()  #works!


(typo correction for other easily-confused newbies like myself)

I think you mean
,
| c['a']()  #works!
`


Oh no, I get it, you meant...
,
| c['b'] = b
| c[a()]()  #works!
`

...or was it?:-
,
| def a(): return 'a'
`

-- 
Doug Woodrow

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


Re: c[:]()

2007-05-31 Thread Douglas Woodrow
On Thu, 31 May 2007 07:49:22, Warren Stringer [EMAIL PROTECTED] wrote
 def a(): return 'b'
 def b(): print 'polly! wakey wakey'
 c = {}
 c['a'] = b
 c[a()]()  #works!
 
 
 (typo correction for other easily-confused newbies like myself)
 
 I think you mean
[...]


Hey Douglas,

Perhaps I was being too abstract? Here goes:

,---
|  def selector():
|...
|return funcKey#get down get down
|
|  def func():
|...
|  funcSwitch = {}
|  funcSwitch[funcKey] = func
|  ...
|  funcSwitch[selector()]()


Thanks Warren, I was merely pointing out the typing mistake you made in 
your first example.

And yes, your abstract names made it difficult to guess the intention of 
the original code.  With the meaningful names you've just provided, I 
can see immediately that you intended to write the 2nd working code 
alternative I suggested:

 Oh no, I get it, you meant...
 ,
 | c['b'] = b
 | c[a()]()  #works!
 `

-- 
Doug Woodrow

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


Re: python shell

2007-05-20 Thread Douglas Woodrow
On Sat, 19 May 2007 21:42:27, Steve Holden [EMAIL PROTECTED] wrote

  http://en.wikipedia.org/wiki/Doctest

Since you claim to be exercising your pedantry, I wonder why I get the 
results I do. Since we *are* being pedantic, by the way, surely the 
name is actually doctest, not Doctest.

Yes, as the page you are referring to mentions right at the top:

,
| Doctest
| From Wikipedia, the free encyclopedia
|
| The correct title of this article is doctest. The initial letter 
is shown
| capitalized due to technical restrictions.
`

-- 
Doug Woodrow

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


Re: Execute commands from file

2007-05-18 Thread Douglas Woodrow
On Fri, 18 May 2007 04:45:30, Dennis Lee Bieber [EMAIL PROTECTED] 
wrote
On 17 May 2007 13:12:10 -0700, i3dmaster [EMAIL PROTECTED] declaimed
the following in comp.lang.python:

 'b' is generally useful on systems that don't treat binary and text
 files differently. It will improve portability.

   b is needed for binary files on systems that /do/ treat binary
differently from text. And it does add to portability only in that it
has no effect on those that treat all files the same.

   However, as I recall the thread, the intent is to process text lines
from a file -- and using b is going to affect how the line endings are
being treated.

Yes that was my understanding too, Dennis, and the reason I queried it 
in the first place.  I had to remove the b option in order to get the 
sample code to work under Windows, because the standard line termination 
under Windows is carriage return + linefeed (\r\n).

Of course if I manually edit the command file so that it only has a 
linefeed character at the end of each line, the binary mode works.

So I think i3dmaster's method is only portable as long as the command 
file is created with unix-style line termination.

-- 
Doug Woodrow

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


Re: Execute commands from file

2007-05-17 Thread Douglas Woodrow
On Thu, 17 May 2007 00:30:23, i3dmaster [EMAIL PROTECTED] wrote
f = open(file,'rb')
for i in f:
exec i

Why are you opening the file in binary mode?

-- 
Doug Woodrow

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