Re: [Tutor] IDLE vs PythonWin

2009-02-10 Thread W W
On Mon, Feb 9, 2009 at 9:29 PM, Eric Dorsey wrote: > You can call a .py script from the command line, and it will run there. So, > in Windows XP: Start > Run > type "CMD" > Vista: Start > type "CMD" into the Start Search field. > If you're in Linux, get to a Terminal. > In Windows another window

Re: [Tutor] List weirdness

2009-02-13 Thread W W
On Fri, Feb 13, 2009 at 11:01 AM, bob gailer wrote: > Moos Heintzen wrote: > >> I guess I can't reference [0] on an empty list. (I come from a C >> background.) >> > Can you have an empty array in C? If so, it does not have any elements, so > you can't refer to element 0. I think the OP was co

Re: [Tutor] "Ctrl-C (unix)" in python

2009-02-18 Thread W W
On Wed, Feb 18, 2009 at 4:44 PM, pa yo wrote: > I am running my Twitter>>Wiki bots in infinite loops but can't find > an easy way to turn them off gracefully once I have started them. At > the moment I have to go into the terminal window where they are > running and type "Ctrl-C". (I am running

[Tutor] Tkinter Grid, Listbox expand

2009-02-26 Thread W W
Hi, I'm writing a Tkinter program and having severe problems with getting my listbox to expand when I resize the window. Here's my code so far: 1 from Tkinter import * 2 import os, shutil, tkFileDialog, tkMessageBox 3 4 class TkSync: 5 def __init__(self, root): 6 self.sbo

Re: [Tutor] Tkinter Grid, Listbox expand

2009-02-26 Thread W W
Aha! I found the key - I was missing the weight argument: 1 from Tkinter import * 2 import os, shutil, tkFileDialog, tkMessageBox 3 4 class TkSync: 5 def __init__(self, root): 6 self.sbox = Listbox(root) 7 self.sbox.grid(row=0, column=0, sticky=N+S+E+W) 8

Re: [Tutor] modular program

2009-03-01 Thread W W
On Sun, Mar 1, 2009 at 3:36 AM, Daniele wrote: > Hi, > I'd like to write a python program which can be easily extended by other > people. Where can I find some "best practices" for writing modular programs? > I thought about a txt file containing function calls that my program will > parse and exe

Re: [Tutor] animation with Tkinter canvas

2009-03-03 Thread W W
On Tue, Mar 3, 2009 at 3:05 AM, Mr Gerard Kelly wrote: > Hello, I am attempting to make a simple animation of a vibrating string using > Tkinter canvas. > I haven't been able to find much information on how to do it. > I have my data of position x on the string at time t. I can plot it > with > r

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-03 Thread W W
On Tue, Mar 3, 2009 at 1:54 PM, Wayne Watson wrote: > > BTW, the Quit function is original but doesn't kill the window when Quit is > used. What fixes that? For more bonus points, it seems as though the try > statement in the dialog should really bring up an "Error" dialog saying > something is wr

Re: [Tutor] print problem python

2009-03-07 Thread W W
On Sat, Mar 7, 2009 at 3:11 AM, Alan Gauld wrote: > Python 3 has a lot of > changes and most of the beginners material hasn't caught > up yet. It will be easier to get answers to your questions if > you stick with v2.6 and then when comfortable with that move > to v3 aand learn about the differenc

Re: [Tutor] Pyusb: get data via USB sent from mouse

2009-03-08 Thread W W
On Sat, Mar 7, 2009 at 9:35 AM, andré palma wrote: > Hi folks, I'm new on pyusb programming and to learn how to get data i'm > trying  to get  data  sent  from  my mouse. > I've download a program called usbview( http://www.kroah.com/linux/usb/ ) to > display the device descriptors of any USB devi

Re: [Tutor] probelm pyhton shell doesnt open help please

2009-03-08 Thread W W
On Sun, Mar 8, 2009 at 3:32 PM, mustafa akkoc wrote: > > it gives this message socket error That's not terribly descriptive... what type of python shell? IDLE? Interactive prompt? Ipython? Certainly you don't mean this? u...@system:~$ python socket error u...@system:~$ -Wayne _

[Tutor] best gui for the job?

2009-03-13 Thread W W
Hi, What is the best gui to implement a simple paint-esque program in? I already built a really simple one in Tkinter - but Tkinter lacks a save functionality. I considered using the PIL to draw in the background, but it didn't seem to have a good enough resolution. I thought about pyGTK because

Re: [Tutor] best gui for the job?

2009-03-13 Thread W W
On Fri, Mar 13, 2009 at 1:18 PM, Lie Ryan wrote: > W W wrote: > > What do you mean "good enough resolution"? I suppose I really meant quality - the shapes I drew with PIL were severely aliased, but maybe I didn't do it right. -Wayne -- To be considered stupid and to be

Re: [Tutor] (no subject)

2009-03-17 Thread W W
On Tue, Mar 17, 2009 at 2:16 PM, Jared White wrote: > This is what i have so far an this is not what i want it to do > "NO this isnt homework" i am trying to learn this myself > > #!/usr/bin/env python > # > #Author: J White > #Python 2.5.2 > # > howmany = int(raw_input('How many lines ')

Re: [Tutor] Left Alignment -- Tkinter

2009-03-28 Thread W W
On Fri, Mar 27, 2009 at 2:46 PM, Wayne Watson wrote: > It's very difficult to tell. I've tried it. > fLocation=Frame(master) > fLocation.pack(side=LEFT) > I need to size the fLocation frame to make it big. As it is, it must be > giving the smallest possible size. > > I tried this

Re: [Tutor] Left Alignment -- Tkinter

2009-03-28 Thread W W
On Sat, Mar 28, 2009 at 9:47 AM, Wayne Watson wrote: > Hi, that's an interesting way to look at it. Actually, I was about to > probe the color idea myself, but needed to better understand how to achieve > it. Where did grid_columnconfigure(3, weight=1) come from? I don't recall > seeing that with

Re: [Tutor] Automated function creation / outsourcing code

2009-03-29 Thread W W
On Sat, Mar 28, 2009 at 5:34 AM, Martin Klimach wrote: > Is there a python editor, that can automatically turn a selection of > code into a function? Matching the input and return variables? > > I've never heard of one. I suppose you could probably write your own using regexes perhaps. -Wayne _

Re: [Tutor] Left Alignment -- Tkinter

2009-03-30 Thread W W
On Sun, Mar 29, 2009 at 9:30 AM, Wayne Watson wrote: > I'm looking at the NM Tech Tkinter ref, pages 5-6, on the grid > method. See pages 84-88 of Lundh. Nothing. It does not show that method. > Search of the pdf doc shows nothing. Are these sources too old? effbot does > have it. Yes, it's pretty

Re: [Tutor] Left Alignment -- Tkinter

2009-04-02 Thread W W
On Wed, Apr 1, 2009 at 11:20 PM, Wayne Watson wrote: > Alan, the game changed in the thread you branched away from to other > considerations. As stated there, I've thrown in the towel, but first let me > say what the game was about. Here's the simplest example. Say I have four > labels: small, bi

Re: [Tutor] Executing a GUI from another GUI with a click of a button

2009-04-06 Thread W W
On Mon, Apr 6, 2009 at 2:30 PM, Chris Lee wrote: > > > I know for certain that the "clock.py" works (because i got it from the > web.. -_-;;) > > but I'm having a real difficulty trying to open clock.py through my real > program > > I know you're busy and everything, but I REALLY hope you can

Re: [Tutor] Event Handling--Key Press, Mouse Movement ...

2009-04-13 Thread W W
On Mon, Apr 13, 2009 at 1:22 PM, Gregor Lingl wrote: > Wayne Watson schrieb: > >> Sometime ago, one of my posts brought a response brief exchange on event >> handling*. Where might I find more about event handling with respect to the >> keyboard, and particularly with a mouse. In the latter case,

Re: [Tutor] Looking for starter projects

2009-04-15 Thread W W
On Wed, Apr 15, 2009 at 3:50 AM, Evert Edel wrote: > Hi all, > > Now since I've got the learning python book I first did a quick read trough > it and now I'm going more slowly trough it and doing all the explained > things (in the interactive prompt). I do understand the basics behind OOP > and

Re: [Tutor] python books

2009-04-15 Thread W W
On Wed, Apr 15, 2009 at 4:45 AM, Wayne Watson wrote: > It's unlikely you are going to find a pdf on Python that's suitable for > beginners. Do you mean pdf or a digital book? There are Python books in > digital form on the web. I'm not quite sure how it works, but I know of at > least one public l

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread W W
On Wed, Apr 15, 2009 at 12:27 PM, Carnell, James E < jecarn...@saintfrancis.com> wrote: > Since # the list seems thick with OOP questions at the moment, I thought > this might # be relevant. Digest and enjoy. > > class Item ( object ): > >def __init__( self ): >self._FullName = '' >

Re: [Tutor] for loop

2009-04-16 Thread W W
On Thu, Apr 16, 2009 at 3:45 PM, mbikinyi brat wrote: > Dear ALL, > I am a beginner in python and I just copied the code in blue below and > execute and had the result in green. Then I thought *letter* should be a > special word in python. Then I now replace letter whith *chic* and yet > the same

Re: [Tutor] Looping

2009-04-20 Thread W W
On Mon, Apr 20, 2009 at 8:48 AM, Matt > wrote: > Hey everyone, > > First post to this list. I hope I'm doing it right. > > Let's say I want to run func 10 times Is there a more pythonic way to do it > than this: > for i in xrange(10): > func() AFAIK that's the most pythonic way to do it... and

Re: [Tutor] Looping

2009-04-20 Thread W W
On Mon, Apr 20, 2009 at 12:34 PM, Matt > wrote: > Thank you. Func is in fact a call to an external non-python program. =] > Therefore, the loop must actually be mindlessly done. My question, however, > has been answered. > As an aside, why use range rather than xrange? I was under the impression

Re: [Tutor] Python help

2009-04-22 Thread W W
On Wed, Apr 22, 2009 at 11:08 AM, IT_ForMe wrote: > > Anyone know how to program this using Python > > Add up the prices for items in a shopping cart. Some items are taxable and > some items are not. You may assume a 7% tax rate for all taxable items. > Apply a 10% discount if the customer is a s

Re: [Tutor] understanding urllib.urlopen

2009-04-23 Thread W W
On Thu, Apr 23, 2009 at 10:58 AM, johnf wrote: > On Thursday 23 April 2009 08:44:07 am Emile van Sebille wrote: > > johnf wrote: > > > > > > > But if I attempt this > > > urllib.urlopen( > > > "http://maps.google.com?q='18Tadlock > > > Place Woodland CA'" > > >

Re: [Tutor] output formatting

2009-04-25 Thread W W
On Fri, Apr 24, 2009 at 10:57 PM, Matt Domeier wrote: > Hello, > > I have a series of lists that I need to output into files with a specific > format. Specifically, I need to have line breaks after each entry of the > list, and I need to do away with the ['..'] that accompany the data after I > t

Re: [Tutor] quick question to open(filename, 'r') vs. file(filename, 'r')

2009-05-05 Thread W W
On Tue, May 5, 2009 at 5:41 AM, spir wrote: > Le Tue, 5 May 2009 00:41:39 +0100, > "Alan Gauld" s'exprima ainsi: > > > > Backwards compatibility. The file type was introduced in python 2.2, > > > before which there was open. > > > > And file has been removed again in Python v3 > > In fact o

Re: [Tutor] Triggering code on 1 minute intervale ..

2009-05-09 Thread W W
On Sat, May 9, 2009 at 3:26 PM, Alex Feddor wrote: > .. What will be the best solution to trigger python code every minute as > soon as PC in on. > an autorun script... and in your script use the time.sleep(60) I believe. HTH, Wayne ___ Tutor maillist

Re: [Tutor] Hi everyone

2009-05-21 Thread W W
On Thu, May 21, 2009 at 2:42 AM, spir wrote: > >while word: > position = random.randrange(len(word)) >jumble += word[position] >word = word[:position] + word[(position + 1):] > Something that many of us use for debugging, and is also useful for comprehension is a sim

Re: [Tutor] Parsing Bible verses

2009-05-21 Thread W W
On Thu, May 21, 2009 at 4:26 PM, Eduardo Vieira wrote: > Hello, I'm planning to create a script to read a certain file, find > the line that contains Bible references and then use that to query a > bible database in order to print the verses in another file. > I will be looking for lines like thes

Re: [Tutor] IP-range

2009-05-25 Thread W W
On Sun, May 24, 2009 at 10:18 PM, Paras K. wrote: > Hello, > > I came across your answer / assistance on the IP range. I am fairly new to > the python world of programming. However, up to this point I have always > been able to get my programs to work by reading the books or following the > guide

Re: [Tutor] Find a good linux distribution with python.

2009-05-25 Thread W W
On Mon, May 25, 2009 at 3:57 AM, Michael Bernhard Arp Sørensen < mich...@arpsorensen.dk> wrote: > > I just wished that Python was upgraded in the distros. If I want to play > with Python3, I will need to compile it my self and specify which Python > interpretor to use in each Python file. But thi

Re: [Tutor] Tinkering with Tkinter

2009-05-26 Thread W W
On Mon, May 25, 2009 at 7:45 PM, Doug Reid wrote: > The following code and it's explanation doesn't seem to work: > > > 1. >>> from Tkinter import * > > 2. >>> tk = Tk() > > 3. >>> btn = Button(tk, text="click me") > > 4. >>> btn.pack() > > > > In line 1, we import the contents of the > Tk modul

Re: [Tutor] how to get variable from an external script or program

2009-05-29 Thread W W
On Fri, May 29, 2009 at 4:27 PM, shawn bright wrote: > Hey all > > I have a small program that when run from the command line, will > return a certain value for an arguement. Like this: > > > mfetchz 45 > > 45j > > so the program is mfetchz and the argument is 45 > > i know i can call the program

Re: [Tutor] Docking Windows using Python

2009-05-29 Thread W W
On Fri, May 29, 2009 at 7:48 PM, Hi wrote: > My program will have two windows. I want to be able to dock the two so they > are side by side. I am wondering if this is doable in Python. If so, could > someone lead me to the right direction on where to look? Thank you very > much. > I think you co

Re: [Tutor] Class Tips

2009-05-30 Thread W W
On Sat, May 30, 2009 at 8:20 PM, David wrote: > > Alan Gauld wrote: >> >> "David" wrote >> >>> I took this program that determines a fertilizer application rate; >>> ... >>> And converted it to class/object to learn how they work. Just looking for some pointers, if I did it correctly etc. >>> >>>

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 2:27 AM, Alan Gauld wrote: > > "Kent Johnson" wrote > >> > Yesterday, I posted a question to python-list involving custom >> > deepcopies in an inheritance hierarchy. I haven't received any >> >> ISTM that in general B.__deepcopy__() should call A.__deepcopy__() to do >> th

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 8:59 AM, Alan Gauld wrote: > > "W W" wrote > > ( Multiple constructors (or factory methods) is one feature I would like >>> to see added to Python! ) >>> >> >> Wouldn't it be possible to create sort of a... bast

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 3:55 PM, Alan Gauld wrote: > > "W W" wrote > >> class C: >>> @constructor >>> def LoadFromFile(fname, count): ... >>> @constructor >>> def Create(valueTuple):... >>> >>> Personally I pre

Re: [Tutor] Spell checking source code?

2009-06-02 Thread W W
On Tue, Jun 2, 2009 at 3:15 AM, ALAN GAULD wrote: > > > From: "wormina...@gmail.com" > > To: Alan Gauld > > Sent: Tuesday, 2 June, 2009 1:09:39 AM > > Subject: Re: [Tutor] Spell checking source code? > > > > In vim, > > > > :set spell > > :set nospell > > :help spell > > > But that will check th

Re: [Tutor] How o convert spaces into tabs??

2009-06-02 Thread W W
On Tue, Jun 2, 2009 at 12:42 PM, jyotsna guleria wrote: > > Hello every one, > > I am trying to parse a file: > > I want to convert all the spaces in between the characters to single tab. > > e.g: my file has contents like: > > 1G579011 10 2 0 00 >

Re: [Tutor] python workspace

2009-06-02 Thread W W
On Tue, Jun 2, 2009 at 1:30 PM, Dave Angel wrote: > roberto wrote: > > On Tue, Jun 2, 2009 at 10:54 AM, roberto wrote: >> >> >>> >> >>> >> hello, >>> >> i'd like to ask if there is anything in python which helps to see what >>> >> variables have been defined and their type and their dimension

Re: [Tutor] serious problem with graphics module

2009-06-02 Thread W W
On Tue, Jun 2, 2009 at 7:12 PM, Gregor Lingl wrote: > > Does anyone have experience with using IPython with Tkinter? Plenty, and it works wonderfully. I've never had any errors (that I know of) that weren't of my own making ;) My personal development environment consists of ipython for trying

Re: [Tutor] serious problem with graphics module

2009-06-03 Thread W W
Forwarding on to the list... -- Forwarded message -- From: Gregor Lingl Date: Wed, Jun 3, 2009 at 3:46 PM Subject: Re: [Tutor] serious problem with graphics module To: W W W W schrieb: > On Tue, Jun 2, 2009 at 7:12 PM, Gregor Lingl gregor.li...@aon.at>&

Re: [Tutor] advise on this loop

2009-06-04 Thread W W
On Thu, Jun 4, 2009 at 8:29 AM, Norman Khine wrote: > Hello, > I have the following code, which searches through a directory structure > such as: > > $ tree -L 2 companies > companies > |-- aberdeen-airport-ltd > | |-- aberdeen-airport-dyce-grampian > | `-- aberdeen-airport-dyce-grampian.meta

Re: [Tutor] serious problem with graphics module

2009-06-04 Thread W W
On Thu, Jun 4, 2009 at 7:47 PM, Kent Johnson wrote: > On Wed, Jun 3, 2009 at 5:51 PM, W W wrote: > > > Do you (or sombody else) know how to get ipython working with Python 2.6 > > (you know, > > the Python release, which has that new turtle module ;-) ) > > >

Re: [Tutor] split or replace

2009-06-05 Thread W W
On Fri, Jun 5, 2009 at 6:18 AM, Norman Khine wrote: > Hello, > What is the way to group each value so that I get a list, from a string > like: > > dir = '/expert/forum/expert/expert' > list = ['/expert', '/forum', '/expert', '/expert'] > > I've tried: > >>> dir = '/expert/forum' > >>> dir.split('

Re: [Tutor] Which Python Script Editor of Choice?

2008-04-03 Thread W W
On Thu, Apr 3, 2008 at 12:15 PM, Michael Langford <[EMAIL PROTECTED]> wrote: > Many people who go this way, program with or without one just fine. Those who > start right away always using IDE's can just plain die when they hit an > environment where they don't have one (due to time, money, locat

Re: [Tutor] a pyball python app

2008-04-03 Thread W W
Dean, Here's a tutorial/book that you should check out: http://www.greenteapress.com/thinkpython/ How to Think Like a (Python) Programmer by Allen B. Downey He generously has a free PDF to download, and the book makes use of some code - swampy.py I think if you 1) Read the book and try the exam

Re: [Tutor] Diff for Python

2008-04-05 Thread W W
Vim also has a similar command On Sat, Apr 5, 2008 at 12:59 AM, Terry Carroll <[EMAIL PROTECTED]> wrote: > On Fri, 4 Apr 2008, Wayne Watson wrote: > > > Is there a Linux diff-like command for Python code? I'd like to see the > > difference between two py files. > > You could just use diff. > >

Re: [Tutor] Code optmisation

2008-04-05 Thread W W
On Sat, Apr 5, 2008 at 2:44 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > "yogi" <[EMAIL PROTECTED]> wrote > > Question 2: If I have convert this code into a function. > > Should I ? > > Only if you have a need to reuse it in a bigger context > or of you want to parameterize it. You could maybe

Re: [Tutor] Creating Sudoku

2008-04-07 Thread W W
Actually, a dictionary might be a good idea. I just played with this so youcan get a little picture. >>> foo = {'1a': 3, '1b': 4} >>> row = raw_input("Row: ") Row: 1 >>> col = raw_input("Column: ") Column: b >>> val = raw_input("Value: ") Value: 1 >>> foo[row+col] = val >>> foo {'1a': 3, '1b': '1'

Re: [Tutor] MemoryError !!! Help Required

2008-04-07 Thread W W
I don't have a lot of experience, but I would suggest dictionaries (which use hash values). A possible scenario would be somthing similar to Andreas' visited = dict() url = "http://www.monty.com"; file = "/spam/holyhandgrenade/three.html" visited[url] = file unvisited = dict() url = "http://

Re: [Tutor] Creating Sudoku

2008-04-07 Thread W W
On 4/7/08, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > W W wrote: > What are you talking about? I don't understand what you mean by "ignores > whitespace between dictionary elements." > > > foo = {'1a': 1, '1b':2, '1c':3, &

Re: [Tutor] Creating Sudoku

2008-04-07 Thread W W
On Mon, Apr 7, 2008 at 10:53 AM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Also, did you test the code that "generates an error?" > It works fine for me. > >>> foo = {'1a': 'b'} > >>> foo['2b'] = 0 > >>> print foo['2b'] > 0 > >>> You're missing 4 spaces in front of foo['2b'] = 0, and h

Re: [Tutor] Writing dictionaries to a file

2008-04-08 Thread W W
On Mon, Apr 7, 2008 at 2:50 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Jerrold Prothero wrote: > > > > I've been trying to understand how writing a dictionary to a file & reading > > it back should work. > > > > It's been suggested that if I had a clue, I'd use pickle, but since I > > star

Re: [Tutor] List comprehensions

2008-04-10 Thread W W
My guess, though I'm not sure, is that google uses hashes... why? Because they're a *ahem* load faster than loops, and the reason is they replace the repetitive nature of a loop by using some type of formula. Exactly /how/ this is implemented, I'm not sure. A simple example of the speed differenc

Re: [Tutor] Font capture from webpages

2008-04-14 Thread W W
beautiful soup would do it. It's still looking into the source, though. On Mon, Apr 14, 2008 at 7:02 AM, Ashish Sharma <[EMAIL PROTECTED]> wrote: > Hi , > > I want to find the font style,Font size written in webpage without > looking into source code. > > Can Any one tell if there is API avalab

Re: [Tutor] Python Best Practice/Style Guide question

2008-04-29 Thread W W
Even with monospace, I can't really see it being that helpful, after all, in: x = 3 y = 5 foobar_fun = 20 3 and 5 are in no way related, x and 3 are. However, sometimes I break them up into more beautiful chunks: x = 3 y = 5 foobar_fun = 20 sometimes it's more helpful that way. just my 2.5c -

[Tutor] Method question?

2008-05-02 Thread W W
I'm playing around with pyGTK, and I have a question to see if I'm understanding things correctly. Is a method just a function inside a class? i.e. def myFunction(): print "This is a function" class myClass: def myMethod(): print "This is a method" and to call: myFunction() I

Re: [Tutor] Method question?

2008-05-02 Thread W W
On Fri, May 2, 2008 at 12:17 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > This just makes x an alias for the class object. Should be > x = myClass() > > > x.myMethod() > > then this will work. Ah! Thank you! I knew/guessed the alias bit from my experience with C++, but I couldn't figure o

Re: [Tutor] Method question?

2008-05-02 Thread W W
I think I'm beginning to understand how classes/methods work now, I'm sure further understanding will come with practice. Thanks for the help and suggestions! -Wayne On Fri, May 2, 2008 at 1:42 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > On Fri, May 2, 2008 at 2:20 PM, W

Re: [Tutor] Cosmetic question about printing

2008-05-06 Thread W W
On Tue, May 6, 2008 at 11:40 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > > > > > At 09:07 AM 5/6/2008, Kent Johnson wrote: > > You can right-justify in a format operation. You will have to do it in > two steps since the string you want to right-justify is itself the > result of a format operation:

[Tutor] timed functions? Timeouts?

2008-05-19 Thread W W
Hi, I'm having trouble finding any information (or if it's possible) on this particular topic. Specifically, there's a feature in javascript that I want to emulate. this is an example I pulled from a webmonkey tutorial -- function writeTime() { // get a date object

Re: [Tutor] timed functions? Timeouts?

2008-05-19 Thread W W
nson <[EMAIL PROTECTED]> wrote: > On Mon, May 19, 2008 at 5:28 PM, W W <[EMAIL PROTECTED]> wrote: >> Now, when I look at that example and try to translate the timeout to >> what I think is going on "behind the scenes" I'm pretty sure it spawns >> a thr

[Tutor] File access times

2008-05-21 Thread W W
I've just made an interesting observation, and I'm curious if anyone knows any more about it. 1 import time 2 3 start = time.time() 4 f = open("test.txt") 5 f.close() 6 end = time.time() 7 print end - start 8 9 10 start = time.time() 11 f = open("/home/wayne/python_files/test/t

Re: [Tutor] Fwd: listing classes

2008-05-22 Thread W W
I don't know if this is the best solution, but what I usually do is create a list that matches the key: mydict = {} mylist = [] for x in range(1, 10): key = raw_input("Enter the key: ") mydict[key] = value mylist.append(key) You just have to change it to read from a file/hard code all

Re: [Tutor] Randomize SSN value in field

2008-05-22 Thread W W
Oops! Maybe it works better with reply to all: You're looking for a completely random 9 digit number that you can't derive the name from? I don't know that anything would really be more or less secure than simply using random. >>> import random >>> random.randrange(1,9) 988559585

Re: [Tutor] Randomize SSN value in field

2008-05-22 Thread W W
On Thu, May 22, 2008 at 12:17 PM, taserian <[EMAIL PROTECTED]> wrote: > so that I can relate it back to the original SSN when needed. Oh! Oops! I didn't clearly understand this sentence the first time. Yes, you want to learn about cryptography. Google for Bruce Schneier - one of the world's forem

[Tutor] Fwd: python 2D list

2008-05-23 Thread W W
Oops! Forgot to "Reply to All" I'm not sure but take a look at this: >>> a = [[0]*3]*4 >>> a [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> a[1] [0, 0, 0] >>> a[0][0] = 4 >>> a [[4, 0, 0], [4, 0, 0], [4, 0, 0], [4, 0, 0]] >>> b = [[0,0,0],[0,0,0],[0,0,0]] >>> b [[0, 0, 0], [0,

Re: [Tutor] What lib should I use?

2008-05-25 Thread W W
However, something to note is that Google prohibits web scraping, at least via urllib. If you try to GET or POST (I can't remember off the top of my head), Google will not return the actual search. HTH, Wayne On Sun, May 25, 2008 at 8:06 PM, bob gailer <[EMAIL PROTECTED]> wrote: > Julia wrote: >

[Tutor] Best way to store space locations?

2008-05-29 Thread W W
For kicks and giggles/exercise, I'm creating a program that will decrypt a simple cypher (i.e. cesar cypher/rot13, or a=1, b=2, c=3), right now I've got my letter count, but I foresee a slight issue: dealing with spaces. For instance: "The quick brown fox jumps over the lazy dog" will give this da

[Tutor] Stripping punctuation

2008-05-29 Thread W W
Is there a faster way to strip punctuation from a string than this? from string import ascii_letters def strip_punctuation(mystring): newstring = '' for x in mystring: if x in ascii_letters: newstring += x else: pass return newstring In my decr

[Tutor] Fwd: Running shell command

2008-05-30 Thread W W
Curse my forgetting to reply to all! -- Forwarded message -- From: W W <[EMAIL PROTECTED]> Date: Fri, May 30, 2008 at 1:05 PM Subject: Re: [Tutor] Running shell command To: Ricardo Dueñas Parada <[EMAIL PROTECTED]> On Fri, May 30, 2008 at 12:52 PM, Ricardo Dueñas Pa

Re: [Tutor] Error in executing: cmd.

2008-05-30 Thread W W
I'm not certain, but it appears the file RNZ9ET~K.PY may not exist, or access is in some other way restricted. It's obviously running for a long time, about 3.75 hours. Is the RNZ*.PY file in some way generated by your original script? -Wayne On Fri, May 30, 2008 at 11:54 AM, Teresa Von Hazmbur

Re: [Tutor] TurtleWorld Windows issue

2008-06-06 Thread W W
You could always use a linux live cd ;) Heck some of them can even emulate linux in windows! That's my best solution in the short time I've got. HTH, Wayne On Fri, Jun 6, 2008 at 1:26 PM, <[EMAIL PROTECTED]> wrote: > I am working through _Think Python_ in spare time at work on a Windows > machi

Re: [Tutor] Why not to use include?

2008-06-09 Thread W W
Python can *too* import from a txt file (even if it contains HTML): f = open("myfile.html", "r") x = f.read() print x f.close() It even retains formatting (as far as I can tell)... HTH, Wayne On Sun, Jun 8, 2008 at 4:25 PM, Dotan Cohen <[EMAIL PROTECTED]> wrote: > 2008/6/8 Kent Johnson <[EMAIL

Re: [Tutor] Empty list validation

2008-06-09 Thread W W
>>> def empty_or_not(mylist): ... if mylist: ... print "Not empty" ... elif not mylist: ... print "Empty!" ... >>> empty_or_not([]) Empty! >>> foo = [] >>> empty_or_not(foo) Empty! >>> foo.append('hi') >>> empty_or_not(foo) Not empty My guess is that if any object is empty,

[Tutor] Controlling applications

2008-06-09 Thread W W
Hi, I've done some cursory searches, and it doesn't appear that what I want to do is popular, if it's even possible. I'm trying to control other applications via python (specifically my web browser). My hope is there is some way to emulate a series of keypresses. My goal is to have a script that

Re: [Tutor] Why not to use include?

2008-06-09 Thread W W
> Thanks, Wayne, I am actually aware of this method. But it seems that > what I really want _is_ a function, and not a simple include. When you say function, exactly what are you referring to? Because really all a function *is* is a set of statements that takes input* does something* gives output

Re: [Tutor] Why not to use include?

2008-06-09 Thread W W
On Mon, Jun 9, 2008 at 11:21 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote: > 2008/6/9 W W <[EMAIL PROTECTED]>: > I was doing this in PHP: > $title="Page title"; > include"/path/to/header.php"; > So in your header.php you had some source: echo "$ti

Re: [Tutor] IDE

2008-06-10 Thread W W
I use vi/vim. I find it extremely useful/powerful. -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] IDE

2008-06-10 Thread W W
On Tue, Jun 10, 2008 at 11:44 AM, Sean Novak <[EMAIL PROTECTED]> wrote: >> however, is the ability to run the current buffer interactively to a python >> command line. Is there a way to set this up in VIM? I know there's some python what-nots with vim, but I just do one of a few options: 1) I ha

Re: [Tutor] do I need f.close()

2008-06-10 Thread W W
On Tue, Jun 10, 2008 at 12:07 PM, dave selby <[EMAIL PROTECTED]> wrote: > Hi All, > > Up to now I when I need to write some data to a file I have been > purposely using close() > > f = open(conf, 'w') > f.writelines(lines) > f.close() > > Is it as safe to use the following > > open(conf, 'w').

Re: [Tutor] IDE

2008-06-10 Thread W W
On Tue, Jun 10, 2008 at 4:27 PM, Lowell Tackett <[EMAIL PROTECTED]> wrote: > > > From the virtual desk of Lowell Tackett > > > --- On Tue, 6/10/08, W W <[EMAIL PROTECTED]> wrote: > > From: W W <[EMAIL PROTECTED]> > Subject: Re: [Tutor] IDE >

Re: [Tutor] wanting to learn

2008-06-11 Thread W W
On Wed, Jun 11, 2008 at 9:48 AM, Michael yaV <[EMAIL PROTECTED]> wrote: > A little background on myself. I am a web designer so I am a Mac person. I > have taught myself HTML and flash by reading manuals and a lot of trial and > error over the last 11 years. I have always wanted to learn a language

Re: [Tutor] python gui

2008-06-11 Thread W W
On Wed, Jun 11, 2008 at 8:03 AM, Gabriela Soares <[EMAIL PROTECTED]> wrote: > Greetings, > > I want to make a dynamic dashboard, something like: > > http://examples.adobe.com/flex3/labs/dashboard/main.html# > > but using python. Is it possible ? Yes. -Wayne ___

[Tutor] Moving a window... on windows?

2008-06-16 Thread W W
I'm not even sure if this is possible... and so far a google search of "python move windows xp" has failed to yield any helpful looking results. I'm trying to create a script that will move a program window around on the desktop, and other than that search I'm not sure where to look. What we have

Re: [Tutor] Replace sequence in list - looking for direction

2008-06-16 Thread W W
On Mon, Jun 16, 2008 at 10:41 AM, GTXY20 <[EMAIL PROTECTED]> wrote: > I need some direction and thoughts on how I might seach the list for the > string (the key in dict b) sequence in list a and replace the occurance with > the value from dict b. At the end I would like to have list a represented >

Re: [Tutor] Visualizing the Python Project

2008-06-17 Thread W W
On Tue, Jun 17, 2008 at 6:40 AM, bhaaluu <[EMAIL PROTECTED]> wrote: > This is very interesting! > > http://www.vimeo.com/1093745 > > Visualizing the commit history of the Python scripting language project. > > http://vis.cs.ucdavis.edu/~ogawa/codeswarm/ That would only be cooler if it was written

Re: [Tutor] Checking the desktop environment

2008-06-20 Thread W W
On Fri, Jun 20, 2008 at 1:48 PM, Timo <[EMAIL PROTECTED]> wrote: > Thanks for your explanation. Apparently it's not possible to detect it > in all cases, but it would be nice to detect it for regular users, so > people who have a default install. > > Well, my program needs a text-editor and a graph

Re: [Tutor] closing a internet explorer com object

2008-06-26 Thread W W
On Tue, Jun 24, 2008 at 3:25 PM, John Chandler <[EMAIL PROTECTED]> wrote: > Below is a bit of code that should work, you might want to change ieregex > because right now it will close anything that has "Microsoft Internet > Explorer" in the title bar. Have fun. The simplest way to do this is use w

Re: [Tutor] need help; save web data

2008-06-30 Thread W W
On Sun, Jun 29, 2008 at 2:28 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Note that this may be a violation of the Google Scholar terms of > service; I know it is a violation to automatically collect normal > Google search results, and IIRC Google takes some steps to make it > difficult as well.

Re: [Tutor] Deleting specified files using a python program...help with code?]

2008-07-01 Thread W W
On Tue, Jul 1, 2008 at 3:47 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > But I find the in technique more flexible. > > If you go with the default approach the test becomes: > > if confirmation in 'yY' or not confirmation: > # go ahead and delete them That's slightly different, but basically th

Re: [Tutor] String concatenation too slow

2008-07-01 Thread W W
> On Tuesday 01 July 2008 00:12, Shrutarshi Basu wrote: >>I've been >> using string concatenation to read through the string, and then create >> the new one based on a dictionary lookup. However it becomes very slow >> once the string gets very long (several thousand characters). Part of >> it is

Re: [Tutor] Fwd: Problem Euler 26

2008-07-01 Thread W W
Just a tidbit: A neat function my friend came up with last year to figure out the length of a whole number (now converted to python for your viewing pleasure): from math import log10 as log from math import floor def findNumberLength(number): number = float(number) x = log(number) x

  1   2   3   >