[Tutor] [OT] Python Study Group

2010-01-29 Thread David Abbott
A group of beginners and intermediate Pythonerrs and getting together to
study the book Core Python Programming by Wesley Chun. We are starting
on chapter one on Feb first. We are hoping to do a chapter every 2
weeks, but some we can devote a month to as needed. It is a self study
group so really no deadline. If you would like to join please email me
off list or just sign up at the wiki;
http://asterisklinks.com/wiki/doku.php?id=core:start#members

thanks,
david

 
-- 
David Abbott 

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


Re: [Tutor] [OT] Python Study Group

2010-01-29 Thread David Abbott
On Fri, 2010-01-29 at 15:26 -0500, Serdar Tumgoren wrote:
> Sounds like a cool idea David. Is this an online study group or do the
> folks who signed up live near each other geographically as well?

Its all online, we have people from India to Germany as an example.

-- 
David Abbott 

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


Re: [Tutor] kudos to alan

2010-01-31 Thread David Abbott
On Sun, 2010-01-31 at 11:58 -0800, David Hutto wrote:
> 
> 
> --- On Sun, 1/31/10, Woodwerks  wrote:
> 
> 
> 
> 
> I think the way you give hints and ideas about how to
> accomplish something in Python is excellent. I sometimes work
> through these problems just to build skills. I know it would
> be easy for you to provide a built solution, but this
> exercises the brain in a much better way. Kudos, Alan.
> 
> 
> 
> 
> I'll second the motion.
> 
> 

+ 3
-- 
David Abbott 

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


tutor@python.org

2010-02-13 Thread David Abbott
I am attempting to understand this little program that converts a
network byte order 32-bit integer to a dotted quad ip address.

#!/usr/bin/python
# Filename : int2ip.py

MAX_IP = 0xL
ip = 2130706433

def int2ip(l):
if MAX_IP < l < 0:
raise TypeError, "expected int between 0 and %d inclusive" %
MAX_IP
return '%d.%d.%d.%d' % (l>>24 & 255, l>>16 & 255, l>>8 & 255, l &
255)

result = int2ip(ip)
print result

I don't understand the l>>24 & 255. 

from the docs;
Right Shift a >> b rshift(a, b)
Bitwise And a & b and_(a, b)

thanks

-- 
David Abbott 

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


tutor@python.org

2010-02-13 Thread David Abbott
On Sat, 2010-02-13 at 11:32 -0800, Steve Willoughby wrote:
On Sat, 2010-02-13 at 13:45 -0600, Wayne Werner wrote:
Thanks Steve and Wayne your explanations;
HAL (helps a lot)

-- 
David Abbott 

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


Re: [Tutor] subprocess

2010-03-27 Thread David Abbott
On Sat, 2010-03-27 at 16:55 +0900, kevin parks wrote:
> I tried readings some toots and tried reading alan's thing. I just still 
> can't grok how to use subprocess.
> 
> I am trying to call sox (fun fact: an early contributer to sox was none other 
> than Guido van Rossum)
> 
> In the old days you would just use os i guess, like:
> 
> import os
> os.system('sox -V3 -D -S St.01.aif -b16 Stout-01.aif rate -s -v 44100')
> 
> to call a unix executable that you would ordinarily run from the terminal.
> 
> what would the equivalent of this in python's new subprocess be? perhaps if i 
> saw an example it would click..
> 
> additionally.. sox is a sound conversion tool. I plan to batch process a 
> bunch of files. Will subprocess start all the jobs as it finds the files? or 
> will it process one job and que the next? If it opened a thread and started a 
> bunch of jobs it would likely bog down the system no?
> 
> anyway  I have the os walk and other stuff that i am working on and i was 
> hoping to get some help on subprocess. There are a few pages on subprocess 
> but they all might just as well be in chinese and none of them, none that i 
> can see are equivalent to what i am trying to do (they all seem to be doing 
> os-y things)
> 
> An example might help. Not sure why i am finding this so hard to get my head 
> around.

Here is an example using subprocess.call
http://dwabbott.com/code/index8.html

and some more here with subprocess.Popen
http://asterisklinks.com/wiki/doku.php?id=wiki:subprocess

HTH
David


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


Re: [Tutor] An interesting situation befalls me

2010-05-09 Thread David Abbott
Now here is a chance to help influence this getting off on the right foot.
> I can use recomendations for texts for use in an introduction to Python
> class,

and I will condense it down and provide them to the good doctor.
>
> --
> end
>
> Very Truly yours,
>- Kirk Bailey,
>  Largo Florida
>
>
Here are a few;

Learning to Program by none other than Alan Gauld
http://www.freenetpages.co.uk/hp/alan.gauld/

Essential Python Reading list
http://wordaligned.org/articles/essential-python-reading-list

Daves Page
http://www.rexx.com/~dkuhlman/

-- 
David Abbott (dabbott)

Gentoo
http://dev.gentoo.org/~dabbott/
Podcast:
http://linuxcrazy.com/
Web:
http://nooone.info/
http://dwabbott.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Recent Documents

2010-05-27 Thread David Abbott
On Thu, May 27, 2010 at 2:45 PM, John Storta Jr.  wrote:
> I am working on an app that runs in gnome and uses gtk.  I am extremely
> new to Python.  (been working with it for all of 2 days).
>
> I am wanting to add a 'Recent Documents' menu option to the app.  Gnome
> tracks your recent documents -- apparently in a file called
> '.recently-used.xbel' in your home directory.
>
> So as to avoid reinventing the wheel, does anyone know of any examples
> of accessing the Gnome recently used file list from within Python?  Or
> is there some samples of how to implement something independently?

If you go here [1] and download Deskbar-Applet 2.30.0, once extracted
go to deskbar handlers and look at recent.py it may give you some
ideas.

class RecentHandler(deskbar.interfaces.Module):

INFOS = {'icon': deskbar.core.Utils.load_icon('document-open-recent'),
"name": _("Recent Documents"),
"description": _("Retrieve your recently accessed files
and locations"),
 "version": VERSION}


[1] 
http://download.gnome.org/sources/deskbar-applet/2.30/deskbar-applet-2.30.1.tar.g




-- 
David Abbott (dabbott)
Gentoo
http://dev.gentoo.org/~dabbott/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] has it gone quiet or is it just me?

2010-07-21 Thread David Abbott
On Wed, Jul 21, 2010 at 1:55 PM, Alan Gauld  wrote:
> I haven't had any tutor messages in 2 days.
> Do I have a problem or are things just very quiet suddenly?
> The archive isn't showing anything either which makes me suspicious.
>
Hi Alan,
Sorry have not been paying attention, but did get this as you I hope can see :)
David

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


Re: [Tutor] using mechanize to authenticate and pull data out of site

2009-12-26 Thread David Abbott
On Sat, 2009-12-26 at 16:46 +0100, Norman Khine wrote:
> Hello,
> 
> I am trying to authenticate on http://commerce.sage.com/Solidarmonde/
> using urllib but have a problem in that there are some hidden fields
> that use javascript to create a security token which then is passed to
> the submit button and to the header.
I used pycurl to login and post to a drupal site;
http://code.google.com/p/gentoo-community-portal/source/browse/trunk/gentooligans.py
I had to go to the page and store the token then use that to login or
enter data. I am new to programming so I am sure I make some mistakes
but it may help. Go down to line 374 I store the token and then use that
later to enter data. 

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


Re: [Tutor] Command line scripts

2011-01-12 Thread David Abbott
On Wed, Jan 12, 2011 at 9:29 PM, David Hutto  wrote:
> On Sun, Jan 9, 2011 at 9:03 AM, ALAN GAULD  wrote:
>>
>>
>>> The following line is what I mean by calling a  command line from within the
>>>app
>>> using subprocess.
>>>
>>> self.espeak =  subprocess.Popen(['espeak', word],stdout  =
>>> subprocess.PIPE).communicate()[0]
>>

I came up with this as an example, I am still learning also :)

[code]
#!/usr/bin/python

# wx python + espeak

from subprocess import call
import sys
import wx

class ESpeak(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, size=(360, 370))

panel = wx.Panel(self, -1)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)

st1 = wx.StaticText(panel, -1, 'Enter Saying: ')

self.tc1 = wx.TextCtrl(panel, -1, size=(180, -1))

button_send = wx.Button(panel, 1, 'Say')

hbox1.Add(st1, 0, wx.LEFT, 10)
hbox1.Add(self.tc1, 0, wx.LEFT, 10)

vbox.Add(hbox1, 0, wx.TOP, 50)
vbox.Add(button_send, 0, wx.ALIGN_CENTER | wx.TOP | wx.TOP |
wx.BOTTOM, 100)

self.Bind(wx.EVT_BUTTON, self.OnSpeak, id=1)
panel.SetSizer(vbox)

self.Centre()
self.ShowModal()
self.Destroy()

def OnSpeak(self, event):
say = self.tc1.GetValue()
if say != "":
espeak = "/usr/bin/espeak"
call([espeak, say])
else:
dlg = wx.MessageDialog(self, 'What did you say?', 'Error',
wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()

app = wx.App()
ESpeak(None, -1, 'wxESpeak')
app.MainLoop()
[/code]

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


[Tutor] Fwd: open linux file browser from nuke python script

2011-01-31 Thread David Abbott
-- Forwarded message --
From: David Abbott 
Date: Mon, Jan 31, 2011 at 9:55 AM
Subject: Re: [Tutor] open linux file browser from nuke python script
To: Pete O'Connell 


On Mon, Jan 31, 2011 at 6:42 AM, Pete O'Connell  wrote:
> Hi, I am trying to get a python script to open up a file browser window with
> the location of a folder. I am using kubuntu 10.04.
> The string that gets created works fine if I paste it into a shell eg:
> 'kde-open path/to/the/sequence',
> but it doesn't seem to want to run from within my interpreter using either
> subprocess.Popen or os.system
> For the first argument I have tried 'kde-open', 'konqueror', and a few
> others that all work fine in the shell but not in my interpreter.
> Here is what my script looks like:
> 
> import nuke
> import subprocess
> def showFolder():
>     subprocess.Popen(['kde-open', 'path/to/the/sequence'])
> showFolder()
> ###
> I must to run it from a specific interpreter (Nuke, the compositing
> software)
> Anyone have any idea what I might be doing wrong? Can anyone suggest a
> workaround?
> Pete
Here is one way this is just an example;
#!/usr/bin/python
from subprocess import call
def open_gedit():
       app = "gedit"
       fname = "test.txt"
       call([app, fname])
def main():
       open_gedit()
if __name__ == "__main__":
       main()



-- 
David Abbott (dabbott)
Gentoo
http://dev.gentoo.org/~dabbott/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python closes out on attempt to run script

2011-03-26 Thread David Abbott
On Sat, Mar 26, 2011 at 4:14 PM, Dave Angel  wrote:
> On 01/-10/-28163 02:59 PM, Matthew Speltz wrote:
>>
>> I'm trying to teach myself python and have run across a rather
>> annoying error.  I'm not sure exactly where the fault lies, so please
>> pardon me for posting too much information, I'm not sure what would be
>> relevant.
Hi Matthew,

I am using linux and ran your program from a terminal I had to change;
#!usr/bin/python
to
#!/usr/bin/python

also get the error;

./temp_test.py
./temp_test.py:20: SyntaxWarning: name 'tempf' is assigned to before
global declaration
  global tempf
./temp_test.py:36: SyntaxWarning: name 'tempf' is assigned to before
global declaration
  global tempf
Temperature converter, by * *.
'
  Please enter the Temperature you wish to convert, followed
  by the unit (C or F).
>  50 f
Temperature in Celsius is 10.0 .

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


Re: [Tutor] Introduction

2011-06-02 Thread David Abbott
On Thu, Jun 2, 2011 at 10:12 AM, Jamie Griffin  wrote:
> Hello everyone
>
> I'm not sure if introductions are customary on this list but I thought
> I would anyway as I'm going to be using it quite a bit from now.
>
> I am just starting out with python and I will no doubt get stuck and
> need some assistance from you all soon. I'll try my best to keep the
> stupidity to a minimum.
>
> Jamie.
Hi Jamie,
Welcome to the list, if you have not read one here is a pretty good
guide [1] for list etiquette, it would have saved me some
embarrassment if I had read it before I started posting to mail lists.
Have Fun :)
David

[1] http://curl.haxx.se/mail/etiquette.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread David Abbott
On Tue, May 8, 2012 at 1:41 PM, Alan Gauld  wrote:
> On 08/05/12 15:18, Rogelio wrote:
>>
>> While reading the subprocess documentation, I found a great example on
>> how to call commands with a PIPE
>>
>> http://docs.python.org/library/subprocess.html
>>
>> **
>> output=`dmesg | grep hda`
>> # becomes
>> p1 = Popen(["dmesg"], stdout=PIPE)
>> p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
>> p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits.
>> output = p2.communicate()[0]
>>
>> 
>>
>> How do I do this and output to a file?
>
>
> Have you tried defining stdout in the second command to be a file?
>
> log = open('log.txt','w')
> p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=log)
> ...
> log.close()
>
> I haven't tried but I think that should work...
>
> --
> Alan G
> 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

I have used this before;

def uptime_report():
"""Generate uptime"""
p = subprocess.Popen("uptime > /tmp/uptime.txt",
shell=True, stdout=subprocess.PIPE)
return p.stdout.readlines()

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


Re: [Tutor] Teaching an 8-year-old programming.

2012-05-20 Thread David Abbott
On Sun, May 20, 2012 at 6:28 PM, Mark Lybrand  wrote:
> Have you considered this book:
>
> http://www.amazon.com/Hello-World-Computer-Programming-Beginners/dp/1933988495
>
> Mark
[snip]
Another great book I really enjoyed it;
http://www.amazon.com/Python-Programming-Absolute-Beginner-Edition/dp/1435455002
All the best,
David
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] subprocess.Popen help

2012-08-22 Thread David Abbott
On Tue, Aug 21, 2012 at 9:39 PM, Ray Jones  wrote:
>
> Does anyone know of a link to a really good tutorial that would help me
> with subprocess.Popen? a tutorial that uses really small words and more
> examples than explanation? After 15 years of scripting, I'm ashamed to
> say that I'm still not all that familiar with input, output, pipes, etc.
> much beyond a simple 'ls | ws -l' or  &2>/dev/null scenarios. The
> docs for Popen have left me completely boggled, and I'm not seeing much
> available on Google search. Any suggestions?
>
> Thanks.
>
>
> Ray
Hi Ray,
http://www.doughellmann.com/PyMOTW/subprocess/

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


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread David Abbott
On Sun, Dec 22, 2013 at 5:21 AM, Oscar Benjamin
 wrote:
>
> On Dec 22, 2013 1:20 AM, "Keith Winston"  wrote:
>
>
>>
>> On Sat, Dec 21, 2013 at 6:00 AM,  wrote:
>>>
>>> I'm unsure as to what the subject line has in common with class and
>>> instance variables, would you care to explain it please.
>>
>>
>>
>> I'm sorry Mark, I'm stuck with using gmail where I have to remember to
>> delete the (essentially invisible) included text of the entire digest I'm
>> responding to, and change the (entirely invisible) subject line. It
>
> The problem is that you're responding to the digest. Change your
> subscription to receive individual messages. Create a filter that
> automatically puts the tutor list emails under a particular label and skips
> the inbox so that the list doesn't clutter your inbox. Then you'll have a
> folder of correctly threaded emails from the list. When you reply to one
> email the subject line will be automatically set and only the previous
> message will be quoted.
>
> Oscar
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

Then what I do is reply to all and remove the individual email address
and move tutor@ to the To: and make sure to reply at the bottom by
clicking on the 3 dots that open up the message.

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


Re: [Tutor] Which computer operating system is best for Python

2014-02-05 Thread David Abbott
On Wed, Feb 5, 2014 at 7:23 PM, Marc Tompkins  wrote:
> On Wed, Feb 5, 2014 at 3:18 PM, Joel Goldstick 
> wrote:
>>
>> I would get a laptop with as large a screen as you can afford. Windows or
>> Linux.
>>
> I second that emotion, and also: try out the keyboard first (or rather, have
> your kid try it out).  We spend a lot of time on our laptops, and a
> badly-designed keyboard can ruin an otherwise-great machine.  Yes, you can
> plug in an external keyboard, mouse, and monitor, but most of the time
> you're gonna stick with what came in the box.  Make sure you won't hate it.

Linux runs great on older Laptops that were the top of the line in
their day, two nice examples with great keyboards are dell e6400 and
ibm T61's. Linux is easy to install and set up now a days :)


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


Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread David Abbott
> It hangs at the print statement and, from the sound of the fans in the
> computer, I suspect it spirals off into an infinite loop somewhere /
> somehow. Does anyone have any ideas about what it is that I might be
> misunderstanding?

Works here.

david@heater ~/python_practice $ ./subprocess_pipe.py
Parrot said:  Squawk: Pushing up daisies.

david@heater ~/python_practice $ python
Python 3.3.5 (default, Oct  2 2014, 07:55:01)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()



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


Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread David Abbott
I did do this also;
david@heater ~/python_practice $ chmod a+x parrot.sh
david@heater ~/python_practice $ chmod a+x subprocess_pipe.py
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor