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 we

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 s

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 s

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] Configuration File Pattern

2008-07-21 Thread Chad Crabtree
What I use in this situation is the INI config file parser in the standard lib. It's easy to use ##CONFIG FILE [paths] images=/home/user/Images ##CODE### import ConfigParser config=ConfigParser.ConfigParser() config.readfp(open(conf,'r')) print config http://docs.python.org/lib/module-Con

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 t

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 wellfile('filename.txt').rea

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 fair

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 t

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

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] Search and Replace

2005-06-24 Thread Chad Crabtree
Reed L. O'Brien wrote: >I ma trying to write a script to search adn replace a sizable chink of >text in about 460 html pages. >It is an old form that usesa search engine no linger availabe. > Well in the vein of Kents suggestion there is http://www.crummy.com/software/BeautifulSoup/ however it wi

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] 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 i

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[i

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

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 instructi

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. http://info.mail.yahoo.co

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

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

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

[Tutor] This Deletes All my Files

2005-02-03 Thread Chad Crabtree
I've tried this and I cannot figure out why this does not work. I figure this has something to do with order of operations. I figured someone would know exactly why it doesn't work. Wouldn't this start inside parens then from left to right? open(item,'w').write(open(item,'r').read().replace(

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

2005-02-03 Thread Chad Crabtree
How about a concrete example where lambda is more elegant than a named block of code aList=['a','bb','ccc','','ee'] bList=aList[:] #deep copy assert not bList is aList def sortByLength(item1,item2): return cmp(len(item1),len(item2)) bList.sort(sortByLength) assert bList==['a', 'bb', 'ee

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 ph

Re: [Tutor] Re: Syntax Check

2005-01-27 Thread Chad Crabtree
I'm going to look more in to import hooks. I am only looking for syntactic sugar, at least at this point. It's not really my ambition to make more efficient code. To Ryan. I looked at COG before (not in this case but general looking at python packages) it doesn't really do what I was thinki

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 o

Re: [Tutor] Unique Items in Lists

2005-01-27 Thread Chad Crabtree
Try a simple bubble sort. This will not have great performance on big files at a worst case scenario it will take n-1 loops to sort. This is not very general and would require a substantially different implementation. def bublesort(l1,l2,l3): modified=True while modified: modif

Re: [Tutor] Syntax Check

2005-01-27 Thread Chad Crabtree
Ok I'll explain what I've done so far. I'm using tokenize to take the file that imports macro; found by using stack inspection and then tokenize it. I look at all the string tokens to see if they match they pattern a macro should have. Then I pass the macro string through the tokenizer agai

Re: [Tutor] Syntax Check

2005-01-27 Thread Chad Crabtree
I'm trying to make a macro system that's work by just doing this import macro class withMacro(prefixMacro): pass mac=withMacro() mac.pattern("item key") macro.expand() g=[] """ with g: .append('a') .append('b') .append(123) """ I would like to not have to use the comment strings

[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] Re: Unique Items in Lists

2005-01-27 Thread Chad Crabtree
Ok you got me thinking. I used the same thing I posted before but created a one liner that as a side affect makes adict like before. [adict.__setitem__(x,adict.get(x,0)+1) for x in l] I think it's kinda funny and ugly, ohh and not particuarly clear about what it does. Wolfram Kraus wrote: > g

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 l=[random.randra

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] 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] 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] How would python messure up in performance?

2005-01-23 Thread Chad Crabtree
Kevin wrote: >Thanks for the advise. I am no ware near ready to do this as i am just > >learning to use python. I just thought it would be interesting to see > >a mud made in python rather then always in C or C++. So for now I am > >only going to start out making small programs to learn with. So t

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Chad Crabtree
I was thinking (it's been a while since I played) that I would do it like this. (strawman code) class Character: def __init__(self,name,attribs,skills,cyberware): ...initialize.. and code to check attrib and skill mins and maxes physical and menatl attributes should be part

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

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Chad Crabtree
Jack Cruzan wrote: >class Character: > > def __init__(self, name = ' ', race = 'Human', magic = 'None'): > > self.name=name > > self.race=race > > self.magic=magic > > I know your going to need some other stuff. class NewCharacter(Character):

Re: [Tutor] py2exe

2005-01-17 Thread Chad Crabtree
Right what he said. I'm sorry I didn't make that clear. This way py2exe can look and see import Tix and see it's needed. Py2exe does not ship the whole python distribution, rather only what is needed. Indeed it tends to ship many things that are not needed but it's better than the whole dis

Re: [Tutor] py2exe

2005-01-16 Thread Chad Crabtree
Try something like. import mx import Tix Sometimes py2exe will not gather up all the modules that it depends on. It does an admirable job but still needs some help. Perhaps you are in advertently using mx? Well try that and see what happens. Guillermo Fernandez Castellanos wrote: >Hi, > >

Re: [Tutor] file-like object

2005-01-14 Thread Chad Crabtree
Danny Yoo wrote: >Using the default parameter 'n' in the readline() method isn't safe: all >class instances will end up using the same 'n'. You may want to put the >current line number as part of an instance's state, since two instances of >a macroString should be able to keep track of their line

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!

Re: [Tutor] Referer file from import

2005-01-14 Thread Chad Crabtree
rted module you could > 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: > &g

[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 self.l

[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 http://ma

Re: [Tutor] flattening a list

2005-01-13 Thread Chad Crabtree
You should post this on the Python Cookbook http://aspn.activestate.com/ASPN/Python/Cookbook/ Orri Ganel wrote > Bill Kranec wrote: > > > >> Hello, > > >> > >> I have a list of lists, for example [ [1,2] , [3,4] ], and I would > > >> like to pass all the elements of that list as arguments to a f

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[

Re: [Tutor] Slightly OT - Python/Java

2005-01-10 Thread Chad Crabtree
I just wanted to let everyone know a detail about Jython. It is not in fact an interpreter written in Java it is a dynamic Python to JavaByteCode compiler. At least that's how I understand this document. http://www.jython.org/applets/issues.html I found this interesting and I thought you all

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

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

Re: [Tutor] Breaking down integers?

2005-01-04 Thread Chad Crabtree
aint=1077 list_of_aint_as_string=list(str(1077)) print list_of_aint_as_string #['1', '0', '7', '7'] #turn it into a list of integers #doc for map() found on http://docs.python.org/lib/built-in-funcs.html list_of_aint_as_integer=map(int,list_of_aint_as_string) print list_of_aint_as_integer #[1, 0, 7

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

Re: [Tutor] Lock down windows with python+usb

2004-12-09 Thread Chad Crabtree
Asif Iqbal wrote: >Hi All > >Has anyone done any script like this? Use a python script for Windows XP >that will continuosly check if my USB is plugged in. So if I unplug my >USB flashdrive it will fork a screensaver with password lock. > >Thanks for any idea/suggestion > > > You could make scre

Re: [Tutor] CGI Video collection application File I/O troubles

2004-12-06 Thread Chad Crabtree
Olli Rajala wrote: > > > >>Ok. I tried running the script on my Apache server on Windows NT and IT >>WORKS The script saves the values of videodb keys correctly. DARN!!! >>I don't get it. Why does the exact same script work on Win and not on Linux. >> >>Oh, did I mention I am developing the

Re: [Tutor] Simple RPN calculator

2004-12-06 Thread Chad Crabtree
Bob Gailer wrote: > For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as input > and prints -0.0481481 8 lines of Python. That indeed is less than > 100. Took about 7 minutes to code and test. I'm quite interested in seeing the sourcecode for that. __