[Tutor] Seek suggestions for script for looking up extensions using C:\>assoc

2010-08-06 Thread Richard D. Moores
Python 3.1; Windows Vista.

I just ran C:\>assoc and was amazed to see 658 associations roll by.
Here's the top of the list:

.001=jZip.file
.386=vxdfile
.3g2=QuickTime.3g2
.3gp=QuickTime.3gp
.3gp2=QuickTime.3gp2
.3gpp=QuickTime.3gpp
.7Z=jZip.file
.aa=NeroShowTime.Files9.aa
.aac=QuickTime.aac
.ac3=QuickTime.ac3
.aca=Agent.Character.2
.acf=Agent.Character.2
.acl=ACLFile
.acr=IrfanView.DCM
.acrobatsecuritysettings=AcroExch.acrobatsecuritysettings
.acs=Agent.Character2.2
.acsm=Adobe.ACSMessage
.AddIn=VCExpress.AddIn.9.0
.adts=QuickTime.adts
.aif=IrfanView.aif
.aifc=WMP11.AssocFile.AIFF
.aiff=WMP11.AssocFile.AIFF
.air=AIR.InstallerPackage

I thought it would be convenient to have a Python script I could use
to look up unfamiliar file extensions. I assume one is possible, but
have no idea where to start, and would appreciate hints and
suggestions.

Thanks,

Dick Moores
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Seek suggestions for script for looking up extensions usingC:\>assoc

2010-08-06 Thread davidheiserca


You wouldn't gain much with a Pyton script. You can specify the extension 
with "assoc".


Try "assoc .zip".

But if you want to try it anyway, look at the "popen2" module (depreciated) 
or the "subprocess" module to extract the data and assign it to a variable 
that you can parse any way you like.



- Original Message - 
From: "Richard D. Moores" 

To: 
Sent: Friday, August 06, 2010 6:11 AM
Subject: [Tutor] Seek suggestions for script for looking up extensions 
usingC:\>assoc




Python 3.1; Windows Vista.

I just ran C:\>assoc and was amazed to see 658 associations roll by.
Here's the top of the list:

.001=jZip.file
.386=vxdfile
.3g2=QuickTime.3g2
.3gp=QuickTime.3gp
.3gp2=QuickTime.3gp2
.3gpp=QuickTime.3gpp
.7Z=jZip.file
.aa=NeroShowTime.Files9.aa
.aac=QuickTime.aac
.ac3=QuickTime.ac3
.aca=Agent.Character.2
.acf=Agent.Character.2
.acl=ACLFile
.acr=IrfanView.DCM
.acrobatsecuritysettings=AcroExch.acrobatsecuritysettings
.acs=Agent.Character2.2
.acsm=Adobe.ACSMessage
.AddIn=VCExpress.AddIn.9.0
.adts=QuickTime.adts
.aif=IrfanView.aif
.aifc=WMP11.AssocFile.AIFF
.aiff=WMP11.AssocFile.AIFF
.air=AIR.InstallerPackage

I thought it would be convenient to have a Python script I could use
to look up unfamiliar file extensions. I assume one is possible, but
have no idea where to start, and would appreciate hints and
suggestions.

Thanks,

Dick Moores
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Seek suggestions for script for looking up extensions usingC:\>assoc

2010-08-06 Thread Richard D. Moores
On Fri, Aug 6, 2010 at 07:56,   wrote:
>
> You wouldn't gain much with a Pyton script. You can specify the extension
> with "assoc".
>
> Try "assoc .zip".
>
> But if you want to try it anyway, look at the "popen2" module (depreciated)
> or the "subprocess" module to extract the data and assign it to a variable
> that you can parse any way you like.

Thanks! I think I will try it anyway, and am already reading the doc
for the subprocess module.

(Someone -- not this Tutoree -- is going to remind you not to top post.)

Dick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Idea for a 'Weekly Python Tips' mailing list

2010-08-06 Thread Ian Ozsvald
Hi all. I'm a long time Pythonista and co-founder of
http://ShowMeDo.com/ (and author of 140 of the Python tutorials
there), I'm here with an idea...

