[Tutor] Careful Dictionary Building

2007-12-28 Thread doug shawhan
I'm building a dictionary from a list with ~ 1M records. Each record in the list is itself a list. Each record in the list has a line number, (index 0) which I wish to use as a dictionary key. The problem: It is possible for two different records in the list to share this line number. If they do,

Re: [Tutor] Careful Dictionary Building

2007-12-28 Thread doug shawhan
*sigh* Ignore folks. I had forgotten about .has_key(). On Dec 28, 2007 11:22 AM, doug shawhan <[EMAIL PROTECTED]> wrote: > I'm building a dictionary from a list with ~ 1M records. > > Each record in the list is itself a list. > Each record in the list has a line number,

Re: [Tutor] Tutor] Careful Dictionary Building

2007-12-28 Thread doug shawhan
Lots of very good answers to a pretty stupid question! *blush* I guess there is more than one way to do it! Uh ... guys? Did I say something wrong...? On Dec 28, 2007 12:23 PM, Tony *** <[EMAIL PROTECTED]> wrote: > Hello Doug, > > You can also use exceptions instead of the if /else. It has mo

[Tutor] Scan Codes, Character Sets: Any Modules?

2006-04-11 Thread doug shawhan
The difficulty I have may or may not be something that may be easily handled with pyserial and some other mystery module.  I am attempting to screen scrape SuperDOS, an extremely closed system that uses wyse 60 terminals to communicate with a dos machine. I have not been able to communicate prope

Re: [Tutor] unpack/regexp

2006-04-11 Thread doug shawhan
I always slice the string  in this sort of situation: s = "12345678901234567890123456789012 " t = s[:10],s[10:20],s[20:-1]     print t ('1234567890', '1234567890', '123456789012') One could always bracket it to make a list or whatever. Hope this helps! On 4/11/06, Paul Kraus <[EMAIL PROTECT

Re: [Tutor] Scan Codes, Character Sets: Any Modules?

2006-04-11 Thread doug shawhan
Oho! http://www.wyse.com/service/support/kbase/Keydetl1.asp?Q=7&R=6 has the hex codes! Thanks! Perhaps this will fix what ails me.On 4/11/06, doug shawhan <[EMAIL PROTECTED]> wrote: Yeah, termca was were I looked first. The OpenBSD 3.8 termcap shows: :cr=^M:ct=\E0:dc=\EW:dl=\ER:do

Re: [Tutor] Scan Codes, Character Sets: Any Modules?

2006-04-11 Thread doug shawhan
No luck. I think I am missing something utterly basic, and completely unrelated to python. :-) I'll quit filling everyone's mailbox with cheese and move on to a terminal newsgroup for my future pesterances. Thanks for the help folks!On 4/11/06, doug shawhan <[EMAIL PROTECTED]>

[Tutor] Raw Bits! (Control characters ahoy!)

2006-04-17 Thread doug shawhan
I am in the middle of a project that requires me to send and retrieve information from a machine connected to a serial port. My problems are these: 1. I cannot send control characters 2. I cannot read data streaming from the serial port I have been doing fine with: os.system("echo '5' >/dev/tty

[Tutor] Brain In Vice: Why is this so fun to me?

2006-04-19 Thread doug shawhan
I think I'm going to have to suck it up and learn some regular expressions. I have finally gotten my script (using the excellent pyserial module) to behave. Most of my troubles as enumerated here before were utterly self-induced. Apparently one cannot watch the execution of one's script through an

Re: [Tutor] Brain In Vice: Why is this so fun to me?

2006-04-21 Thread doug shawhan
be escapedin regex strings.Namely, these ones - .^$*+?{[|( That second to last one is a pipe by the way, not an I.And * is very greedy, but a ? limits it's greediness greatly.Good luck,Liam ClarkeOn 4/21/06, doug shawhan <[EMAIL PROTECTED] > wrote:> I am discovering that. They tend to get all A

[Tutor] SOAP Modules - I need a little direction.

2006-04-26 Thread doug shawhan
I am in preparation mode for creating a script which uses SOAP. I have been looking at the various SOAP modules: soapy, soap.py, ZSI, pywebsvcs. I'm very confused as to the status of these projects. Most seem to be only partially supported, if not abandoned completely. Thre appears to have been a

Re: [Tutor] SOAP Modules - I need a little direction.

2006-04-27 Thread doug shawhan
protocol. Reading the official SOAP documentation has been like licking the hoof of a very angry mule. But if you gotta, you gotta!On 4/26/06, Kent Johnson <[EMAIL PROTECTED]> wrote: doug shawhan wrote:> I am in preparation mode for creating a script which uses SOAP.>> I have been looking

Re: [Tutor] SOAP Modules - I need a little direction.

2006-04-27 Thread doug shawhan
would like to have the whole shebang on one computer and not worry about making sure my hosting provider is using the same version of as I am developing with ... I'm just chicken, I guess. :-) On 4/27/06, Kent Johnson <[EMAIL PROTECTED]> wrote: doug shawhan wrote:> The problem

Re: [Tutor] SOAP Modules - I need a little direction.

2006-04-27 Thread doug shawhan
=1" to the requests. *blush* Ah well, not the first time I have dined on my foot on this mailing list! (Memo to self, stock up on ketchup)On 4/27/06, doug shawhan < [EMAIL PROTECTED]> wrote:The https/XML API is deprecated and will no longer be supported after the first of June. :-/ The re

[Tutor] python cgi and html streams

2006-05-05 Thread doug shawhan
I've been a-googling for examples or information on recieving and parsing html streams in a cgi script. I need to send a request like: ''http://www.foo.com/cgi-bin/responder.cgi?foo=hi&bar=there&bat=buddy&identifier=myname" to a remote server which will then stream a response to my script, simil

Re: [Tutor] python cgi and html streams

2006-05-06 Thread doug shawhan
On 5/5/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > I was hoping for something magical like:>> gulp = cgi.StreamIO("> http://www.foo.com/cgi-bin/responder.cgi?foo=hi&bar=there&bat=buddy ").read()>> ... but for some reason not one of the python creators foresaw that I might> one day need them to do al

[Tutor] Drifting Values in urllib.

2006-05-06 Thread doug shawhan
I am having difficulty inderstanding urllib's handling of values passed to it. I assign values from cgi.FieldStorage() thusly: if form.has_key("id"):     id = form["id"].value     if form.has_key("origin"):     origin = form["origin"].value     if form.has_key("dest"):     dest = form["dest"].

[Tutor] partial string matching in list comprehension?

2006-05-25 Thread doug shawhan
I have a series of lists to compare with a list of exclusionary terms. junkList =["interchange",  "ifferen", "thru"] The comparison lists have one or more elements, which may or may not contain the junkList elements somewhere within: l = ["My skull hurts", "Drive the thruway", "Interchangabili

[Tutor] XML Parsing Woes.

2006-05-31 Thread doug shawhan
Having been dragged kicking and screaming into the fussy, fussy world of XML, I find myself in a pickle. I keep getting an error complaining of a missing end-tag:  : XML Parse error. XML Error Text: "; nested exception is:     org.xml.sax.SAXParseException: The element type "Description" mus

[Tutor] Offtopic observation

2006-06-07 Thread doug shawhan
This marks the third time this week I have been typing in a question for the group, and have made the answer apparent just by trying to explain my question clearly. This suggests that either I think better in text, or Proust was onto something ... but then again, I majored in english.

[Tutor] errno vs. sys.exc_info

2006-06-09 Thread doug shawhan
I am in need of a clear way to return exceptions within a try loop. I have been looking at both errno and sys.exc_info. I know that using errno is not encouraged in threaded programs, but this is no big deal for my purposes. I found a good, clear example for translating the rather cryptic output

[Tutor] XML: Expletive Deleted

2006-06-09 Thread doug shawhan
I realize XML is going to save us all from something or other, but I just can't get my head around it. I have been trying to do what should be a very simple action: Extract values from element tags. I first grab my data from a website with httplib: >> connection = httplib.HTTPSConnection(serve

Re: [Tutor] XML: Expletive Deleted

2006-06-12 Thread doug shawhan
Kent, Danny, Lawrence, et. al. Thanks! I was kind of cringing as I sent this plaint/rant, but it seems I'm not the only one who has had trouble grokking DOM. I spanked the problem temporarily with regex, but can now actually fix it properly. Appreciate all the help!On 6/10/06, Kent Johnson <[

[Tutor] datetime: What happended yesterday? :-)

2006-06-12 Thread doug shawhan
I've been looking at datetime and cannot figure out what was a very simple operation with the time module. How does one add or subtract 24 (or any number) of hours from a given date and time using the datetime module? ___ Tutor maillist - Tutor@pytho

Re: [Tutor] datetime: What happended yesterday? :-)

2006-06-12 Thread doug shawhan
Heh. Your example would look very, very nice in the timedelta (http://docs.python.org/lib/datetime-timedelta.html) section of the docs! :-) It makes perfect sense, the authors probably thought it was too easy to need an explaination ...On 6/12/06, Kent Johnson < [EMAIL PROTECTED]> wrote:doug shawh

Re: [Tutor] die or exit function?

2006-06-14 Thread doug shawhan
Hi Andy, Putting a try:/except: loop in your __main__() (or whatever you call your base function) with sys.exit("Message") is pretty much the way I always do it. try: gak = puke + die except: sys.exit("Oy!") If you would like sys.exit() to provide you with a bit more information (like wh

Re: [Tutor] How to make the loop work?

2006-06-22 Thread doug shawhan
Hi Bob, You can use a while loop in this case, but range() might be a bit more appropriate! c = 0 d = raw_input("Enter Number Limit: ") for i in range(int(d)): #note, we make sure "d" is an integer!     c = c + 1     print cOn 6/22/06, Bob Gailer <[EMAIL PROTECTED]> wrote: Ivan Low wrote:> Hi, I

Re: [Tutor] python text adventures question

2006-09-29 Thread doug shawhan
I got a copy of Creating Adventure Games on Your Computer in the mail yesterday. Very fun! I set up a moodle class for the project. It seems like a good way to do such a thing. http://crackrabbit.com/moodle/ I realize that I am probably not anyone's idea of a programming howto writer, but hey!

Re: [Tutor] python text adventures question

2006-09-29 Thread doug shawhan
Whoops, the password is 'ascii'. :-) Guess I could just take that off, couldn't I? On 9/29/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: doug shawhan wrote:> I got a copy of Creating Adventure Games on Your Computer in the mail > yesterday.>> Very fun! I set

[Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-25 Thread doug shawhan
I'm having a rather difficult time understanding the proper use of "self". I have two functions (yes, they are ugly, I was getting ready to split them in to smaller bits when this particular hole in my skull opened up) in a module. They use the same list of dictionaries to create some tables in a

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-26 Thread doug shawhan
On 10/25/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: >> I'm sure this is so obvious that a crack-addled tapeworm head down in> a bucket of stupid could understand it, unfortunately, I'm not quite> at that level today. Sorry.Uh, I don't understand why you're passing Fields to the functions but

[Tutor] Fwd: Self, Scopes and my unbelievable muddleheadedness.

2006-10-26 Thread doug shawhan
-- Forwarded message --From: doug shawhan <[EMAIL PROTECTED]>Date: Oct 26, 2006 1:45 PM Subject: Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.To: Alan Gauld <[EMAIL PROTECTED]> On 10/26/06, Alan Gauld <[EMAIL PROTECTED]> wrote: "doug sha

Re: [Tutor] Help with Elementtree ...how to access the attributes..

2006-11-10 Thread doug shawhan
I'm having some difficulties with elementtree as well. I'm attempting to parse a fairly sizeable xml file (it's the ebay "category tree" report. I've cached a copy at http://www.crackrabbit.com/misc/CatTree.xml). 900K or so! :-) For some reason I'm unable to read any elements from the file. I hav

Re: [Tutor] Help with Elementtree ...how to access the attributes..

2006-11-10 Thread doug shawhan
Ah. Apparently, the string xmlns="urn:ebay:apis:eBLBaseComponents" is causing some sort of outfreakage. I'm not well versed in xml lore: is the "urn:" tag out of context here? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinf

Re: [Tutor] Help with Elementtree ...how to access the attributes..

2006-11-13 Thread doug shawhan
Oho! Thanks, Kent (and everyone else.) That clears up some things. The link has some embarassment reducing info as well. :-)On 11/11/06, Kent Johnson < [EMAIL PROTECTED]> wrote:doug shawhan wrote:> I'm having some difficulties with elementtree as well. >> I'm attempting to parse a fairly sizeable x

Re: [Tutor] free IDE for Python?

2006-11-16 Thread doug shawhan
I know it's merely a text editor, but for any non-gui stuff I use SciTE. The little execution pane is gawgeous, gawgeous, gawgeous. (Though I find it best to use at least a 19" monitor! ) On 11/15/06, Chris Hengge <[EMAIL PROTECTED]> wrote: BTW... that also counts as my vouce for using SPE =D

Re: [Tutor] wrapping a command line tool

2006-12-15 Thread doug shawhan
Actually, I've had excellent results with pyserial. http://pyserial.sourceforge.net/ I've used it to write a screen-scraping tool. It comes with a little demo terminal program that shows many interesting ways to fiddle about with the module. I use it in conjunction with the wy60 emulator on Open

[Tutor] Regular expressions - Ignoring linefeeds

2007-03-02 Thread doug shawhan
I've been looking through various sites, but cannot find the magic button that allows me to match a string with linefeeds I'd rather not strip out the linefeeds, then stick them back in. :-) I'm attempting something that should be fairly simple: snippy = re.compile('Hi there.*Bye there.') s = '