Re: [Tutor] 'word jumble' game

2007-04-17 Thread Jason Massey
The main thing your program lacks is flexibility. Adding new puzzles requires chaining together a series of if..else statements and creating variables for each hint. Here's my quick version. I store the puzzles and the hints in a two-tuple sequence. Following this method you could easily add a

[Tutor] Text matching

2007-05-15 Thread Jason Massey
heh... forwarding to the list, too. -- Forwarded message -- From: Jason Massey <[EMAIL PROTECTED]> Date: May 15, 2007 6:51 AM Subject: Re: [Tutor] Text matching To: "Gardner, Dean" <[EMAIL PROTECTED]> Look at it a different way. If the one thing that is s

Re: [Tutor] Python for s60

2007-05-16 Thread Jason Massey
Google is your friend: http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLR,GGLR:2006-33,GGLR:en&q=python+symbian The first link in particular looks good. On 5/16/07, Chenthil <[EMAIL PROTECTED]> wrote: Hi can some one show nd some good tutorials for writing scripts for symbian

Re: [Tutor] Get max quantity

2007-06-13 Thread Jason Massey
More than one way to skin a cat: import operator sort_key = operator.itemgetter(1) sorted(inventory.items(),key=sort_key)[-1] ('oranges',525) or... inventory.items() [('pears', 217), ('apples', 430), ('oranges', 525), ('bananas', 312)] count_first = [(count,fruit) for fruit,count in invent

Re: [Tutor] Help converting base32 to base16

2007-06-18 Thread Jason Massey
Nice entry at wikipedia: http://en.wikipedia.org/wiki/Base_32 I like the naming of Base32: *duotrigesimal *Gotta try to work that into a conversation somehow.* * On 6/18/07, Alan Gauld <[EMAIL PROTECTED]> wrote: "cms cms" <[EMAIL PROTECTED]> wrote > Newbie here trying to find a module that I

Re: [Tutor] subprocess and launching an editor

2007-06-22 Thread Jason Massey
I'm running Feisty as well. I launched python in two separate consoles and tried this: 1st console import subprocess subprocess.call('gedit --new-window window1',shell=True) gedit launches with a blank file called window1. The python shell is now waiting for gedit to exit be

Re: [Tutor] Fastest way to iterate through a file

2007-06-26 Thread Jason Massey
Also since you're writing your found results to a file there's no need to print the results to the screen. That should shave off some time, especially if you have a lot of hits. On 6/26/07, Kent Johnson <[EMAIL PROTECTED]> wrote: Robert Hicks wrote: > idList only has about 129 id numbers in it

Re: [Tutor] Bundle help!

2007-07-16 Thread Jason Massey
A nice tutorial on using regular expressions in Python: http://www.amk.ca/python/howto/regex/ On 7/15/07, bhaaluu <[EMAIL PROTECTED]> wrote: Hi! http://docs.python.org/lib/module-re.html Regular Expressions module. On 7/15/07, Sara Johnson <[EMAIL PROTECTED]> wrote: >

Re: [Tutor] Capturing ctrl-c

2007-09-24 Thread Jason Massey
Interesting. As Michael suggested this works, mostly: from time import sleep def loop(): x = 0 while 1: print "x:",x x += 1 sleep(0.5) if __name__ == "__main__": while 1: try: loop() except KeyboardInterrupt: print "Nop

Re: [Tutor] for a given file, how to find file size?

2007-10-03 Thread Jason Massey
Are you sure? From the link you provided it looks as if: *stat*( path) Perform a stat() system call on the given path. The return value is an object whose attributes correspond to the members of the statstructure, namely: st_mode (protection bits), st_ino (inode number), st_dev (device), st_nlink

Re: [Tutor] update a ws.ListBox

2007-11-28 Thread Jason Massey
Inserting this line: self.listbox2.InsertItems([choice],0) in your OnListBox1 method after your if/then/else statement puts the item you select in ListBox1 appear in ListBox2. You have to force choice into a list, otherwise it will insert each individual letter in the string into the box one at

Re: [Tutor] Random Number Generator

2007-12-04 Thread Jason Massey
Easy enough. You'll want to import the random module and use the functions in it. Also, http://docs.python.org/lib/lib.html is going to be your best friend. You'll notice on that page among many other things is a section on random number generation. As to your code: >>>import random >>>a = ran

Re: [Tutor] Projects

2008-01-23 Thread Jason Massey
On Jan 22, 2008 5:10 PM, Damian Archer <[EMAIL PROTECTED]> wrote: > So anyone have any good project ideas, perhaps projects that people have > undertaken before?? > > I'm taking a Java class this semester and our first program is a number translator. Here's the assignment: *Below is a sample

Re: [Tutor] if-elif-else statements

2005-10-13 Thread Jason Massey
More than anything, I think clearer variable names will help here. Something like: def main(): ... speed_limit = 60 ... clocked = int(raw_input("Clocked speed:")) ... miles_over = clocked - speed_limit ... fine = 50 + 5 * miles_over ... if miles_over >= 30: ... pri

Re: [Tutor] string.split() into a list

2005-10-18 Thread Jason Massey
Works fine for me: >>> l = [] >>>a='1|2|3|4' >>> l=a.split('|') >>>l ['1', '2', '3', '4'] On 10/18/05, Randy Bush <[EMAIL PROTECTED]> wrote: > and stupid question of the morning (for me) > > i want to string.split() into a sequence, a la > > l = [] > l = myString.split('|') > > but, of cours

Re: [Tutor] string.split() into a list

2005-10-18 Thread Jason Massey
well that would definitely cause your error. The string.split sends the list to a, but after that it's looking for something to assign to l and there's nothing leftover from the command for it to assign. On 10/18/05, Randy Bush <[EMAIL PROTECTED]> wrote: > > >>> l = [] > > >>>a='1|2|3|4' > > >>>

Re: [Tutor] IDLE error msgs and line continuations?

2005-10-27 Thread Jason Massey
All you need is the line continuation character, '\': if (condition 123 and \ condition 456) : On 10/27/05, CPIM Ronin <[EMAIL PROTECTED]> wrote: > When using IDLE, after hitting F5 to save and run, if an error occurs, it > merely flashes at the code location of the error. While I usually figu

Re: [Tutor] triangulation

2005-11-10 Thread Jason Massey
lol, that's just funny. On 11/10/05, Shi Mu <[EMAIL PROTECTED]> wrote: > the Internet is down for one day and so wonderful to have so many > responses. i have checked all the links you guys mentioned. what i > want is delaunay triangulation and the available ones online are > written in C, Java

[Tutor] UnboundLocal Error

2005-11-20 Thread Jason Massey
I've got a problem with scope that I can't say I've ever encountered. The comments explain the situation pretty well. import player class Game: def __init__(self,screen): self.market = Market.Market() self.countries = pickle.load(open("sup.coords",'r'))

Re: [Tutor] using help

2005-11-28 Thread Jason Massey
Boyan, A listing of all the built-in exceptions can be found at: http://docs.python.org/lib/module-exceptions.html And is this what you're looking for? >>> a='123' >>> int(a) 123 >>> A description of this, and the other built-in functions, is at: http://docs.python.org/lib/built-in-funcs.ht

Re: [Tutor] Is it a good idea to use TKInter to change my password program into a GUI?

2005-11-29 Thread Jason Massey
Nathan, Look here: http://effbot.org/tkinterbook/entry.htm Apparently you can change the default setting for the entry box so that it will show whatever character you like rather than what the user is typing. On 11/29/05, Nathan Pinno <[EMAIL PROTECTED]> wrote: Hey Danny and all,Alberto told me

Re: [Tutor] dynamic lists

2006-01-03 Thread Jason Massey
googled for rsa & python: http://www.python.org/workshops/1995-05/pct.html On 1/3/06, lfiedor <[EMAIL PROTECTED]> wrote: Hiim looking for very simple DES and RSA algorithms writen in python (orC), can anyone know where i can find them___Tutor maillist  

[Tutor] Syntax Errors

2006-01-03 Thread Jason Massey
I've just finished ripping out a bunch of lines in one of my wxPython programs.  Testing it out I get: C:\Python24>tla2.py   File "C:\Python24\tla2.py", line 412     self.grid.SetCellValue(0,0,"Site")     ^ SyntaxError: invalid syntax There's nothing wrong with that line.  I didn't even touch it

Re: [Tutor] Syntax Errors

2006-01-03 Thread Jason Massey
ECTED]> wrote: On Tue, 3 Jan 2006, Jason Massey wrote:> I've just finished ripping out a bunch of lines in one of my wxPython> programs.  Testing it out I get:>> C:\Python24>tla2.py>   File "C:\Python24\tla2.py", line 412 > self.grid.SetCellValue(0,0,&

Re: [Tutor] Why doesn't this work?

2006-01-23 Thread Jason Massey
Christopher, I copied and pasted your code and it worked only a few modifications.  The thing I had to change was the indention level of the: def __and__(self, other): return self.intersect(other) def __or__(self, other): return self.union(other) def __repr__(self): return 'Set:' + list.__repr__(

Re: [Tutor] getting around ValueError in os.walk

2006-01-30 Thread Jason Massey
Andrew, I put in your code, exactly as you have it, with only three changes: #!/usr/bin/python import os for (dirpath, subdirs, filenames) in os.walk("/python24"):    # a comma instead of a period after dirpath    for file in filenames:    if file.endswith(".py"):

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Jason Massey
How about: >>> [pow(2,x) for x in [1,2,3,4]] [2, 4, 8, 16] On 2/14/06, Michael Broe <[EMAIL PROTECTED]> wrote: I read somewhere that the function 'map' might one day be deprecatedin favor of list comprehensions.But I can't see a way to do this in a list comprehension: >>> map (pow, [2, 2, 2, 2],

Re: [Tutor] import of source code still not working

2006-02-20 Thread Jason Massey
The problem here is that you need to reference the factor30 namespace to get to your functions: Your calls to your functions would then look like: factor30.factor(109) & factor30.factor0(109) If you don't want to have to put the factor30 in front of all your function names you can do t

Re: [Tutor] dictionary datatype

2006-04-11 Thread Jason Massey
Works for me:>>> dict1 = { 0x2018:u'k', 0x2019:u'd'}>>> n = 0x2018>>> print dict1[n]k>>> On 4/11/06, kakada <[EMAIL PROTECTED]> wrote: Hello all,For example, I have a dictionary:dict1 = { 0x2018:u'k', 0x2019:u'd'}I assign:n = 0x2018print dict1[n]Then:KeyError: '0x2018'But I can call directly:print

Re: [Tutor] Checking in lists

2006-04-26 Thread Jason Massey
John,Basically it's not evaluating it the way you think it is:Your first example really equates to:if (1 or 5) in rollList:   etc...(1 or 5) equals 1  and 1 isn't in the your list. On 4/26/06, John Connors <[EMAIL PROTECTED]> wrote: G'day,I found something today that has me confused. I'm making a l

Re: [Tutor] Halting execution

2006-05-03 Thread Jason Massey
How about:import syssys.exit()On 5/3/06, Matthew Webber <[EMAIL PROTECTED] > wrote:This has got to be trivial, but I can't find the answer ... I want to stop execution of my main script half way through. This is just for debugging -the code in the bottom half of the script generates a whole lot of

Re: [Tutor] Python challenge

2006-05-04 Thread Jason Massey
David,What answer did you get?  One of the things to rember on the challenge is to take your answer and put ".html" (no qutoes) on the end of it in the url.So for the first problem the url would be: http://www.pythonchallenge.com/pc/def/.htmlOn 5/4/06, David Holland < [EMAIL PROTECTED]> wrote: I lo

Re: [Tutor] If then else question

2006-06-14 Thread Jason Massey
How about:elif ch_val in ['040','011','012']:On 6/14/06, Andrew Robert <[EMAIL PROTECTED] > wrote:-BEGIN PGP SIGNED MESSAGE-Hash: SHA1Hi Everyone, In the middle of an if then else, I have the following lineelif ch_val == '040' or ch_val == '011' or ch_val == '012':The line works but

Re: [Tutor] modbus communication with python?

2006-07-05 Thread Jason Massey
Googling for modbus python turned up:https://lintouch.org/repos/lintouch/lsp-modbus/trunk/tests/ On 7/5/06, Jeff Peery <[EMAIL PROTECTED]> wrote: Hello, I need to talk read write to a modbus so that I can work with a PLC. I have not a clue how this all works. does python have a modbus module or whe

Re: [Tutor] AmigaOS like ReadArgs() for Python ?

2006-07-20 Thread Jason Massey
I came across this at: http://www.monkeyhouse.eclipse.co.uk/amiga/python/For more powerful operation under AmigaDOS, and because it is needed for the ARexx implementation, there are two additional modules. The first is the low-level builtin module Doslib, and the other, the Dos module, is written o

Re: [Tutor] [tutor] ipconfig

2006-08-10 Thread Jason Massey
I found this on an artima forum:http://www.artima.com/forums/flat.jsp?forum=181&thread=113874 This worked on my machine (win xp):socket.getaddrinfo(socket.gethostname(), None)[0][4][0]On 8/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:hello list is there in python an independent from the syst

Re: [Tutor] SQL Queries For MySQL

2006-10-12 Thread Jason Massey
On 10/12/06, johnf <[EMAIL PROTECTED]> wrote: On Thursday 12 October 2006 00:31, Alan Gauld wrote:> > query = "SELECT * FROM DB WHERE NAME = %s" % (name)> > cursor.execute(query)>> There can be security issues with this style, especially > if the parameters can be modified by users - for example> y

Re: [Tutor] passing a variable ?

2006-10-19 Thread Jason Massey
It should look like this:fout = file('/home/cable/sandbox/%s' % savename, 'a''w')The variables come immediately after the string your formatting.On 10/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I am stumped.  I am trying to pass the variable 'savename' to a stringand get errors.can someon

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Jason Massey
Why not:if item in list: loc = list.index(item) list[loc] = strOn 10/20/06, Chris Hengge < [EMAIL PROTECTED]> wrote:I'm trying to build a little piece of code that replaces an item in a list. Here is a sample of what I'd like to do.str = "This was replaced"ff item in list:   replace item with str

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Jason Massey
ll that replace the location? or add to it? Thanks.On 10/20/06, Jason Massey < [EMAIL PROTECTED] > wrote:Why not:if item in list: loc = list.index(item)  list[loc] = strOn 10/20/06, Chris Hengge < [EMAIL PROTECTED]> wrote: I'm trying to build a little piece of code that repla

Re: [Tutor] regarding GNUPLOT and MATPLOTLIB..

2006-10-23 Thread Jason Massey
Very possible:For gnuplot:http://gnuplot-py.sourceforge.net/  See the instructions for using on Windows.For Matplotlib: http://matplotlib.sourceforge.net/installing.htmlPossibly what's confusing you is that both versions have external dependencies such as Numpy and Numeric (are those the same?  I'l

Re: [Tutor] regarding GNUPLOT and MATPLOTLIB..

2006-10-23 Thread Jason Massey
e 17, in ?     from matplotlib._ns_nxutils import *ImportError: numpy.core.multiarray failed to import   On 10/23/06, Jason Massey < [EMAIL PROTECTED]> wrote: Very possible:For gnuplot: http://gnuplot-py.sourceforge.net/  See the instructions for using on Windows.For Matplotlib: http://

Re: [Tutor] Decimal truncation, rounding etc.

2006-10-25 Thread Jason Massey
More specifically, Joe, where and what types of errors are you getting?When I type in your example exactly as above I get the following:>>>from decimal import *>>> Decimal('7.').quantize(Decimal('1.000'),rounding=decimal.ROUND_DOWN)Traceback (most recent call last):  File "", line 1, in ?NameE

Re: [Tutor] problem importing class

2006-10-26 Thread Jason Massey
Shawn,Python already has a module called site.  From http://docs.python.org/lib/module-site.html :This module is automatically imported during initialization. The automatic import can be suppressed using the interpreter's -S option. Importing this module will append site-specific paths to the mo

Re: [Tutor] Tuple and Dicts?

2006-11-09 Thread Jason Massey
How about something like:>>> data = "" 0, 'title': 'Linux'}, {'id': 1, 'title': 'FreeBSD'})>>> id = 0>>> result = [x for x in data if x['id'] == id][{'id': 0, 'title': 'Linux'}] >>> result = [x for x in data if x['id'] == id]>>> result[0]{'id': 0, 'title': 'Linux'}>>> You get the entire dict entry

Re: [Tutor] how to extract time from datetime.date.time()

2006-11-16 Thread Jason Massey
How about two different ways: import datetime t = datetime.datetime.now() t datetime.datetime(2006, 11, 16, 11, 28, 15, 75) t.hour 11 t.minute 28 t.second 15 a = "%d:%d:%d" % (t.hour,t.minute,t.second) a '11:28:15' or, a bit more succinctly: t.strftime('%H:%M:%S') '11:28:15'

Re: [Tutor] Problem making '.exe' from python.

2006-11-17 Thread Jason Massey
Check to make sure that under the shortcut properties that you have the "Start in" field filled out with the directory the script is located. On 11/17/06, Chris Hengge <[EMAIL PROTECTED]> wrote: Whether using py2exe or pyInstaller I've noticed a problem and I'm not sure how to fix it... When I

Re: [Tutor] Having trouble with " table % listTable.values() " line

2006-11-24 Thread Jason Massey
So you want to convert a list into a tuple. Here ya go, using your example of the table setup: raw_table =""" %s | %s | %s -- %s | %s | %s -- %s | %s | %s """ from random import choice x_o = [choice(['x','o']) for i in range(9)] x_o ['x', 'x', 'x', 'x', 'o', 'o', 'o',

Re: [Tutor] Why SelectAll() cannot work well ?

2006-11-30 Thread Jason Massey
I'm running WinXP and the entire text is selected when you enter a new choice. In fact, on XP at least, you don't have to use SelectAll, SetFocus selected the entire text. On 11/30/06, Jia Lu <[EMAIL PROTECTED]> wrote: Hi all I am using wx Py with FC6. I ran the program below but I found th

Re: [Tutor] How to allow user to choose an option from a window

2006-12-12 Thread Jason Massey
If you mean which type of GUI model to use you have at least two popular choices. Tkinter: It's bundled with Python, and there's a tutorial at: http://www.pythonware.com/library/tkinter/introduction/ wxPython: My GUI of choice. http://wxpython.org A quick and dirty example in wxPython of what y

Re: [Tutor] python cx_Oracle.LOB

2007-01-02 Thread Jason Massey
An example of your code would help. According to the cx_oracle docs at http://www.python.net/crew/atuining/cx_Oracle/html/index.html under the LOB Objects heading: 6. LOB Objects *NOTE*: This object is an extension the DB API. It is returned whenever Oracle CLOB, BLOB and BFILE columns are fetch

Re: [Tutor] Python gui for file input

2007-01-05 Thread Jason Massey
The simplest way would be to use TkInter which is distributed with Python. Check out the cookbook recipe at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438123 for a bunch of examples. jason On 1/5/07, Mike Ellis <[EMAIL PROTECTED]> wrote: Hi all, I am looking to create a simple

Re: [Tutor] Reg Google Web Toolkit and Python

2007-02-16 Thread Jason Massey
Oh, the irony...googling for python and gwt gave me: http://pyjamas.pyworks.org/ On 2/16/07, Shadab Sayani <[EMAIL PROTECTED]> wrote: Hi , We have a project where I need to read files store them in database in the backend.We have done this in python.Now we decided to use Ajax technique for u

Re: [Tutor] Two sys.exit questions

2007-02-28 Thread Jason Massey
When you call sys.exit() you're raising a SystemExit exception. help(sys.exit) Help on built-in function exit in module sys: exit(...) exit([status]) Exit the interpreter by raising SystemExit(status). If the status is omitted or None, it defaults to zero (i.e., success). If the s

Re: [Tutor] Squlite3 problem

2007-03-13 Thread Jason Massey
I found a similar discussion on the pysqlite mailing list ( http://lists.initd.org/pipermail/pysqlite/2005-August/000127.html) Try committing your changes and then closing your cursor. db.commit() cur.close() db.close() On 3/13/07, Jim Roush <[EMAIL PROTECTED]> wrote: I'm geting the followin

Re: [Tutor] declaring decaration on ul list

2007-03-14 Thread Jason Massey
You'll need a style sheet. See: http://alistapart.com/articles/taminglists/ On 3/14/07, Kirk Bailey <[EMAIL PROTECTED]> wrote: It just occurred to me that when my wiki does a backsearch it is useful to list the results with a * for decorating the unordered list results, so I can mousecopy it t

Re: [Tutor] HTTP file download

2007-03-14 Thread Jason Massey
I've tested this on my Apache server setup, it succesfully downloads the gif file and the text file and saves them. Even though I used the 'wb' flag (write binary) for the text file it turned out okay (the difference in 'w' and 'wb' seemed to be that 'wb' stripped off some of my blank lines). On

Re: [Tutor] Why is it...

2007-03-22 Thread Jason Massey
In the interpreter this doesn't work: f = open(r"c:\python24\image.dat") line = f.readline() while line: ... line = f.readline() ... f.close() Traceback ( File "", line 3 f.close() ^ SyntaxError: invalid syntax But this does: f = open(r"c:\python24\image.dat") line = f.readline()