Re: ignorance and intolerance in computing communties

2007-05-02 Thread Edward
On May 2, 8:33 am, Xah Lee <[EMAIL PROTECTED]> wrote:



> As i have indicated in my post, it is non-trivial to implement a
> function that returns the positive angle of a vector. For example, it
> can be done with sign checking of the coordinate components (in total
> 4 cases, which can be done as 2 levels of nesting if, or simply 4
> if.), and or the evaluation of Min[Abs[ArcCos[x],Abs[ArcSin[x]]], or
> use clever ways with dot product, or ArcTan. It is not a trivial to
> know which algorithm is in general more efficient. (this is important,
> since finding the angle of a vector is a basic function, that may
> needs to be called millions times directly or indirectly) Further,
> consider the inverse trig function, it is likely 99.99% of people with
> a PH D in math wouldn't know how these are actually implemented. So,
> the question of whether calling one of the inverse trig function is
> more robust or efficient than another is a open question. And, besides
> the algorithmic level, the question also entails how the language
> actually implement the inverse trig functions.



"We should forget about small efficiencies, say about 97% of the time:
premature optimization is the root of all evil."

The question you are asking depends a great deal on other factors
outside of the coding environment such as the compiler and the
hardware.  If you are coding for a specific language/compiler/hardware
combination,  all you need do is profile different versions of your
code until you're happy with the results.


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


Coexistence of Python 2.x and 3.x on same OS

2012-09-30 Thread Edward Diener
Has there been any official software that allows both the Python 2.x and 
3.x releases to coexist on the same OS so that the end-user can easily 
switch between them when invoking Python scripts after each has been 
installed to their own directories/folders ?


I know of some unoffical solutions, but they require lots of tweaks. 
Given the vagaries of the different OSs on which Python can run I am 
hoping for some offical solution which will work on any of the most 
popular OSs ( Windows, Linux, Mac ).


The situation is so confusing on Windows, where the file associations, 
registry entries, and other internal software which allows a given 
Python release to work properly when invoking Python is so complicated, 
that I have given up on trying to install more than one Python release 
and finding a relaible, foolproof way of switching between them. So 
although I would like to use the latest 3.x series on Windows I have 
decide to stick with the latest 2.x series instead because much software 
using Python does not support 3.x yet.

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


Re: Coexistence of Python 2.x and 3.x on same OS

2012-09-30 Thread Edward Diener

On 9/30/2012 3:38 PM, Andrew Berg wrote:

On 2012.09.30 14:14, Edward Diener wrote:

The situation is so confusing on Windows, where the file associations,
registry entries, and other internal software which allows a given
Python release to work properly when invoking Python is so complicated,
that I have given up on trying to install more than one Python release
and finding a relaible, foolproof way of switching between them. So
although I would like to use the latest 3.x series on Windows I have
decide to stick with the latest 2.x series instead because much software
using Python does not support 3.x yet.


http://www.python.org/dev/peps/pep-0397/

Unix-based OSes should already obey the shebang line, and on Windows,
there's py.exe in 3.3 that will launch the intended version based on
that shebang line.


The problem with that is that one has to already being using 3.3 to use 
this facility. I was hoping for a solution which was backwards 
compatible with Python 2.x.


My thought is a program distributed by Python which finds the versions 
of Python on an OS, lets the end-user choose which version should be 
invoked when Python is invoked, and does whatever is necessary to make 
that version the default version.



While I was using the alpha/beta versions of 3.3, I
had no problems invoking either 3.2 or 3.3 with the shebang line on Windows.


That does not solve the problem for Python 2.x distributions.

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


Re: Coexistence of Python 2.x and 3.x on same OS

2012-10-05 Thread Edward Diener

On 10/1/2012 1:32 PM, Dennis Lee Bieber wrote:

On Sun, 30 Sep 2012 23:06:04 -0400, Edward Diener
 declaimed the following in
gmane.comp.python.general:



My thought is a program distributed by Python which finds the versions
of Python on an OS, lets the end-user choose which version should be
invoked when Python is invoked, and does whatever is necessary to make
that version the default version.


Which wouldn't be usable on any system that has to boot/process
unattended, and run's Python scripts for configuration set-up.


I can understand that but my use of Python on Windows is not that case. 
I simply want to be able to choose which version of Python runs when it 
is invoked, when I have multiple versions installed. Surely that is a 
very common case for end-users running 'python' or invoking some script 
which is associated with python.




Making a version "default" pretty much means being able to rewrite
the PATH environment variable... And I've seen too many messes made by
some software already (including once having two generations of Python
showing up in one PATH!)


The PATH environment is constantly changing whether in Linux or Windows. 
Claiming that this is too dangerous" is silly.


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


Re: Coexistence of Python 2.x and 3.x on same OS

2012-10-05 Thread Edward Diener

On 10/1/2012 12:02 PM, Alister wrote:

On Sun, 30 Sep 2012 15:14:17 -0400, Edward Diener wrote:


Has there been any official software that allows both the Python 2.x and
3.x releases to coexist on the same OS so that the end-user can easily
switch between them when invoking Python scripts after each has been
installed to their own directories/folders ?

I know of some unoffical solutions, but they require lots of tweaks.
Given the vagaries of the different OSs on which Python can run I am
hoping for some offical solution which will work on any of the most
popular OSs ( Windows, Linux, Mac ).

The situation is so confusing on Windows, where the file associations,
registry entries, and other internal software which allows a given
Python release to work properly when invoking Python is so complicated,
that I have given up on trying to install more than one Python release
and finding a relaible, foolproof way of switching between them. So
although I would like to use the latest 3.x series on Windows I have
decide to stick with the latest 2.x series instead because much software
using Python does not support 3.x yet.


on my fedora system it was a simple matter of:-
#> yum install python3

to use python 3 i specify it in my shebang line

#!/usr/bun/env python3

Simple

Not sure about Windoze though (Although from memory the install asks
where to install so should not be a major issue)


Windows installs of Python do not distinguish releases by Pythonx(.x) 
but just install different versions of Python in different directories. 
However one can make links to the different versions based on their 
release numbers, and that would allow a shebang line work if it was 
supported.



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


Re: Coexistence of Python 2.x and 3.x on same OS

2012-10-05 Thread Edward Diener

On 9/30/2012 3:38 PM, Andrew Berg wrote:

On 2012.09.30 14:14, Edward Diener wrote:

The situation is so confusing on Windows, where the file associations,
registry entries, and other internal software which allows a given
Python release to work properly when invoking Python is so complicated,
that I have given up on trying to install more than one Python release
and finding a relaible, foolproof way of switching between them. So
although I would like to use the latest 3.x series on Windows I have
decide to stick with the latest 2.x series instead because much software
using Python does not support 3.x yet.


http://www.python.org/dev/peps/pep-0397/

Unix-based OSes should already obey the shebang line, and on Windows,
there's py.exe in 3.3 that will launch the intended version based on
that shebang line. While I was using the alpha/beta versions of 3.3, I
had no problems invoking either 3.2 or 3.3 with the shebang line on Windows.



Thanks ! I will get this and hopefully it will do what I want.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Coexistence of Python 2.x and 3.x on same OS

2012-10-05 Thread Edward Diener

On 10/5/2012 5:32 PM, Dennis Lee Bieber wrote:

On Fri, 05 Oct 2012 08:15:30 -0400, Edward Diener
 declaimed the following in
gmane.comp.python.general:



Windows installs of Python do not distinguish releases by Pythonx(.x)
but just install different versions of Python in different directories.


Really?

E:\Python27>dir
  Volume in drive E is Data
  Volume Serial Number is 2626-D991

  Directory of E:\Python27

08/28/2012  05:32 PM  .
08/28/2012  05:32 PM  ..
08/28/2012  02:11 PM  DLLs
08/28/2012  05:43 PM  Doc
08/28/2012  02:11 PM  include
08/31/2012  04:58 PM  Lib
08/28/2012  02:11 PM  libs
08/28/2012  02:15 PM   108,255 matplotlib-wininst.log
08/28/2012  02:18 PM 4,169 MySQL-python-wininst.log
08/28/2012  02:15 PM98,498 numpy-wininst.log
08/28/2012  02:20 PM17,816 PIL-wininst.log
08/28/2012  03:29 PM 1,572 PyOpenGL-accelerate-wininst.log
08/28/2012  03:38 PM 3,009 pyserial-wininst.log

06/24/2011  12:38 PM27,136 python.exe   
06/24/2011  12:38 PM27,136 python2.7.exe
06/24/2011  12:38 PM27,136 python2.exe  

08/28/2012  05:32 PM90,943 PythonCard-wininst.log

06/24/2011  12:38 PM27,136 pythonw.exe  
06/24/2011  12:38 PM27,136 pythonw2.7.exe   
06/24/2011  12:38 PM27,136 pythonw2.exe 


That's, as you say, ActievState. The normal Python installer does not 
create a python2.7.exe etc.


But of course I can create any links I want, so that's not really the 
problem. The major difficulty is that prior to invoking either "python" 
directly or a script with a normal Python file association, I want to be 
able to specify which version of Python should be invoked as the default 
without having to specifically invoke a partiocular version  by typing 
'python2.7 ...' or 'python3.3 ...' etc.




08/28/2012  02:15 PM   196,096 Removematplotlib.exe
08/28/2012  02:18 PM   196,096 RemoveMySQL-python.exe
08/28/2012  02:15 PM   196,096 Removenumpy.exe
08/28/2012  02:20 PM   196,096 RemovePIL.exe
08/28/2012  03:29 PM   196,096 RemovePyOpenGL-accelerate.exe
08/28/2012  03:38 PM   196,096 Removepyserial.exe
08/28/2012  05:32 PM61,440 RemovePythonCard.exe
08/28/2012  02:20 PM   196,096 Removereportlab.exe
08/28/2012  02:19 PM   196,096 Removescipy.exe
08/28/2012  05:29 PM   196,096 RemoveWConio.exe
08/28/2012  02:20 PM40,362 reportlab-wininst.log
08/28/2012  02:19 PM   159,420 scipy-wininst.log
08/28/2012  05:32 PM  Scripts
08/28/2012  02:11 PM  tcl
08/28/2012  02:11 PM  Tools
11/28/2007  04:32 PM   258,352 unicows.dll
06/24/2011  12:38 PM49,664 w9xpopen.exe
08/28/2012  05:29 PM   891 WConio-wininst.log
   28 File(s)  2,822,071 bytes
   10 Dir(s)  148,557,684,736 bytes free

E:\Python27>

That's what was set up by a recent ActiveState installer (well,
recent for me -- I'd still been using 2.5 three months ago)

Yes, it IS in a version numbered directory, but there are copies of
the executable named as plain python, pythonX, and pythonX.Y

E:\Python27>cd %homepath%

E:\UserData\Wulfraed\My Documents>python
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

^Z



E:\UserData\Wulfraed\My Documents>python2.7
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.




Granted, one would need to have each installation directory in the
PATH, ordered such that the preferred version would be found first when
using just "python".


There is much more than just the PATH needed to change to have a 
different Python be the default. File associations also. I thnk there 
are more things too, but I know it has always been difficult on Windows 
to easily change which distribution is called when "python" is executed 
or some Python file association is executed.


I welcome the new Python launcher for Windows mentioned but have not had 
a chance to use it and see how it works yet. I will try it this weekend 
and hopefully it will work well to solve the problem of having multiple 
Python installations installed on Windows at the same time, and being 
able to easily specify the one I want invoked.


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


How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Edward d'Auvergne
Hi,

I was wondering if anyone knows of how to detect when IO redirection
of any form is happening within a Python program?  I would like to
emulate the behaviour of the GNU tools (for example the Unix commands
'ls' or 'grep') whereby ascii escape sequences are printed if the
output is solely to the terminal, and in all other cases (redirection
to file via '>', pipes via '|', or more complex redirections) the
ascii escape characters are suppressed.  Any ideas would be
appreciated!

Cheers,

Edward


--
Edward d'Auvergne, PhD
Lead developer of the projects relax, minfx, and bmrblib
http://www.nmr-relax.com
http://gna.org/projects/minfx
http://gna.org/projects/bmrblib
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Edward d'Auvergne
Hi,

Thanks for the incredibly quick responses!  The os.isatty() call (and
sys.std*.isatty() calls as suggested by Chris Angelico at
http://mail.python.org/pipermail/python-list/2012-April/1291048.html)
work perfectly for this job!  I might have to do some testing later on
Windows though to see what happens when the ansi escape characters are
not supported.

Cheers,

Edward



On 17 April 2012 16:29, pat  wrote:
> Check os.isatty(fd). It will return True if fd is a terminal-like device.
>
> On Tue, Apr 17, 2012 at 5:21 PM, Edward d'Auvergne 
> wrote:
>>
>> Hi,
>>
>> I was wondering if anyone knows of how to detect when IO redirection
>> of any form is happening within a Python program?  I would like to
>> emulate the behaviour of the GNU tools (for example the Unix commands
>> 'ls' or 'grep') whereby ascii escape sequences are printed if the
>> output is solely to the terminal, and in all other cases (redirection
>> to file via '>', pipes via '|', or more complex redirections) the
>> ascii escape characters are suppressed.  Any ideas would be
>> appreciated!
>>
>> Cheers,
>>
>> Edward
>>
>>
>> --
>> Edward d'Auvergne, PhD
>> Lead developer of the projects relax, minfx, and bmrblib
>> http://www.nmr-relax.com
>> http://gna.org/projects/minfx
>> http://gna.org/projects/bmrblib
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
>

--
Edward d'Auvergne, PhD
Lead developer of the projects relax, minfx, and bmrblib
http://www.nmr-relax.com
http://gna.org/projects/minfx
http://gna.org/projects/bmrblib
-- 
http://mail.python.org/mailman/listinfo/python-list


Suppressing newline writing to file after variable

2011-06-28 Thread Ellerbee, Edward
Hi all, newbie question here. I'm using python 2.7. I've built my first
program to pull some info off the web, process it, and build dialpeers
for a cisco router. I have 2 problems - the first is the formatting of
printing the gathered information to a file. It seems to be inserting a
new line after the variable is written. I've searched the web, but
unsure of which method could fix this issue. 

Here is my code snippet:

count=0
o = open('dialpeers.txt', 'w')
for line in open('final.txt', 'r'):
figureDpn = count + 1000
dpn = str(figureDpn)
label = "dial-peer voice " + dpn
o.write(label)
o.write('\n')
destpatt = "destination-pattern " + line + ""
o.write(destpatt)
o.write('\n')
o.write("description *** local outbound dialpeer ***")
o.write('\n')
port = "port " + p
o.write(port)
o.write('\n')
o.write('\n')
count = count + 1

Output:
dial-peer voice 1000
destination-pattern 252200

description *** local outbound dialpeer ***
port 0/1


Desired Output:
dial-peer voice 1000
destination-pattern 252200
description *** local outbound dialpeer ***
port 0/1


I've just started with Python 3 weeks ago, so my code is poortly
written. I would appreciate any suggestions to improve.

Ed Ellerbee


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


RE: Suppressing newline writing to file after variable

2011-06-28 Thread Ellerbee, Edward
Thank you!

That works perfect, I'll have to look into string formatting more. 

My next issue to solve I've been researching is:

How to condense a group of numbers to a wildcard list. For example:

252205
252206
252208
252220
252221
25
252223
919745
919725
919785
704770 thru 704799 (all numbers listed individually in a file)

Condense to:
25220[568]
25222[0-3] (or 25222[0123] is fine too)
9197[248]5
7047[0-9][0-9] 

Any recommendations on where to start, a method or function to research?

Thanks!

Edward Ellerbee



-Original Message-
From: Noah Hall [mailto:[email protected]] 
Sent: Tuesday, June 28, 2011 12:18 PM
To: Ellerbee, Edward
Cc: [email protected]
Subject: Re: Suppressing newline writing to file after variable

On Tue, Jun 28, 2011 at 5:05 PM, Ellerbee, Edward  wrote:
> Hi all, newbie question here. I'm using python 2.7. I've built my 
> first program to pull some info off the web, process it, and build 
> dialpeers for a cisco router. I have 2 problems - the first is the 
> formatting of printing the gathered information to a file. It seems to 
> be inserting a new line after the variable is written. I've searched 
> the web, but unsure of which method could fix this issue.
>
> Here is my code snippet:
>
> count=0
> o = open('dialpeers.txt', 'w')
> for line in open('final.txt', 'r'):
>     figureDpn = count + 1000

>     dpn = str(figureDpn)
>     label = "dial-peer voice " + dpn
>     o.write(label)
>     o.write('\n')
>     destpatt = "destination-pattern " + line + ""

Try line.rstrip() instead. It'll remove all newlines. Also, I suggest you use 
string formatting, for example,
>>>destpatt = "destination-pattern %s" % line.rstrip()

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


I don't know list, I not good at list.

2011-07-13 Thread Ellerbee, Edward
I've been beating my head against the desk trying to figure out a method
to accomplish this:

Take a list (this example is 5 items, It could be 150 or more - i.e.
it's variable length depending on the city/local calling zones)
The first 6 digits of phone numbers(NPA/NXX) in a local calling area. I
want to concatenate the last digit for insertion into a call routing
pattern. 

I tried this and failed miserably:

list1=['252205','252246','252206','252247','252248']
for item in list1:
try:
item1=list1[0]
item2=list1[1]
if item1[0:5] == item2[0:5]:
print item1[0:5] + '[' + item1[5:6] + item2[5:6]
+ ']'
list1.pop(0)
else:
print item1
list1.pop(0)
except:
try:
print item1
list1.pop(0)
except:
pass

#-
My intent is to have the end data come out (from the example list above)
in the format of 
25220[56]
25224[678]

I tried putting together a variable inserted into a regular expression,
and it doesn't seem to like:
Item1=list1[0]
Itemreg = re.compile(Item1[0:5])
For stuff in itemreg.list1:
#do something

Can somebody throw me a bone, code example or module to read on
python.org? I'm a n00b, so I'm still trying to understand functions and
classes.

I thought the experts on this list might take pity on my pathetic code
skillz!

Thanks so much :)

Ed Ellerbee

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


RE: I don't know list, I not good at list.

2011-07-14 Thread Ellerbee, Edward
Thank you all for the advice, let me spin this in a different way.

I've built a program that goes to the NANPA website, scrapes area
code/exchange (npa/nxx) digits for a specified area - be it carolina,
alabama, texas, etc - drops it into a file, then massages the data and
prints out the correct format to insert into a voice router. The code is
ugly, but it works great.

The thing I haven't been able to get my script to do is to reduce the
amount of dial-peers. Hence the need to reduce the numbers to the least
common denominator, and put it in the x[xx] format.If we had a set
number of digits, we could build a dictionary(unless it's possible to do
that dynamically). 

So, a couple assertions:
1. the data will always be 6 digit numbers (in a string format)
2. the data is in a txt file after being put there from my script
3. the data will never be the same (I'm going to use this for site
conversions/new site builds
e.g. today I might be dealing with 252-, 919- and 704- area
codes, tomorrow might be 304- and 754-
4. I wanted a script to reduce the time taking to build the dial-peers
manually. I'd previously spent 3-4 hours
   on gathering and processing data. The script I have so far pulls data
and massages in about 6 seconds
5. I'm using python 2.7 - it seems like it had more module availability
than 3

And a couple question:
1. Would lists be the best way to handle this data? Would it be better
to process this data from a file?
2. Is there a way to determine the common (first-5 digits) denominator
among a list (or file) of data?
3. and... Could those common numbers be inserted in a dict for
processing?

Sorry for the book!

thanks

Edward Ellerbee


-Original Message-
From: [email protected]
[mailto:[email protected]] On Behalf
Of MRAB
Sent: Wednesday, July 13, 2011 5:59 PM
To: [email protected]
Subject: Re: I don't know list, I not good at list.


 > I've been beating my head against the desk trying to figure out a  >
method to accomplish this:
 >
 > Take a list (this example is 5 items, It could be 150 or more - i.e.
 > it's variable length depending on the city/local calling zones)  >  >
The first 6 digits of phone numbers(NPA/NXX) in a local calling area.
 > I want to concatenate the last digit for insertion into a call  >
routing pattern.
 >
 > I tried this and failed miserably:
 >
 > list1=['252205','252246','252206','252247','252248']
 > for item in list1:
 > try:
 > item1=list1[0]
 > item2=list1[1]
 > if item1[0:5] == item2[0:5]:
 > print item1[0:5] + '[' + item1[5:6] + 
item2[5:6] + ']'
 > list1.pop(0)
 > else:
 > print item1
 > list1.pop(0)
 > except:
 > try:
 > print item1
 > list1.pop(0)
 > except:
 > pass
 >
 > #-
 > My intent is to have the end data come out (from the example list  >
above) in the format of  > 25220[56]  > 25224[678]  >  > I tried putting
together a variable inserted into a regular  > expression, and it
doesn't seem to like:
 > Item1=list1[0]
 > Itemreg = re.compile(Item1[0:5])
 > For stuff in itemreg.list1:
 > #do something
 >
 > Can somebody throw me a bone, code example or module to read on  >
python.org? I'm a n00b, so I'm still trying to understand functions  >
and classes.
 >
 > I thought the experts on this list might take pity on my pathetic  >
code skillz!
 >
defaultdict comes in handy:

 >>> list1 = ['252205','252246','252206','252247','252248']
 >>> from collections import defaultdict  >>> d = defaultdict(set)  >>>
for item in list1:
d[item[ : 5]].add(item[5 : ])


 >>> d
defaultdict(, {'25224': {'8', '7', '6'}, '25220': {'5',
'6'}})  >>> for k, v in d.items():
print(k + "[" + "".join(v) + "]")


25224[876]
25220[56]
--
http://mail.python.org/mailman/listinfo/python-list

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


RE: Suppressing newline writing to file after variable

2011-07-14 Thread Ellerbee, Edward
Holy cow, that's perfect!

Thanks so much :) 

Would it be alright if I post my code on the list for critiquing? I'm
learning python to supplement my voice engineering position - time
consuming tasks that can be automated will take less time.


Edward Ellerbee


-Original Message-
From: [email protected]
[mailto:[email protected]] On Behalf
Of Chris Angelico
Sent: Thursday, July 14, 2011 10:39 AM
To: [email protected]
Subject: Re: Suppressing newline writing to file after variable

On Fri, Jul 15, 2011 at 12:04 AM, Ellerbee, Edward
 wrote:
> Hey Chris,
>
> I was reading over this again, trying to understand the logic (I'm a
> n00b)
>
> Could you explain this a bit? I'd like to build this emit function, 
> but I still don't have a firm grasp on functions. All of my code is 
> line by line. I'll convert it as a learn more.

I'm responding on-list as I believe others will wish to weigh in (if
only to point out some improvements to my code - it's hastily put
together). Caution, post is long.

Defining functions in Python is, broadly speaking, just a matter of
collecting up a bunch of statements and giving it a name. Compare:

if x>5:
   do_this()
   do_that()
   etc()

with:

def abcde():
   do_this()
   do_that()
   etc()

The first one does the three statements, in order, if and only if the
condition is true. The second one gives a name to those three
statements, so you can use it as a new statement:

abcde()

It'll do the same three things, every time you call it. It's effectively
the same as putting the function's body in where you call it (that's an
extremely sloppy explanation, but near enough).

> So, I'd want this to go after the sort step, and before the format
step.
> I can figure that piece out, just trying to get this little block of 
> code to work.

Yes, that would be the place to put it.

Here's a reworked version that you can test in IDLE:


def combine(list_of_numbers, position):
 lastprefix=tails=lastsuffix=None
 result=[]
 for cur in list_of_numbers:
  prefix=cur[:position]; tail=cur[position]; suffix=cur[position+1:]
  if prefix!=lastprefix or suffix!=lastsuffix:
   if lastprefix!=None:
if len(tails)>1:
result.append("%s[%s]%s"%(lastprefix,tails,lastsuffix))
else: result.append(lastprefix+tails+lastsuffix)
   lastprefix,tails,lastsuffix=prefix,"",suffix
  tails+=tail
 if lastprefix!=None:
  if len(tails)>1:
result.append("%s[%s]%s"%(lastprefix,tails,lastsuffix))
  else: result.append(lastprefix+tails+lastsuffix)
 return result

It incorporates some of the enhancements I mentioned in the original
post.

>>> combine(['252205','252206','252208'],5)
['25220[568]']
>>> combine(['252205','252215','252225'],4)
['2522[012]5']

Notice that the 'emit' function is now 'result.append()' - it builds up
a list to return. You can now chain the calls; start with a list of
numbers and then call combine() in a loop.

# List of numbers from your previous post numbers = ['252205', '252206',
'252208', '252220', '252221', '25', '252223', '919745', '919725',
'919785', '704770', '704771', '704772', '704773', '704774', '704775',
'704776', '704777', '704778', '704779', '704780', '704781', '704782',
'704783', '704784', '704785', '704786', '704787', '704788', '704789',
'704790', '704791', '704792', '704793', '704794', '704795', '704796',
'704797', '704798', '704799']


numbers = combine(numbers,5)

numbers = combine(numbers,4)

numbers = combine(numbers,3)

numbers = combine(numbers,2)

numbers = combine(numbers,1)

numbers = combine(numbers,0)

If you do these statements one at a time in IDLE and inspect the
'numbers' list each time, you'll see the combinations sorting themselves
out. (With this starting list, only the first two will have any effect.)

The last set of calls can be turned into a for loop:
for pos in range(5,-1,-1):
   numbers = combine(numbers,pos)

In fact, you could actually take it out of being a function, if you
wanted to:

list_of_numbers = ['252205', '252206', '252208', '252220', '252221',
'25', '252223', '919745', '919725', '919785', '704770', '704771',
'704772', '704773', '704774',

Please critique my script

2011-07-14 Thread Ellerbee, Edward
I've been working on this for 3 weeks as a project while I'm learning
python. It's ugly, only function in there is from a fellow lister, but
it works perfectly and does what it is intended to do.

I'd love to hear comments on how I could improve this code, what would
be good to turn into a function/class etc.

# The function of this script is to gather user data from the user to
# build appropriate local dial-peers in a cisco voice gateway.
# Data gathered from the user:
# name of file to write dial-peers to
# NPA
# NXX
# outbound port to send calls
# question if home npa local calls are 7 digit
# script navigates to nanpa.com, gathers the local calling area
# and returns the data
# the data is converted to beautiful soup (I had a problem with the xml
format)
# the data is parsed for the proper NPA/NXXs
# list is sorted, duplicates removed
# data from list is formatted and printed to the file specified


#Import dependencies---
import urllib2
from BeautifulSoup import BeautifulSoup
import re

#Define variables
count = 0
count2 = 0
count3 = 0
npalist = []
nxxlist = []
sortlist = []
sortedlist = []
npaReg = re.compile('(?<=)(...)(?=)')
nxxReg = re.compile('(?<=)(...)(?=)')
proxy = urllib2.ProxyHandler({'http': 'proxy.com:8080'})
# --actual proxy was removed for confidentiality--
opener = urllib2.build_opener(proxy)

#- function to concatenate numbers - thanks to Chris Angelico -
def combine(list_of_numbers, position):
lastprefix=tails=lastsuffix=None
result=[]
for cur in list_of_numbers:
prefix=cur[:position]; tail=cur[position];
suffix=cur[position+1:]
if prefix!=lastprefix or suffix!=lastsuffix:
if lastprefix!=None:
if len(tails)>1:
result.append("%s[%s]%s"%(lastprefix,tails,lastsuffix))
else: result.append(lastprefix+tails+lastsuffix)
lastprefix,tails,lastsuffix=prefix,"",suffix
tails+=tail
if lastprefix!=None:
if len(tails)>1:
result.append("%s[%s]%s"%(lastprefix,tails,lastsuffix))
else: result.append(lastprefix+tails+lastsuffix)
return result


#---Gather info from user
x = raw_input("please enter a filename: ")
y = raw_input("please enter the npa: ")
z = raw_input("please enter the nxx: ")
p = raw_input("please enter the port: ")
q = raw_input("Is home npa local dialing 7 digit?(y/n) ")
#print x

#---Modify user data-
o = open(x, 'w')
y = str(y)
z = str(z)
p = str(p)
pagedef = ("http://www.localcallingguide.com/xmllocalprefix.php?npa="; +
y + "&nxx=" + z)
print "Querying", pagedef

#--Get info from NANPA.com --
urllib2.install_opener(opener)
page = urllib2.urlopen(pagedef)
soup = BeautifulSoup(page)
soup = str(soup)

#--Parse Gathered Data--
for line in npaReg.findall(soup):
npalist.insert(count,line)
count = count + 1

for line2 in nxxReg.findall(soup):
nxxlist.insert(count2,line2)
count2 = count2 + 1

#-Sort, remove duplicates, concatenate the last digits for similiar
NPA/NXX --
for makenewlist in range(0,count):
sortlist.append(npalist.pop(0) + nxxlist.pop(0))

sortlist.sort()

for sortednumber in sortlist:
if sortednumber not in sortedlist:
sortedlist.append(sortednumber)

catlist = combine(sortedlist,5)
catlist2 = combine(catlist,4)

#--Print the dial-peers to file
for line in catlist2:
figureDpn = count3 + 1000
dpn = str(figureDpn)
label = "dial-peer voice " + dpn
o.write(label)
o.write('\n')
o.write("description *** local outbound dialpeer ***")
o.write('\n')
destpatt = "destination-pattern %s" % line.rstrip()
o.write(destpatt)
o.write('\n')
port = "port " + p
o.write(port)
o.write('\n')
if line[0:3] == y and q == "y":
o.write("forward-digits 7")
o.write('\n')
o.write('\n')
count3 = count3 + 1

o.close()

#---

Thanks!

Edward Ellerbee



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


Switching between Python releases under Windows

2011-03-08 Thread Edward Diener
I have multiple versions of Python installed under Vista. Is there any 
easy way of switching between them so that invoking python and file 
associations for Python extensions files work automatically ?

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


matchpy

2017-11-12 Thread Edward Montague
 After successfully installing python 3.6.3 and the appropriate version of
IDLE ,
I attempted to run a matchpy example , to no avail .

 I'm using a debian distribution , 8.x or greater , is there something I
need to be aware of .
The error report points to a statement containing a ' -> ' character , as
far as I know ,
this isn't valid python syntax .
-- 
https://mail.python.org/mailman/listinfo/python-list


Add a method to list the current named logging levels

2021-09-02 Thread Edward Spencer
Sometimes I like to pass the logging level up to the command line params so my 
user can specific what level of logging they want. However there is no easy 
method for pulling the named logging level names.

Looking into the code, it would actually be incredibly easy to implement;

in `logging.__init__.py`;

def listLevelNames():
return _nameToLevel.keys()

You could obviously add some other features, like listing only the defaults, 
sorted by numerical level or alphabetically, etc. But really this basic 
implementation would be enough to expose the internal variables which shouldn't 
be accessed because they change (and in fact, between python 2 and 3, they did).

Any thoughts?

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


Re: Add a method to list the current named logging levels

2022-03-30 Thread Edward Spencer
在 2021年9月3日星期五 UTC+1 18:50:51, 写道:
> > On 2 Sep 2021, at 23:38, Dieter Maurer  wrote:
> > 
> > Edward Spencer wrote at 2021-9-2 10:02 -0700: 
> >> Sometimes I like to pass the logging level up to the command line params 
> >> so my user can specific what level of logging they want. However there is 
> >> no easy method for pulling the named logging level names. 
> >> 
> >> Looking into the code, it would actually be incredibly easy to implement; 
> >> 
> >> in `logging.__init__.py`; 
> >> 
> >> def listLevelNames(): 
> >> return _nameToLevel.keys() 
> >> 
> >> You could obviously add some other features, like listing only the 
> >> defaults, sorted by numerical level or alphabetically, etc. But really 
> >> this basic implementation would be enough to expose the internal variables 
> >> which shouldn't be accessed because they change (and in fact, between 
> >> python 2 and 3, they did). 
> >> 
> >> Any thoughts? 
> > 
> > Usually, you use 5 well known log levels: "DEBUG", "INFO", "WARNING", 
> > "ERROR" and "CRITICAL". 
> > No need to provide a special function listing those levels.
> I add my own levels, but then I know I did it. 
> 
> Barry 
> 
> > 
> > 
> > 
> > -- 
> > Dieter 
> > -- 
> > https://mail.python.org/mailman/listinfo/python-list 
> >

Yes, the names are already well defined. But every software project anyone has 
that needs to use logging then has to define that list, which is a waste of 
time since they're already defined inside the logging repo. But no-one can 
access them unless they use protected variables. If it's a case of not wanting 
users to be able to modify the defaults, then just define that list of log 
levels as a tuple. Hiding it is unnecessary.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Add a method to list the current named logging levels

2022-03-30 Thread Edward Spencer
在 2022年3月30日星期三 UTC+1 16:38:26, 写道:
> > On 30 Mar 2022, at 16:11, Edward Spencer  wrote:
> > 
> > 在 2021年9月3日星期五 UTC+1 18:50:51, 写道: 
> >>>> On 2 Sep 2021, at 23:38, Dieter Maurer  wrote: 
> >>> 
> >>> Edward Spencer wrote at 2021-9-2 10:02 -0700: 
> >>>> Sometimes I like to pass the logging level up to the command line params 
> >>>> so my user can specific what level of logging they want. However there 
> >>>> is no easy method for pulling the named logging level names. 
> >>>> 
> >>>> Looking into the code, it would actually be incredibly easy to 
> >>>> implement; 
> >>>> 
> >>>> in `logging.__init__.py`; 
> >>>> 
> >>>> def listLevelNames(): 
> >>>> return _nameToLevel.keys() 
> >>>> 
> >>>> You could obviously add some other features, like listing only the 
> >>>> defaults, sorted by numerical level or alphabetically, etc. But really 
> >>>> this basic implementation would be enough to expose the internal 
> >>>> variables which shouldn't be accessed because they change (and in fact, 
> >>>> between python 2 and 3, they did). 
> >>>> 
> >>>> Any thoughts? 
> >>> 
> >>> Usually, you use 5 well known log levels: "DEBUG", "INFO", "WARNING", 
> >>> "ERROR" and "CRITICAL". 
> >>> No need to provide a special function listing those levels. 
> >> I add my own levels, but then I know I did it. 
> >> 
> >> Barry 
> >> 
> >>> 
> >>> 
> >>> 
> >>> -- 
> >>> Dieter 
> >>> -- 
> >>> https://mail.python.org/mailman/listinfo/python-list 
> >>> 
> > 
> > Yes, the names are already well defined. But every software project anyone 
> > has that needs to use logging then has to define that list, which is a 
> > waste of time since they're already defined inside the logging repo. But 
> > no-one can access them unless they use protected variables. If it's a case 
> > of not wanting users to be able to modify the defaults, then just define 
> > that list of log levels as a tuple. Hiding it is unnecessary.
> Is logging.getLevelNamesMapping() what you are looking for? 
> 
> Barry 
> 
> 
> > -- 
> > https://mail.python.org/mailman/listinfo/python-list

Hi Barry,

What version for python / logging are you seeing that method in? I don't appear 
to be able to find it.
I vaguely remember seeing something similar to it though, did it return a dict 
of {: } only or did it also include the reverse of int to 
str?

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


os with python[s]

2018-07-13 Thread Edward Montague
 I encounter numerous problems when changing between versions of python ;
one
possible answer , Fedora 28 Labs python .

  So far this has been fairly reliable , I installed
Geany , as this is my preferred editor for Python.
-- 
https://mail.python.org/mailman/listinfo/python-list


mayavi mlab mesh plot3d grid from mesh

2016-06-15 Thread Edward Montague
Hi,

  I'm  wondering if there's any way to overlay a grid upon
a mlab.mesh or mlab.surf graph.

  As an example of what I mean I shall attempt to attach a
small file maya2.jpg  .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 3 on Windows

2016-08-02 Thread Edward Diener

On 8/2/2016 8:11 AM, Uri Even-Chen wrote:

Hi,

I want to install Python 3 on Windows, but I also need Python 2 for Google
App Engine SDK. When I type a name of a Python file in command line, I want
it to run with Python 3. However, I checked with "print 3/5" and it printed
0 - Python 2. I have the latest versions of Python installed
- python-2.7.12.msi and python-3.5.2.exe


python --version

Python 2.7.12


assoc .py

.py=Python.File


ftype Python.File

Python.File="C:\Python27\python.exe" "%1" %*

By the way, it there a way to print the Python version from Python?


Use the Python Launcher for Windows.

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


Unable to find newly installed Python 3.7.1

2018-11-23 Thread Edward Popko
Snake people:


I'm a Java person and thought to try Python for Windows.
I installed Python 3.7.1 (64-bit) hoping for an IDE, documentation and even
a sample or two.
The python-3.7.1-amd64.exe unpacks and installs fine.
Only problem is I cannot find it. There was no install option to add an
shortcut to the
desktop, there is no C:\ folder, no folder added to Program Files or Program
Files (x86).


I have Windows 10, 64 bit professional

 

Where did it go? Where is the IDE?

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


wxFormBuilder

2020-02-28 Thread Edward Montague
 The videos on YouTube by fandangleproductions, have been
of some use.

 However as I also use the Geany editor, I find that I need to
append this extra code to the Python script generated from
wxFormBuilder.

 # - extra code ---

class MyApp(wx.App):
def OnInit(self):
self.frame = frameMain(None)
self.SetTopWindow(self.frame)
self.frame.Show()
return True

# end of class MyApp

if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()


 Where frameMain is the name of this particular frame.

 This may help you with your Python coding.
-- 
https://mail.python.org/mailman/listinfo/python-list


rubi integrate

2020-04-19 Thread Edward Montague
 After wrestling with version incompatibilities and incomplete
code, I have produced test code and an edited version of
rubi.py  .
 For rubi.py I found it necessary to replace exp with rubi_exp,
in a few locations; you may want to check this, files are attached. Perhaps
this isn't an issue with a more recent version of sympy.

I'm using Ubuntu 19.10, python 3.7.6, gcc  7.3.0, pip3 version
20.0.2.
  Sympy 1.4, matchpy 0.5.1, numpy 1.8.1, scipy 1.3.3 .
-- 
https://mail.python.org/mailman/listinfo/python-list


multiprocessing

2020-04-20 Thread Edward Montague
 Upon using sympy's rubi_integrate upon my quad core
computer, I find that the first CPU is being used 100%,
whilst the other three are around 1% and 2% .

 I'm wondering if you have some code to overcome this limitation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Name of IDLE on Linux

2005-04-02 Thread Edward Diener
What is the name of the IDLE program on Linux and where is it installed 
in a normal Linux distribution ? I have installed all the Python 2.3.5 
RPMs on my Fedora 3 system but I have no idea where they are installed 
or what IDLE is called. I lloked in the Python web pages to try to find 
a list of the files in the various installations, but was unable to find 
the information.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Name of IDLE on Linux

2005-04-02 Thread Edward Diener
Jim Benson wrote:
On Sat, 2 Apr 2005, Edward Diener wrote:

What is the name of the IDLE program on Linux and where is it installed 
in a normal Linux distribution ? I have installed all the Python 2.3.5 
RPMs on my Fedora 3 system but I have no idea where they are installed 
or what IDLE is called. I lloked in the Python web pages to try to find 
a list of the files in the various installations, but was unable to find 
the information.


Try idle (all lower case). 
On my RH-9 system it is in /usr/local/bin
Thanks. The system came with Python and the development libraries but 
not with the latest installation and tools. Once I was able to install 
all the latest Python RPM for Fedora 3, 'idle' showed up. Now all I have 
to do is find everything else, including the latest documentation files. 
It is a pity the Python Linux binary installations do not create folders 
on the desktop or in the Gnome menu system with links to the Python to 
the documentation and a readme telling me what executables were installed.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Name of IDLE on Linux

2005-04-02 Thread Edward Diener
Thomas Rast wrote:
> Edward Diener <[EMAIL PROTECTED]> writes:
>
>> It is a pity the Python Linux binary installations do not
>> create folders on the desktop or in the Gnome menu system with links
>> to the Python to the documentation and a readme telling me what
>> executables were installed.
>
> Imagine they did, and the other 1392 packages (on my system) too :-)

I can understand that . But I would rather have links somewhere than not
know what it was a particular package does and how to use it. As a relative
Linux newbie, I have found it disconcerting to have things installed on my
system when I first booted the system or when I install new packages or
upgrade existing ones, and not know what these packages are used for. One
can always delete links, and they are cheap, so I would rather have too much
to begin with than too little.

>
> Documentation usually resides in /usr/share/doc/,
> /usr/share/doc/packages/ or similiar.  You're on an RPM-based
> system, so
>
> $ rpm -ql 
>
> lists all files belonging to that package.  You should have little
> trouble spotting the documentation files there.

Thanks. That does help.


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


Installing Python 2.4 on Linux

2005-04-05 Thread Edward Diener
I can install Python 2.4 on the Fedora 3 Linux system, but after I do a 
number of Linux utilities and commands, like yum, stop working because 
they were dependent on the Python 2.3 installation. What happens is that 
Python 2.4 replaces the /usr/bin/python module with the Python 2.4 
version. If I replace /usr/bin/python with the Python 2.3 version 
executable, which is still on my system, that all the aforesaid modules 
depend on, they start working again, but I can no longer execute 
modules, like IDLE, which was part of my Python 2.4 distribution.

What is the solution to this ? The operating system was installed with 
Python 2.3 and the development libraries but no tools, doc, or 
otherwise. I have installed Python 2.4 with all the RPMs and copied down 
the Python 2.4 documentation to my machine ( since python24-docs.rpm 
gives one very little ). I would naturally like to use Python 2.4 
without killing all the commands that depend on Python 2.3. No doubt 
these commands have their modules in the site libraries for Python 2.3. 
Of course I would love to update these dependencies to use Python 2.4 
but newer RPMs for these commands do not exist.

I do not know whether this is a Python problem or a Fedora 3 problem but 
I thought I would ask here first and see if anybody else had the same 
problem. I imagine the problem might exist on other Linux systems.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 2.4 on Linux

2005-04-05 Thread Edward Diener
Marcin Stêpnicki wrote:
> Dnia Tue, 05 Apr 2005 21:21:37 +0000, Edward Diener napisal(a):
>
>> I can install Python 2.4 on the Fedora 3 Linux system, but after I
>> do a number of Linux utilities and commands, like yum, stop working
>> because they were dependent on the Python 2.3 installation. What
>> happens is that Python 2.4 replaces the /usr/bin/python module with
>> the Python 2.4 version. If I replace /usr/bin/python with the Python
>> 2.3 version executable, which is still on my system, that all the
>> aforesaid modules depend on, they start working again, but I can no
>> longer execute modules, like IDLE, which was part of my Python 2.4
>> distribution.
>>
>> What is the solution to this ? The operating system was installed
>> with Python 2.3 and the development libraries but no tools, doc, or
>> otherwise. I have installed Python 2.4 with all the RPMs and copied
>> down the Python 2.4 documentation to my machine ( since
>> python24-docs.rpm gives one very little ). I would naturally like to
>> use Python 2.4 without killing all the commands that depend on
>> Python 2.3. No doubt these commands have their modules in the site
>> libraries for Python 2.3. Of course I would love to update these
>> dependencies to use Python 2.4 but newer RPMs for these commands do
>> not exist.
>>
>> I do not know whether this is a Python problem or a Fedora 3 problem
>> but I thought I would ask here first and see if anybody else had the
>> same problem. I imagine the problem might exist on other Linux
>> systems.
>
> It's rather Fedora related, I have Python 2.2, 2.3 and 2.4 on my
> Ubuntu box and they seem to coexist without problems.
>
> If you can afford breaking package dependencies a bit, save a copy of
> python2.3 binary somewhere and recreate it after installing Python
> 2.4

After I installed Python 2.4, the Python 2.3 executable still existed on the
system. So the only difference which occurred is that the Python 2.4
installation copied to the /usr/bin/python executable the /usr/bin/python2.4
executable ( it would seem more understandable that /usr/bin/python be a
link instead ). So there is really no need to recreate it. Essentially the
two versions co-exist on the system but only one can be /usr/bin/python and
therefore executed when a Python script is is used as a command.

>, OR make a symbolic link /usr/bin/python to /usr/bin/python2.3
> and use /usr/bin/python2.4 explicitely when you want to use the newer
> version.

Yes, this is the right solution. I am so used to just executing a Python
script that I forgot that I could just say 'python2.4 ascript.py'.

> You may also try to link modules from
> /usr/lib/python2.3/site-packages to /usr/lib/python2.4/site-packages
> (all or just few of them) - most should be upwards compatible.

By link do you simply mean moving the unique modules in the site packages
from the python2.3 directory to the python2.4 site-packages directory, or is
there something else I must do to see if they work ?

> It may
> make Fedora utilities work again (you haven't provided error
> messages, so it's hard to tell) even with Python 2.4.

The errors when executed from the command line, when python2.4 is python,
involved not being able to find modules, no doubt because they were not in
the python2.4 site-packages subdirectory. When python2.3 is python, the
modules are found and everything works. Maybe it is just a matter of moving
of copying these modules on over and seeing if that fixes things. Do
site-packages have to "register" themselves in any way during setup ? I do
not think so, but I may be wrong.


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


Re: Installing Python 2.4 on Linux

2005-04-08 Thread Edward Diener
David Fraser wrote:
Edward Diener wrote:
I can install Python 2.4 on the Fedora 3 Linux system, but after I do 
a number of Linux utilities and commands, like yum, stop working 
because they were dependent on the Python 2.3 installation. What 
happens is that Python 2.4 replaces the /usr/bin/python module with 
the Python 2.4 version. If I replace /usr/bin/python with the Python 
2.3 version executable, which is still on my system, that all the 
aforesaid modules depend on, they start working again, but I can no 
longer execute modules, like IDLE, which was part of my Python 2.4 
distribution.

What is the solution to this ? The operating system was installed with 
Python 2.3 and the development libraries but no tools, doc, or 
otherwise. I have installed Python 2.4 with all the RPMs and copied 
down the Python 2.4 documentation to my machine ( since 
python24-docs.rpm gives one very little ). I would naturally like to 
use Python 2.4 without killing all the commands that depend on Python 
2.3. No doubt these commands have their modules in the site libraries 
for Python 2.3. Of course I would love to update these dependencies to 
use Python 2.4 but newer RPMs for these commands do not exist.

I do not know whether this is a Python problem or a Fedora 3 problem 
but I thought I would ask here first and see if anybody else had the 
same problem. I imagine the problem might exist on other Linux systems.

Actually the Fedora RPMS supplied on the Python website are fine:
http://www.python.org/2.4.1/rpms.html
Quoting from that page:
# Q) Is it safe to install these RPMs on a Red Hat system? Will they 
over-write the system python and cause problems with other Red Hat 
applications that expect a different version of Python?
# A) The RPMs that start with "python2.4" are built to not interfere 
with the system Python. They install as "/usr/bin/python2.4" and will 
not conflict with the system Python unless you are running on a system 
that ships the a version of Python which has the same major/minor number.

To invoke the interpreter with these packages, you will explicitly 
have to run "python2.4". Note that all Python RPMs provided by 
Python.org and Red Hat provide a "/usr/bin/python2.4" (or similar, 
with major/minor number), even if they also provide "/usr/bin/python". 
So, yes, it should be safe.

Note that you may need to build and install a second copy of any 
packages which you need access to with the supplemental version of 
Python. You can build packages of these files for the Python 2.4 
interpreters for packages which use Distutils, by using the command 
"python2.4 setup.py bdist_rpm". 

This is by far the preferred way to install a different version of 
Python to the default version provided with a distribution, as you don't 
then conflict with packages that require the default version.
I do have a separate package installed for Python2.4 and it coexists 
with Python2.3. The real problem is that a great number of other 
packages, which are initially part of the system, depend on Python2.3 so 
I must leave /usr/bin/python as Python2.3. I do not know of a way to 
reinstall these other packages to use Python2.4 instead. Does the line 
above, "python2.4 setup.py bdist_rpm" mean that I am supposed to run 
this against each of these other package's rpm files and substitute for 
"bdist_rpm" the name of the rpm file ?

Also, it is better to do it like this using real packages than to rename 
files manually. I have used the above successfully on Fedora Core 3 (and 
other similar versions on other distro versions), if it doesn't work for 
you there is a source RPM available to rebuild from
Is "bdist_rpm" the source rpm for these packages which currently depend 
on Python2.3 ?

Further help getting my Fedora 3 packages which depend on Python2.3 to 
use Python2.4 would be appreciated.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 2.4 on Linux

2005-04-08 Thread Edward Diener
John Ridley wrote:
--- Edward Diener <[EMAIL PROTECTED]> wrote:
[snip]
I do not know whether this is a Python problem or a Fedora 3 problem
but 
I thought I would ask here first and see if anybody else had the same

problem. I imagine the problem might exist on other Linux systems.

On my Mandrake 10.1 system I have the default python 2.3 installation
plus a separate python 2.4 installation which I compiled from source.
There are two executables (python2.3 and python2.4) in /usr/bin, plus a
hard-link (from python2.4) named python. If necessary, I could switch
back to the default setup by replacing the hard-link with one from
python2.3 - so the system would then have its preferred python version
and I could selectively run python2.4 whenever appropriate. So far,
Mandrake has not complained about using python 2.4 exclusively, so I
might try removing the old installation eventually. (Then again, it's
always handy to keep it for compatibility testing).
I need python to be python2.3 else many utilities no longer work. The 
problem is then using IDLE and pydoc for Python2.4 since neither are .py 
scripts and need python to be a link to python2.4 and not python2.3. I 
guess the solution is to write a script a shell script which links 
python to python2.4, run IDLE let's say, then link back to python2.3. 
However while I am doing this, other system facilities which depend on 
python to be python2.3 will be dead.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 2.4 on Linux

2005-04-08 Thread Edward Diener
Joseph Garvin wrote:
Another solution is to just install 2.4 and then make an alias for
yum='/usr/bin/python2.3 yum' or whatever the path is :)
If it were just 'yum' under Fedora 3, I could probably do that but 
looking at the dependencies on the python2.3 package in Synaptic there 
must be about 50 other packages mentioned. Which one of these 
specifically use python2.3 to execute their .py scripts and which ones 
just use python2.3 shared libraries is another matter which will take 
much work to discover. But thanks for your suggestion nonetheless.

Edward Diener wrote:

I can install Python 2.4 on the Fedora 3 Linux system, but after I do
a number of Linux utilities and commands, like yum, stop working
because they were dependent on the Python 2.3 installation. What
happens is that Python 2.4 replaces the /usr/bin/python module with
the Python 2.4 version. If I replace /usr/bin/python with the Python
2.3 version executable, which is still on my system, that all the
aforesaid modules depend on, they start working again, but I can no
longer execute modules, like IDLE, which was part of my Python 2.4
distribution.
What is the solution to this ? The operating system was installed with
Python 2.3 and the development libraries but no tools, doc, or
otherwise. I have installed Python 2.4 with all the RPMs and copied
down the Python 2.4 documentation to my machine ( since
python24-docs.rpm gives one very little ). I would naturally like to
use Python 2.4 without killing all the commands that depend on Python
2.3. No doubt these commands have their modules in the site libraries
for Python 2.3. Of course I would love to update these dependencies to
use Python 2.4 but newer RPMs for these commands do not exist.
I do not know whether this is a Python problem or a Fedora 3 problem
but I thought I would ask here first and see if anybody else had the
same problem. I imagine the problem might exist on other Linux systems.


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


Re: Installing Python 2.4 on Linux

2005-04-09 Thread Edward Diener
John Ridley wrote:
* Edward Diener wrote:
I need python to be python2.3 else many utilities no longer work.

Then leave your 2.3 installation exactly as it is (so that python is a
link to python2.3) and run python2.4 where needed.
To specifically use python 2.4 to run IDLE, simply type in a shell:
[user]$ python2.4 /usr/bin/idle
Alternatively, create your own (executable) idle or pydoc with a
shebang that points permanently at python2.4. For example:
file: $HOME/bin/idle2.4
---
#!/usr/bin/python2.4
from idlelib.PyShell import main
if __name__ == '__main__':
main()
---
Then if $HOME/bin is on your PATH, you can simply run: idle2.4
This change worked. Thanks !

The problem is then using IDLE and pydoc for Python2.4 since neither
are .py scripts

Really?! What are they on Fedora, then?
I realized they are links to the respective idle2.4.py and pydoc2.4.py 
scripts.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4.1 install broke RedHat 9 printconf-backend

2005-04-10 Thread Edward Diener
BrianS wrote:
> Hi,
>
> I'm trying to learn Python and wanted to play with Tkinter.  I
> couldn't get it to work so I figured it would help if I installed the
> newest verison of Python.  I downloaded the source, compiled it and
> installed it.  No problem.  The next time I booted my machine I the
> following errors when it tried to start CUPS:
>
> Traceback (most recent call last):
>   File "/usr/sbin/printconf-backend", line 6, in ?
> import backend
>   File "/usr/share/printconf/util/backend.py", line 37, in ?
> import cups_import
>   File "/usr/share/printconf/util/cups_import.py", line 7, in ?
> from printconf_conf import *
>   File "/usr/share/printconf/util/printconf_conf.py", line 83, in ?
> from xml.utils import qp_xml
> ImportError: No module named utils
>
> It seems that the xml package have been changed.  My problem is that I
> don't know enough Python to fix it properly.  The old verison of
> Python was 2.2.2 and the
> version I just installed is 2.4.1.  This is on a Dell Inspiron 8500
> running Red Hat 9.
>
> Anyone have any ideas?  Thanks in advance.

Change the /usr/bin/python link from python2.4 to whatever version of python
exe it used to point to, probably python2.2 in your case. The Python2.4
install does not overwrite any of your python2.2 files, it just changes the
python link.

> Brian


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


Python launcher options

2016-01-05 Thread Edward Diener
The Python launcher in Windows is a neat tool for running multiple 
versions of Python 2 and Python 3 at different times. It allows as 
options the ability to specify the latest version of either Python 2 or 
Python 3 defaulting to the 64-bit version if both exist, or a specific 
32-bit or 64-bit version of Python 2 or Python 3. What is missing is the 
ability to specify the latest 32-bit version of Python 2 or Python 3. 
The equivalent syntax would be '-2-32' or '-3-32'. Is there some reason 
why this option has been disallowed ?

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


Re: Python launcher options

2016-01-09 Thread Edward Diener

On 1/9/2016 11:03 AM, Tim Golden wrote:

On 06/01/2016 00:48, Edward Diener wrote:

The Python launcher in Windows is a neat tool for running multiple
versions of Python 2 and Python 3 at different times. It allows as
options the ability to specify the latest version of either Python 2 or
Python 3 defaulting to the 64-bit version if both exist, or a specific
32-bit or 64-bit version of Python 2 or Python 3. What is missing is the
ability to specify the latest 32-bit version of Python 2 or Python 3.
The equivalent syntax would be '-2-32' or '-3-32'. Is there some reason
why this option has been disallowed ?


As far as I can remember, it's not so much a question of "disallowed" as
just "not thought of by anyone". If you wanted this to go anywhere,
could I suggest you create an issue on the Python issue tracker:

   http://bugs.python.org

and mark it as "Windows" in the [Components] field (that makes sure that
some relevant people get to see it). It's got a much better chance of
achieving traction if you can actually provide a code patch to implement
the behaviour. Failing that, at least make a good case which might
convince one of the developers that it would it be worth their while
implementing the change.


I have tried to register with the link above so I can an issue with the 
Python Issue tracker but all attempts fail with:


"Failed issue tracker submission

An unexpected error occurred during the processing
of your message. The tracker administrator is being
notified."


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


Re: Python launcher options

2016-01-10 Thread Edward Diener

On 1/10/2016 6:38 AM, Tim Golden wrote:



On 10/01/2016 05:18, Edward Diener wrote:

On 1/9/2016 11:03 AM, Tim Golden wrote:

On 06/01/2016 00:48, Edward Diener wrote:

The Python launcher in Windows is a neat tool for running multiple
versions of Python 2 and Python 3 at different times. It allows as
options the ability to specify the latest version of either Python 2 or
Python 3 defaulting to the 64-bit version if both exist, or a specific
32-bit or 64-bit version of Python 2 or Python 3. What is missing is
the
ability to specify the latest 32-bit version of Python 2 or Python 3.
The equivalent syntax would be '-2-32' or '-3-32'. Is there some reason
why this option has been disallowed ?


As far as I can remember, it's not so much a question of "disallowed" as
just "not thought of by anyone". If you wanted this to go anywhere,
could I suggest you create an issue on the Python issue tracker:

   http://bugs.python.org

and mark it as "Windows" in the [Components] field (that makes sure that
some relevant people get to see it). It's got a much better chance of
achieving traction if you can actually provide a code patch to implement
the behaviour. Failing that, at least make a good case which might
convince one of the developers that it would it be worth their while
implementing the change.


I have tried to register with the link above so I can an issue with the
Python Issue tracker but all attempts fail with:

"Failed issue tracker submission

An unexpected error occurred during the processing
of your message. The tracker administrator is being
notified."


Hmmm. Thanks for making the effort -- and for reporting back. I've just
successfully registered a (dummy) account there, so it's possible that
there was a temporary glitch.

If you wouldn't mind trying once more, that would be helpful. If not, I
can create the issue on your behalf, and inform the tracker admins.


I tried again only to run into the exact same problem. I don't know what 
it means that I am not being allowed to register for the Python bug 
tracker. Needless to say the obscure error message is not telling me 
anything. Of course as a programmer who uses Python I would like to find 
out why I am not able to register. But in the meantime if you could 
create the issue on my behalf it would be appreciated. Thanks !


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


Re: Python launcher options

2016-01-10 Thread Edward Diener

On 1/10/2016 6:38 AM, Tim Golden wrote:



On 10/01/2016 05:18, Edward Diener wrote:

On 1/9/2016 11:03 AM, Tim Golden wrote:

On 06/01/2016 00:48, Edward Diener wrote:

The Python launcher in Windows is a neat tool for running multiple
versions of Python 2 and Python 3 at different times. It allows as
options the ability to specify the latest version of either Python 2 or
Python 3 defaulting to the 64-bit version if both exist, or a specific
32-bit or 64-bit version of Python 2 or Python 3. What is missing is
the
ability to specify the latest 32-bit version of Python 2 or Python 3.
The equivalent syntax would be '-2-32' or '-3-32'. Is there some reason
why this option has been disallowed ?


As far as I can remember, it's not so much a question of "disallowed" as
just "not thought of by anyone". If you wanted this to go anywhere,
could I suggest you create an issue on the Python issue tracker:

   http://bugs.python.org

and mark it as "Windows" in the [Components] field (that makes sure that
some relevant people get to see it). It's got a much better chance of
achieving traction if you can actually provide a code patch to implement
the behaviour. Failing that, at least make a good case which might
convince one of the developers that it would it be worth their while
implementing the change.


I have tried to register with the link above so I can an issue with the
Python Issue tracker but all attempts fail with:

"Failed issue tracker submission

An unexpected error occurred during the processing
of your message. The tracker administrator is being
notified."


Hmmm. Thanks for making the effort -- and for reporting back. I've just
successfully registered a (dummy) account there, so it's possible that
there was a temporary glitch.

If you wouldn't mind trying once more, that would be helpful. If not, I
can create the issue on your behalf, and inform the tracker admins.


I was finally able to register so I will report this issue on the Python 
issue tracker myself.

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


Help with exscript with Cisco asa

2014-12-07 Thread Edward Manning
I am trying to login to enable mode on a Cisco ASA with this script. I can’t 
seem to get the enable mode to work. Can anyone help. Does anyone know of a 
good doc for exscript lib.

Thank you 

Ed








from Exscript.util.start import quickstart
from Exscript.util.file  import get_hosts_from_file
from Exscript.protocols.drivers import ios


def do_something(job, host, conn):


 conn.send("enable\r")
 get_password_prompt(self)
 print conn.response


#conn.execute('sh run | i  ipv6-address-pool')
#print conn.response




hosts = get_hosts_from_file('myhosts.txt','ssh')
quickstart(hosts, do_something,max_threads = 4 )



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


gethostbyaddr()

2014-07-28 Thread Edward Manning
I wrote this code, but it seem to work fine if I only have one ip in the file. 
When I have more than one IP in the file 
I get a error. Does anyone have an idea why.


import socket
 
 
def main():
 
# get file names
infileName = input ("What file our the IP adderss in?  ")
outfileName = input("What file should the results go in?")
 
# open files
infile = open(infileName, "r")
outfile = open(outfileName, "w")
 
 
#Proccess each line of the input file
 
for line in infile:
ipAddress = line.strip()
resluts = socket.gethostbyaddr(ipAddress)
print(resluts[0],resluts[2], end="")-- 
https://mail.python.org/mailman/listinfo/python-list


Re: gethostbyaddr()

2014-07-28 Thread Edward Manning
Chris 

Thank you for the info.  I figure it out. But thank you again.

Ed 
> On Jul 28, 2014, at 5:42 PM, Chris Kaynor  wrote:
> 
> On Mon, Jul 28, 2014 at 2:33 PM, Edward Manning  wrote:
> I wrote this code, but it seem to work fine if I only have one ip in the 
> file. When I have more than one IP in the file 
> I get a error. Does anyone have an idea why.
> 
> It would be helpful to know what the error you are getting is. It is also a 
> good idea to generally provide the Python version and OS version with your 
> messages, as they can often make a major difference. As it is, I've made my 
> best guess below (in bold), I've also included some other notes that may 
> cause issues, but I doubt are causing your error.
>  
> import socket
>  
>  
> def main():
>  
> # get file names
> infileName = input ("What file our the IP adderss in?  ")
> outfileName = input("What file should the results go in?")
>  
> # open files
> infile = open(infileName, "r")
> outfile = open(outfileName, "w")
> 
> While this shouldn't cause the issue your reporting (without other issues 
> going on), Its generally a better idea to use the with statement to open 
> file, like so:
> with open(infileName, "r") as infile:
> # code that needs infile goes here.
> 
> This will ensure that the file is closed when you are done with it, even if 
> an error occurs in the code that may prevent the code from running to 
> completion.
>  
>  
>  
> #Proccess each line of the input file
>  
> for line in infile:
> ipAddress = line.strip()
> 
> I'm guessing that, when you only have one IP, you do not have a trailing 
> new-line in the file, but when you put more than one in the file, you have a 
> trailing new-line. You can try adding:
> 
> if not ipAddress:
> continue
> 
> here to ignore any empty lines (due to the line.strip() above, it will also 
> ignore all white-space lines) you might get. This may be the cause of your 
> error...
>  
> resluts = socket.gethostbyaddr(ipAddress)
> print(resluts[0],resluts[2], end="")
> 
> Note that this does not seem to be printing into outfile (its printing to 
> stdout instead). I presume this is for debugging purposes.
>  
> --
> https://mail.python.org/mailman/listinfo/python-list

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


Controlling py.exe launcher on Windows

2014-08-05 Thread Edward Diener
I am trying to control the default version of the py.exe launcher on 
Windows. I have the Python 2.7.8 and 3.4.1 installed with both the 32 
bit and 64 bit versions, all in different directories. I assume that .py 
and .pyw files are associated with the py.exe launcher.


I am trying to control which version starts through a py.ini file in the 
same directory as the py.exe file in the 3.4.1 version last installed.


If I specify in the [defaults] section of py.ini:

python=3.4

then launching py.exe will show:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 
bit (AM

D64)] on win32

If I specify:

python=3.4-32

then launching py.exe will show:

Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit 
(AMD64)] on win

32

Is it really true that I cannot specify the 32 bit version in the .ini 
file or am I doing something wrong here ?






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


Python 3.4.1 install does not create a file association for .py files on Windows

2014-08-05 Thread Edward Diener

I install Python 3.4.1 64-bit on Windows. After the install I type:

assoc .py

and I get back:

File association not found for extension .py

Why does not the Python install to associate extension .py with the 
Python Launcher for Windows ?

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


Re: Python 3.4.1 install does not create a file association for .py files on Windows

2014-08-05 Thread Edward Diener

On 8/5/2014 6:16 PM, Terry Reedy wrote:

On 8/5/2014 3:36 PM, Edward Diener wrote:

I install Python 3.4.1 64-bit on Windows. After the install I type:


I have done the same, on Win 7, but I had previous installs going back 3
years on this machine.


assoc .py

and I get back:

File association not found for extension .py


I get
C:\Users\Terry>assoc .py
.py=Python.File

C:\Users\Terry>assoc .pyw
.pyw=Python.NoConFile

C:\Users\Terry>assoc .pyo
.pyo=Python.CompiledFile

C:\Users\Terry>assoc .pyc
.pyc=Python.CompiledFile

None of this specifies the program, which is currently Python Launcher
for Windows (console).  (See Control Panel / Default Programs / Set
Associations.)


Why does not the Python install to associate extension .py with the
Python Launcher for Windows ?


Somewhere during the install, there is a checkbox or something about
grabbing file associations or about making the install the default
version. I do not remember.



I uninstalled all my Python versions and then re-installed each one. Now 
the correct file association has been made. Something was fouled up in 
the installation process which is now fixed.

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


Re: Controlling py.exe launcher on Windows

2014-08-05 Thread Edward Diener

On 8/5/2014 1:27 PM, Edward Diener wrote:

I am trying to control the default version of the py.exe launcher on
Windows. I have the Python 2.7.8 and 3.4.1 installed with both the 32
bit and 64 bit versions, all in different directories. I assume that .py
and .pyw files are associated with the py.exe launcher.

I am trying to control which version starts through a py.ini file in the
same directory as the py.exe file in the 3.4.1 version last installed.

If I specify in the [defaults] section of py.ini:

python=3.4

then launching py.exe will show:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64
bit (AM
D64)] on win32

If I specify:

python=3.4-32

then launching py.exe will show:

Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit
(AMD64)] on win
32

Is it really true that I cannot specify the 32 bit version in the .ini
file or am I doing something wrong here ?


After uninstalling my Python versions and re-installing them, everything 
works properly and I can control the version which py.exe starts from 
the py.ini file.


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


Hands on Documentation for Python methods and Library

2006-10-04 Thread Wijaya Edward

Hi,
 
One can do the following with Perl
 
$ perldoc -f chomp
$ perldoc -f function_name
 
or 
 
$ perldoc List::MoreUtils
$ perldoc Some::Module 
 
Can we do the same thing in Python?
 
-- Edward
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Initialization of variables using no-arg constructor

2006-10-09 Thread Edward Waugh
Consider the following (working) Python code:

import sys

def sum(list):
# total = 0 does not work for non-numeric types
total = list[0].__class__()
for v in list:
total += v
return total

l = [1, 2, 3]
print sum(l)

l = [1.1, 2.2, 3.3]
print sum(l)

l = ["a", "b", "c"]
print sum(l)

In order for sum() to be generic I initialize total to the value of 
list[0].__class__().  This works but I would like to know if this is the 
correct or preferred way of doing it.  It means that sum() must be given a 
list whose elements are types or classes that have a no-arg constructor 
(through this is probably almost always the case).

Thanks,
Edward


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


Click and Drag Functionality in Web Apps with Python

2006-10-12 Thread Wijaya Edward

Hi,
 
Some recent webapps like Kiko <http://www.kiko.com/> , Google's gadget 
<http://www.google.com/ig/directory?hl=en> , and spreadsheets 
<http://spreadsheets.google.com>  to name a few, 
have this functionality. 

I wonder how can this funcitonalities be implemented in Python. 
Do you guys have any experience with it?
Any Python module that support that?
 
Regards,
Edward WIJAYA
SINGAPOE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Python Best Practice References

2006-10-13 Thread Wijaya Edward

Can anybody suggest any references (links, books, etc)about this?
I'm thinking of something similar with D.Conway's "Perl Best Practice".
 
-- Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Loops Control with Python

2006-10-13 Thread Wijaya Edward

Can we make loops control in Python?
What I mean is that whether we can control
which loops to exit/skip at the given scope.
 
For example in Perl we can do something like:
 
OUT:
foreach my $s1 ( 0 ...100) {
   
IN:
foreach my $s2 (@array) {

  if ($s1 == $s2) {
 next OUT;
  }
  else {
  last IN; 
  } 
 
 }
}
 
How can we implement that construct with Python?
 
-- 
Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Where to find pydoc?

2006-10-16 Thread Wijaya Edward

I tried to call pydoc from my Linux box.
To my realization that it doesn't contain
pydoc.
 
I thought this module should be a default module.
 
Can anybody suggest where can I find the module?
I tried:
 
$ easy_install pydoc
Searching for pydoc
Reading http://sqlobject.org/ <http://sqlobject.org/> 
Reading http://peak.telecommunity.com/dist <http://peak.telecommunity.com/dist> 
Reading http://www.python.org/pypi/pydoc/ <http://www.python.org/pypi/pydoc/> 
Couldn't find index page for 'pydoc' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://www.python.org/pypi/ <http://www.python.org/pypi/> 
No local packages or download links found for pydoc
error: Could not find suitable distribution for Requirement.parse('pydoc')

 
Hope to hear from you again.
 
Regards,
Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


RE: Where to find pydoc?

2006-10-16 Thread Wijaya Edward

Hi,
Thanks for the reply.
 
Red Hat Linux Enterprise:
Linux host.com 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 i686 
i386 GNU/Linux

 
Python 2.3.4.
 
Any problem with that?
 
--- Edward



From: [EMAIL PROTECTED] on behalf of Marc 'BlackJack' Rintsch
Sent: Mon 10/16/2006 5:00 PM
To: [email protected]
Subject: Re: Where to find pydoc?



In <[EMAIL PROTECTED]>, Wijaya Edward
wrote:

>
> I tried to call pydoc from my Linux box.
> To my realization that it doesn't contain
> pydoc.
> 
> I thought this module should be a default module.

Yes it is part of the standard library.  What distribution are you using?

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list



 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


RE: Where to find pydoc?

2006-10-18 Thread Wijaya Edward

Hi,
Can you be specific on which URLs can I find "python-tools".
Cause I tried the one under easy_install, I still can't find it.
 
Thanks and hope to hear from you again.
 
-- Edward WIJAYA
SINGAPORE



From: [EMAIL PROTECTED] on behalf of Fredrik Lundh
Sent: Mon 10/16/2006 5:08 PM
To: [email protected]
Subject: Re: Where to find pydoc?




look for "python-tools" or a similar package in your favourite package
repository.



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



 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Auto Completion for Python in VIM editor

2006-10-23 Thread Wijaya Edward

Dear all,

Perl and C/C++  have perl-support.vim and c.vim by Fritz Mehner
that support a very convenient auto completion shortcut in visual mode 
(e.g \aw for While construct).

Does anybody know if such a comprehensive scripts
also exist for Python?

python.vim doesn't seem to suppor this kind
of autocompletion.

 
Regards,
Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Problem Commenting within Filehandle Iteration

2006-10-26 Thread Wijaya Edward

Hi all,
 
I have the following code:
 
 
import sys   
import re

ham_count = 0
spam_count = 0
myfile = open('full/index')
for line in myfile.readlines():
p = re.compile('ham')
m = p.match(line)
if m:
print line,
else:
#print 'SPAM -- %s' % line
myfile.close()

Sometime while developing/debugging the code we usually 
put in such situation. Where expression under "else"
is not yet supplied, yet we would like see the printout of the
previous "if" condition. 
 
Notice that I wanted to comment out the #print line there.
However I found problem with myfile.close(), with identation error.
This error doesn't occur when commenting (#) is not in use.
 
Why so?  Is there away to do the commenting in correct way
under this circumstances?
 
-- 
Edward WIJAYA
SINGAPORE
 
 

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Printing Hidden Character in Python

2006-10-26 Thread Wijaya Edward

Hi,
 
How can we print out the hidden character like
"\n", "\r" etc in Python?
 
-- Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


RE: Printing Hidden Character in Python

2006-10-26 Thread Wijaya Edward

Ben,
 
I mean while opening a file, like this

for line in open('somefile.txt'):
print line

printing "line" will not show the hidden chars like "\n","\r".
Is there  a way to print it out?
 
-- Edward WIJAYA
SINGAPORE



From: [EMAIL PROTECTED] on behalf of Ben Finney
Sent: Thu 10/26/2006 4:59 PM
To: [email protected]
Subject: Re: Printing Hidden Character in Python



Wijaya Edward <[EMAIL PROTECTED]> writes:

> How can we print out the hidden character like "\n", "\r" etc in
> Python?

What result do you want that you're not getting with:

print "\n"

--
 \  "Two rules to success in life: 1. Don't tell people everything |
  `\ you know."  -- Sassan Tat |
_o__)  |
Ben Finney

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



 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Insert Content of a File into a Variable

2006-10-26 Thread Wijaya Edward

Hi,
 
How can we slurp all content of a single file 
into one variable?
 
I tried this:
 
>>> myfile_content = open('somefile.txt')
>>> print myfile_content,

>>> 

 
But it doesn't print the content of the file.
 
Regards,
-- Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


How to Split Chinese Character with backslash representation?

2006-10-26 Thread Wijaya Edward

Hi all,

I was trying to split a string that 
represent chinese characters below:
 
 
>>> str = '\xc5\xeb\xc7\xd5\xbc'
>>> print str2,
???
>>> fields2 = split(r'\\',str)
>>> print fields2,
['\xc5\xeb\xc7\xd5\xbc']

But why the split function here doesn't seem
to do the job for obtaining the desired result:
 
['\xc5','\xeb','\xc7','\xd5','\xbc']
 
 
 
Regards,
-- Edward WIJAYA
SINGAPORE



 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


RE: How to Split Chinese Character with backslash representation?

2006-10-26 Thread Wijaya Edward

Thanks but my intention is to strictly use regex.
Since there are separator I need to include as delimiter
Especially for the case like this:

>>> str = '\xc5\xeb\xc7\xd5\xbc--FOO--BAR'
>>> field = list(str)
>>> print field
['\xc5', '\xeb', '\xc7', '\xd5', '\xbc', '-', '-', 'F', 'O', 'O', '-', '-', 
'B', 'A', 'R']

What we want as the output is this instead:
['\xc5', '\xeb', '\xc7', '\xd5', '\xbc','FOO','BAR]

What's the best way to do it?

-- Edward WIJAYA
SINGAPORE



From: [EMAIL PROTECTED] on behalf of Cameron Walsh
Sent: Fri 10/27/2006 12:03 PM
To: [email protected]
Subject: Re: How to Split Chinese Character with backslash representation?



Wijaya Edward wrote:
> Hi all,
>
> I was trying to split a string that
> represent chinese characters below:
>
>
>>>> str = '\xc5\xeb\xc7\xd5\xbc'
>>>> print str2,
> ???
>>>> fields2 = split(r'\\',str)
>>>> print fields2,
> ['\xc5\xeb\xc7\xd5\xbc']
>
> But why the split function here doesn't seem
> to do the job for obtaining the desired result:
>
> ['\xc5','\xeb','\xc7','\xd5','\xbc']
>

Depends on what you want to do with them:

 >>> string = '\xc5\xeb\xc7\xd5\xbc'
 >>> for char in string:
 print char


Å
ë
Ç
Õ
¼
 >>> list_of_characters = list(string)
 >>> list_of_characters
['\xc5', '\xeb', '\xc7', '\xd5', '\xbc']
 >>> for char in string:
 char


'\xc5'
'\xeb'
'\xc7'
'\xd5'
'\xbc'
 >>> for char in list_of_characters:
 print char


Å
ë
Ç
Õ
¼
 >>> string[3]
'\xd5'
 >>> string[1:3]
'\xeb\xc7'

Basically, you characters are already separated into a list of
characters, that's effectively what a string is (but with a few more
methods applicable only to lists of characters, not to other lists).
--
http://mail.python.org/mailman/listinfo/python-list



 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Slurping All Content of a File into a Variable

2006-10-26 Thread Wijaya Edward

Hi,
 
How can we slurp content of a single file 
into one variable?
 
I tried this:
 
>>> myfile_content = open('somefile.txt')
>>> print myfile_content,

>>> 

But it doesn't print the content of the file.
 
Regards,
-- Edward WIJAYA
SINGAPORE
 

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


RE: Slurping All Content of a File into a Variable

2006-10-26 Thread Wijaya Edward

 



From: [EMAIL PROTECTED] on behalf of Wijaya Edward
Sent: Thu 10/26/2006 11:47 PM
To: [email protected]
Subject: Slurping All Content of a File into a Variable




Hi,

How can we slurp content of a single file
into one variable?

I tried this:

>>> myfile_content = open('somefile.txt')
>>> print myfile_content,

>>>

But it doesn't print the content of the file.

Regards,
-- Edward WIJAYA
SINGAPORE


 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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



 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Matching Pure Numeric and '' with Python re

2006-10-27 Thread Wijaya Edward

Hi,
 
Given this list:
 
list = ['0123', '1A34' , '333-' , '' ]
 
I want to match only this element 
'0123' (pure numeric) and '' (empty element).
 
Why this construct doesn't work?
 
 p = re.compile("''+|[0-9]+")
   m = p.match(word)
   if m:
 print word,
 
Namely it doesn't print 0123 and ''.
What's wrong with my regex?
 
-- Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Re: send an email with picture/rich text format in the body

2006-05-29 Thread Edward Elliott
Ten wrote:

> Sorry for the rant, good luck to the guy if he's solved his problem,
> but damn, that "90% so let's not bother doing things properly" stuff makes
> my blood boil.

You must really hate browsing the web then. :)

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding a lost PYTHONPATH with find

2006-05-29 Thread Edward Elliott
John J. Lee wrote:

> find / -maxdepth 3 -size -100k -type f -exec grep -sli pythonpath '{}' \;
> 
> 
> The minus in '-100k' (meaning "less than 100k") seems to be
> undocumented, at least on my system.  

It should be standard in linux man pages, can't speak for other unices:

   TESTS
   Numeric arguments can be specified as

   +n for greater than n,

   -n for less than n,

   n  for exactly n.

Maybe you were fooled because it's not directly under the description of
-size.


> I suppose the -maxdepth is 
> redundant since I think find searches breadth-first by default.

??? maxdepth determines how deep the search will look, not the order the
search occurs.  Your search only find things within 3 levels of the root,
unless your directory tree goes no deeper than that (very unlikely) the
maxdepth can't be redundant.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTMLParser chokes on bad end tag in comment

2006-05-29 Thread Edward Elliott
Fredrik Lundh wrote:

>> Should it? The end tag it chokes on is in comment, isn't it?
> 
> no.  STYLE and SCRIPT elements contain character data, not parsed
> character data, so comments are treated as characters, and the first
> "http://www.w3.org/TR/html4/appendix/notes.html#notes-specifying-data

Element content 

When script or style data is the content of an element (SCRIPT and STYLE),
the data begins immediately after the element start tag and ends at the
first ETAGO ("") before the SCRIPT end tag:


  document.write ("<EM>This won't work</EM>")


In JavaScript, this code can be expressed legally by hiding the ETAGO
delimiter before an SGML name start character:


  document.write ("<EM>This will work<\/EM>")



Guess you learn something new every day.  Too bad there's so much illegal
code in the wild. :(

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ricerca Programmatore Python

2006-05-29 Thread Edward Elliott
Scott David Daniels wrote:

> I understand there is an Italian-language Python group, but _here_
> the language is English, even if you begin by an apology in English.
> ... In consideration for such people, please limit yourself to English.

I doubt he'll ever see your reprimand, looks like a hit-and-run job.  Too
bad we can't force non-English posts through Babelfish first.  At the very
least, we'll get a good laugh out of it:

Blank to all, 
I write in order to inform you of one proposed of collaboration. I am trying
a programmatore for the realization of a minium-software useful in order to
analyze and to represent multigrafi. An optimal competence is demanded in
uses of Python with the relati to you packages of mathematical
rappresentazione (es. matplotlib). For the notion of grafo it is referred
to the following pages: http://it.wikipedia.org/wiki/Teoria_dei_grafi
(Italian). http://en.wikipedia.org/wiki/Graph_theory (English). The
residence in province of Milan, sight of a possible encounter is
preferibile. Draft of one retribuita external collaboration. The interested
ones can directly contact to the present deliveries in tail to the email,
sending the relative resume to me. I hope of to have made what appreciate
postando this announcement. In contrary case, I make excuses myself for the
disturbance.
Salutes, 
Giandomenico Sica 

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need C# Coding for MD5 Algorithm...

2006-05-29 Thread Edward Elliott
Dennis Lee Bieber wrote:

> As for the algorithm... http://www.faqs.org/rfcs/rfc1321.html
> 
> Implement per that spec. It even includes a C-language
> implementation that you might be able to bastardize into C#

Please don't.  Crypto algorithms are hard enough to implement correctly as
it is.  Leave it to the experts and use a library.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Howto pass Array/Hash into Function

2006-10-03 Thread Wijaya Edward

Hi,
 
How can I pass Array, Hash, and a plain variable
in to a function at the same time.
 
I come from Perl. Where as you probably know
it is done like this:
 
sub myfunc {
 
my ($plain_var, $hash_ref,$arref) = @_;
# Do sth with those variables
 
   return;
}
 
I wonder how can that be done in Python.
 
Regards,
Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


RE: Howto pass Array/Hash into Function

2006-10-03 Thread Wijaya Edward

Thanks for your understanding Steve.
 
Furthermore, my related concern
is how does Python actually  deal with 'reference' in Perl.
But now, it is clear to me now that Python simply 
treats them as object.
 
Regards,
Edward WIJAYA
SINGAPORE



From: [EMAIL PROTECTED] on behalf of Steve Holden
Sent: Tue 10/3/2006 8:08 PM
To: [email protected]
Subject: Re: Howto pass Array/Hash into Function




It wouldn't be obvious to someone who learned Perl as their first
programming language because Perl chose to ignore the otherwise almost
universal convention that formal parameters determine the arguments that
a function or procedure can be calles with.

regards
  Steve




 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Benchmarking Python's subroutines/function

2006-10-03 Thread Wijaya Edward

Hi,
 
How does one benchmark
multiple subroutines in Python?
Is there a built-in library for that?
 
--
Regards,
Edward WIJAYA
SINGAPORE

 Institute For Infocomm Research - Disclaimer -
This email is confidential and may be privileged.  If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.

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


Re: list1.append(list2) returns None

2006-12-20 Thread Edward Kozlowski

Pyenos wrote:
> def enlargetable(table,col):
> return table.append(col)
>
> def removecolfromtable(table,col):
> return table.remove(col)
>
> print enlargetable([[1],[2],[3]],[4]) # returns None
>
> Why does it return None instead of [[1],[2],[3],[4]] which I expected?

return the table.  Ex:

def enlargetable(table, col):
table.append(col)
return table

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


Re: failing to instantiate an inner class because of order of inner classes

2006-12-27 Thread Edward Kozlowski
Pyenos wrote:
> class model:pass
> class view:
> model()
> class controller:
> model()
>
> I can instantiate clsss model from inside class view but I can't
> instantiate class model from inside controller, due to the nature of
> python interpreter.
>
> I wish to circumvent this restriction by:
>
> class model:pass
> class view:
> parent_class.model()
> class controller:
> parent_class.model()
>
> but, I don't know the built-in variable that points to the parent
> class. Could someone tell me how can I instantiate class model from
> inside controller AND instantiate class model from inside view?

I would try the following:

class model:
def printFoo(self):
print "foo"
class view:
def __init__(self):
self.model = model()
class controller:
def __init__(self):
self.model = model()

Then you can do:
vObj = view()
vObj.model.printFoo()

And:
cObj = controller()
cObj.model.printFoo()

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


Number Format function

2006-02-08 Thread Edward Hartfield
I'm am relatively new to Python but use it daily.  Today, I went looking 
for a function, like PHP's number_function, that will take a number and 
return a string with number formatted with grouped thousands and the 
decimal portion rounded to a given number of places.  This is certainly 
needed when you want to take a floating-point value from a database and 
display it as currency, for instance.  I could not find what I was 
looking for so I wrote the following function.  I hope either (a) I've 
provided something useful or (b) someone can tell me what I *should* 
have done!  Thanks.


import math

def number_format(num, places=0):
   """Format a number with grouped thousands and given decimal places"""

   #is_negative = (num < 0)
   #if is_negative:
   #num = -num

   places = max(0,places)
   tmp = "%.*f" % (places, num)
   point = tmp.find(".")
   integer = (point == -1) and tmp or tmp[:point]
   decimal = (point != -1) and tmp[point:] or ""

   count = commas = 0
   formatted = []
   for i in range(len(integer) - 1, 0, -1):
   count += 1
   formatted.append(integer[i])
   if count % 3 == 0:
   formatted.append(",")

   integer = "".join(formatted[::-1])
   return integer+decimal
begin:vcard
fn:Edward Hartfield
n:Hartfield;Edward
org:BungeeCraft Technologies
adr;dom:;;4824 W Medford Avenue;Milwaukee;Wisconsin;53216
email;internet:[EMAIL PROTECTED]
title:President
tel;work:414 839-2387
tel;fax:414 449-9105
note:Milwaukee-based BungeeCraft Technologies provides cost-effective technology solutions for small and mid-sized businesses. From aligning our clients' business and IT strategies to improving business processes and deploying and supporting solutions that accelerate business results, we are able and ready to provide YOU with comprehensive information technology solutions and services.
x-mozilla-html:FALSE
url:http://www.bungeecraft.com
version:2.1
end:vcard

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

Re: Number Format function

2006-02-08 Thread Edward Hartfield
Thanks.  I noticed the bugs later.  But after talking with my boss, he 
suggested something more elegant (again *untested*, yet):


import locale

def number_format(num, places=0)
   """Format a number according to locality and given places"""
   locale.setlocale(locale.LC_ALL, locale.getdefaultlocale()[0])
   return locale.format("%.*f", (places, num), 1)

[EMAIL PROTECTED] wrote:

Your code has a little bug, I highly recommend to add a test to your
code, for an idea see below - I fixed your code as well.

#!/usr/bin/env python
import math

def number_format(num, places=0):
"""Format a number with grouped thousands and given decimal
places"""
#is_negative = (num < 0)
#if is_negative:
#num = -num

places = max(0,places)
tmp = "%.*f" % (places, num)
point = tmp.find(".")
integer = (point == -1) and tmp or tmp[:point]
decimal = (point != -1) and tmp[point:] or ""

count = commas = 0
formatted = []
for i in range(len(integer) - 1, 0, -1):
count += 1
formatted.append(integer[i])
if count % 3 == 0:
formatted.append(",")
formatted.append(integer[0]) # this misses in your part
integer = "".join(formatted[::-1])
return integer+decimal


#
# add something like this: it helps to prevent you break your code
#
import unittest

class test_number_format(unittest.TestCase):
def test(self):
self.assertEqual(number_format(100, 2), '1,000,000.00')
self.assertEqual(number_format(10, 2), '100,000.00')
self.assertEqual(number_format(100, 2), '100.00')
self.assertEqual(number_format(100.33, 2), '1,000,000.33')
self.assertEqual(number_format(100.333, 2), '1,000,000.33')
self.assertEqual(number_format(100.3, 2), '1,000,000.30')
self.assertEqual(number_format(123456, 2), '123,456.00')
self.assertEqual(number_format(12345, 2), '12,345.00')
self.assertEqual(number_format(123, 2), '123.00')
self.assertEqual(number_format(123456.33, 2), '123,456.33')
self.assertEqual(number_format(12345.333, 2), '12,345.33')
self.assertEqual(number_format(123.3, 2), '123.30')

suite = unittest.makeSuite(test_number_format)
unittest.TextTestRunner(verbosity=2).run(suite)

  
begin:vcard
fn:Edward Hartfield
n:Hartfield;Edward
org:BungeeCraft Technologies
adr;dom:;;4824 W Medford Avenue;Milwaukee;Wisconsin;53216
email;internet:[EMAIL PROTECTED]
title:President
tel;work:414 839-2387
tel;fax:414 449-9105
note:Milwaukee-based BungeeCraft Technologies provides cost-effective technology solutions for small and mid-sized businesses. From aligning our clients' business and IT strategies to improving business processes and deploying and supporting solutions that accelerate business results, we are able and ready to provide YOU with comprehensive information technology solutions and services.
x-mozilla-html:FALSE
url:http://www.bungeecraft.com
version:2.1
end:vcard

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

unicode question

2006-02-24 Thread Edward Loper
I would like to convert an 8-bit string (i.e., a str) into unicode,
treating chars \x00-\x7f as ascii, and converting any chars \x80-xff
into a backslashed escape sequences.  I.e., I want something like this:

 >>> decode_with_backslashreplace('abc \xff\xe8 def')
u'abc \\xff\\xe8 def'

The best I could come up with was:

   def decode_with_backslashreplace(s):
   "str -> unicode"
   return (s.decode('latin1')
.encode('ascii', 'backslashreplace')
.decode('ascii'))

Surely there's a better way than converting back and forth 3 times?  Is
there a reason that the 'backslashreplace' error mode can't be used with 
codecs.decode?

 >>> 'abc \xff\xe8 def'.decode('ascii', 'backslashreplace')
Traceback (most recent call last):
   File "", line 1, in ?
TypeError: don't know how to handle UnicodeDecodeError in error callback

-Edward

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


Re: unicode question

2006-02-27 Thread Edward Loper
Walter Dörwald wrote:
> Edward Loper wrote:
> 
>> [...]
>> Surely there's a better way than converting back and forth 3 times?  Is
>> there a reason that the 'backslashreplace' error mode can't be used 
>> with codecs.decode?
>>
>>  >>> 'abc \xff\xe8 def'.decode('ascii', 'backslashreplace')
>> Traceback (most recent call last):
>>File "", line 1, in ?
>> TypeError: don't know how to handle UnicodeDecodeError in error callback
> 
> The backslashreplace error handler is an *error* *handler*, i.e. it 
> gives you a replacement text if an input character can't be encoded. But 
> a backslash character in an 8bit string is no error, so it won't get 
> replaced on decoding.

I'm not sure I follow exactly -- the input string I gave as an example 
did not contain any backslash characters.  Unless by "backslash 
character" you mean a character c such that ord(c)>127.  I guess it 
depends on which class of errors you think the error handler should be 
handling. :)  The codec system's pretty complex, so I'm willing to 
accept on faith that there may be a good reason to have error handlers 
only make replacements in the encode direction, and not in the decode 
direction.

> What you want is a different codec (try e.g. "string-escape" or 
> "unicode-escape").

This is very close, but unfortunately won't quite work for my purposes, 
because it also puts backslashes before "'" and "\\" and maybe a few 
other characters.  :-/

 >>> print "test: '\xff'".encode('string-escape').decode('ascii')
test: \'\xff\'

 >>> print do_what_i_want("test:\xff'")
test: '\xff'

I think I'll just have to stick with rolling my own.

-Edward

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


Getting the home directory in Python and a bug in os.path.expanduser

2007-07-06 Thread Edward Diener
What is the generic operating system way of getting the home directory ?

I am guessing it is os.path.expanduser("~"). Is there a better way or an 
alternate way ?

If it is as I surmise, the aforementioned expanduser("~") of os.path 
seems incorrect to me under Windows. The document says:

"On Windows, only "~" is supported; it is replaced by the environment 
variable HOME or by a combination of HOMEDRIVE and HOMEPATH."

But HOME is never the home directory for Windows, only the combination 
of HOMEDRIVE and HOMEPATH is valid, which is always set. If MSYS is 
installed under Windows, where HOME must be set to the MSYS home 
directory for a given user in order to emulate Linux/Unix, attempting to 
use os.path.expanduser("~") will incorrectly return the MSYS home 
directory for a given user rather than the Windows home directory for 
the logged in user. So I think the os.path.expanduser("~") works 
incorrectly in this case and needs to be fixed, else you are telling 
users never to use MSYS under Windows.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting the home directory in Python and a bug in os.path.expanduser

2007-07-07 Thread Edward Diener
Josiah Carlson wrote:
> Edward Diener wrote:
>> What is the generic operating system way of getting the home directory ?
>>
>> I am guessing it is os.path.expanduser("~"). Is there a better way or 
>> an alternate way ?
>>
>> If it is as I surmise, the aforementioned expanduser("~") of os.path 
>> seems incorrect to me under Windows. The document says:
>>
>> "On Windows, only "~" is supported; it is replaced by the environment 
>> variable HOME or by a combination of HOMEDRIVE and HOMEPATH."
>>
>> But HOME is never the home directory for Windows, only the combination 
>> of HOMEDRIVE and HOMEPATH is valid, which is always set. If MSYS is 
>> installed under Windows, where HOME must be set to the MSYS home 
>> directory for a given user in order to emulate Linux/Unix, attempting 
>> to use os.path.expanduser("~") will incorrectly return the MSYS home 
>> directory for a given user rather than the Windows home directory for 
>> the logged in user. So I think the os.path.expanduser("~") works 
>> incorrectly in this case and needs to be fixed, else you are telling 
>> users never to use MSYS under Windows.
> 
> Some people have "sane" values for HOME on Windows.

And some people use Linux/Unix emulation software on Windows where HOME 
has nothing to do with the Windows home directory, but everything to do 
with the emulation's notion of a "home" directory. In fact Microsoft may 
well have anticipated this by automatically generating HOMEDRIVE and 
HOMEPATH based on the user's home directory when he logs on.

>  That's the only 
> reason why it was included in expanduser().  The current trunk version 
> of ntpath offers HOME, USERPROFILE or HOMEDRIVE+HOMEPATH, as well as the 
> expansion of ~/extra/stuff .

There is no problem checking the other values but on Windows 
HOMEDRIVE+HOMEPATH should always be first, USERPROFILE should be second 
if either HOMEDRIVE or HOMEPATH does not exist ( which is extremely 
unlikely), and finally HOME should only be used if the others fail. I 
will even go for USERPROFILE coming before the check for HOMEDRIVE and 
HOMEPATH, although I think it is wrong because the notion of a "home" 
directory on Windows may not stay tied to a user profile ( in fact they 
may be already different on Vista, which I do not have, for all I know 
). But at least USERPROFILE is generated by Windows, like HOMEDRIVE and 
HOMEPARTH.

Using HOME as the first option on Windows is definitely wrong, 
especially for the reason I pointed out, that Linux/Unix emulation 
systems on Windows have the user set HOME to the emulation's "home" 
directory, and that is definitely not the Windows "home" directory. HOME 
is of course perfectly viable in the Linux/Unix world.

Probably most reliable on Windows is a Windows API function, if it 
exists, for getting the home directory, as opposed to using environment 
variables, but I can not find any Windows API for it at present.

> 
> If you would like to get rid of Python's support of HOME, please post a 
> bug report or feature request on the sourceforge tracker.

I realized I could post a bug report after I posted my OP, so I 
subsequently posted a bug report on the sourceforge tracker. I do not 
need a new feature, but only to have the current feature, which is 
expanduser, work correctly on Windows. It is currently a serious problem 
for Window's users, who have Linux/Unix emulation software on their 
syetem, running a Python script which correctly uses expanduser to get 
the Windows home directory and ends up with the wrong location.

Thank you for responding. I hope Python will fix this problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-07-07 Thread Edward Dodge
Twisted <[EMAIL PROTECTED]> writes:

> Besides, ANY interface that involves fumbling around in the dark
> trying to find a light switch is clunky. You should be able to see
> what the hell you're doing and navigate easily. Applications that not
> only eschew normal methods of navigation of the interface, but force
> you to fumble your way between the help and the task you're trying to
> do, are definitely clunky. An analogy to a genuine emacs experience:
> you enter a workshop with some raw materials and tools. Unfortunately
> there's no big ceiling lights so you can just flip the switch by the
> door and then always be able to see where everything is. Instead
> there's little lights here and there by various specific tools and
> storage areas, and in one area a map of the place with switches to
> control the lights.

So -- what magical computer app illuminates the entire room and shows
you how to use everything at the flip of a switch?  This brilliant
discovery would put Sam's, O'Reilly, the for-Dummies series, and
virtually every other computer book publisher out of business in weeks.
Naturally, this would include the publishers of books on "easy-to-use"
Microsoft products.

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


Re: Getting the home directory in Python and a bug in os.path.expanduser

2007-07-07 Thread Edward Diener
Neil Hodgson wrote:
> Edward Diener:
> 
>> Probably most reliable on Windows is a Windows API function, if it 
>> exists, for getting the home directory, as opposed to using 
>> environment variables, but I can not find any Windows API for it at 
>> present.
> 
>Look at SHGetFolderPath(CSIDL_PROFILE, ...) for Windows Me/2000 or 
> later. CSIDL_APPDATA is probably a better idea than CSIDL_PROFILE (its 
> equivalent to "%USERPROFILE%\Application Data" and roams) but 
> %USERPROFILE% (CSIDL_PROFILE) is compatible with previous Python behaviour.
> http://msdn2.microsoft.com/en-us/library/ms647764.aspx

Thanks, that looks good. For Windows Vista one should evidently use 
SHGetKnownFolderPath(FOLDERID_Profile,...) instead.

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


Re: Emacs + python

2007-08-01 Thread Edward O'Connor
> Could anyone put me on the right track to developing Python with emacs
> please : modes to consider, debugging etc hopefully all within emacs.

Personally, I prefer the python.el that ships with Emacs 22 to the
python-mode.el from python.org. It seems more like other Emacs major
modes.


Ted

-- 
Edward O'Connor
[EMAIL PROTECTED]

Ense petit placidam sub libertate quietem.

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


re: mmm-mode, python-mode and doctest-mode?

2007-08-07 Thread Edward Loper
[John J Lee]
> Is it possible to get doctest-mode to work with mmm-mode and python-mode 
> nicely so that docstrings containing doctests are editable in 
> doctest-mode?

I recently released a new version of doctest-mode [1], and I came across 
your email [2] (it was on the first page of google hits for 
"doctest-mode").  So I decided to have a go at getting doctest-mode to 
play nicely with mmm-mode.  The result is available here:

https://python-mode.svn.sf.net/svnroot/python-mode/trunk/python-mode/doctest-mode.el

I still consider it alpha code (the version that's available for 
download on the official doctest-mode webpage [3] doesn't include the 
mmm-mode features), but it works pretty well for me.  If you want to 
give it a spin, let me know what you think.  The following should load 
everything you need:

(autoload 'doctest-mode "doctest-mode" "doctest mode" t)
(autoload 'doctest-register-mmm-classes "doctest-mode")
(doctest-register-mmm-classes t t)

It defines 2 classes.  Quoting from the docstring for doctest-register- 
mmm-classes:

> `doctest-docstring'
> 
> Used to edit docstrings containing doctest examples in python-
> mode.  Docstring submode regions start and end with triple-quoted
> strings (\"\"\").  In order to avoid confusing start-string
> markers and end-string markers, all triple-quote strings in the
> buffer are treated as submode regions (even if they're not
> actually docstrings).  Use (C-c % C-d) to insert a new doctest-
> docstring region.  When `doctest-execute' (C-c C-c) is called
> inside a doctest-docstring region, it executes just the current
> docstring.  The globals for this execution are constructed by
> importing the current buffer's contents in Python.
> 
> `doctest-example'
> 
> Used to edit doctest examples in text-editing modes, such as
> `rst-mode' or `text-mode'.  Docstring submode regions start with
> optionally indented prompts (>>>) and end with blank lines.  Use
> (C-c % C-e) to insert a new doctest-example region.  When
> `doctest-execute' (C-c C-c) is called inside a doctest-example
> region, it executes all examples in the buffer.

Take care,
-Edward

[1] doctest-mode 0.4 announcement:
 
http://mail.python.org/pipermail/python-announce-list/2007-August/006038.html

[2] email re mmm-mode:
 http://mail.python.org/pipermail/python-list/2005-November/354482.html

[3] doctest-mode homepage:
 http://www.cis.upenn.edu/~edloper/projects/doctestmode/

[4] doctest-mode walkthrough:
 http://tinyurl.com/25bljc

[5] doctest-mode subversion:
 
https://python-mode.svn.sf.net/svnroot/python-mode/trunk/python-mode/doctest-mode.el


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


Python FNV Hash

2007-08-07 Thread Edward Blake
Before I go through the work of wrapping the FNV hash source found on
http://isthe.com/chongo/tech/comp/fnv/ I thought I would ask here to see if
anyone already has an implementation of it available. I'm particularly
interested in hash_64, the 64 bit Fowler/Noll/Vo-0 FNV-1a hash code.
-- 
http://mail.python.org/mailman/listinfo/python-list

mmm-mode, python-mode and doctest-mode?

2007-08-08 Thread Edward Loper
> Anyone testing on xemacs?  I tried it, and C-c C-c sent xemacs into an
> infinite loop (apparantly).

It works fine for me in XEmacs 21.4 (patch 17) (i386-debian-linux, 
Mule).  If you could answer a few questions, it might help me track down 
the problem:

- What version of xemacs are you running?
- What version of doctest-mode are you running (0.4 or 0.5)?
- Are you using doctest-mode by itself, or in combination with another
   mode (via mmm-mode)?
- Does pressing control-g (possibly repeatedly) cause it to become
   unstuck?
- Does it always freeze when you hit C-c C-c?  Or does it depend on the
   contents of the buffer?  Does it freeze if you run it in an empty
   buffer?

You could try changing the value of doctest-python-command, to see if 
that helps -- "M-x customize-variable doctest-python-command".  Set it 
to the full path to a Python interpreter.

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


Re: mmm-mode, python-mode and doctest-mode?

2007-08-09 Thread Edward Loper
Edward Loper wrote:
>> Anyone testing on xemacs?  I tried it, and C-c C-c sent xemacs into an
>> infinite loop (apparantly).

I may have tracked down the cause of this problem.  Please download the 
most recent version, and try again.  And when you do, let me know 
whether that fixed it. :)

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


Re: simple question on dictionary usage

2007-10-26 Thread Edward Kozlowski
On Oct 26, 11:29 pm, Frank Stutzman <[EMAIL PROTECTED]>
wrote:
> My apologies in advance, I'm new to python
>
> Say, I have a dictionary that looks like this:
>
> record={'BAT': '14.4', 'USD': '24', 'DIF': '45', 'OAT': '16',
> 'FF': '3.9', 'C3': '343', 'E4': '1157', 'C1': '339',
> 'E6': '1182', 'RPM': '996', 'C6': '311', 'C5': '300',
> 'C4': '349', 'CLD': '0', 'E5': '1148', 'C2': '329',
> 'MAP': '15', 'OIL': '167', 'HP': '19', 'E1': '1137',
> 'MARK': '', 'E3': '1163', 'TIME': '15:43:54',
> 'E2': '1169'}
>
> From this dictionary I would like to create another dictionary calld
> 'egt') that has all of the keys that start with the letter 'E'.  In
> otherwords it should look like this:
>
> egt = {'E6': '1182','E1': '1137','E4': '1157','E5': '1148',
>'E2': '1169','E3': '1163'}
>
> This should be pretty easy, but somehow with all my googling I've
> not found a hint.
>
> Thanks in advance
>
> --
> Frank Stutzman

I think this should do the trick.  There's probably something more
concise than this, but I can't think of it at the moment.

egt = {}
for key in record:
if key.startswith('E'):
egt[key] = record[key]

print egt
{'E5': '1148', 'E4': '1157', 'E6': '1182', 'E1': '1137', 'E3': '1163',
'E2': '1169'}


-Edward Kozlowski

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


Epydoc 3.0 beta release

2007-02-26 Thread Edward Loper
Epydoc 3.0 beta is now available for download from SourceForge.
Epydoc is a tool for generating API documentation for Python modules,
based on their docstrings.

   - The epydoc homepage.
 

   - Download epydoc 3.0 beta.
 

For some examples of the documentation generated by epydoc, see:

   - The API documentation for epydoc.
 

   - The API documentation for the Python 2.5 standard library.
 

   - The API documentation for NLTK, the natural language toolkit.
 

The most significant change since Epydoc 2.1 has to do with the way
that epydoc extracts documentation information about python modules.
In previous versions, epydoc extracted information about each module
by importing it, and using introspection to examine its contents.  The
new version of epydoc still supports introspection, but is also
capable of extracting information about python modules by parsing
their source code.  Furthermore, the new version of epydoc can combine
these two sources of information (introspection & parsing).  This is
important because each source has its own advantages and disadvantages
with respect to the other.  For information about the new features in
epydoc 3.0, see the "What's New" page:

 

If you find any bugs, or have suggestions for improving epydoc, please
report them on sourceforge:

   - Bugs: 
   - Features: 

Or send email to <[EMAIL PROTECTED]>.

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


Re: SimpleXMLRPCServer interruptable?

2007-12-05 Thread Edward Kozlowski
On Dec 5, 6:22 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Wed, 05 Dec 2007 18:20:35 -0300, Bret <[EMAIL PROTECTED]> escribió:
>
> > I just tried changing this so that I now have a threading.Event()
> > called self.done, which is set within the body of the shutdown()
> > method.  The serverWrapper loop now looks like this:
>
> > def serverWrapper():
> > while True:
> > server.handle_request()
> > if self.done.isSet():
> > break
>
> > This works, but only if I follow the shutdown() rpc call a few seconds
> > later with ... something else to cause handle_request() to complete
> > again.  Obviously, not quite the right approach
>
> You could try setting a reasonable timeout on the listening socket; I
> would override the server_bind method, calling self.socket.settimeout(xxx)
> before calling the inherited method. I've never actually done it with a
> SimpleXMLRPCServer, but *should* work. Don't use a very small timeout,
> because it affects *all* subsequent operations.
>
> --
> Gabriel Genellina

Try this:

def __init__(self, host, port):
self.done = False
server = SimpleXMLRPCServer((host, port))
:
: Bunch of server.register_function calls
:
def serverWrapper():
try:
while not self.done:
server.handle_request()
except:
pass

Your shutdown method becomes:

def shutdown(self):
self.done = True

HTH

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


Re: SimpleXMLRPCServer interruptable?

2007-12-05 Thread Edward Kozlowski
On Dec 5, 10:19 pm, Edward Kozlowski <[EMAIL PROTECTED]> wrote:
> On Dec 5, 6:22 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
>
>
> > En Wed, 05 Dec 2007 18:20:35 -0300, Bret <[EMAIL PROTECTED]> escribió:
>
> > > I just tried changing this so that I now have a threading.Event()
> > > called self.done, which is set within the body of the shutdown()
> > > method.  The serverWrapper loop now looks like this:
>
> > > def serverWrapper():
> > > while True:
> > > server.handle_request()
> > > if self.done.isSet():
> > > break
>
> > > This works, but only if I follow the shutdown() rpc call a few seconds
> > > later with ... something else to cause handle_request() to complete
> > > again.  Obviously, not quite the right approach
>
> > You could try setting a reasonable timeout on the listening socket; I
> > would override the server_bind method, calling self.socket.settimeout(xxx)
> > before calling the inherited method. I've never actually done it with a
> > SimpleXMLRPCServer, but *should* work. Don't use a very small timeout,
> > because it affects *all* subsequent operations.
>
> > --
> > Gabriel Genellina
>
> Try this:
>
> def __init__(self, host, port):
> self.done = False
> server = SimpleXMLRPCServer((host, port))
> :
> : Bunch of server.register_function calls
> :
> def serverWrapper():
> try:
> while not self.done:
> server.handle_request()
> except:
> pass
>
> Your shutdown method becomes:
>
> def shutdown(self):
> self.done = True
>
> HTH
>
> -Edward Kozlowski

Sorry about the first post, I shot from the hip and had to make a few
more modifications to make it 'working' code.  The example below works
fine for me.

import SimpleXMLRPCServer

class myServer:
def __init__(self, host, port):
self.done = False
self.server = SimpleXMLRPCServer.SimpleXMLRPCServer((host,
port))

def shutdown(self):
self.done = True
return 0

def getName(self):
return "Hey, I'm Ed"

def serverWrapper(self):
self.server.register_function(self.getName)
self.server.register_function(self.shutdown)
try:
while not self.done:
self.server.handle_request()
except:
pass


if __name__ == "__main__":
myServer('localhost', 6058).serverWrapper()


>>> s.getName()
"Hey, I'm Ed"
>>> s.shutdown()
0

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


Re: Uniquifying a list?

2006-04-18 Thread Edward Elliott
You could do

 >>> uniq = [x for x in set(myList)]

but that's not really any different than what you already have.

This almost works:

 >>> uniq = [x for x in myList if x not in uniq]

except the r-val uniq isn't updated after each iteration.

Personally I think list(set(myList)) is as optimal as you'll get.


Tim Chase wrote:
> Is there an obvious/pythonic way to remove duplicates from a list 
> (resulting order doesn't matter, or can be sorted postfacto)?  My 
> first-pass hack was something of the form
> 
>  >>> myList = [3,1,4,1,5,9,2,6,5,3,5]
>  >>> uniq = dict([k,None for k in myList).keys()
> 
> or alternatively
> 
>  >>> uniq = list(set(myList))
> 
> However, it seems like there's a fair bit of overhead here...creating a 
> dictionary just to extract its keys, or creating a set, just to convert 
> it back to a list.  It feels like there's something obvious I'm missing 
> here, but I can't put my finger on it.
> 
> Thanks...
> 
> -tkc
> 
> 
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


multiline comments

2006-04-18 Thread Edward Elliott
At the risk of flogging a dead horse, I'm wondering why Python doesn't have 
any multiline comments.  One can abuse triple-quotes for that purpose, but 
that's obviously not what it's for and doesn't nest properly.  ML has a 
very elegant system for nested comments with (* and *).

Using an editor to throw #s in front of every line has limitations.  Your 
editor has to support it and you have to know how to use that feature.  Not 
exactly intuitive or easy for novices to pick up.  Also a pain if your 
preferred editor is python/perl/sh-agnostic.

Saying coders shouldn't use multiline comments to disable code misses the 
point.  Coders will comment out code regardless of the existence of 
multiline comemnts.  There has to be a better argument for leaving them out.

Keeping the language small and simple is desirable, but it's not an 
absolute.  A little syntactic sugar like 'for x in s' makes code easier to 
read than 'for i in len(s): x = s[i]'.  So what are the tradeoffs involved 
with nested multiline comments?  I'd like to understand the reasoning 
behind keeping them out.
-- 
http://mail.python.org/mailman/listinfo/python-list


temporary scope change

2006-04-18 Thread Edward Elliott
The only time I miss block delimiters in Python is when I want to 
temporarily change the scope of a block.  Suppose I have this code:

for x in list1:
 i += 1
 for y in list2:
 print x * i

Ignore the semantics for the moment (yes the code is suboptimal).  Say I 
need to disable the for y loop for a moment, but I want to keep the print 
statement.  I'd like to just do this

for x in list1:
 i += 1
#   for y in list2:
 print x * i

and have the print line execute as part of the for x block.  In other 
words, I want the block with print to be in the scope of the for x loop. 
But instead it raises a SyntaxError because the indentation is different.

Changing the indentation here isn't a big deal, but imagine the block 
inside y is very long.  Imagine you're disabling several blocks or multiple 
levels of nested blocks at one time.  It quickly becomes a thorny issue. 
Using a debugger to disable it at run-time doesn't always help either.

This seems a common enough problem that I suspect there's a python way to 
handle it.  I don't see a good way without resorting to block delimiters 
though, so I'm asking here for ideas.

Apologies if this has been covered before.  I did some searches of the 
python docs and newsgroup archives but couldn't find anything relevant 
(which may say more about my searching abilities than anything else).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: temporary scope change

2006-04-18 Thread Edward Elliott
Michael Spencer wrote:
> Just replace:
> for y in list2:
> with:
> if True:

Of course.  I knew it would be blindingly obvious.  Sometimes you just 
can't shake the blinders off though.  Thanks.

> Note that neither the `if` nor the `for` statement actually creates a 
> new scope.

Good catch.  I'm used to thinking block = scope.  Old habits die hard I guess.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiline comments

2006-04-18 Thread Edward Elliott
Atanas Banov wrote:
> want to comment block of code? use tripple-quotes. does not nest? ahhh,
> maybe it's time to get rid of that block you commented out a month ago
> "just in case the new code doesnt work".
> 
> that gives you incentive to tidy up. don't be a code slob... don't
> leave a mess forever ;-)

And when the section I want to comment out contains a legit doc string in 
the middle, triple-quotes won't work.  There are valid reasons to nest 
comments which have nothing to do with laziness or sloppy code.

Forcing programmers to write clean code with syntax is like teaching a pig 
to sing: it wastes your time and annoys the pig.  Good coding is a state of 
mind, not a parser option.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiline comments

2006-04-18 Thread Edward Elliott
Ben Finney wrote:
> And/or switch to an editor that can perform editing operations on a
> range of lines.

I'm not unsympathetic to this point of view, as I would feel hamstrung 
without my vim.  It's more that I object to the paternalism of telling 
people they have to use such an editor.  There are times when notepad is 
all that's available.

On top of that, the expressive power of nested comments seems greater than 
an endless string of ^#s.  Sometimes it's just easier to see what's going on.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiline comments

2006-04-18 Thread Edward Elliott
Ben Finney wrote:
> Indeed. Using revision control means never needing to comment out
> blocks of code.

Typing (* and *) on a few line will always be quicker, easier, and less 
confusing than any rcs diffs/restores.  Once you delete the code you can no 
longer see it or add pieces back in without retrieving it from an external 
store.  I'm not saying nested comments solve every problem, just that there 
exists a certain (perhaps small) class of problems they solve particularly 
well.

Personally, I rarely leave code commented out beyond a single coding 
session.  But my particular coding habits aren't relevant here.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   >