Recently I've started to follow a couple of email lists that send me
regular tip emails, I've found them to be rather nice - an easy to
read tip that comes every week that I can digest when I'm ready and I
can reference afterwards.

I don't recall ever coming across a Python Learners tip series in this
format and I'm guessing it would be well received. Could I get some
feedback please?

I've already planned a set of 10 weekly tips (each about 5 paragraphs
of text plus code examples) covering a bunch of things that are useful
for a new Python programmer. Some are about the 'right' way to write
Python code, some introduce neat modules (like Excel, web scraping,
processes), some show you how to do complex stuff (like 3D, web
servers and faster mathematics) in just a few lines of Python.

It would also be quite nice to wrap up some of the oft-asked Python
Tutor questions into the tips (I always meant to create some ShowMeDo
videos covering these problems but never had the time :-( ).

Before proceeding I'd like to do a sanity check - has anyone done this
already? I'd hate to re-invent the wheel!

Assuming it hasn't been done - would *you* choose to subscribe to the
list (it would be free, just an email, nothing complex and no
spam/sillyness)? Just say 'yes' if so, that way I know there's an
audience.

If the interest is good then I'll extend the series of 10 and
introduce some guest authors into the mix.

Any takers?
Ian.

-- 
Ian Ozsvald (A.I. researcher, screencaster)
i...@ianozsvald.com

http://IanOzsvald.com
http://MorConsulting.com/
http://blog.AICookbook.com/
http://TheScreencastingHandbook.com
http://FivePoundApp.com/
http://twitter.com/IanOzsvald
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Idea for a 'Weekly Python Tips' mailing list

2010-08-06 Thread Eric Hamiter
Your ideas are intriguing to me, and I wish to subscribe to your newsletter.

Eric


On Fri, Aug 6, 2010 at 11:19 AM, Ian Ozsvald  wrote:

> Hi all. I'm a long time Pythonista and co-founder of
> http://ShowMeDo.com/ (and author of 140 of the Python tutorials
> there), I'm here with an idea...
>
> Recently I've started to follow a couple of email lists that send me
> regular tip emails, I've found them to be rather nice - an easy to
> read tip that comes every week that I can digest when I'm ready and I
> can reference afterwards.
>
> I don't recall ever coming across a Python Learners tip series in this
> format and I'm guessing it would be well received. Could I get some
> feedback please?
>
> I've already planned a set of 10 weekly tips (each about 5 paragraphs
> of text plus code examples) covering a bunch of things that are useful
> for a new Python programmer. Some are about the 'right' way to write
> Python code, some introduce neat modules (like Excel, web scraping,
> processes), some show you how to do complex stuff (like 3D, web
> servers and faster mathematics) in just a few lines of Python.
>
> It would also be quite nice to wrap up some of the oft-asked Python
> Tutor questions into the tips (I always meant to create some ShowMeDo
> videos covering these problems but never had the time :-( ).
>
> Before proceeding I'd like to do a sanity check - has anyone done this
> already? I'd hate to re-invent the wheel!
>
> Assuming it hasn't been done - would *you* choose to subscribe to the
> list (it would be free, just an email, nothing complex and no
> spam/sillyness)? Just say 'yes' if so, that way I know there's an
> audience.
>
> If the interest is good then I'll extend the series of 10 and
> introduce some guest authors into the mix.
>
> Any takers?
> Ian.
>
> --
> Ian Ozsvald (A.I. researcher, screencaster)
> i...@ianozsvald.com
>
> http://IanOzsvald.com
> http://MorConsulting.com/
> http://blog.AICookbook.com/
> http://TheScreencastingHandbook.com
> http://FivePoundApp.com/
> http://twitter.com/IanOzsvald
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Idea for a 'Weekly Python Tips' mailing list

2010-08-06 Thread Lie Ryan
On Fri, 6 Aug 2010 17:19:46 +0100, Ian Ozsvald  
wrote:

Recently I've started to follow a couple of email lists that send me
regular tip emails, I've found them to be rather nice - an easy to
read tip that comes every week that I can digest when I'm ready and 

I

can reference afterwards.


In the main python list there is Python Weekly URL that summarizes 
the week's most interesting posts in c.l.py


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-06 Thread Wayne Watson

Yes, porpoises was a (old) pun.

Back in Feb. I raised a question related to Subject. I just wanted to 
know if Python code could be compiled in some sense. Robert Berman 
pitched in with some help. Although I was making progress, I put it off 
for a future date. I really don't want to get into py2exe here, but am 
wondering if there are Python vendors who in some way sell their product 
in compiled form?


My intent though is really not to produce a commercial product. My 
question relates to difficulty my partner and I have to exchanging py 
programs w/o him stumbling. I send him a py program written using 
Windows Python 2.5. He has the same. I've executed it IDLE and it works 
fine. He executes, and it squawks per my post here on finding a version 
#, showing his output. We need to make sure we are on the same playing 
ground with numpy and scipy. I don't think we are. He barely knows 
Python, but did, supposedly, a install of it, numpy and scipy from the 
same written direction I use. I think he mistakenly installed a 
different version of numpy. So how can we make sure we or anyone are on 
the same playing field? Perhaps we should resort to command like 
execution. I am not confident that using py2exe will solve this problem. 
Is there a Python tool that provides some thorough description of a 
Python installation?


--
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

"An experiment is a question which science poses to
 Nature, and a measurement is the recording of
 Nature’s answer." -- Max Planck


Web Page:

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-06 Thread Chris Fuller

It sounds like maybe you could use Enthought Python, which is a bundle of most 
of the popular numerical libraries by the scipy sponsors.  Not free, however, 
there's a trial version.

http://enthought.com/products/epd.php

The problem of bundling stuff is a real thorny one and has been beaten to death 
many times in this list and elsewhere.  It really doesn't solve the problem, 
anyway, if you want your friend to be able to play with and rerun the code.

Another idea is to make a virtual machine that you can duplicate or even mail 
back and forth with just the stuff required.  Then you'd need an OS license for 
it (or use a minimal Linux, like Arch or DSL, but you probably want to stick 
to the Windows platform, I'd guess.)

Cheers

On Friday 06 August 2010, Wayne Watson wrote:
> Yes, porpoises was a (old) pun.
> 
> Back in Feb. I raised a question related to Subject. I just wanted to
> know if Python code could be compiled in some sense. Robert Berman
> pitched in with some help. Although I was making progress, I put it off
> for a future date. I really don't want to get into py2exe here, but am
> wondering if there are Python vendors who in some way sell their product
> in compiled form?
> 
> My intent though is really not to produce a commercial product. My
> question relates to difficulty my partner and I have to exchanging py
> programs w/o him stumbling. I send him a py program written using
> Windows Python 2.5. He has the same. I've executed it IDLE and it works
> fine. He executes, and it squawks per my post here on finding a version
> #, showing his output. We need to make sure we are on the same playing
> ground with numpy and scipy. I don't think we are. He barely knows
> Python, but did, supposedly, a install of it, numpy and scipy from the
> same written direction I use. I think he mistakenly installed a
> different version of numpy. So how can we make sure we or anyone are on
> the same playing field? Perhaps we should resort to command like
> execution. I am not confident that using py2exe will solve this problem.
> Is there a Python tool that provides some thorough description of a
> Python installation?

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-06 Thread Emile van Sebille

On 8/6/2010 10:51 AM Wayne Watson said...

Yes, porpoises was a (old) pun.

Back in Feb. I raised a question related to Subject. I just wanted to
know if Python code could be compiled in some sense. Robert Berman
pitched in with some help. Although I was making progress, I put it off
for a future date. I really don't want to get into py2exe here, but am
wondering if there are Python vendors who in some way sell their product
in compiled form?



I think you're making it harder.  Go to your partners site, build an 
appropriate base environment, document and leave instructions on where 
to put new *.py modules you send him, run through it, and you're done.


A little education will likely go a lot further than delving deeper into 
heavier technologies in an attempt to 'simplfy'.


HTH,

Emile

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-06 Thread Alan Gauld

"Wayne Watson"  wrote

programs w/o him stumbling. I send him a py program written using 
Windows Python 2.5. He has the same. I've executed it IDLE and it 
works fine. He executes, and it squawks


IDLE is a development environment. Never, ever test final code in
a development environment, test it as it should be run. Double click
the file in explorer. Better still install a separate copy wherever 
the

file will go on the target system - usually somewhere different to
where you develop it - and run it there.

same written direction I use. I think he mistakenly installed a 
different version of numpy. So how can we make sure we or anyone are 
on the same playing field? Perhaps we should resort to command like 
execution.


You should definitely not run it from IDLE, that's inefficient and
likely to hide errors. Run it from a command prompt or by double
clicking in explorer, or create a shortcut on the desktop.

To check the versions of your packages you could write a short
test program that simply imports all needed modules and prints
out the version info (if available) and file details xxx.__file__

You could even use the __file__ info to check the size of the files
by using the os module functions.

Is there a Python tool that provides some thorough description of a 
Python installation?


I'm not aware of such but it should not be hard to check the basics.
One of the best thins about Python is the high level of portability
of programs across versions and OS. Its most likely a location
or PATH setting

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] modify csv textfile

2010-08-06 Thread TGW
I have a pipe delimited text file with 5 columns which looks like this:
12345|some text|some more text|example125 oo3 3456|example32423
11223|more text|and more|example/73d 77665|example455667
12677|text|more|anotherexample 123|anotherexample45

What I want to output is:
12345|some text|some more text|example|example32423
11223|more text|and more|example|example455667
...
12677|text|more|anotherexample 123|anotherexample45

So column 4 is where the change occurs, but only if the beginning of the string 
in column 4  =~ /^example/i  # and it should be case insensitive

#!/usr/bin/env python
import csv
import re

filename = raw_input("Enter the filename to edit: ")

reader = csv.reader(open(filename, 'rb'), delimiter='|', quoting=csv.QUOTE_NONE)
for row in reader:
print row


I can print the file, I just need a little help searching and replacing the 
column 4 data element.

Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-06 Thread j ram
>
> My intent though is really not to produce a commercial product. My question
> relates to difficulty my partner and I have to exchanging py programs w/o
> him stumbling. I send him a py program written using Windows Python 2.5. He
> has the same. I've executed it IDLE and it works fine. He executes, and it
> squawks per my post here on finding a version #, showing his output. We need
> to make sure we are on the same playing ground with numpy and scipy.
>
>
Why not try bundling your .py modules in a zip file and then importing the
run modules from this zip file? In that way, the package integrity is
ensured. You'd just have to ship your collaborator the zip archive and also
make sure that both of you are running the same versions of numpy, scipy,
python and other packages.

http://docs.python.org/library/zipimport.html

http://www.doughellmann.com/PyMOTW/zipimport/

Regards,
Iyer
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-06 Thread Che M


> #, showing his output. We need to make sure we are on the same playing 
> ground with numpy and scipy. I don't think we are. He barely knows 
> Python, but did, supposedly, a install of it, numpy and scipy from the 
> same written direction I use. I think he mistakenly installed a 
> different version of numpy. So how can we make sure we or anyone are on 
> the same playing field? 

Both of you do this from IDLE:

import numpy
help(numpy)

Read the version # at the end.
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] modify csv textfile

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 12:35 PM, TGW  wrote:
> I have a pipe delimited text file with 5 columns which looks like this:
> 12345|some text|some more text|example125 oo3 3456|example32423
> 11223|more text|and more|example/73d 77665|example455667
> 12677|text|more|anotherexample 123|anotherexample45
>
> What I want to output is:
> 12345|some text|some more text|example|example32423
> 11223|more text|and more|example|example455667
> ...
> 12677|text|more|anotherexample 123|anotherexample45
>
> So column 4 is where the change occurs, but only if the beginning of the 
> string in column 4  =~ /^example/i  # and it should be case insensitive

So do it :)

> #!/usr/bin/env python
> import csv
> import re
>
> filename = raw_input("Enter the filename to edit: ")
>
> reader = csv.reader(open(filename, 'rb'), delimiter='|', 
> quoting=csv.QUOTE_NONE)
> for row in reader:
>    print row
>
> 
> I can print the file, I just need a little help searching and replacing
the column 4 data element.

Use re.match to match the column.

Use csv.writer to write our a new csv file
based on the one you're reading, filtering
and modifying.

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor