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.





__ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


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 application on Linux. And now
I tried
>>it on Win XP with Apache and it works. On Linux I have httpd too.
>>
>>
>
>Have you triplechecked that you really can write to the file. I
don't
>know how python would react, if you can't write to the file (raise
>IOError perhaps) but it doesn't cost you anything to check that...
:)
>
>Yours, 
>  
>
You know.  I that is what happened to me once.  I could not for the
life 
of me figure it out.  I just chmod 777 it.



__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


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 screensaver program that is placed in the taskbar that

periodicly check for the usbkey.  I would look at wxwindows or
pygame, 
you would makea  full screen ap,  that somehow captures all the key 
presses except username password thing.

HTH



__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


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 Nick Parlante of the Nifty
> Assignments project; he's been collecting material on fun
> projects:
>
> http://nifty.stanford.edu/

>>>
 What do others think?
>>>
>>>
>>> Private channel or not, I'm in. (at least until classes spike up 
>>> again in
>>> early February) Sounds like a good way to burn through a winter.
>>
> 
>
>>>
>>> David Broadwell
>>
>
> Hi Jacob,
>
> I've privately sent you what correspondence there has been amongst 
> those who expressed interest.
>
> If/once we pick a common project to undertake, I will post an 
> announcement here. (We will also likely put up a wiki page
somewhere.)
>
> Best to all,
>
> Brian vdB
>




__ 
Do you Yahoo!? 
Send a seasonal email greeting and help others. Do good. 
http://celebrity.mail.yahoo.com
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


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, 7]
#or
#a list comprehension tutorial found
#http://nltk.sourceforge.net/tutorial/advpython/nochunks.html#list_comprehensions
list_of_aint_as_integer=[int(x) for x in list_of_aint_as_string]
print list_of_aint_as_integer #[1, 0, 7, 7]
#now put it into one operation
broken_int=map(int,list(str(1077)))
print broken_int
def return_a_broken_int(aint):
return [int(x) for x in list(str(1077))]
print return_a_broken_int(aint) #[1, 0, 7, 7]

Now just put what you want or understand into a function and you can
use 
this.

HTH

kilovh wrote:

> I would like to be able to take an integer, break it down into 
> individual items in a list, and then put them back together. I know

> how to do this last part thanks to Orri Ganel and Guillermo
Fernandex, 
> but what about taking the integer apart?
>  
> Sorry if the questions have incredibly obvious answers, I'm new to
this.
>  
> ~kilovh
>
>
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>  
>




__ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 Python Tutorials auf Deutsch heir
>  
>
One can find Python Turorials in German here .. and .. and...

>http://www.freenetpages.co.uk/hp/alan.gauld/german/index.htm
>und
>http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index_ger.html
>und
>http://starship.python.net/crew/gherman/publications/tut-de/
>finden.
>I habe Alan Gauld Tutorial vorgelesen. Es is gut und es abdeckt
zimliche
>viele Themen.
>  
>
I have learned from Alan Gaulds Tutorial.  It is good and is ? ? ? ?.

###This is where my coco the gorilla size german vocabulary meets
it's 
end.###

>Ara
> Done with text ##
>Great! Another chance to try and decipher another language!
>Guten Tag = Good Morning
>  
>
Guten Tag=Good Day #coloquially

>Mein = My
>Deutsch = German (In *this* case, I guess)
>ist = is
>nicht = not
>so = so
>gut = good
>ich = I
>habe = have
>keinen = learned?
>  
>
keinen=little
geschrieben=writen

>Deutsche = German (I guess again)
>in = in
>sieben = seven? No, that can't be it...
>Mann = many
>kann = kind? (roughly?)
>auf = of
>  
>
auf=in #in this case#

>heir = here OR at?
>und = and
>finden = used as end of a list
>  
>
finden=find/found

>Es = it
>
>That's all I can decipher
>
>Thanks for some fun,
>Jacob
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>  
>




__ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 something like "f(x) = 
> sin(2*x)" and
> >then your program will plot it --- is that correct?
>
> Yes, that's what I want.

I can understand you fear.   Check out this post that Danny made in 
October I found it very helpful.
http://mail.python.org/pipermail/tutor/2004-October/032364.html
This one by kent at the same time was good too.
http://mail.python.org/pipermail/tutor/2004-October/032340.html
I felt this was a very good and helpful.


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 might find it useful.






__ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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:])
>
> _
> Play online games with your friends with MSN Messenger 
> http://messenger.msn.nl/
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>




__ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
function 
>
>
>> (for example the intersection of all list elements).  Is there a 
>
>
>> command in regular Python to do this?  I would like to avoid the 
>
>
>> hassle and speed hit of a loop to extract all the list elements.
>
>
>>
>
>> In the past, I believe I have used something like flatten(list),
which 
>
>
>> was part of Numarray (I think).  Am I missing an obvious or clever

>
>
>> solution in regular Python?
>
>
>>
>
>> Thanks for your help!
>
>
>>
>
>> Bill
>
>
>> ___
>
>
>> Tutor maillist  -  Tutor@python.org
>
>
>> http://mail.python.org/mailman/listinfo/tutor
>
>
>>
>
> Well, here's something i put together (works for lists and tuples,
> ignores strings and dicts):
>
>
>
> ### Start Code ###
>
> def flatten(sequence):
>
>
>
>def rflat(seq2):
>
>seq = []
>
>for entry in seq2:
>
>if '__contains__' in dir(entry) and \
>
> type(entry) != str and \
>
> type(entry)!=dict:
>
>seq.extend([i for i in entry])
>
>else:
>
>seq.append(entry)
>
>return seq
>
>
>
>def seqin(sequence):
>
>for i in sequence:
>
>if '__contains__' in dir(i) and \
>
> type(i) != str and \
>
> type(i) != dict:
>
>return True
>
>return False
>
>
>
>seq = sequence[:]
>
>while seqin(seq):
>
>seq = rflat(seq)
>
>return seq
>
> ### End Code ###
>
>
>
> Tested it on a few different scenarios, all performed as expected:
>
>
>
> >>> flatten([1])
>
> [1]
>
> >>> flatten([1,[1]])
>
> [1, 1]
>
> >>> flatten(['ab',1])
>
> ['ab', 1]
>
> >>> flatten([10,(34,42),54,'abc'])
>
> [10, 34, 42, 54, 'abc']
>
> >>> flatten([{'abc':[1,2,3]},[{'a':'1'},{'[1,2]':'ab'}]])
>
> [{'abc': [1, 2, 3]}, {'a': '1'}, {'[1,2]': 'ab'}]
>
>
>
> Cheers,
>
> Orri
>





__ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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.list=self.macro.split("\n")
for n,v in enumerate(self.list):
self.list[n]=v+'\n'
def readline(self,n=[-1]):
n[0]+=1
return self.list[n[0]]
def __str__(self):
return str(self.list)
def __len__(self):
return len(self.list)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Referer file from import

2005-01-14 Thread Chad Crabtree
Ok I will investigate this.  Thank you that is probably what I
needed.
I am trying to make a macro expander for python based on BOO's
facility
for this.  I thought it was neat.  In addition I think it would be
helpful to simulate adding keywords so that all these bloggers
talking
about proposed syntax could actually try it.  But mostly I want to
implement the
with keyword

with g:
append(1)
append(2)
append('woah')

Kent Johnson wrote:

> You could use trackback.extract_stack() to get the current stack 
> trace. If you inspect this from within the imported 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:
>
>> Chad Crabtree wrote:
>>>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!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
tested!):
> class _macroString(object):
> def __init__(self,s):
> self.macro=s
> self.list=[ line+'\n' for line in self.macro.split("\n") ]
> self._iter = iter(self.list)
> def readline(self):
> try:
> return self._iter.next()
> except StopIteration:
> return ''
> def __str__(self):
> return str(self.list)
> def __len__(self):
> return len(self.list)
>
> Note that your implementation of readline will raise IndexError
when 
> there are no more lines which is not correct behaviour.
>
> Kent
>
>




__ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 positions
>independently.
>
>But that being said, there's already a module in the Standard
Library that
>turns strings into file-like objects.  Can you use
StringIO.StringIO?
>  
>
I used kent's solution at first but I'm just using StringIO now I
didn't 
realize what that module  did.  Thank you all for your suggestion.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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,
>
>
>
>I've done a GUI program and it works perfectly.
>
>
>
>but when I try to package it with py2exe, I obtain the following
result:
>
>The following modules appear to be missing
>
>['mx']
>
>
>
>And when i run it, it crashes with this error message:
>
>Traceback (most recent call last):
>
>  File "openwar.py", line 41, in ?
>
>  File "Tix.pyc", line 210, in __init__
>
>_tkinter.TclError: can't find package Tix
>
>
>
>I guess the two errors are not related (mx is an optional package to
>
>pysqlite, but you don't *need* it), but I'm surprised there's an
error
>
>due to Tix, a standard package in the python distribution...
specially
>
>that my Python can work with Tix without problems!
>
>
>
>Does anyone have a guess about what's happening?
>
>
>
>Thanks a lot,
>
>
>
>G
>
>___
>
>Tutor maillist  -  Tutor@python.org
>
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>  
>




__ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 distribution, especially if you are using several libraries

and such.



__ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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):
def __init__(self,stats,*args,**kwds):
   super(Character,self).__init__(*args,**kwds)
   self.stats=stats

super is a function that calls a specific function from a parent
class.  
This way you can still use the previous __init__ code and then extend

it.  *args represents a tuple of arguments of unspecified length or 
type, **kwds is a dictionary of named arguments, like name='' like 
above.  That way you capture the keywords needed to pass to the
parent 
class so that name race magic is still updated at class
instantiation.

This way you can extend classes.  So you *could* subclass Character
as a 
Dwarf, a Troll etc so that each class already knows about being a
Dwarf, 
eg special abilities skill bonuses and such.  If you don't understand

this, that's ok it took me quite a while.  However once I got this it

made certain tasks much easier.  I could figure out how to do
something, 
then never need to think about how it works later in the project.

>def createChar(book):
>
>   name = raw_input("Enter your character's name. ")
>
>   race = int(raw_input("What race? (1: Human, 2: Elf, 3: Ork, 4:
Troll,
>
>5: Dwarf,)"))
>
>   book[name] = race
>
>  
>
try this (untested)

races={1:'Human',2:'Elf',3:'Ork',4:'Troll',5:'Dwarf'} #this is a
dictionary
book[name]=races[race]
print "The Name is " + name
print "The Race is " + book[name]

>def loadChar(book):
>
>   import os
>
>   filename = 'SRchargen.dat'
>
>   if os.path.exists(filename):
>
>   store = open(filename,'r')
>
>   while store:
>
>   name = store.readline().strip()
>
>   race = store.readline().strip()
>
>   book[name] = race
>
>   else:
>
>   store = open(filename, 'w')
>
>   store.close
>  
>
I'm not sure why this doesn't work, perhaps you should post what is
in 
'SRchargen.dat'.  You do know that this format will only work with
one 
character?  Do you get an error? If so post that traceback message.

Anyway good luck.



__ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 for...but I have a feeling that it's working through sheer
brute
>force and could be better:
>
>insideipgrepfd = os.popen("grep ifconfig_fxp0 /etc/rc.conf")
>insideipgrep = insideipgrepfd.readlines()
>  
>
insideipgrep=os.popen("grep ifconfig_fxp0 /etc/rc.conf").readlines()

>insideipfield, insideip =
string.split(string.strip(insideipgrep[0]), "=")
>  
>
insideip = string.split(string.strip(insideipgrep[0]), "=")[1]

>insideipsplit = string.split(insideip, " ")
>insideipquads = string.split(insideipsplit[1], ".")
>insidemaskquads = string.split(insideipsplit[4], ".")
>  
>
insideipquads=string.split(string.split(insideip, " ")[1],".")
insidemaskquads = string.split(string.split(insideip, " ")[4], ".")

>the line in /etc/rc.conf looks like:
>
>ifconfig_fxp0="inet 172.31.2.100 netmask 255.255.255.0"
>
>Any and all thoughts/pointers are appreciated.
>
>~elh
>
>  
>




__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 of the character
(why would an attri bute need to be a separate class?)
def addCyberware(self...):
def removeCyberware(...):
etc et al.
class Troll(Character):
update min max code in class for each race
class Skill:
def __init__(self, stuff):
   perhaps have a subclass for each skill?
   in addition the class would be responsible for it's
presentation
class Cyberware:
set attributes skill atribute mods and sanity or what ever thne
subclass for each item.  Also taking care of presentation
class Spell:
just like cyberware but perhaps one level further abstraction

class Augment(Spell):
class Damage(Spell):
class Curse(Spell):
 
I guess the question is should the character class be a *is a* or
*has 
a* relationship with Race.  Perhaps they could be mixins.

For persistence the only reasonable solution would be an object 
persistence scheme of some sort.  Then throw in a Top Down RPG Engine

and life is good.

   

Max Noel wrote:

>
> On Jan 17, 2005, at 20:51, Jack Cruzan wrote:
>
>> Ok, so each character has his name, race, his stats, his skills,
and his
>> gear.
>>
>> since the name and character is unique there is no need for a
class
>> these things.
>>
>> hmmm maybe I am conceptualizing this wrong.
>>
>> would each new character then be a dictonary? Made up of different
>> elements or would the character be a list? Since each character is
>> basically just a list of stats... the stats get modified up and
down by
>> race and certain gear... am I conceptulizing this correctly?
>
>
> I've thought about it a few times. Actually, when I learn a 
> language, I often try to design and implement a SR character 
> generator. Then I give up because it's really complicated and I
don't 
> have time (other things to do using the aforementioned programming 
> languages, mostly :D ).
> I'm probably gonna end up making a web-based one at some point,

> using either mod_python or Ruby on Rails. Gah, so many things to
do, 
> and so little time...
>
> Anyway, my view of the problem was that at least the following 
> should be classes:
> - Character
> - Attribute
> - Skill (perhaps a subclass: Specialization?)
> - Augmentation (with subclasses like Cyberware, Bioware,
AdeptPower)
> - GearItem
>
> Character would mostly be a container for the other classes, so

> most of its attributes would be dictionaries, like:
>
> class Character:
> def __init__():
> self.attributes = {'Body': Attribute(), 'Quickness': 
> Attribute(), 'Strength': Attribute(), 'Charisma': Attribute(), 
> 'Intelligence': Attribute(), 'Willpower': Attribute()}
>
>
> Ah, things would be so much easier if McMackie would release
the 
> NSRCG source code (despite this abomination being written in Visual

> Basic), wouldn't they? ;)
>
> -- Max
> maxnoel_fr at yahoo dot fr -- ICQ #85274019
> "Look at you hacker... A pathetic creature of meat and bone,
panting 
> and sweating as you run through my corridors... How can you
challenge 
> a perfect, immortal machine?"
>
>
>




__ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
thanks
>
>for answering the question.
>  
>
There are several efforts made in mud's in python on sourceforge. 
Check 
them out, you can read thier source.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 google "python url encode"

Good Luck

Luis N wrote:

>How would I best turn this string:
>
>
>
>'2005-01-24 00:00:00.0'
>
>
>
>into this string:
>
>
>
>'2005%2D01%2D24%2000%3A00%3A00%2E0'
>
>
>
>In order to call a URL.
>
>
>
>I've hunted through the standard library, but nothing seemed to jump
out.
>
>
>
>Thank You.
>
>___
>
>Tutor maillist  -  Tutor@python.org
>
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>  
>




__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 of way
>(simulating mouse clicks and so on), although the name escapes me at
the
>moment.  However, are you positive that you can't control it
properly?
>Check to see if it has a COM interface (you can use PythonWin to do
that),
>and use that if possible.
>
>=Tony.Meyer
>




__ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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. What is the preferred way of doing this? Should I just use
the find 
>command or is there a good module out there for searching?
>
>Thanks.
>  
>


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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.randrange(1,20) for x in range(100)]
l
[7, 18, 17, 17, 6, 11, 14, 9, 4, 16, 2, 9, 3, 13, 4, 2, 5, 15, 15, 3,
3, 
11, 18, 12, 6, 8, 15, 3, 7, 9, 9, 7, 12, 11, 11, 9, 19, 19, 15, 2,
17, 
18, 16, 8, 15, 3, 19, 19, 19, 1, 3, 17, 3, 8, 16, 1, 5, 19, 17, 16,
19, 
6, 3, 8, 16, 11, 12, 7, 10, 13, 13, 11, 6, 2, 18, 15, 17, 8, 12, 13,
5, 
12, 2, 19, 2, 19, 7, 10, 4, 14, 15, 14, 5, 1, 16, 1, 9, 10, 17, 12]
adict={}
for x in l:
if adict.has_key(x):
#then there is already an item
adict[x]+=1 #increment the count by one
else: #there is no key the item hasn't been seen
adict[x]=1 #there is one instance so far
   
adict
{1: 4, 2: 6, 3: 8, 4: 3, 5: 4, 6: 4, 7: 5, 8: 5, 9: 6, 10: 3, 11: 6,
12: 
6, 13: 4, 14: 3, 15: 7, 16: 6, 17: 7, 18: 4, 19: 9}

Srinivas Iyyer wrote:

>Dear Jacob, thank you for your suggestion.
>
>however, i think my question was not clear. what i
>meant to ask in my previous question was, how to know
>which elements repeated and how many times they were
>repeated. 
>
>while my question was flying, i did a small test:
>
>took a list:
>  
>
a


>[1, 1, 2, 3, 4, 2, 2]
>
>wanted to know which elements repeated and how many
>times:
>



__ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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:

> get(key, default) is your friend here:
>   for i in a_list:
>   items_dict[i] = items_dict.get(i, 0) + 1
>
> get() (and his "brother" setdefault()) are mighty
dictionary-methods.
>



__ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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.  So when
expand() 
is called it sucks in the file toeknizes it and expands the macro
then 
runs the resulting modified code.

Alan Gauld wrote:

>>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.
>>
>>
>
>So don't use them! They aren't mandatory.
>I'm not sure I understand youir problem? Why would turning 
>off syntax checking ever help?
>
>Alan G.
>




__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 again to expand this and to maintain the indentation needed

for the block.  I did this as an exercise and I thought the 'with' 
extension would be nice for my own benefit.  I thought it would be 
useful for all those syntax propositions in PEPs and stuff to
actually 
implement them to see how they work in real life.  However in it's 
current state I have to use anonymous ('''''') strings to
surround 
the macro.  I just thought it would be nice to just have python
import 
macro run the first few things with out looking to far into the file,
at 
which point macro.expand() would take over.

Now that you mention it and I'm thinking about it, it would probably 
take some sort of MacroPython->Python compiler type thing.  To get
the 
feel I'm really looking for.  I guess I was thinking it would work
like 
psyco

import psyco
psyco.full()

I hope I made myself clearer.

Alan Gauld wrote:

