Re: How security holes happen

2014-03-04 Thread sffjunkie
On Monday, 3 March 2014 22:55:32 UTC, Chris Kaynor  wrote:
 You can go much simpler than that. Merely port Python to LISP, then write a 
 LISP interpreter in Python. Done.

http://blog.pault.ag/post/46982895940/heres-my-talk-from-pycon-2013-i-tried-to-queue
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python : parsing the command line options using optparse

2014-02-26 Thread sffjunkie
On Wednesday, 26 February 2014 09:30:21 UTC, Ganesh Pal  wrote:
 Here is what is happening ( only short hand with -)
 
 # python-5.py -p=/ifs/1.txt -q=XOR  -f=1234 -n=1 -l
 
 Usage: python-5.py [options]
 python-5.py: error: option -q: invalid choice: '=XOR' (choose from 'XOR', 
 'ADD',
 
  'SET', 'MODIFY', 'RENAME', 'DELETE', 'KILL')

Short hand options don't use '=' signs. Try

python-5.py -p /ifs/1.txt -q XOR  -f 1234 -n 1 -l

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


Re: Python powerpoint automation using pywin32

2014-02-25 Thread sffjunkie
On Tuesday, 25 February 2014 03:52:29 UTC, Jaydeep Patil  wrote:
 I need to use COM interface for PowerPoint generation.

The following will get you started

http://nbviewer.ipython.org/github/sanand0/ipython-notebooks/blob/master/Office.ipynb

Then you'll need to interpret the Microsoft MSDN docs for anything else

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.aspx

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


Re: Install python 2 and 3 in the wrong order

2014-02-25 Thread sffjunkie
On Sunday, 16 February 2014 08:13:14 UTC, Nagy László Zsolt  wrote:
  Though I don't see anything in the ActiveState builds (which are all
  I've ever used) to handle the #! type selection of the desired version.
  Just got done updating my 2.7, replacing 3.2 with 3.3, and then having to
  edit my path to make 2.7 primary... No py.exe
 I need both 2.7 and 3.3. And apparently, py.exe does not work the way it 
 should be.

Is the following any help

http://www.perlmonks.org/?node_id=998428
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functions help

2014-02-24 Thread sffjunkie
On Sunday, 23 February 2014 05:43:17 UTC, Scott W Dunning  wrote:
 I had a question regarding functions.  Is there a way to call a function 
 multiple times without recalling it over and over.  Meaning is there a way I 
 can call a function and then add *5 or something like that?
 

The following answers your question but is probably not a method you want to 
employ.

from functools import partial

def a(ch):
  print(ch)

def b(x):
  print(x + 10)

[x() for x in [partial(a, 'd'), partial(b, 10)]*5]

Produces

d
14
d
14
d
14
d
14
d
14

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


Re: Functions help

2014-02-24 Thread sffjunkie
On Sunday, 23 February 2014 05:43:17 UTC, Scott W Dunning  wrote:
 
 I had a question regarding functions.  Is there a way to call a function 
 multiple times without recalling it over and over.  Meaning is there a way I 
 can call a function and then add *5 or something like that?

The following answers your question but is probably not a method you want to 
employ. 

from functools import partial 

def a(ch): 
  print(ch) 

def b(x): 
  print(x + 4) 

[x() for x in [partial(a, 'd'), partial(b, 10)]*5] 

Produces 

d 
14 
d 
14 
d 
14 
d 
14 
d 
14 

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


Re: The sum of numbers in a line from a file

2014-02-24 Thread sffjunkie
On Thursday, 20 February 2014 16:22:00 UTC, kxjakkk  wrote:
 Let's say I have a sample file like this:
 Name1   2 34 5  6 78
 
 name1099-66-7871   A-FY10067815998
 name2999-88-7766   A-FN99   100969190
 name3000-00-0110AUD5100281976
 name4398-72-P/FY7684496978
 name5909-37-3689A-FY97941006179
 
 For name1, I want to add together columns 4, 5, 6, and get an average from 
 that, then do the same for the last two columns. I want to do this for every 
 name. 

The following solution works for Python3 (due to the unpacking using the * 
syntax)



from collections import defaultdict, namedtuple

info = namedtuple('info', 'sum avg')

interesting_data = (x.strip(' \n') for idx, x in 
enumerate(open('file').readlines()) if idx  1 and len(x.strip(' \n'))  0)

split_points = [2, 4, 5]

results = defaultdict(list)
for line in interesting_data:
name, _, _, _, *rest = line.split()

last_point = 0
for point in split_points:
s = sum(map(int, rest[last_point:point]))
i = info(s, s / (point - last_point))

results[name].append(i)
last_point = point

print(results)
print(results['name3'][0].avg)

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


Re: Python powerpoint automation using pywin32

2014-02-24 Thread sffjunkie
On Monday, 24 February 2014 11:35:08 UTC, Jaydeep Patil  wrote:
 I need to create a new powerpoint presentation. I need to add images, paste 
 some graphs, add texts, tables into powerpoint.
 
 Is any link or document available which help me to do this work more 
 effectivey  faster.

Always remember, PyPi is your friend.

I've not used it but the following is available which works with Microsoft's 
XML based document types. It is not automation per se (and doesn't use pywin32) 
but a library for pptx document manipulation.

https://pypi.python.org/pypi/python-pptx/

Docs are here

https://python-pptx.readthedocs.org/en/latest/

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


Re: The sum of numbers in a line from a file

2014-02-24 Thread sffjunkie
On Monday, 24 February 2014 11:48:23 UTC, sffj...@gmail.com  wrote:

 split_points = [2, 4, 5]

Change this to `split_points = [3, 5]` for your requirements

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