Re: Do you feel bad because of the Python docs?

2013-02-26 Thread Adam W.
I think learning a language from the documentation is an unreasonable expectation and burden for the authors. Buy a book, take a class, they are designed to provide you with a path from start to finish in a sensible manner, the documentation in my opinion is supposed to be a reference and a ref

Re: stmplib MIMEText charset weirdness

2013-02-26 Thread Adam W.
On Tuesday, February 26, 2013 2:10:28 AM UTC-5, Steven D'Aprano wrote: > On Mon, 25 Feb 2013 20:00:24 -0800, Adam W. wrote: > > The documentation for MIMEText is rather terse, but it implies that the > > parameter given should be a string, not bytes: > > >

stmplib MIMEText charset weirdness

2013-02-25 Thread Adam W.
Can someone explain to me why I can't set the charset after the fact and still have it work. For example: >>> text = MIMEText('❤¥'.encode('utf-8'), 'html') >>> text.set_charset('utf-8') >>> text.as_string() Traceback (most recent call last): File "", line 1, in text.as_string() File "C:\

Re: using urllib on a more complex site

2013-02-24 Thread Adam W.
On Sunday, February 24, 2013 7:27:54 PM UTC-5, Chris Rebert wrote: > On Sunday, February 24, 2013, Adam W. wrote: > I'm trying to write a simple script to scrape > http://www.vudu.com/movies/#tag/99centOfTheDay/99c%20Rental%20of%20the%20day > > > > > in order

Re: using urllib on a more complex site

2013-02-24 Thread Adam W.
On Sunday, February 24, 2013 7:30:00 PM UTC-5, Dave Angel wrote: > On 02/24/2013 07:02 PM, Adam W. wrote: > > > I'm trying to write a simple script to scrape > > http://www.vudu.com/movies/#tag/99centOfTheDay/99c%20Rental%20of%20the%20day > > > > > > i

using urllib on a more complex site

2013-02-24 Thread Adam W.
I'm trying to write a simple script to scrape http://www.vudu.com/movies/#tag/99centOfTheDay/99c%20Rental%20of%20the%20day in order to send myself an email every day of the 99c movie of the day. However, using a simple command like (in Python 3.0): urllib.request.urlopen('http://www.vudu.com/mo

Re: Sending USB commands with Python

2012-08-30 Thread Adam W.
On Thursday, August 30, 2012 12:55:14 AM UTC-4, Dennis Lee Bieber wrote: > > How many bytes did it claim to send? > 11, which is what I expected. But I changed the byte value to 16 (because I was having trouble getting single digit hex values working in the command) and sent this command:

Re: Sending USB commands with Python

2012-08-29 Thread Adam W.
On Wednesday, August 29, 2012 10:07:54 PM UTC-4, Dennis Lee Bieber wrote: > On Wed, 29 Aug 2012 16:45:10 -0700 (PDT), "Adam W." > > I'm a tad curious if using the notation > > > > b'\x1bA' > > > > without the .en

Re: Sending USB commands with Python

2012-08-29 Thread Adam W.
On Wednesday, August 29, 2012 6:56:16 PM UTC-4, Dennis Lee Bieber wrote: > > BUT you do give a possible clue. Is the OP using a 3.x Python where > > strings are Unicode -- in which case the above may need to be explicitly > > declared as a "byte string" rather than text (unicode) string. >

Re: Sending USB commands with Python

2012-08-29 Thread Adam W.
On Wednesday, August 29, 2012 4:09:49 PM UTC-4, Dennis Lee Bieber wrote: > > Don't the commands require an character? "\x1BA" (or >"\x1B\x41") > > OTOH, if the is issued behind the scenes, I'm not sure which esc char it is asking for, I don't think libusb is providing its own,

Re: Sending USB commands with Python

2012-08-29 Thread Adam W.
On Wednesday, August 29, 2012 2:45:17 AM UTC-4, Tim Roberts wrote: > Which operating system are you using? If you are on Windows, then the > > operating system has already loaded a printer driver for this device. > > > The libusb or libusbx libraries can be used to talk to USB devices. There

Sending USB commands with Python

2012-08-28 Thread Adam W.
So I'm trying to get as low level as I can with my Dymo label printer, and this method described the PDF http://sites.dymo.com/Documents/LW450_Series_Technical_Reference.pdf seems to be it. I'm unfamiliar with dealing with the USB interface and would greatly appreciate it if someone could tell

Re: Classes and threading

2010-05-19 Thread Adam W.
On May 19, 4:30 am, Gregory Ewing wrote: > Or if you do need to override it for some reason, you > need to accept the extra args and pass them on: > >    class nThread(threading.Thread): > >        def __init__(self, *args, **kwds): >            threading.Thread.__init__(self, *args, **kwds) >    

Re: Classes and threading

2010-05-19 Thread Adam W.
On May 19, 12:04 am, Erik Max Francis wrote: > Adam W. wrote: > > I thought I knew how classes worked, but this code sample is making my > > second guess myself: > > > import threading > > > class nThread(threading.Thread): > >     def __init__(self): >

Classes and threading

2010-05-18 Thread Adam W.
I thought I knew how classes worked, but this code sample is making my second guess myself: import threading class nThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self,args): print self.name print self.args pants = nThread(a

urllib, can't seem to get form post right

2009-09-24 Thread Adam W.
I'm trying to scrape some historical data from NOAA's website, but I can't seem to feed it the right form values to get the data out of it. Heres the code: import urllib import urllib2 ## The source page http://www.erh.noaa.gov/bgm/climate/bgm.shtml url = 'http://www.erh.noaa.gov/bgm/climate/pic

Re: two's complement bytes

2008-08-23 Thread Adam W.
On Aug 24, 1:11 am, castironpi <[EMAIL PROTECTED]> wrote: > On Aug 23, 11:52 pm, "Adam W." <[EMAIL PROTECTED]> wrote: > > > > > > > On Aug 24, 12:23 am, castironpi <[EMAIL PROTECTED]> wrote: > > > > Try this out.  Does it come clo

Re: two's complement bytes

2008-08-23 Thread Adam W.
On Aug 24, 12:23 am, castironpi <[EMAIL PROTECTED]> wrote: > Try this out.  Does it come close to what you want? > > import struct > struct.pack( 'i', ~10 ) > ~struct.unpack( 'i', _ )[ 0 ] > > > > > > >>> import struct > >>> struct.pack( 'i', ~10 ) > '\xf5\xff\xff\xff' > >>> ~struct.unpack( 'i', _

two's complement bytes

2008-08-23 Thread Adam W.
I'm dabbling with AVR's for a project I have and that means I have to use C (ageist my will). Because my AVR will be tethered to my laptop, I am writing most of my logic in python, in the hopes of using at little C as possible. In my quest I came across a need to pass a pair of sign extended two'

Unicode characters, XML/RSS

2008-07-30 Thread Adam W.
So I wrote a little video podcast downloading script that checks a list of RSS feeds and downloads any new videos. Every once in a while it find a character that is out of the 128 range in the feed and my script blows up: Traceback (most recent call last): File "C:\Users\Adam\Desktop\Rev3 DL\Re

Re: Python seems to be ignoring my except clause...

2008-02-19 Thread Adam W.
On Feb 19, 8:49 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > The example you posted isn't complete and while I can easily expand it to a > working example it will unfortunately be a working example. > > Try cutting it down yourself to a minimal self-contained example that you > can post. 99% of th

Python seems to be ignoring my except clause...

2008-02-19 Thread Adam W.
I am trying to handle a Unicode error but its acting like the except clause is not even there. Here is the offending code: def characters(self, string): if self.initem: try: self.data.append(string.encode()) except:

Re: Dont know what my class is called...

2008-02-17 Thread Adam W.
On Feb 17, 6:12 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > It's a bit hard to get what you are after, but maybe this solves your > problem? > > handler = FeedHandler() > > parse(handler) > > print handler.my_instance_variable_of_choice > > The above assumes that my_instance_variable_of_cho

Dont know what my class is called...

2008-02-17 Thread Adam W.
I am using the xml.sax package, and I'm running into a little problem. When I use the parse(url, ContentHandler()) method, I don't know what parse() is naming the instance of ContentHandler. I have a sub-class of ContentHandler make a dictionary of what it parses, but the problem is I don't know

How do I use SendInput in Python?

2008-02-16 Thread Adam W.
I'm at the last stage of my project and the only thing left to do is trigger a mouse click. I did some searching around for example code and stumped upon SendInput http://msdn2.microsoft.com/en-us/library/ms646310.aspx . However I was not able to find example code for python USING SendInput, and

Easy PIL question

2008-02-16 Thread Adam W.
I know there is an easy way to do this, but I can't figure it out, how do I get the color of a pixel? I used the ImageGrab method and I want to get the color of a specific pixel in that image. If you know how to make it only grab that pixel, that would also be helpful. Basically I'm trying to mak

Re: Broke my IDLE!

2008-02-05 Thread Adam W.
, Chris <[EMAIL PROTECTED]> wrote: > On Feb 5, 7:05 pm, "Adam W." <[EMAIL PROTECTED]> wrote: > > > > > > > Tried running IDEL from the command prompt to get this: > > > Traceback (most recent call last): > >   File "c:\Python2

Re: Broke my IDLE!

2008-02-05 Thread Adam W.
Tried running IDEL from the command prompt to get this: Traceback (most recent call last): File "c:\Python25\Lib\idlelib\idle.pyw", line 21, in idlelib.PyShell.main() File "c:\Python25\lib\idlelib\PyShell.py", line 1404, in main shell = flist.open_shell() File "c:\Python25\lib\idlel

Broke my IDLE!

2008-02-05 Thread Adam W.
I did a stupid thing and "wrote in" under the advance key bindings section, and after hitting apply I got a load of exceptions. Now my shell wont open and my IDEL wont start anymore I uninstalled and reinstalled Python with no luck, the whacked settings must be lingering around somewhere. I

Urllib keyerror, confused

2008-02-02 Thread Adam W.
I took this script: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/83208 And decided to try it out, it works when I first download a file, and when I try to resume a downloaded file, but if the file is already downloaded, and I expect to see the print "File already downloaded" message com

Re: Who told str() to round my int()'s!!!

2007-08-11 Thread Adam W.
On Aug 11, 12:53 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > If `str()` would not round you would get very long numbers because of the > inaccuracies of floating point values. I know Python is lying when 0.1 > prints as 0.1, but do you really want to see > 0.155511151

Who told str() to round my int()'s!!!

2007-08-11 Thread Adam W.
After a fair amount of troubleshooting of why my lists were coming back a handful of digits short, and the last digit rounded off, I determined the str() function was to blame: >>> foonum 0.0071299720384678782 >>> str(foonum) '0.00712997203847' >>> Why in the world does str() have any business ro

Easy question: More items in a For loop?

2007-04-05 Thread Adam W.
I'm trying to write a script that will parse IRC chat logs and color code them if it finds certain characters. I was able to make this work with one character, but to make it even more accurate I would like to use two identifying characters. Here is my code : import urllib2 response = urllib2.u