>>I'm trying to make a macro system that's work by just doing this
>>
>>
>
>OK, But to get your acros to use a language extension to python
>(the with syntax) you are going to have to write your own
>language interpreter/parser. Even if that just turns the 'with'
>stuff into Python.
>
>So why is the """ marker even necessary? Your interpreter doesn't
>need it - although it might make things easier... I'm still
>confused I think.
>
>Alan G.
>  
>




__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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:
modified=False
for number,value in enumerate(l3):
if number>0:#to avoid index error
if l3[number]Dear Danny, thank you for ur help. But a basic
>question ?
>
>In a table, more specifically a matrix 3X3,
>
>AppleFruitDenmark
>F-16 Fighter  USA
>Taj  Wonder   India
>MummyAntique  Egypt
>
>
>IF I have to sort on country, it should be
>
>AppleFruitDenmark
>MummyAntique  Egypt
>Taj  Wonder   India
>F-16 Fighter  USA
>  
>



__ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 option.

Jeff Shannon wrote:

> Perhaps you could turn things around, and make your macro
preprocessor 
> into an import hook?  I.E., you'd use it like --
>
> import macro
> module = macro.import("module_with_macros"[, macro_list])
> module.do_stuff()
>
> Not sure if you'd need to have a list of macros in the module to be

> imported, or not.  Perhaps the macro module would hold a list of 
> currently active macros, instead...
>
> In any case, this (I think) gives you a chance to interrupt the
import 
> process and modify the target module before the Python parser gets
it, 
> which should enable you to avoid the SyntaxError problems.
>
> (Of course, I've never messed around with hooking __import__(), so
I 
> could just be talking out of my ...)
>
>




__ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 thinking, but I
can 
see how it would be very useful for it's problem domain of code 
generation for other languages.

Javier Ruere wrote:

>  Yes. To add new stuff to the language you would have to work at
the
>interpreter level. Probably you can avoid going too deep using
import
>hooks, as it has already been suggested, to modify what's being
imported
>on the fly.
>  I believe it could work like Psyco if the preprocessor installed
the
>import hooks when imported.
>  Are you interested only in the syntactic sugar or you plan to
generate
>more efficient code?
>  
>



__ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 photo gallery.

#!/usr/bin/env python
import sys,os
print sys.argv
if len(sys.argv)<3:
print """
Please type dir.py dir= ext=
Example
dir.py dir=. ext=html
To list all the html files in the current directory"""
sys.exit()
dir=sys.argv[1]
ext=sys.argv[2]
dir=dir.split('=')
ext=ext.split('=')
if not (dir[0].lower()=='dir' and ext[0].lower()=='ext'):
print """
Invalide Command line systax
dir.py dir= ext=
"""
sys.exit()
#now we can get started
dirlist=os.listdir(dir[1])
dirlist=[tuple(x.split('.')) for x in dirlist]
for x in dirlist:
if x[-1]==ext[1]:
print '.'.join(x)


kumar s wrote:

>f2.close()
>
>
>The problem with this approach is that, i have to give
>on file per a run. I have 50 files to pare and i want
>to do that in one GO.  I kepy those 50 files in one
>directory. Can any one suggest an approach to automate
>this process. 
>
>I tried to use f1 = stdin(...) it did not work. i dont
>know , possible is that i am using incorrect syntax.
>
>Any suggestions. 
>
>Thank you. 
>



__ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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', 'ccc', '']

aList.sort(lambda x,y:cmp(len(x),len(y)))
assert aList==['a', 'bb', 'ee', 'ccc', '']

Now this is a concrete example of how lambda simplifies code, at
least 
for me because it does not clutter my mental name space.  Also it is 
much shorter.  However it should be said that this is very much a 
question of taste.  However I must say that lambda's are very useful 
even necessary for using Tkinter.

Here's something else, while not exactly the same but an
illustration.

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()
In summary there has been a great deal of argument about lambda's,
even 
on this mostly sanguine mailing list.  I feel that it's one of those 
strange things about python true.  Guido purposely made it very
limited 
because it could get hairy very fast with more powerful lambda's, the

functional people would make code that would break newcomers heads. 
God 
knows I had a hard enough time with them at first.




__ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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(' ',''))

I tried this on the shell just trying to do some quick text
replacement 
because I could figure out how to get awk to do it, and I didn't want
to 
spend 5 hours RTFM.  I got it to work by breaking it up to several 
statements, but I would like to know.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 write(self, *args):
>... print "dummyfile.write:", args
>... def read(self, *args):
>... print "dummyfile.read:", args
>... return ""
>  
>
def dummyopen(filename, type):


>... print "dummyopen:", filename, type
>... d = dummyfile()
>... d.open(filename, type)
>... return d
>
>  
>
dummyopen(s, 'w').write(dummyopen(s, 'r').read())


>dummyopen: d:/tests/test.txt w
>dummyfile.open: ('d:/tests/test.txt', 'w') <--- first open for
writing
>dummyopen: d:/tests/test.txt r
>dummyfile.open: ('d:/tests/test.txt', 'r') <--- then for reading
>dummyfile.read: ()
>dummyfile.write: ('',)
>
>  
>
>>spend 5 hours RTFM.  I got it to work by breaking it up to several 
>>statements, but I would like to know.
>>
>>
>
>And that's the way you *should* write it - code like this doesn't
deserve to
>work anyway :). 
>
>Yours,
>
>Andrei
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>  
>




__ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 if(foo) versus if (foo), and whether or not to use 
> braces for single-line blocks. (the latter issue being why I think
The 
> Whitespace Thing is an instance of Best Thing Ever(TM))

Bracing single line expressions is something I constantly agonize
over.  
I'm always thinking may as well brace it because I may want to add
more 
to this if clause. That's one of the reasons I like python is because

it's relatively painless to make sure that your blocks are closed 
properly, especially when you aren't using a decent IDE.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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():
>print stri
>return x
> aFuncList = [makefunct('one'),makefunct('two'),makefunct('three')]
> for item in aFuncList:
>item()
>
> It's shorter, it works and it looks cool.
> Thanks to Jeff Shannon for the backbone of this example.

My intent in showing the above code was not to really print one two 
three, but to show that a function doesn't care what it's called.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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.com/mail_250
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
>
>implementation, as per the specifications of Java's LinkedList and
>
>Python's list.  The full code may be found at
>
>http://rafb.net/paste/results/JKhsQn59.html.  Once the link expires,
>
>please feel free to email me for the code.  Any suggestions and
>
>comments are welcome.  As far as I can tell, the only possible
>
>improvement to be made is adding comments.
>
>
>
>Thanks in advance,
>
>Orri
>
>
>
>  
>




__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 instructions:
>
> # A very simple setup script to create 2 executables.
> #
> # hello.py is a simple "hello, world" type program, which alse
allows
> # to explore the environment in which the script runs.
> #
> # test_wx.py is a simple wxPython program, it will be converted
into a
> # console-less program.
> #
> # If you don't have wxPython installed, you should comment out the
> #   windows = ["test_wx.py"]
> # line below.
> #
> #
> # Run the build process by entering 'setup.py py2exe' or
> # 'python setup.py py2exe' in a console prompt.
> #
> # If everything works well, you should find a subdirectory named
'dist'
> # containing some files, among them hello.exe and test_wx.exe.
>
>
> from distutils.core import setup
> import py2exe
>
> setup(
> # The first three parameters are not required, if at least a
> # 'version' is given, then a versioninfo resource is built from
> # them and added to the executables.
> version = "0.5.0",
> description = "py2exe sample script",
> name = "py2exe samples",
>
> # targets to build
> # windows = ["test_wx.py"],
> console = ["hello.py"],
> )
>
> What does it mean by the 'console prompt'? I tried Command Prompt 
> (Windows XP) but I get errors when I type 'setup.py py2exe' or
'python 
> setup.py py2exe'. I also don't get anything when I run the setup.py
in 
> IDLE (or the Python command line). In fact I get an error:
> Traceback (most recent call last):
>   File
"C:\Python24\Lib\site-packages\py2exe\samples\simple\setup.py", 
> line 22, in ?
> import py2exe
> ImportError: No module named py2exe
>
> If you have used or are using py2exe, /please/ tell me what I'm
doing 
> wrong!
> Thanks,
>   Joseph Q.
>
>
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>  
>




__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 check the first cell of every insider
>>list.
>>
>>
>
>With Python 2.4:
> >>> l= [ [1], [2,3], [4,5], [6]]
> >>> 2 in (i[0] for i in l)
>True
> >>> 3 in (i[0] for i in l)
>False
>
>with Python 2.3 use [i[0] for i in l] instead which is a little less
efficient.
>
The second case you show should be true because I believe that's what
he
asked for.  Here is I believe the correct way to do this.

>>> l= [ [1], [2,3], [4,5], [6]]
>>> def isin(test,alist):
... return bool([x for x in alist if test in x])
...
>>> isin(2,l)
True
>>> isin(3,l)
True
>>> isin(10,l)
False
>>> def isin2(test,alist):
... for x in alist:
... if test in x:
... return True
... return False
>>> isin2(2,l)
True
>>> isin2(10,l)
False
>>>


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
...
 >>> counter
{0: 9, 1: 9, 2: 9, 3: 14, 4: 15, 5: 15, 6: 13, 7: 5, 8: 11, 9: 12,
10: 
9, 11: 12, 12: 13, 13: 8, 14: 5, 15: 12, 16: 14, 17: 9, 18: 11, 19:
8, 
20: 6, 21: 13, 22: 11, 23: 10, 24: 8, 25: 15, 26: 19, 27: 11, 28: 13,

29: 13, 30: 12, 31: 18, 32: 10, 33: 5, 34: 9, 35: 5, 36: 9, 37: 12,
38: 
8, 39: 11, 40: 8, 41: 12, 42: 6, 43: 13, 44: 11, 45: 8, 46: 8, 47: 6,

48: 9, 49: 6, 50: 5, 51: 11, 52: 11, 53: 12, 54: 15, 55: 15, 56: 10,
57: 
12, 58: 13, 59: 6, 60: 6, 61: 7, 62: 8, 63: 13, 64: 14, 65: 7, 66: 7,

67: 12, 68: 5, 69: 10, 70: 8, 71: 7, 72: 12, 73: 12, 74: 6, 75: 13,
76: 
12, 77: 13, 78: 9, 79: 5, 80: 13, 81: 14, 82: 4, 83: 6, 84: 8, 85:
12, 
86: 8, 87: 10, 88: 10, 89: 7, 90: 7, 91: 9, 92: 12, 93: 14, 94: 8,
95: 
7, 96: 10, 97: 11, 98: 8, 99: 8}
 >>>


Asif Iqbal wrote:

>Hi All
>
>I have a very simple problem and I am looking for the simplest
solution.
>
>I have a list of elements in a file. I like to find the total
occurance
>of each element in the list like this
>
>10 string1
>7 string2
>1 string3
>
>from a list which has only string1,string2 and string3 like this
>
>string1
>..
>string2
>...
>string1
>..
>string3
>...
>...
>
>
>I have a list of 3 lines and I think I have only 615 unique
>elements. So I like the script not to take too much memory of the
>system. I will be running it on Solaris 8
>
>Thanks a lot
>
>  
>




 
Yahoo! Sports 
Rekindle the Rivalries. Sign up for Fantasy Football 
http://football.fantasysports.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
filehandle=open('/tmp/logfile','r').readlines()

Look here
http://docs.python.org/lib/built-in-funcs.html#built-in-funcs
and
http://docs.python.org/lib/bltin-file-objects.html

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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
>information on web. ok, easy enough.
>heres the trick.
>the database is MS Access. - ick.
>what could i do to manipulate data in an access database ? can
it be 
>done ?
>all the research i have done just points me to sql, sqlite,
etc...
>i wouldnt mind if i can find a way to push everything from
access to 
>another kind of database,
>but i dont know where to start.
>any ideas?
>
>-thanks
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>  
>




 
Yahoo! Sports 
Rekindle the Rivalries. Sign up for Fantasy Football 
http://football.fantasysports.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 will change
the 
output some.  So if you have some bizarre markup I think it'll try to

fix it. Which afaik most html parsers outputers will do.  I don't
know 
how to do regex's so I would just do he string manipulation method. 

Good Luck

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 = "foo"
> >>> for c in cb:c()
> foo
> foo
> foo
> foo
>
> I expected the output to be 1 2 3 4. Now I understand the cookbook
> recipe for currying:
> def curry(func, *args, **kwds):
> def callit(*moreargs, **morekwds):
> kw = kwds.copy()
> kw.update(morekwds)
> return func(*(args+moreargs), **kw)
> return callit
>
> cb = [curry(f,what) for what in "1234"]
>
> gives the right functions.
>
> Regards,
> Igor
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 thread.
>
> * Gregor Lingl <[EMAIL PROTECTED]>, [2006-05-03  0:24 +0200]:
> >  v=
> >  if isinstance(v, int) or isinstance(v, float):
> >   
>
> I wonder which is the recommended way to check the type of a value.
>
> In other words, what should I choose between:
> isinstance(v, int)
> type(v) is int
> v.__class__ is int
>
> There's simply more than one way to do it or some of them are
> discouraged?
>
> I've been told on #python that .__class__ is probably the worst one, but
> without precise motivation, just as a personal opinion.
>
> ciao,
> ema
>
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.3 (GNU/Linux)
>
> iD8DBQFEX4X7C6DuA+rxm2ARAio8AJ9VWrIjlXL5bk43o0LwS1ZwPE3gZACdGTWI
> eIRPzxfs6KRpYc3bF2W4RwU=
> =Tmcs
> -END PGP SIGNATURE-
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 fairly easy to package up with,
say py2exe.

Another option, with CGI (pretty easy) is found in the standard library.
http://docs.python.org/lib/module-CGIHTTPServer.html

If you do this as a personal app I would make sure to use an alternate
port number like 11224, or something.

HTH
Best of Luck.

On 5/6/06, Alfonso <[EMAIL PROTECTED]> wrote:
> I would like to experiment with web interfaces and python. After some 
> googling, I'm quite confused, does somebody know of a good link about this 
> topic / what do you think that is the best software option to design web user 
> intefaces with python? I mean web interfaces  for common programms (so it's 
> not important to me to have a very robust web server), the web server should 
> run in the machine of the user of the programm.And it should be easy 
> installed, as bundle, when I distribute the programm.
>
> Thank very much for your help.
>
>
>
> __
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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').readlines()[-1]Some will say that this is no good because the file is still open.  However I've been told that when the object is cleaned the file is closed so it should be fine.
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 question cause it's as simple
> as it's confusing for me.
>
> Why does urllib2.urlopen("http://www.anuntul.ro";) return HTTPError: HTTP
> Error 400: Bad Request, while the site opens with no problems in any regular
> browser.
>
> Thank you in advance for answering :)
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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-ConfigParser.html

On Mon, Jul 21, 2008 at 10:08 AM, Daniele <[EMAIL PROTECTED]> wrote:
> Hi list,
> I've recently developed a basic python program which needs to store
> some data in a file (e.g. a directory path).
> What the program needs is a dictionary containing the data, so I used
> the pickle module to store the dictionary in a file and read it back
> when the program is launched.
> I wanted to know which is the common pattern in python programming in
> this case, because the way I've choosen only lets the user configure
> the data via a GUI (the file is somehow "compiled"). Is it better to
> store the data in a text file and then parse it and construct a
> dictionary? Or is there e third way?
>
> Thanks, Daniele
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 some thoughts on how two separate threads can
>> communicate in Python
>
> You will probably get out of your doubts by reading about the SocketServer
> module
> and SocketServer.ThreadingTCPServer class.
>
> Once your get a server up & running you can run parallel threads, from there
> you can build
>
> a global dictionary & use it to share data between you threads.
>
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 make up something nice for
you to program.  Then when you have problems with the program come
back and ask questions.  Since you already programmed in PHP I don't
think you'll have too much trouble picking up python.

On Fri, Aug 8, 2008 at 5:22 PM, A. Joseph <[EMAIL PROTECTED]> wrote:
> Hello everybody, i`m new to this list. I was programming in PHP before, of
> recent I started learning python. I need someone who can be giving me some
> assignment based on the chapter I read in the book, and the person will
> sometime review my code and tell me if it`s well structured.
>
> Thanks-
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 vim.  These editors allow you to shovel around code
like your a ditch digger, with cybernetic implants.

Vim has code completion and it's very easy to use your keyboard to
switch to specific tabs, instead of ctrl-tab,tab,tab,tab,tab,tab.  It
does have command completion though it requires you to tell it how to
do so.  Syntax highlighting and many other must haves for me. There is
one thing that VIM and emacs have for them that many of the more GUI
editors lack.  That is terminal support that is equal to the GUI
version.

I do a lot of system administration just to get my programming tasks
done and I often do not have physical access to the machine so I need
to do it remotely.  Which is a huge win for me.

On Tue, Aug 12, 2008 at 4:09 PM, Steve Willoughby <[EMAIL PROTECTED]> wrote:
> Jaggo wrote:
>>
>> Why do you use your editor rather than using Pywin? What feature has
>> editor
>> X got that PyWin hasn't?
>> (That is, other than "My editor runs on unix / linux"; while that does
>> count
>> for something it is rather irrelevant to my current situation.)
>
> I use a different editor (in my case vim) because it has a lot of advanced
> editing features (regular expression searching and replacing, filtering
> ranges of text through commands, and a list of scores of other things) that
> don't exist in the simpler editors built into most IDEs like Pywin or IDLE.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 curly braces is
> not what I was aiming for. If I could have it my way, I'd have indentation
> and curly braces. I don't want to change official python syntax either.. I
> just want to be able to easily do it myself.
>
> The big problem I had that I didn't explain well enough when I said
> "visually" is that it is visually hard to tell when code blocks end when
> other code blocks and statements begin immediately after them. With curly
> braces you can easily visualize when looking at a lot of code where the code
> block ends. The best thing you can do in python currently is to put an empty
> line in between the last line of a code block and the following code, so you
> can better visualize the end of the code block.
>
> On Wed, Aug 13, 2008 at 4:23 AM, Chris Fuller
> <[EMAIL PROTECTED]> wrote:
>>
>> Some clarifications w.r.t. indentation and Python:
>> http://www.secnetix.de/olli/Python/block_indentation.hawk
>>
>> It's just a joke, really:
>> http://timhatch.com/projects/pybraces/
>>
>> Turnabout is fair play!
>> http://blog.micropledge.com/2007/09/nobraces/
>>
>> Also, pindent.py in the Tools/scripts directory of your Python
>> distribution
>> will produce correctly indented scripts if the blocks are designated with
>> a "#end" line.
>>
>>
>> But seriously, you don't want to go creating a separate class of source
>> file.
>> It'll be harder for you and the other programmers to context switch when
>> working with code that uses the standard style, will confuse others who
>> won't
>> know what to do with your code, adds overhead to the compiling, will break
>> when somebody tries to run it under the standard environment, could
>> clutter
>> up your development directories, depending on the implementation, etc.
>>
>> Here's a thread from 1999 on the Python mailing list that discusses the
>> issue:
>> http://mail.python.org/pipermail/python-list/1999-June/004450.html
>>
>> There's another script towards the end that might even do what you want,
>> but
>> you might want to read what they have to say first :)
>>
>> Cheers
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 says
this is a fine practice.

However synchronizing two separeatly running databases is a very hard task,
and is very very easy to get wrong.

However if all that one does is read and does no updates or deletes then you
could just copy the database over to the 'client' user.

On Tue, Sep 9, 2008 at 6:56 PM, Che M <[EMAIL PROTECTED]> wrote:

>  Hi list,
>
> I have been trying to create a small desktop application with Python
> that uses a small SQLite database.  Recently I've got use of a 2nd computer
>
> (for my job) and have thought now about using the app on that one as well.
>
>
> I'd like to get ideas about how I could extend the application so that the
> databases on each computer could be kept "synchronized" (not sure that is
> the right term here); that is, each new change on either computer would
> be updated on the other computer(s), given a bit of help from the user.
>
> I know that, for example, the Chandler PIM has a "hub" that allows sync'ing
> across
> multiple computers (though I was surprised to see it is a 8 step process
> for the user:
>
> http://chandlerproject.org/Projects/GetStarted#Sync%20Chandler%20Desktop%20across%20Mul)
>
> (I realize a good way to do all of this is entirely as a web service, but
> that is beyond
> my abilities, and I am trying to just complete a desktop app before
> learning much of that)
>
> So, if anyone has ideas on ways to do this with Python and Sqlite that are:
> - fairly simple (I'm not a real programmer)
> - not laborious for the user to do (so that they actually keep the two dbs
> in sync)
> I'd love to hear about it.
>
> Thanks,
> Che
>
>
> --
> Stay up to date on your PC, the Web, and your mobile phone with Windows
> Live. See Now
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 says
this is a fine practice.

However synchronizing two separeatly running databases is a very hard task,
and is very very easy to get wrong.

However if all that one does is read and does no updates or deletes then you
could just copy the database over to the 'client' user.

On Tue, Sep 9, 2008 at 6:56 PM, Che M <[EMAIL PROTECTED]> wrote:

>  Hi list,
>
> I have been trying to create a small desktop application with Python
> that uses a small SQLite database.  Recently I've got use of a 2nd computer
>
> (for my job) and have thought now about using the app on that one as well.
>
>
> I'd like to get ideas about how I could extend the application so that the
> databases on each computer could be kept "synchronized" (not sure that is
> the right term here); that is, each new change on either computer would
> be updated on the other computer(s), given a bit of help from the user.
>
> I know that, for example, the Chandler PIM has a "hub" that allows sync'ing
> across
> multiple computers (though I was surprised to see it is a 8 step process
> for the user:
>
> http://chandlerproject.org/Projects/GetStarted#Sync%20Chandler%20Desktop%20across%20Mul)
>
> (I realize a good way to do all of this is entirely as a web service, but
> that is beyond
> my abilities, and I am trying to just complete a desktop app before
> learning much of that)
>
> So, if anyone has ideas on ways to do this with Python and Sqlite that are:
> - fairly simple (I'm not a real programmer)
> - not laborious for the user to do (so that they actually keep the two dbs
> in sync)
> I'd love to hear about it.
>
> Thanks,
> Che
>
>
> --
> Stay up to date on your PC, the Web, and your mobile phone with Windows
> Live. See Now
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 well suited to just
spraying code inside markup.

On Fri, Sep 19, 2008 at 11:38 AM, dorje tarap <[EMAIL PROTECTED]>wrote:

> Hi All,
>
> I would really like to learn about using python for creating a website
> from scratch to allow me to learn about web programming and python.
>
> I have zero experience of web programming, and some limited exposure
> to python. Can someone recommend a book or resource that will
> introduce me to web programming.
>
> Thanks
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor