Re: Egos, heartlessness, and limitations

2011-04-15 Thread Steven D'Aprano
On Fri, 15 Apr 2011 13:55:58 +1000, Ben Finney wrote:

> Steven D'Aprano  writes:
> 
>> Save yourself a lot of time and just killfile him now. You'll thank me
>> for it later.
> 
> You never thanked *me* for it, after you eventually realised that was
> the right decision :-)

It's not "later" enough yet :-P


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


Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico  writes:
That loop will exit at the first gap in the sequence.  If that's what
you want, you could try (untested):

   from itertools import takewhile

   seq = takewhile(lambda n: ('Keyword%d'%n) in dct, count(1))
   lst = map(dct.get, seq)

This does 2 lookups per key, which you could avoid by making the code
uglier (untested):

   sentinel = object()
   seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1))
   lst = list(takewhile(lambda x: x != sentinel, seq))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-15 Thread Chris Angelico
On Fri, Apr 15, 2011 at 5:24 PM, Paul Rubin  wrote:
> This does 2 lookups per key, which you could avoid by making the code
> uglier (untested):
>
>   sentinel = object()
>   seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1))
>   lst = list(takewhile(lambda x: x != sentinel, seq))

If I understand this code correctly, that's creating generators,
right? It won't evaluate past the sentinel at all?

That might well be what I'm looking for. A bit ugly, but efficient and
compact. And I can bury some of the ugliness away.

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


Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico  writes:
>>   sentinel = object()
>>   seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1))
>>   lst = list(takewhile(lambda x: x != sentinel, seq))
>
> If I understand this code correctly, that's creating generators,
> right? It won't evaluate past the sentinel at all?

Right, it should stop after hitting the sentinel once.

> That might well be what I'm looking for. A bit ugly, but efficient and
> compact. And I can bury some of the ugliness away.

It occurs to me, operator.ne might be a little faster than the
interpreted lambda.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: memory usage multi value hash

2011-04-15 Thread Algis Kabaila
On Friday 15 April 2011 02:13:51 christian wrote:
> Hello,
> 
> i'm not very experienced in python. Is there a way doing
> below more memory efficient and maybe faster.
> I import a  2-column file and  then concat for every unique
> value in the first column ( key) the value from the second
> columns.
> 
> So The ouptut is something like that.
> A,1,2,3
> B,3,4
> C,9,10,11,12,90,34,322,21
> 
> 
> Thanks for advance & regards,
> Christian
> 
> 
> import csv
> import random
> import sys
> from itertools import groupby
> from operator import itemgetter
> 
> f=csv.reader(open(sys.argv[1]),delimiter=';')
> z=[[i[0],i[1]] for i in f]
> z.sort(key=itemgetter(0))
> mydict = dict((k,','.join(map(itemgetter(1), it)))
>for k, it in groupby(z, itemgetter(0)))
> del(z)
> 
> f = open(sys.argv[2], 'w')
> for k,v in mydict.iteritems():
> f.write(v + "\n")
> 
> f.close()
Two alternative solutions - the second one with generators is 
probably the  most economical as far as RAM usage is concerned.

For  you example data1.txt is taken as follows:
A, 1
B, 3
C, 9
A, 2
B, 4
C, 10
A, 3
C, 11
C, 12
C, 90
C, 34
C, 322
C, 21

The "two in one" program is:
#!/usr/bin python
'''generate.py - Example of reading long two column csv list and
sorting. Thread "memory usage multi value hash"
'''

# Determine a set of unique column 1 values
unique_set = set()
with open('data1.txt') as f:
for line in f:
unique_set.add(line.split(',')[0])
print(unique_set)
with open('data1.txt') as f:
for x in unique_set:
ls = [line.split(',')[1].rstrip() for line in f if 
line.split(',')[0].rstrip() == x]
print(x.rstrip(), ','.join(ls))
f.seek(0)

print ('\n Alternative solution with generators')
with open('data1.txt') as f:
for x in unique_set:
gs = (line.split(',')[1].rstrip() for line in f if 
line.split(',')[0].rstrip() == x)
s = ''
for ds in gs:
s = s + ds
print(x.rstrip(), s)
f.seek(0)

The output is:
{'A', 'C', 'B'}
A  1, 2, 3
C  9, 10, 11, 12, 90, 34, 322, 21
B  3, 4

 Alternative solution with generators
A  1 2 3
C  9 10 11 12 90 34 322 21
B  3 4

Notice that data sequence could be different, without any effect 
on output.

OldAl.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-15 Thread Peter Otten
Paul Rubin wrote:

> Chris Angelico  writes:
>>> sentinel = object()
>>> seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1))
>>> lst = list(takewhile(lambda x: x != sentinel, seq))
>>
>> If I understand this code correctly, that's creating generators,
>> right? It won't evaluate past the sentinel at all?
> 
> Right, it should stop after hitting the sentinel once.
> 
>> That might well be what I'm looking for. A bit ugly, but efficient and
>> compact. And I can bury some of the ugliness away.
> 
> It occurs to me, operator.ne might be a little faster than the
> interpreted lambda.

Or operator.is_not as you are dealing with a singleton. You also need 
functools.partial:

$ python -m timeit -s'sentinel = object(); predicate = lambda x: x != 
sentinel' 'predicate(None)'
100 loops, best of 3: 0.369 usec per loop

$ python -m timeit -s'sentinel = object(); predicate = lambda x: x is not 
sentinel' 'predicate(None)'
100 loops, best of 3: 0.314 usec per loop

$ python -m timeit -s'from functools import partial; from operator import 
ne; sentinel = object(); predicate = partial(ne, sentinel)' 
'predicate(None)'
100 loops, best of 3: 0.298 usec per loop

$ python -m timeit -s'from functools import partial; from operator import 
is_not; sentinel = object(); predicate = partial(is_not, sentinel)' 
'predicate(None)'
100 loops, best of 3: 0.252 usec per loop



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


Re: memory usage multi value hash

2011-04-15 Thread Peter Otten
Terry Reedy wrote:

> On 4/14/2011 12:55 PM, Peter Otten wrote:
> 
>> I don't expect that it matters much, but you don't need to sort your data
>> if you use a dictionary anyway:
> 
> Which means that one can build the dict line by line, as each is read,
> instead of reading the entire file into memory. So it does matter for
> intermediate memory use.

Yes, sorry, that was a bit too much handwaving.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-15 Thread Peter Otten
Chris Angelico wrote:

> Apologies for interrupting the vital off-topic discussion, but I have
> a real Python question to ask.
> 
> I'm doing something that needs to scan a dictionary for elements that
> have a particular beginning and a numeric tail, and turn them into a
> single list with some processing. I have a function parse_kwdlist()
> which takes a string (the dictionary's value) and returns the content
> I want out of it, so I'm wondering what the most efficient and
> Pythonic way to do this is.
> 
> My first draft looks something like this. The input dictionary is
> called dct, the output list is lst.
> 
> lst=[]
> for i in xrange(1,1000): # arbitrary top, don't like this
>   try:
> lst.append(parse_kwdlist(dct["Keyword%d"%i]))
>   except KeyError:
> break
> 
> I'm wondering two things. One, is there a way to make an xrange object
> and leave the top off? (Sounds like I'm risking the numbers
> evaporating or something.) And two, can the entire thing be turned
> into a list comprehension or something? Generally any construct with a
> for loop that appends to a list is begging to become a list comp, but
> I can't see how to do that when the input comes from a dictionary.
> 
> In the words of Adam Savage: "Am I about to feel really, really stupid?"
> 
> Thanks in advance for help... even if it is just "hey you idiot, you
> forgot about X"!

The initial data structure seems less than ideal. You might be able to 
replace it with a dictionary like

{"Keyword": [value_for_keyword_1, value_for_keyword_2, ...]}

if you try hard enough.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-15 Thread Chris Angelico
On Fri, Apr 15, 2011 at 6:25 PM, Peter Otten <__pete...@web.de> wrote:
> The initial data structure seems less than ideal. You might be able to
> replace it with a dictionary like
>
> {"Keyword": [value_for_keyword_1, value_for_keyword_2, ...]}
>
> if you try hard enough.

The initial data structure comes from a CSV file, and is not under my control.

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


PYTHONPATH

2011-04-15 Thread Algis Kabaila
Hi,

An elementary question that is bugging me, regarding sys.path 
values.sys.path can be altered easily, but the changes last for 
the current session only. I would like the changes to stay for 
several sessions.  Is PYTHONPATH a system variable that sets the 
path for several sessions and if so, where in the system is it?  
Do I need to create one for setting python path for several 
sessions?

Your answers will be greatly appreciated!

TIA,
OldAl.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TextWrangler "run" command not working properly

2011-04-15 Thread Fabio
In article 
<382709dd-5e3f-4b07-a642-4ce141ef4...@18g2000prd.googlegroups.com>,
 Jon Clements  wrote:

> http://www.velocityreviews.com/forums/t570137-textwrangler-and-new-python-vers
> ion-mac.html

Thank you for the reply Jon.
I saw the post in velocityreviews. Unfortunately it doesn't solve my 
problem.

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


Can you advice a Python library to query a lan subnet with SNMP and collect MAC addresses of nodes?

2011-04-15 Thread Aldo Ceccarelli
Hello All,
in my specific problem I will be happy of a response where possible
to:

1. distinguish different operating systems of answering nodes
2. collect responses of Wyse thin-clients with "Thin OS" to get node
name and MAC address in particular

Thanks a lot in advance for any sharing / forward to documentation,
products in the area.

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


Re: PYTHONPATH

2011-04-15 Thread Chris Rebert
On Fri, Apr 15, 2011 at 1:33 AM, Algis Kabaila  wrote:
> Hi,
>
> An elementary question that is bugging me, regarding sys.path
> values.sys.path can be altered easily, but the changes last for
> the current session only. I would like the changes to stay for
> several sessions.  Is PYTHONPATH a system variable that sets the
> path for several sessions and if so, where in the system is it?

It is an environment variable:
http://en.wikipedia.org/wiki/Environment_variable

Alternatively, you can use a .pth file to add directories to the
module search path:
http://docs.python.org/library/site.html

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Free software versus software idea patents

2011-04-15 Thread Dan Stromberg
On Thu, Apr 14, 2011 at 1:46 PM, Westley Martínez  wrote:
> On Thu, 2011-04-14 at 14:02 +, Steven D'Aprano wrote:
>> On Thu, 14 Apr 2011 19:15:05 +1000, Chris Angelico wrote:
>>
>> > 4) Assumes people aren't deliberately fiddling the figures. Yeah, that
>> > would be correct. We're in the realm of conspiracy theories here... does
>> > anyone seriously think that browser stats are THAT important that they'd
>> > go to multiple web servers with deceitful hits?
>>
>> Back in the day, not that many years ago, when it looked like Internet
>> Explorer would never dip below 90% market share and web developers coded
>> for IE quirks instead of standards as a matter of course, I used to
>> fantasize of writing a Windows virus that (apart from propagating) did
>> nothing but change the user-agent string on IE. It would have been
>> awesome to witness the consternation among web developers.
>>
>> But thanks to the EU doing what the US DOJ refused to do, and the grass-
>> roots popularity of Firefox (plus a fewer well-known even if not often
>> used browsers like Safari and Opera), and then Google's scarily efficient
>> way they can capture hearts and minds on the Internet, IE's market share
>> has been whittled away to the point that there are places in the world
>> where IE is a minority browser. A large minority, it is true, but still a
>> minority.
>>
>> Now, if only we could convince web users that having your browser execute
>> untrusted code downloaded from the Internet is not such a good idea,
>> supposed sandbox or not. What the world needs is a virus that silently
>> removes Javascript and Flash from browsers...
>>
>>
>>
>> --
>> Steven
>
> Web developers will always use the tool they find to be the most
> reliable, efficient, and useful, as will consumers.

You're kidding.

Web developers will usually use what they believe will reach users,
without excessive pain or embarrassment - and sometimes with.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-15 Thread Peter Otten
Chris Angelico wrote:

> On Fri, Apr 15, 2011 at 6:25 PM, Peter Otten <__pete...@web.de> wrote:
>> The initial data structure seems less than ideal. You might be able to
>> replace it with a dictionary like
>>
>> {"Keyword": [value_for_keyword_1, value_for_keyword_2, ...]}
>>
>> if you try hard enough.
> 
> The initial data structure comes from a CSV file, and is not under my
> control.
> 
> ChrisA

Here's some code that might give you an idea. You can ignore the chunk 
before 'import csv'; it is there to make the demo self-contained.

from contextlib import contextmanager

@contextmanager
def open(filename):
assert filename == "example.csv"
from StringIO import StringIO
yield StringIO("""\
beta3,alpha1,alpha2,beta1,beta2
b31,a11,a21,b11,b21
b32,a12,a22,b12,b22
b33,a13,a23,b13,b23
b34,a14,a24,b14,b24
""")

import csv
import re

def parse_name(s):
name, index = re.match(r"(.+?)(\d+)$", s).groups()
return name, int(index)-1

with open("example.csv") as instream:
rows = csv.reader(instream)
header = next(rows)
dct = {}
appends = []
for h in header:
name, index = parse_name(h)
outer = dct.setdefault(name, {})
inner = outer.setdefault(index, [])
appends.append(inner.append)
for row in rows:
for value, append in zip(row, appends):
append(value)
print dct

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


Re: PYTHONPATH

2011-04-15 Thread Gabriel Genellina
En Fri, 15 Apr 2011 05:33:18 -0300, Algis Kabaila   
escribió:



An elementary question that is bugging me, regarding sys.path
values.sys.path can be altered easily, but the changes last for
the current session only. I would like the changes to stay for
several sessions.  Is PYTHONPATH a system variable that sets the
path for several sessions and if so, where in the system is it?
Do I need to create one for setting python path for several
sessions?


PYTHONPATH is an environment variable, you set it the same way as any  
other, the details depend on the operating system/shell you're currently  
using.


But - why do you think you need to set PYTHONPATH? Don't do that. Use the  
standard places to put your library modules and packages, like  
site-packages (where third-party libraries are installed by default). From  
Python 2.6+ the search path includes per-user directories like  
~/.local/lib/python2.6/site-packages and  
%APPDATA%\Python\Python26\site-packages (see PEP370 [1] for details) so  
you don't even have to mess with the Python installation directories.



[1] http://www.python.org/dev/peps/pep-0370/

--
Gabriel Genellina

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


Re: Can you advice a Python library to query a lan subnet with SNMP and collect MAC addresses of nodes?

2011-04-15 Thread frankcui

On 04/15/2011 05:00 PM, Aldo Ceccarelli wrote:

Hello All,
in my specific problem I will be happy of a response where possible
to:

1. distinguish different operating systems of answering nodes
2. collect responses of Wyse thin-clients with "Thin OS" to get node
name and MAC address in particular

Thanks a lot in advance for any sharing / forward to documentation,
products in the area.

KR Aldo
I think for your interest, if what you described is not a part of your 
software you are doing but only a specific task, you could use some 
network scanning tools like nmap to achieve your goals.


there is also a module called pysnmp and you can look into it to see if 
it meets your need.


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


Re: PYTHONPATH

2011-04-15 Thread Algis Kabaila
On Friday 15 April 2011 19:21:12 Chris Rebert wrote:
> On Fri, Apr 15, 2011 at 1:33 AM, Algis Kabaila 
 wrote:
> > Hi,
> > 
>>snip..
> It is an environment variable:
> http://en.wikipedia.org/wiki/Environment_variable
> 
> Alternatively, you can use a .pth file to add directories to
> the module search path:
> http://docs.python.org/library/site.html
> 
> Cheers,
> Chris

From Gabriel Genellina:
> 
> escribió:
> > An elementary question that is bugging me, regarding
> 
> PYTHONPATH is an environment variable, you set it the same
> way as any other, the details depend on the operating
> system/shell you're currently using.
> 
> But - why do you think you need to set PYTHONPATH? Don't do
> that. Use the standard places to put your library modules
> and packages, like site-packages (where third-party
> libraries are installed by default). From Python 2.6+ the
> search path includes per-user directories like
> ~/.local/lib/python2.6/site-packages and
> %APPDATA%\Python\Python26\site-packages (see PEP370 [1] for
> details) so you don't even have to mess with the Python
> installation directories.
> 
> 
> [1] http://www.python.org/dev/peps/pep-0370/

Thank you Gabriel and Thank you Chris, for your valuable advice 
and equally valuable set of references.  Greatly appreciated!  

To answer the question of why consider a local "sandbox" to test 
various versions of a set of programs downloaded from the net.  
It is very handy to be able to change the "standard" behaviour 
to a localised "users standard".  Even more important, of 
course, is to know what standards there are.

Thank you for your prompt and valuable assistance,
OldAl.


-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can you advice a Python library to query a lan subnet with SNMP and collect MAC addresses of nodes?

2011-04-15 Thread Aldo Ceccarelli
On 15 Apr, 11:54, frankcui  wrote:
> On 04/15/2011 05:00 PM, Aldo Ceccarelli wrote:> Hello All,
> > in my specific problem I will be happy of a response where possible
> > to:
>
> > 1. distinguish different operating systems of answering nodes
> > 2. collect responses of Wyse thin-clients with "Thin OS" to get node
> > name and MAC address in particular
>
> > Thanks a lot in advance for any sharing / forward to documentation,
> > products in the area.
>
> > KR Aldo
>
> I think for your interest, if what you described is not a part of your
> software you are doing but only a specific task, you could use some
> network scanning tools like nmap to achieve your goals.
>
> there is also a module called pysnmp and you can look into it to see if
> it meets your need.
>
> frank

Thanks Frank! I've browsed pysnmp as you kindly adviced, now looking
also into http://pynetsnmp.sourceforge.net/
KR Aldo
-- 
http://mail.python.org/mailman/listinfo/python-list


http://DuplicateFilesDeleter.com - This software deletes duplicate files in media collection of any type

2011-04-15 Thread Max Loger
http://DuplicateFilesDeleter.com - find duplicates

http://DuplicateFilesDeleter.com is an innovative tool that can
recognize duplicate audio files even if they are stored in different
file formats and not marked with ID3 tags.

It will find fast all similar or exact duplicate audio files in a
folder and its sub folders.

Unlike common duplicate file finders it will actually "listen" to your
music and can recognize a song even if it is saved in different file
formats.

Supports MP3, MP2, MP1, MPA, WAV, OGG, AIFF, AAC, MP4, FLAC, AC3,
WavPack (WV), Musepack (MPC) and Windows Media Audio (WMA) file
formats, has an intuitive user interface and is well documented.

http://DuplicateFilesDeleter.com - find duplicates
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TextWrangler "run" command not working properly

2011-04-15 Thread Brian Blais
Hello Fabio You have two versions of 2.6 on your system.  

On Apr 15, 2011, at 4:51 AM, Fabio wrote:
> I have the "built-in" Python2.5 which comes installed by "mother Apple".


My OSX comes with 2.3, 2.5, and 2.6.  :)  These are under:

/System/Library/Frameworks/Python.framework/Versions/
^

the ones you installed are under:

/Library/Frameworks/Python.framework/Versions/

I can reproduce this problem on my system, because /usr/bin/python2.6 points to 
the system version.  There is an easy solution:

#!/usr/bin/env python

will work, or, 

#!/usr/local/bin/python

it's better to use the former, as it will work even as you change versions, 
etc...  You should avoid using the shebang with a *specific* python version.  
just use #!/usr/bin/env python



bb


-- 
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/



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


Re: Pythonic infinite for loop?

2011-04-15 Thread Steven D'Aprano
On Fri, 15 Apr 2011 18:32:23 +1000, Chris Angelico wrote:

> On Fri, Apr 15, 2011 at 6:25 PM, Peter Otten <__pete...@web.de> wrote:
>> The initial data structure seems less than ideal. You might be able to
>> replace it with a dictionary like
>>
>> {"Keyword": [value_for_keyword_1, value_for_keyword_2, ...]}
>>
>> if you try hard enough.
> 
> The initial data structure comes from a CSV file, and is not under my
> control.

There's no reason to duplicate the CSV file's design in your own data 
structures though.


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


Re: Pythonic infinite for loop?

2011-04-15 Thread Steven D'Aprano
On Fri, 15 Apr 2011 13:58:22 +1000, Chris Angelico wrote:

> The dictionary is potentially a lot larger than this particular set of
> values (it's a mapping of header:value for a row of a user-provided CSV
> file). Does this make a difference to the best option? (Currently I'm
> looking at "likely" figures of 60+ keys in the dictionary and 3-8
> postage options to pick up, but both of those could increase
> significantly before production.)

SIXTY keys?

When you get to sixty thousand keys, it might take a few seconds to 
process.


> Efficiency is important, though not king; this whole code will be inside
> a loop. But readability is important too.
> 
> I can't just give all of dct.values() to parse_kwdlist; the function
> parses a particular format of text string, and it's entirely possible
> that other values would match that format (some of them are pure
> free-form text). This has to get only the ones starting with Keyword,
> and in order. Steven, the line you suggested:
> 
> lst = [parse_kwdlist(dct["Keyword%d"%i]) for i in xrange(1, len(dct)+1)]
> 
> will bomb with KeyError when it hits the first one that isn't present, I
> assume. Is there an easy way to say "and when you reach any exception,
> not just StopIteration, return the list"? (I could wrap the whole "lst =
> " in a try/except, but then it won't set lst at all.)

No. 

You could use the list comprehension form at the cost of running over the 
dict twice:

maxkey = 0
for key in dct:
if key.startswith("Keyword"):
maxkey = max(maxkey, int(key[7:]))
lst = [parse_kwdlist(dct["Keyword%d"%i]) for i in xrange(1, maxkey+1)]


but quite frankly, at this point I'd say, forget the one-liner, do it the 
old-fashioned way with a loop. Or change your data structure: often you 
can simplify a task drastically just by changing the way you store the 
data.




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


Re: Pythonic infinite for loop?

2011-04-15 Thread Roy Smith
In article <4da83f8f$0$29986$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> for key in dct:
> if key.startswith("Keyword"):
> maxkey = max(maxkey, int(key[7:]))

I would make that a little easier to read, and less prone to "Did I 
count correctly?" bugs with something like:

prefix = "Keyword"
n = len(prefix)
for key in dct:
name, value = key[:n], key[n:]
if name == prefix:
maxkey = max(maxkey, int(value))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-15 Thread Ethan Furman

Chris Angelico wrote:

lst=[]
for i in xrange(1,1000): # arbitrary top, don't like this
  try:
lst.append(parse_kwdlist(dct["Keyword%d"%i]))
  except KeyError:
break


Possibly overkill:

import dbf
table = dbf.from_csv("csvfile")   # fields get names f0, f1, f2, ...
table.rename_field('f3', 'key') # or whatever

def keyword_only(record):
if record.key.startswith('keyword'):
return int(record.key[len('keyword'):]))
return dbf.DoNotIndex

keywords = table.create_index(keyword_only)
# keywords is usable as an iterator
for rec in keywords:


# if you only want the first contiguous records
for i, rec in enum(keywords):
if rec.key != 'keyword%d' % enum:
break
...

Disclosure: I am the author of the dbf module.

Depending on your needs for the other fields of the csv file, this might 
be an easier way to access them.  Field names can also be specified when 
opening the csv file, I didn't bother for this example since I don't 
know what all your field names are.  ;)


Hope this helps!

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


Re: Can you advice a Python library to query a lan subnet with SNMP and collect MAC addresses of nodes?

2011-04-15 Thread Verde Denim
On Fri, Apr 15, 2011 at 5:00 AM, Aldo Ceccarelli
wrote:

> Hello All,
> in my specific problem I will be happy of a response where possible
> to:
>
> 1. distinguish different operating systems of answering nodes
> 2. collect responses of Wyse thin-clients with "Thin OS" to get node
> name and MAC address in particular
>
> Thanks a lot in advance for any sharing / forward to documentation,
> products in the area.
>
> KR Aldo
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Aldo
If you haven't already, have a look at dpkt and scapy as well. Both good
tools to have for tasks such as these.

Regards

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


Re: Pythonic infinite for loop?

2011-04-15 Thread Chris Angelico
On Fri, Apr 15, 2011 at 10:52 PM, Steven D'Aprano
 wrote:
> On Fri, 15 Apr 2011 13:58:22 +1000, Chris Angelico wrote:
>
>> The dictionary is potentially a lot larger than this particular set of
>> values (it's a mapping of header:value for a row of a user-provided CSV
>> file). Does this make a difference to the best option? (Currently I'm
>> looking at "likely" figures of 60+ keys in the dictionary and 3-8
>> postage options to pick up, but both of those could increase
>> significantly before production.)
>
> SIXTY keys?
>
> When you get to sixty thousand keys, it might take a few seconds to
> process.

This whole code is inside a loop that we took, in smoke testing, to a
couple hundred million rows (I think), with the intention of having no
limit at all. So this might only look at 60-100 headers, but it will
be doing so in a tight loop.

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


Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico  writes:
> This whole code is inside a loop that we took, in smoke testing, to a
> couple hundred million rows (I think), with the intention of having no
> limit at all. So this might only look at 60-100 headers, but it will
> be doing so in a tight loop.

If you're talking about data sets that large, you should rethink the
concept of using python dictionaries with a key for every row.  Try
importing your CSV into an SQL database and working from there instead.
-- 
http://mail.python.org/mailman/listinfo/python-list


Questions about GIL and web services from a n00b

2011-04-15 Thread Chris H
So I'm in a startup where we are considering using python as our primary 
development language for all the wonderful reasons you would expect.  
However, I've had a couple of things come up from mentors and other 
developers that is causing me to rethink whether python is the right 
choice.  I hope this is the right list for this type of discussion 
(please forgive me if not and point me in the right direction).


We are looking to build an e-commerce integration product so the 
majority of our work will be linking external SOAP and REST based web 
service API's to our own REST based API and backend database.I have 
had the following comments/questions come to me:


1. Are you sure you want to use python because threading is not good due 
to the Global Lock (GIL)?  Is this really an issue for multi-threaded 
web services as seems to be indicated by the articles from a Google 
search?  If not, how do you avoid this issue in a multi-threaded process 
to take advantage of all the CPU cores available?


2. Are there good web services frameworks available for building a REST 
based service?  I admit I have looked at web2py, Django, pyramid/pylons, 
and a few others.  SOAP seems to be pretty well supported but I'm not 
finding the same for quick development of REST based services for 
exchanging JSON or XML formatted data.  This is probably just my n00b 
status, but what tools are best for building a simple REST data exchange 
API?


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


genfromtxt and comment identifier

2011-04-15 Thread simona bellavista
Hi All,

I have a problem with reading data from a file using genfromtxt of
numpy module.

I have prepared a minimal example similar to the ones presented in

http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html#splitting-the-lines-into-columns

The script is

import numpy as np
from StringIO import StringIO
file = open('esempio.dat')
for line in file.xreadlines() :
if not line : break
print line
np.genfromtxt(StringIO(line), comments="#", delimiter=",")

I have a data file - esempio.dat - like the following:

#
# Skip me !
# Skip me too !
1, 2
3, 4
5, 6 #This is the third line of the data
7, 8
# And here comes the last line
9, 0
"""

The code is breaking at the first line, it looks like it doesn't
recognize # like comment identifier.

The error in the python interpreter is

Traceback (most recent call last):
  File "", line 1, in 
  File "esempio.py", line 7, in 
np.genfromtxt(StringIO(line), comments="#", delimiter=",")
  File "/opt/numpy/1.5.1/lib/python2.6/site-packages/numpy/lib/
npyio.py", line 1174, in genfromtxt
raise IOError('End-of-file reached before encountering data.')
IOError: End-of-file reached before encountering data.


It is clear that I haven't understood something, what am I doing
wrong?

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


Re: Questions about GIL and web services from a n00b

2011-04-15 Thread Chris H

On 4/15/11 1:03 PM, Tim Wintle wrote:

On Fri, 2011-04-15 at 12:33 -0400, Chris H wrote:

1. Are you sure you want to use python because threading is not good
due to the Global Lock (GIL)?  Is this really an issue for
multi-threaded web services as seems to be indicated by the articles
from a Google search?  If not, how do you avoid this issue in a
multi-threaded process to take advantage of all the CPU cores
available?

Is the limiting factor CPU?

If it isn't (i.e. you're blocking on IO to/from a web service) then the
GIL won't get in your way.

If it is, then run as many parallel *processes* as you have cores/CPUs
(assuming you're designing an application that can have multiple
instances running in parallel so that you can run over multiple servers
anyway).

Tim Wintle


Great question.  At this point, there isn't a limiting factor, but yes 
the concern is around CPU in the future with lots of threads handling 
many simultaneous transactions.


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


Re: Questions about GIL and web services from a n00b

2011-04-15 Thread Tim Wintle
On Fri, 2011-04-15 at 12:33 -0400, Chris H wrote:
> 
> 1. Are you sure you want to use python because threading is not good
> due to the Global Lock (GIL)?  Is this really an issue for
> multi-threaded web services as seems to be indicated by the articles
> from a Google search?  If not, how do you avoid this issue in a
> multi-threaded process to take advantage of all the CPU cores
> available?

Is the limiting factor CPU?

If it isn't (i.e. you're blocking on IO to/from a web service) then the
GIL won't get in your way.

If it is, then run as many parallel *processes* as you have cores/CPUs
(assuming you're designing an application that can have multiple
instances running in parallel so that you can run over multiple servers
anyway).

Tim Wintle

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


Re: genfromtxt and comment identifier

2011-04-15 Thread Peter Otten
simona bellavista wrote:

> Hi All,
> 
> I have a problem with reading data from a file using genfromtxt of
> numpy module.
> 
> I have prepared a minimal example similar to the ones presented in
> 
> http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html#splitting-
the-lines-into-columns
> 
> The script is
> 
> import numpy as np
> from StringIO import StringIO
> file = open('esempio.dat')
> for line in file.xreadlines() :
> if not line : break
> print line
> np.genfromtxt(StringIO(line), comments="#", delimiter=",")
> 
> I have a data file - esempio.dat - like the following:
> 
> #
> # Skip me !
> # Skip me too !
> 1, 2
> 3, 4
> 5, 6 #This is the third line of the data
> 7, 8
> # And here comes the last line
> 9, 0
> """
> 
> The code is breaking at the first line, it looks like it doesn't
> recognize # like comment identifier.
> 
> The error in the python interpreter is
> 
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "esempio.py", line 7, in 
> np.genfromtxt(StringIO(line), comments="#", delimiter=",")
>   File "/opt/numpy/1.5.1/lib/python2.6/site-packages/numpy/lib/
> npyio.py", line 1174, in genfromtxt
> raise IOError('End-of-file reached before encountering data.')
> IOError: End-of-file reached before encountering data.
> 
> 
> It is clear that I haven't understood something, what am I doing
> wrong?

The examples use StringIO to simulate a file, but you are wrapping every 
line of your actual file. The first "simulated file" is then

StringIO("#\n")

i. e. it contains only a comment, no data -- and that's what genfromtxt() 
complains about. Read the file in one fell swoop and you should be OK:

import numpy as np

with open('esempio.dat') as instream:
print np.genfromtxt(instream, comments="#", delimiter=",")


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


Re: Questions about GIL and web services from a n00b

2011-04-15 Thread Dan Stromberg
On Fri, Apr 15, 2011 at 9:33 AM, Chris H
 wrote:

> 1. Are you sure you want to use python because threading is not good due to
> the Global Lock (GIL)?  Is this really an issue for multi-threaded web
> services as seems to be indicated by the articles from a Google search?  If
> not, how do you avoid this issue in a multi-threaded process to take
> advantage of all the CPU cores available?

Concurrency in Python is a largish topic.

It's true that CPython's multithreading is poor.  In fact, running a
multithreaded CPython application on n vs 2n cores can actually take
more time on the 2n cores.

However:
1) In Jython, and likely IronPython, threading is good.
2) In CPython, there's a module called "multiprocessing" that's a
little slower than a good threading implementation, but gives looser
coupling between the discrete components of your software.
Programming with multiprocessing feels similar to programming with
threads - you have safe queues, safe scalars or simple arrays in
shared memory, etc.
3) There's something called "stackless" and (similar to stackless)
"greenlets".  While stackless allows you to use thousands of threads
comfortably, it's still pretty single-core.  It's essentially a fork
of CPython, and is being made a part of PyPy.  I believe greenlets are
an attempt to bring what's good about stackless to CPython, in the
form of a C extension module.
4) I've heard that in CPython 3.2, the GIL is less troublesome, though
I've not yet heard in what way.
5) Even in CPython, I/O-bound processes are not slowed significantly
by the GIL.  It's really CPU-bound processes that are.
6) PyPy is quite a bit faster than CPython for non-concurrent
applications, but also has a GIL.
7) Cython, which compiles a dialect of Python into faster C
(especially if you give it a few type declarations), has
GIL-implications.  I've heard that Cython can selectively release the
GIL on request, but I've also heard that C extension modules always
release the GIL.  This seems contradictory, and merits further
investigation.

It's important to remember: Python != CPython.  CPython remains the
reference implementation, and runs the most Python code, but there are
other, significant implementations now.

This page looks like a summary of many (more) options:
http://wiki.python.org/moin/Concurrency/

> 2. Are there good web services frameworks available for building a REST
> based service?  I admit I have looked at web2py, Django, pyramid/pylons, and
> a few others.  SOAP seems to be pretty well supported but I'm not finding
> the same for quick development of REST based services for exchanging JSON or
> XML formatted data.  This is probably just my n00b status, but what tools
> are best for building a simple REST data exchange API?

I have no experience with REST, but Grig of SoCal Piggies did a
presentation on "restish" a while back.  You might see if you can find
something about that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Mac OSX] TextWrangler "run" command not working properly

2011-04-15 Thread Jason Swails
On Thu, Apr 14, 2011 at 1:52 PM, Fabio  wrote:

> Then, I started to use TexWrangler, and I wanted to use the "shebang"
> menu, and "run" command.
> I have the "#! first line" pointing to the 2.6 version.
> It works fine, as long as I don't import the libraries, in which case it
> casts an error saying:
>
> ImportError: No module named scipy
>
> Maybe for some reason it points to the old 2.5 version.
> But I might be wrong and the problem is another...
>
>
TextWrangler doesn't launch a shell session that sources your typical
resource files (i.e. .bashrc, etc.), so any changes you make in an
interactive terminal session probably WON'T be loaded in TextWrangler.

See this website about setting environment variables for native Mac OS X
applications to see them:
http://www.astro.washington.edu/users/rowen/AquaEnvVar.html

Maybe if you prepend your Python 2.6 (MacPorts?) location to your PATH,
it'll find it.

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


Can Python control Thuderbird?

2011-04-15 Thread marceepoo
I want to control Mozilla Thunderbird using Python.
Does anyone know if that is that possible?
I would like to use Python to save email attachments to a specific
directory, depending on the name of the sender, content in the email,
etc.--- and to rename the attachment file  -- and to save the email to
an html file -- and to insert into the email file links to the locally
saved copies of the attachments.  Is this possible? 
 If the answer is yes, where could I find information about how to use 
Python to control Thuderbird (and/or examples of saving attachments to locval 
filenames,and/or saving emails to htmlfiles and/or connecting to the list of
contacts) ? 
   While hunting around, I came across "Python 18.4. mailbox — Manipulate 
mailboxes in various formats — Python v2.7.1 documentation".  I'm so totally 
ignorant of MAPI that I don't know if that is what I'm looking for.  If it is, 
does anyone know where I could find some examples of python scripts using the 
"Python 18.4. mailbox module"?

Thanks,

   Marceepoo


Thanks for your tme and the knowledge you share,

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


Is it possible to execute Python code from C++ without writing to a file?

2011-04-15 Thread Roger House

I'm a Python newbie who's been given a task requiring calls of Python code
from a C++ program.  I've tried various tutorials and dug into The Python/C
API doc and the Extending and Embedding Python doc, but I haven't been able
to answer this question:

Is it possible in a C++ program to generate Python code, execute
it, and get output back (say a tuple of 10 or so items) without
doing any file i/o?

Clearly it works to write the generated Python to a file and then use
PyImport_Import and PyObject_CallObject to call a function returning the
output tuple.  But it seems like it should be possible to do this without
writing the Python code to a file.  I tried PyRun_String, but I can't 
see how it
can be used to return a tuple (the Py_file_input option always returns 
None).


Any help will be greatly appreciated.

Roger House
Software Developer

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


Re: Is it possible to execute Python code from C++ without writing to a file?

2011-04-15 Thread Chris Angelico
On Sat, Apr 16, 2011 at 9:46 AM, Roger House  wrote:
> I'm a Python newbie who's been given a task requiring calls of Python code
> from a C++ program.  I've tried various tutorials and dug into The Python/C
> API doc and the Extending and Embedding Python doc, but I haven't been able
> to answer this question:
>
>    Is it possible in a C++ program to generate Python code, execute
>    it, and get output back (say a tuple of 10 or so items) without
>    doing any file i/o?
>
> Clearly it works to write the generated Python to a file and then use
> PyImport_Import and PyObject_CallObject to call a function returning the
> output tuple.  But it seems like it should be possible to do this without
> writing the Python code to a file.  I tried PyRun_String, but I can't see
> how it
> can be used to return a tuple (the Py_file_input option always returns
> None).

What I do for this is have the Python code place its return value into
a particular location. If you're using file input, I think it's
restricted to returning an integer; but you can do something like
this:

const char *python_code="result=('hello','world',42)";
PyObject *globals=... (use same as locals if you don't need globals)

PyObject *locals=PyDict_New();
Py_XDECREF(PyRun_StringFlags(python_code,Py_file_input,globals,locals,0);
PyObject *returned_tuple=PyDict_GetItemString(locals,"result");
Py_DECREF(locals);

You now own a reference to whatever the Python code put into its
variable "result", in the C variable returned_tuple. Of course, it
might not be a tuple at all, and it might not even be present (in
which case returned_tuple will be NULL). This is a fairly effective
way for Python to return hefty amounts of data to C.

Don't forget to decref the return value.

Hope that helps!

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


Re: Questions about GIL and web services from a n00b

2011-04-15 Thread Raymond Hettinger
> > Is the limiting factor CPU?
>
> > If it isn't (i.e. you're blocking on IO to/from a web service) then the
> > GIL won't get in your way.
>
> > If it is, then run as many parallel *processes* as you have cores/CPUs
> > (assuming you're designing an application that can have multiple
> > instances running in parallel so that you can run over multiple servers
> > anyway).
>
> Great question.  At this point, there isn't a limiting factor, but yes
> the concern is around CPU in the future with lots of threads handling
> many simultaneous transactions.

In the Python world, the usual solution to high transaction loads is
to use event-driven processing (using an async library such as
Twisted) rather than using multi-threading which doesn't scale well in
any language.

Also, the usual way to take advantage of multiple-cores is to run
multiple pythons in separate processes.

Threading is really only an answer if you need to share data between
threads, if you only have limited scaling needs, and are I/O bound
rather than CPU bound


Raymond

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


Re: Questions about GIL and web services from a n00b

2011-04-15 Thread David Cournapeau
On Sat, Apr 16, 2011 at 10:05 AM, Raymond Hettinger  wrote:
>> > Is the limiting factor CPU?
>>
>> > If it isn't (i.e. you're blocking on IO to/from a web service) then the
>> > GIL won't get in your way.
>>
>> > If it is, then run as many parallel *processes* as you have cores/CPUs
>> > (assuming you're designing an application that can have multiple
>> > instances running in parallel so that you can run over multiple servers
>> > anyway).
>>
>> Great question.  At this point, there isn't a limiting factor, but yes
>> the concern is around CPU in the future with lots of threads handling
>> many simultaneous transactions.
>
> In the Python world, the usual solution to high transaction loads is
> to use event-driven processing (using an async library such as
> Twisted) rather than using multi-threading which doesn't scale well in
> any language.

My experience is that if you are CPU bound, asynchronous programming
in python can be  more a curse than a blessing, mostly because the
need to insert "scheduling points" at the right points to avoid
blocking and because profiling becomes that much harder in something
like twisted.

It depends of course of the application, but designing from the ground
up with the idea of running multiple processes is what seems to be the
most natural way of scaling - this does not prevent using async in
each process. This has its own issues, though (e.g. in terms of
administration and monitoring).

Chris, the tornado documention mentions a simple way to get multiple
processes on one box: http://www.tornadoweb.org/documentation (section
mentiong nginx for load balancing). The principle is quite common and
is applicable to most frameworks (the solution is not specific to
tornado).

cheers.

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


Python IDE/text-editor

2011-04-15 Thread Alec Taylor
Good Afternoon,

I'm looking for an IDE which offers syntax-highlighting,
code-completion, tabs, an embedded interpreter and which is portable
(for running from USB on Windows).

Here's a mockup of the app I'm looking for: http://i52.tinypic.com/2uojswz.png

Which would you recommend?

Thanks in advance for any suggestions,

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


Re: Python IDE/text-editor

2011-04-15 Thread Ben Finney
Alec Taylor  writes:

> I'm looking for an IDE which offers syntax-highlighting,
> code-completion, tabs, an embedded interpreter and which is portable
> (for running from USB on Windows).

Either of Emacs http://www.gnu.org/software/emacs/> or Vim
http://www.vim.org/> are excellent general-purpose editors that
have strong features for programmers of any popular language or text
format.

They are available for every major OS, including MS Windows, are mature
and have enormous community support, and are free software and community
developed.

Learn either one, and you won't have to keep switching to different
editing tools for different programming tasks.

-- 
 \ “Geeks like to think that they can ignore politics. You can |
  `\leave politics alone, but politics won't leave you alone.” |
_o__)—Richard Stallman, 2002-07-26 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE/text-editor

2011-04-15 Thread rusi
On Apr 16, 8:20 am, Alec Taylor  wrote:
> Good Afternoon,
>
> I'm looking for an IDE which offers syntax-highlighting,
> code-completion, tabs, an embedded interpreter and which is portable
> (for running from USB on Windows).
>
> Here's a mockup of the app I'm looking for:http://i52.tinypic.com/2uojswz.png

As Ben suggested you can use emacs (Dunno if vi will give an embedded
interpreter)
but be prepared to have to work a bit -- it does not just work out of
the box.
In particular emacs will default to using a different python mode
(python.el) than the one that python programmers seem prefer
https://launchpad.net/python-mode/

You may also want to look at ipython

BTW how did you make that mockup?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH

2011-04-15 Thread harrismh777

Algis Kabaila wrote:

Is PYTHONPATH a system variable that sets the
path for several sessions and if so, where in the system is it?
Do I need to create one for setting python path for several
sessions?


It can be, and there are lots of ways to accomplish what you want, some 
of which depends on the platform you are using. I will show one of the 
ways that I accomplish this for my linux sessions. This is based on a 
very common snippet of code usually found in the users  .profile  which 
modifies the users path in the even the user has a ~/bin directory--- 
looks like this:



# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


When this snippet finds a ~/bin directory in the users ~/ then (and only 
then) it modifies the users bash session path with the ~/bin folder at 
the head of the path. Well, you can use this same snippet on your system 
to modify the PYTHONPATH system variable so that a special folder in 
your ~/ directory tree is at or near the head of the sys.path--- looks 
like this:



# set PATH so it includes user's private Python if it exists
if [ -d "$HOME/Python" ] ; then
export PYTHONPATH="$HOME/Python:$PYTHONPATH"
fi


You will notice that there is a tiny baby change in the second 
snippet... the export. If you want you IDLE launches from the Desktop to 
"see" the path set in  .profile  provide that with the export.


Of course this only works if the Python folder exists in the users ~/ 
directory tree (or elsewhere, if you code it that way).


By default the sys.path always shows the directory python was opened in, 
usually the users home directory. With  .profile  you can set the path 
any way you want... most useful for setting up special test directories 
ahead of the "real" code, or for setting up separate directories for 
versions--- one for Python26, Python27, and of course Python32.



(there are other ways of accomplishing the same thing, and of course, 
this one only really works with *nix systems--- windows is another mess 
entirely)


kind regards,
m harris




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


Re: Egos, heartlessness, and limitations

2011-04-15 Thread Littlefield, Tyler

>And who pissed in Guido's punch bowl anyway? Why is he such an elitist
>now? Why can he not come over once and a while and rub shoulders with
http://www.youtube.com/watch?v=FMEe7JqBgvg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Free software versus software idea patents

2011-04-15 Thread harrismh777

CM wrote:

What was criticized was your approach, which
seemed counter-productive, and so much so that it seemed like you are
"really" advocating FOR software patents by discrediting the position
against them.


Oh, the "thou protesteth too much" argument...

... well, I can only say that none of us can afford to protest too 
little about this issue. Too many have their heads in the sand and time 
is running out. If we're ever going to see this changed in our 
life-times then a whole lot of somebodies better get on the stick...

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


Re: Python IDE/text-editor

2011-04-15 Thread TerrorBite Lion
On Apr 15, 11:20 pm, Alec Taylor  wrote:
> Good Afternoon,
>
> I'm looking for an IDE which offers syntax-highlighting,
> code-completion, tabs, an embedded interpreter and which is portable
> (for running from USB on Windows).
>
> Here's a mockup of the app I'm looking for:http://i52.tinypic.com/2uojswz.png
>
> Which would you recommend?
>
> Thanks in advance for any suggestions,
>
> Alec Taylor

You seem to have drawn PSPad (http://www.pspad.com/). With one
preferences change and a little bit of window rearranging, you can
make PSPad do what you want.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Free software versus software idea patents

2011-04-15 Thread harrismh777

geremy condra wrote:

>  http://www.groklaw.net/articlebasic.php?story=2009151305785
>



This is not a proof. This is an argument. There's a very big difference.

To be clear, this article makes basically the same mistake you do- you
assume that a program is exactly equivalent to its computation,



Yes, I agree there is a difference between argument and proof. I 
full well know that what you are requiring here is a formal rigorous 
"mathematical" proof. I'm not trying to be coy about that issue, nor the 
issue of undecidability;  because at the moment it is not necessary for 
the purpose of isolating the problem underlying software idea patents. 
I'll explain that in a bit... in another post where it better fits... 
(hold that thought...)


The main point here is that *all* that is necessary at the moment 
is to make the "argument" crystal clear, demonstrably (but not rigorous 
by mathematical standards), that software *is* mathematics. But, that 
Mathematics *is not* necessarily Software... something new to follow...


Please consider these statements as pairs, then a small argument:

Mathematics *is not* chess.

Chess *is* mathematics.


Mathematics *is not* Tic-Tac-Toe

Tic-Tac-Toe *is* mathematics.


Mathematics *is not* "The Towers of Hanoi".

"The Towers of Hanoi" *is* mathematics.


Mathematics *is not* Fourier Analysis.

Fourier Analysis *is* mathematics.


Mathematics *is not* computation.

Computation *is* mathematics.


Mathematics *is not* software.

Software *is* mathematics.


I am not stating the problem as "natural" and "obvious" from the 
direction of Mathematics ==> Software. *NOT*   That aspect would in fact 
require a formal rigorous proof (in my opinion). That aspect of the 
discussion must at this point remain stipulated as merely conjecture--- 
maybe with resounding circumstantial evidence and demonstration, but 
conjecture none the less. At least, I have never seen a formal proof. 
(This is the direction of my work and research, but more on that later...)


I am asserting something of a subset in computational theory, even 
logic, and certainly number theory--- but there are others--- that the 
discussion at this point is from the other direction, namely,
Software ==> Mathematics. This aspect of the discussion (and the only 
one I believe matters for software idea patents at the moment) does not 
*require* a formal rigorous mathematical proof (we are not trying to 
prove a theorem here, rather to only demonstrate that software is the 
same 'thought' and 'process' (certainly a subset) as natural and obvious 
mathematical 'thought' and 'process'.  What?


Namely--- input, control, arithmetic, logic, and output.

These are subset to the broad and rich categories of mathematical 
thought and process. However, these small categories *are* definitive 
subsets of mathematics, obvious and natural, for all thinkers all over 
the globe. This is the reason I presume to apply for why you find 
software idea patents unfair and detestable. Because down underneath 
somewhere (like the rest of us), you too know that this aspect is 
natural and obvious. Its unfair (I really don't like that word) because 
it violates truth. Truth and freedom are very closely related topics.


In this pursuit for freedom we are not violating (nor abusing) 
mathematics. (quite the opposite) The full rigor of mathematical thought 
and philosophical reasoning in mathematics are at the pinnacle of human 
endeavor and at the height of science. This I fully and truly respect. 
The issue is *not* to pull mathematics down somehow... the issue is to 
clearly define *what* software *is* and from where it ultimately derives 
(as a subset)--- what constitutes "software"?  The constituency of 
software is nothing less than mathematics, from my viewpoint.


In a different post (in response to another of your good questions) 
I will try to lay out a different argument that comes a little closer at 
what you are looking for in terms of proof... still not rigorous 
mathematical proof...  but perhaps more demonstrable logically. Be 
patient, I'm trying to limit my posts to *not too many* whatever I mean 
by that.   :)



kind regards,
m harris






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


Re: Python IDE/text-editor

2011-04-15 Thread John Bokma
Ben Finney  writes:

> Alec Taylor  writes:
>
>> I'm looking for an IDE which offers syntax-highlighting,
>> code-completion, tabs, an embedded interpreter and which is portable
>> (for running from USB on Windows).
>
> Either of Emacs http://www.gnu.org/software/emacs/> or Vim
> http://www.vim.org/> are excellent general-purpose editors that
> have strong features for programmers of any popular language or text
> format.

I second Emacs or vim. I currently use Emacs the most, but I think it's
good to learn both.

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Facebook: http://www.facebook.com/j.j.j.bokma
Freelance Perl & Python Development: http://castleamber.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE/text-editor

2011-04-15 Thread Alec Taylor
Thanks, but non of the IDEs so far suggested have an embedded python
interpreter AND tabs... a few of the editors (such as Editra) have
really nice interfaces, however are missing the embedded
interpreter... emacs having the opposite problem, missing tabs (also,
selecting text with my mouse is something I do often).

Please continue your recommendations.

Thanks,

Alec Taylor

On Sat, Apr 16, 2011 at 3:29 PM, John Bokma  wrote:
> Ben Finney  writes:
>
>> Alec Taylor  writes:
>>
>>> I'm looking for an IDE which offers syntax-highlighting,
>>> code-completion, tabs, an embedded interpreter and which is portable
>>> (for running from USB on Windows).
>>
>> Either of Emacs http://www.gnu.org/software/emacs/> or Vim
>> http://www.vim.org/> are excellent general-purpose editors that
>> have strong features for programmers of any popular language or text
>> format.
>
> I second Emacs or vim. I currently use Emacs the most, but I think it's
> good to learn both.
>
> --
> John Bokma                                                               j3b
>
> Blog: http://johnbokma.com/    Facebook: http://www.facebook.com/j.j.j.bokma
>    Freelance Perl & Python Development: http://castleamber.com/
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE/text-editor

2011-04-15 Thread harrismh777

Alec Taylor wrote:

Please continue your recommendations.




IDLE?


(works for me)







3.2 is working much better for me this week...   :)


(thanks)




kind regards,
m harris
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE/text-editor

2011-04-15 Thread CM
On Apr 16, 1:43 am, Alec Taylor  wrote:
> Thanks, but non of the IDEs so far suggested have an embedded python
> interpreter AND tabs... a few of the editors (such as Editra) have
> really nice interfaces, however are missing the embedded
> interpreter... emacs having the opposite problem, missing tabs (also,
> selecting text with my mouse is something I do often).

Boa Constructor has syntax-highlighting, code-completion, tabs, line
numbers, and an embedded interpreter.  It also does a lot of other
IDEish stuff and it's a GUI builder, too. I've never tried to run it
from a USB, though, and the interpreter (the "shell") is in a separate
tab, not on the bottom as you've drawn it.

You might want to just look at this page for other ideas:
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Free software versus software idea patents

2011-04-15 Thread geremy condra
On Fri, Apr 15, 2011 at 10:21 PM, harrismh777  wrote:



This looks to me like an application of the troll motto "if you can't
dazzle them with brilliance, baffle them with bull". It certainly does
nothing to prove your claim, despite clearly attempting to word-salad
your way through an argument.

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


Re: Python IDE/text-editor

2011-04-15 Thread Ian Kelly
On Fri, Apr 15, 2011 at 9:20 PM, Alec Taylor  wrote:
> Good Afternoon,
>
> I'm looking for an IDE which offers syntax-highlighting,
> code-completion, tabs, an embedded interpreter and which is portable
> (for running from USB on Windows).
>
> Here's a mockup of the app I'm looking for: http://i52.tinypic.com/2uojswz.png
>
> Which would you recommend?

Komodo has all of those features and might be worth a look.  However,
I don't think the free version includes the embedded interpreter, and
I doubt whether the licensed version can be run from USB.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list