Re: [Tutor] Web programming advice

2008-09-19 Thread Chad Crabtree
Things you need to know. In order * HTML * Javascript * CGI Webscripting, this teaches you the difference between GET and POST, with this you can make simple things, like a page view counter for example, or a simple game of hangman. * Web framework or Templating language, python is not

Re: [Tutor] ways to sync databases with Python and SQLite?

2008-09-10 Thread Chad Crabtree
One way to work around this and still use SQLight is to put the database on a shared drive. SQLight does table locking, or is it file locking. Anyways conflicts will be very minimal to non-existant with only two clients as most operations will complete in microseconds. The SQLight website even

Re: [Tutor] Is there python editor or plugin for a python editor for curly brackets around code blocks?

2008-08-13 Thread Chad Crabtree
Oh, I forgot there's another way to add braces if it_is_way_cool: #{ print 'coolness' #} On Wed, Aug 13, 2008 at 11:06 PM, xbmuncher [EMAIL PROTECTED] wrote: I'll check out your links. But in response to some of the things said: I'm a fan of indentation, a replacement of indentation with

Re: [Tutor] What has Editor X got that PyWin32 hasn't?

2008-08-12 Thread Chad Crabtree
Well I would imagine that many of the programmers here use emacs or vim. I use vim, however I've used komodo for python and I liked it a lot. However if you are going to program a great deal (I don't' know what your intentions are) then I recomend taking the 20-40 hour it takes to learn emacs or

Re: [Tutor] I need a Python mentor

2008-08-08 Thread Chad Crabtree
Actually the way this list works is there is no one person who will do this. However if you pose a specific question I'm sure you will get several helpful people will respond. Like this. What book did you read and what topics did it cover? From there someone perhaps even myself will be able to

Re: [Tutor] Communication between threads

2008-07-31 Thread Chad Crabtree
This is a great suggestion. I too learned how to do threading in python from reading code. For me I read the btdownloadheadless.py code. Which comes as part of the standard bittorrent client in linux. On Thu, Jul 31, 2008 at 7:11 AM, Monika Jisswel [EMAIL PROTECTED] wrote: I'm looking for

Re: [Tutor] confusing HTTP error while using urlopen

2008-07-18 Thread Chad Crabtree
Well I can confirm this behavior. I tried changing the user-agent thinking there might be some filtering based on that but no go. Still HTTP 400 error. WGET works just fine though On Fri, Jul 18, 2008 at 4:31 PM, asdg asdg [EMAIL PROTECTED] wrote: I'll skip the introduction and go right to the

Re: [Tutor] Trying to extract the last line of a text file

2006-10-19 Thread Chad Crabtree
On 10/19/06, Chris Hengge [EMAIL PROTECTED] wrote: I'd personally do something like this. file = open(myfile, 'r')fileContents = file.readlines() # read the entire document into memory for speed.file.close()print fileContents[-1] # This is the last line. This works as

Re: [Tutor] simple question about numeric types

2006-05-08 Thread Chad Crabtree
I think isinstance() is probably the best way to do this. I however always do type(x)==TestType: where TestType is a string that is returned from type() or not what ever the case. On 5/8/06, Emanuele Rocca [EMAIL PROTECTED] wrote: Hello list, I've got a question partially related to this

Re: [Tutor] web intefaces?

2006-05-08 Thread Chad Crabtree
While everything that Alan Guald said is true, there are a couple of options for you. Provided you know HTML (you must), you could generate html pragmatically but, knowledge of html is still mandatory. Your options are, basically http://www.cherrypy.org Which is an app server that should be

Re: [Tutor] Books

2006-05-03 Thread Chad Crabtree
I have learend a great deal of python, and I have never bought a book. All the information one really needs is available freely on the internet. As long as you understand the basic data types you should be able to piece together what you need from the internet.

Re: [Tutor] Bitten by lexical closures

2006-05-03 Thread Chad Crabtree
Are you just trying to make a continuation? On 5/3/06, Igor [EMAIL PROTECTED] wrote: Hi. And I thought I understood python pretty well. Until I got hit by this: def f(x): ... print x cb = [lambda :f(what) for what in 1234] for c in cb:c() 4 4 4 4 And even this works what =

Re: [Tutor] database app

2005-06-18 Thread Chad Crabtree
Well when working with M$ db's you should use odbc. http://www.egenix.com/files/python/mxODBC.html nephish wrote: Hey there, i have used the cgi module and dig it. heres the deal, my employer wants me to build a dynamic website that will access a database and display customer

Re: [Tutor] Checking if value exist in a '2D array'

2005-06-17 Thread Chad Crabtree
Kent Johnson wrote: Olli Rajala wrote: Hi again, I have a '2D array', I mean a list inside a list ([[][],[][],...]) and would need to check if the value exists in it. Of course I could do a for loop, but that just seem to be a little overkill, so is there any other way to do it? I have to

Re: [Tutor] test

2005-06-17 Thread Chad Crabtree
How about this. from random import choice alist=[choice(range(100)) for x in range(1000)] #just making a list to look at pretend this is a file counter={} for item in alist: ... if item in counter.keys(): ... counter[item]+=1 ... else: ... counter[item]=1 ...

Re: [Tutor] test

2005-06-17 Thread Chad Crabtree
Asif Iqbal wrote: On Fri, Jun 17, 2005 at 07:41:17AM, Chad Crabtree wrote: How about this. from random import choice alist=[choice(range(100)) for x in range(1000)] #just making a How do I do this in python? alist /tmp/logfile The logfile has the list of entries. ok sorry

Re: [Tutor] Py2exe (Joseph Q.)

2005-04-05 Thread Chad Crabtree
The symptoms you explain mean you don't have py2exe installed correctly. Try uninstalling it and reinstalling it. Joseph Quigley wrote: Joseph Q. (Uspantan, Guatemala) Using Python 2.4 I downloaded py2exe and can't get it to make exe's of my python files. There are a list of

Re: [Tutor] A Pythonic LinkedList Implementation

2005-03-28 Thread Chad Crabtree
I'm at a loss as to why this is helpful. How and why would one use this instead of a regular list? I know what linked lists are and why they would be useful in C++ or C or any other but not python. Orri Ganel wrote: Hello all, I've been working on making a complete pythonic LinkedList

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-07 Thread Chad Crabtree
Alan Gauld wrote: ie No lambda used at all. I wish Python had real lambdas! If python had real lambda's then it would be lisp or schema. __ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more.

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-06 Thread Chad Crabtree
Jacob S. wrote: aFuncList=[] def x(): print one aFuncList.append(x) def x(): print two aFuncList.append(x) def x(): print three aFuncList.append(x) for item in aFuncList: item() Okay, for this problem (it can be altered otherwise) def makefunct(stri): def x():

Re: [Tutor] Re: This Deletes All my Files

2005-02-04 Thread Chad Crabtree
Thank you all for answering my question. I thought it would be some misunderstanding on my part. The example Andrei made was very telling. Andrei wrote: s = d:/tests/test.txt class dummyfile(object): ... def open(self, *args): ... print dummyfile.open:, args ... def

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-04 Thread Chad Crabtree
Max Noel wrote: According to the Jargon file, this one is called Whitesmiths style. I tend to use Allman style myself, but given the code completion, spellchecking, etc. in modern IDEs, I suspect it's become more a question of personal preference than anything else. A bit like

Re: [Tutor] files in a directory

2005-01-30 Thread Chad Crabtree
Well in the same vein as what the others put out there I made a verbose 'ls *.ext' so that you can see how to do it in one go. I figured this would give you enough of an example. You can hard code these things into your program. I used a construct similar to this to create an instant html

[Tutor] Syntax Check

2005-01-27 Thread Chad Crabtree
Does anyone happen to know how to turn of the syntax checking in python? I've been working on a module driven preprocessor but I'd like to not have to use comment strings. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection

Re: [Tutor] Syntax Check

2005-01-27 Thread Chad Crabtree
Well I don't think that it would really require that. I could just define macro's in a module and just do it like so import macro import defined_macros as m macro.expand(m.with(),m.assert()) I just thought it would be best to have definitions at the head of a script, or at least to have the

Re: [Tutor] New to Python

2005-01-26 Thread Chad Crabtree
I too once had trouble remembering (and finding) the name of this library so here it is. http://www.tizmoi.net/watsup/intro.html I have not used it but the documentation by example, seemed to me to be approachable. Tony Meyer wrote: There's a Python library for controlling Windows in this sort

Re: [Tutor] Preffered way to search posix filesystem

2005-01-26 Thread Chad Crabtree
Try the os module. I think this should probably get you there. http://docs.python.org/lib/module-os.html Miles Stevenson wrote: I would like to search filesystem structures using globs on Posix systems from within Python. I don't see an obvious method to do this with in the standard modules.

Re: [Tutor] Unique Items in Lists

2005-01-26 Thread Chad Crabtree
Ok. I think I understand and I happen to be up at 1:30 my time so here is the solution as I understand the problem. This is a very common problem and has a fairly easy solution. You can then take adict.keys() which returns a list of unique elements. Good Luck import random

Re: [Tutor] ascii encoding

2005-01-24 Thread Chad Crabtree
I got this from spyce http://spyce.sourceforge.net _url_ch = re.compile(r'[^A-Za-z0-9_.!~*()-]') # RFC 2396 section 2.3 def url_encode(o, **kwargs): '''Return URL-encoded string.''' return _url_ch.sub(lambda match: %%%02X % ord(match.group(0)), str(o)) It was just the first thing I found in

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Chad Crabtree
I can't really think of a more elegant solution than what you have, maybe regex's but I hate those. You *can* reduce the number of lines by two, and there was a variable you never used. HTH Eric L. Howard wrote: The following block of code works, and provides the necessary output I'm looking

[Tutor] file-like object

2005-01-14 Thread Chad Crabtree
I have created a file-like object out of a triple quoted string. I was wondering if there is a better way to implement readline than what I have below? It just doesn't seem like a very good way to do this. class _macroString(object): def __init__(self,s): self.macro=s

Re: [Tutor] Referer file from import

2005-01-14 Thread Chad Crabtree
probably figure out who is importing you. Do you really want the module where the import was done (the place where the import statement is)? Or are you trying to find the file containing the imported module? Kent Isr Gish wrote: Chad Crabtree wrote: Is there a way to know what the path

Re: [Tutor] file-like object

2005-01-14 Thread Chad Crabtree
Thank you KentBot. That was what I wanted. Kent Johnson wrote: Best: use the StringIO or cStringIO module instead, this is exactly what it is for. If you really need len() you could maybe subclass StringIO to do what you want. Next best: Use an iterator. Something like this (Warning! not

[Tutor] Referer file from import

2005-01-13 Thread Chad Crabtree
Is there a way to know what the path of the file is that imported a module? I've tried __file__ and playing with globals() but I can't seem to crack this. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around

Re: [Tutor] flattening a list

2005-01-12 Thread Chad Crabtree
The only problem with this if it is to big or to deeply nested then it will overflow the stack? Mario Rol wrote: nice and concise, found on comp.lang.python: def flatten(a): if not isinstance(a,(tuple,list)): return [a] if len(a)==0: return [] return flatten(a[0])+flatten(a[1:])

Re: [Tutor] Input to python executable code and design question

2005-01-10 Thread Chad Crabtree
Ismael Garrido wrote: [EMAIL PROTECTED] wrote: Quoting Ismael Garrido [EMAIL PROTECTED]: I am trying to make a program that will plot functions. For that, I need to be able to get an input (the function to be plotted) and execute it. So you want the user to be able to type

Re: [Tutor] German Tutorials auf Deutsch

2005-01-08 Thread Chad Crabtree
Jacob S. wrote: ## Spoken by Ara ## Pardon to the non-german speaking (or readers) on the list. Guten Tag. Mein Deutsch ist nicht so gut (ich habe keinen Deutsche in sieben Good Day. My German is not so good (I have writen very little german in seven years) Jahren geschreiben). Mann kann

Re: [Tutor] Nifty

2004-12-18 Thread Chad Crabtree
I think it's a great idea, I would like to participate also. Brian van den Broek wrote: Jacob S. said unto the world upon 2004-12-18 21:06: I probably wouldn't be any help on projects, but I would probably learn stuff from it. I'm okay with it. Jacob Schmidt I just got in contact with