Re: [Tutor] Assistance with Psuedocode

2010-11-17 Thread Dave Angel
On 2:59 PM, Joe Ohmer wrote: Hello, The following code works well but I don't understand why the mysteryEffect code block changes the picture. Doesn’t 64*(r/64) just equal r? (Same with g and b.) So this function should not change the picture at all. But it does! If anyone can explain how and

Re: [Tutor] Issues Parsing XML

2009-03-12 Thread Dave Kuhlman
) in ElementTree. Stefan did not tell you about that because he is a developer who has helped give us lxml, and perhaps he is a bit modest. There is a bit to learn in order to use the XPath capability in lxml. But, if you are doing any amount of XML processing in Python, it's likely to be wo

Re: [Tutor] Paython as a career

2009-03-17 Thread Dave Kuhlman
ber of times to teach classes in corporations that had a need for Python skills. So, there are definitely companies out there that would view Python programming skills as valuable. I suspect that there are others on this list who also teach Python in a corporate setting. - Dave -- Dave Kuhlm

Re: [Tutor] text editor and debugger for python

2009-03-24 Thread Dave Kuhlman
t Jed, emacs, Kate, Joe, ... They are all installable on Ubuntu Debian GNU/Linux. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Binary Real to Decimal

2009-03-30 Thread Dave Angel
I don't know what "sufficient numbers" means, but perhaps it's "significant digits" that was intended. And you have to decide if you want ten digits to the right of the decimal point, or ten significant digits in the whole number. That determines whether you want to round decnum2 or the final

Re: [Tutor] incrementing one minute

2009-03-30 Thread Dave Angel
mktime() and gmtime() are not inverses of each other. The first assumes local time, and the latter gmt (or utc). So unless you happen to be in England, and not in daylight savings time, you'd expect a problem. mktime() is documented as the inverse of localtime(), according to the docs. I'd

Re: [Tutor] incrementing one minute

2009-03-30 Thread Dave Angel
This is the second post I've seen on this homework assignment. You might look at the Python List for other ideas. mktime() and gmtime() are not inverses of each other. The first assumes local time, and the latter gmt (or utc). So unless you happen to be in England, and not in daylight savin

Re: [Tutor] incrementing one minute

2009-03-31 Thread Dave Angel
I am trying to filter Open Street Map nodes from http://planet.openstreetmap.org/minute/ ... into wikimark up for Yellowikis (http://www.yellowikis.org) I work from home - but this isn't a homework assignment. :-) Paul Y On Mon, Mar 30, 2009 at 5:52 PM, Dave Angel wrote: This is the s

[Tutor] os.popen3 > subprocess.Popen but nohup.out won't go

2009-04-04 Thread dave selby
/dev/null &' % kmotion_dir, shell=True) all is well except I now get nohup: appending output to `nohup.out' on the terminal which '&> /dev/null' used to ditch to /dev/null. I think this is because subprocess simulates the shell differently. Any idea how to ditch to

Re: [Tutor] renumbering a sequence

2009-04-04 Thread Dave Angel
Christopher Spears wrote: I want to write a script that takes a list of images and renumbers them with a user supplied number. Here is a solution I came up while noodling around in the interpreter: >>> alist = ["frame.0001.tif","frame.0002.tif","frame.0003.tif"] >>> new_start = 5000 >>> for x i

Re: [Tutor] base n fractional

2009-04-06 Thread Dave Angel
Chris Castillo wrote: Message: 1 Date: Sun, 5 Apr 2009 15:36:09 -0500 From: Chris Castillo Subject: [Tutor] base n fractional To: tutor@python.org Message-ID: <50e459210904051336v60dfc6ddt280d3c9c8f6e0...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I need some help c

[Tutor] Yet another Python book

2009-04-10 Thread Dave Kuhlman
can get it at no cost, in various formats here: http://www.rexx.com/~dkuhlman/#a-python-book And, if you really do feel a need to kill a tree, you can purchase a copy on paper here: http://www.lulu.com/content/paperback-book/a-python-book/2599081 - Dave -- Dave Kuhlman http

Re: [Tutor] Problem with converting Python to EXE using py2exe

2009-04-11 Thread Dave Angel
ALAN GAULD wrote: > That's a great idea Mr. Gauld! > But I have no idea how to do that... > can you maybe write a small example for a newb like me?? pretty please with cheese on top?? > > > base = pic(file="base.gif") > > > > > > Now, I'm just wondering... for the "base.gif" part, would

Re: [Tutor] Problem with converting Python to EXE using py2exe

2009-04-11 Thread Dave Angel
Alan Gould wrote: Good idea, I forgot that in Python you can find the full path that way. Too used to working in C/C++ where the file macro only gives the filename... In C++, you wouldn't want the full path to the source file, but the full path to the .EXE file. That can be gotten in Windo

Re: [Tutor] Problem with converting Python to EXE using py2exe

2009-04-11 Thread Dave Angel
Dave Angel wrote: In C++, you wouldn't want the full path to the source file, but the full path to the .EXE file. That can be gotten in Windows, by using GetModuleHandle(0), and some other function on that handle. Sorry I don't remember the name of the second function, but I ha

Re: [Tutor] print output

2009-04-16 Thread Dave Angel
mbikinyi brat wrote: Dear ALL, I have defined variables as below and when I call them using the print function, I have something discontinous as in pink colour. How do I call it so that my output should be as in blue counter=101 miles=1000 name="joe" print counter

Re: [Tutor] Functions output

2009-04-17 Thread Dave Angel
mbikinyi brat wrote: Dear all, Here are two functions printme and change quite spaced apart. When executed the output in bold are joined. What can I do so that the results are separate in two blocks? ? #Function definition is here def printme(str): ??? "This prints a passed string into this fun

Re: [Tutor] output formatting

2009-04-25 Thread Dave Angel
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 transform the list into a string. Can

[Tutor] Printing Problem python 3

2009-04-29 Thread Dave Crouse
Trying to print something with a { in it. Probably extremely simple, but it's frustrating me. :( print ('The \"This is a test \" {') i get this error ValueError: Single '{' encountered in format string ___ Tutor maillist - Tutor@python.org http://ma

Re: [Tutor] Printing Problem python 3

2009-04-29 Thread Dave Crouse
The double {{ }} worked perfectly, THANK YOU ! :) This was driving me crazy. On Wed, Apr 29, 2009 at 2:03 PM, Kent Johnson wrote: > print ('The \"This is a test \" {') > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/

Re: [Tutor] Printing Problem python 3

2009-04-29 Thread Dave Crouse
I got the same thing with idle, but when running as a script, it's not the same, it errors. I tried it on Windows and Linux. --- [da...@arch64 Python]$ less test.py #/usr/bin/python3 print ('The \"This is a test \" {') [da...@arch64 Python]$ sh test.py tes

Re: [Tutor] How to Extend a class in another file in same directory

2009-04-29 Thread Dave Angel
sudhanshu gautam wrote: 2.Now another file in which I want to extend that same parent class is here .First code running successfully but in another one having problem 'This another source code will represent the new Entry of database' import title class Newstudent(Studentdatabase): def

Re: [Tutor] Different Command Result Executing in Shell vs. Program

2009-05-09 Thread Dave Angel
robert mcquirt wrote: Hi. I've not been working with Python very long and have run into a puzzling thing. I'm working on a program that needs to identify the filetype of files without extensions. Using the file command in the shell works fantastic, as in: rob...@ubuntu:~$ file -b linu

Re: [Tutor] Suggestions for while loop

2009-05-10 Thread Dave Angel
David wrote: Hi, I am going through Wesley Chun's book and this is Exercise 8-11; Write a program to ask the user to input a list of names, format "Last Name" "comma" "First Name". Write a function that manages the input so that when/if the user types in the names in the wrong format the err

Re: [Tutor] moving files from one dir to another

2009-05-11 Thread Dave Angel
Matt Herzog wrote: Should be simple, right? Not for me, heh. def schmove(src,dst): ... src = '/home/datasvcs/PIG/cjomeda_exp/' ... dst = '/home/datasvcs/PIG/cjomeda_exp_archive/' ... listOfFiles = os.listdir(src) ... for filez in listOfFiles: ... os.s

Re: [Tutor] finding difference in time

2009-05-15 Thread Dave Angel
R K wrote: Gurus, I'm trying to write a fairly simple script that finds the number of hours / minutes / seconds between now and the next Friday at 1:30AM. I have a few little chunks of code but I can't seem to get everything to piece together nicely. import datetime,time now = datetime.dat

Re: [Tutor] Iterating through a function list

2009-05-20 Thread Dave Kuhlman
if name in funcs: funcs[name](arg, ...) Python is making this too easy for you, making it hard to spot the solution. Think of parentheses as a "function call operator", which you can apply to any callable value. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___

Re: [Tutor] Iterating over list of functions

2009-05-20 Thread Dave Angel
Robert Berman wrote: Thank you, Christian. This solution was one I was not expecting and am glad to receive it. It is one I will explore in greater detail later. Robert On Wed, 2009-05-20 at 16:44 +0200, Christian Witts wrote: Robert Berman wrote: Hi, Given a list of options: optio

Re: [Tutor] ?????

2009-05-25 Thread Dave Angel
prasad rao wrote: Hello It is printing wether the item is callable or not. I want it to print sys.getdefaultencoding ASCII sys.getfilesystemencoding mbcs Like that Prasad But when you get to sys.exit(), you'll be terminating your test. In general, it's not safe to just run through a lis

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

2009-05-25 Thread Dave Crouse
It's not a newbie distro by any means, but i am very fond of Arch Linux. It has 3 versions of python available. Currently, python24 2.4.6-1 python 2.6.2-1 python3 3.0.1-1 are all very simple to install in Arch. I have 2.6 and 3.0 both installed. [cro...@veronica ~]$ python --version Python 2.6.2

Re: [Tutor] Python Function Doubt

2009-05-26 Thread Dave Angel
nikhil wrote: Hi, I am learning Python and came across this example in the Python Online Tutorial ( http://docs.python.org/tutorial/controlflow.html#default-argument-values) for Default Argument Values. ex: def func(a, L=[ ]): L.append(a) return L print func(1) print func(2) print func(3)

Re: [Tutor] IDLE shortcut doesn't exist except for in the Start Menu

2009-05-26 Thread Dave Angel
Gregory Morton wrote: Looking in the directory for Python, I see no real sign of IDLE anywhere in it. The reason for why I want it visible is because I plan on storing Python (this is 3.0.1 by the way) in my USB thumbdrive so I can use and transfer it on other computers. Is there any logic b

Re: [Tutor] Error installing review board on windows

2009-05-28 Thread Dave Angel
vishwajeet singh wrote: Hi List, I am trying to install review board on windows. It fails saying it could not build PIL 1.1.6 because visual studio was not found on the system and but I have already installed the PIL 1.1.6 using binaries available on the site but review board fails to locate

Re: [Tutor] python workspace

2009-06-02 Thread Dave Angel
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 etc; >> >> if any of you has ever used Matlab, i mean something really sim

Re: [Tutor] python workspace

2009-06-06 Thread Dave Kuhlman
On Tue, Jun 02, 2009 at 04:40:43PM -0500, W W wrote: > >On Tue, Jun 2, 2009 at 1:30 PM, Dave Angel <[1]da...@ieee.org> wrote: > > You could use the commercial Komodo IDE. It's got a debugger that > runs the Python code as a separate process, so it

Re: [Tutor] glob.glob(pattern, dir) ?

2009-06-09 Thread Dave Angel
spir wrote: Hello, is there a way to make glob work in a specified dir? (or is it necessary to use os.chdir first?) Thank you, denis You can hand glob.glob either a relative pathname (in which it's relative to the current directory), or an absolute pathname.

Re: [Tutor] Simple factorial program

2009-06-11 Thread Dave Angel
Eddie wrote: I'm trying to write a simple factorial program and am unsure at what is wrong with it. Why Can't I go *factorial = factorial * number* where factorial and number are both integers? #Factorial program print "Factorial finder" number = input("Please enter a non-negative integer: "

Re: [Tutor] Help..Concatenaton Error

2009-06-11 Thread Dave Angel
Randy Trahan wrote: Attached is an error I cannot get to work, I was doing a print concatenation but it won't let me get past "+ "ibly impressive. " \ (then to next line) If you had included the sample lines in your message, instead of an attachment, then it'd be part of the mailing list, a

Re: [Tutor] 3.0 on Mac

2009-06-11 Thread Dave Angel
acfleck wrote: I'm a Python nubie and having trouble with 3.0.1 on Mac (10.4.11). I did a default install of MacPython 3.0.1. The IDLE.app works fine, but from a Terminal window, the 'python' command still gets me V2.5.3 (the original Apple installed version). A 'python3' command is not reco

Re: [Tutor] Best Python Editor

2009-06-13 Thread Dave Angel
Eddie wrote: Hi guys, What would you regard as the best free Python editor to use on Windows for a new guy? Searching Google i see that there is quite a few out there and is "VIM" the best one to go with? Regards Eddie This is such a common question on the python forums it ought to be in

Re: [Tutor] Eliminating consecutive duplicates in a list

2009-06-18 Thread Dave Angel
karma wrote: I was playing around with eliminating duplicates in a list not using groupby. From the two solutions below, which is more "pythonic". Alternative solutions would be welcome. Thanks x=[1,1,1,3,2,2,2,2,4,4] [v for i,v in enumerate(x) if x[i]!=x[i-1] or i==0] [x[i] for i in range(l

Re: [Tutor] reference to directory a module is located at

2009-06-18 Thread Dave Angel
bob gailer wrote: Elisha Rosensweig wrote: > Hi, > > How can I determine the directory in which a module is located, from > within that module? sys.modules[__name__].__file__ -- Bob Gailer Or more simply, __file__ But the OP wanted the directory, which can be extracted with method d

Re: [Tutor] list of instance objects, access attribute

2009-06-18 Thread Dave Angel
Vincent Davis wrote: given a class like class B(): def __init__(self, b1, b2): ??? self.fooa = fooa ??? self.foob = foob Ok now I have several instances in a list b1 = B(1, 2) b2 = B(3, 4) b3 = B(9, 10) alist = [b1, b2, b3] Lets say for each instance of the class I want to print the value of fo

[Tutor] home directory usage script

2009-06-18 Thread dave chachi
I was wondering if I can get some incite on how to create a python that will accomplish the following tasks: issue: /home partition is partitioned to 80 or so G of space 24 G's is used         A. What is taking up this amount of space     B. Not alot of packages are installed and shouldnt take

Re: [Tutor] Handling Generator exceptions in Python 2.5

2009-06-19 Thread Dave Angel
Joe Python wrote: I have a generator as follows to do list calculations. *result = [(ListA[i] - ListB[i-1])/ListA[i] for i in range(len(ListA))]* The above generator, throws '*ZeroDivisionError*' exception if ListA[i] = 0. Is there a way to say 'Don't divide by ListA[i] if its equal to 0 (wi

Re: [Tutor] Need help with code.

2009-06-19 Thread Dave Angel
Raj Medhekar wrote: Hi, I need help with the code below. I am trying to pair the list in the hint with the list of words. However, the list is not matching up correctly. Also when the correct guess is entered the program just continues without acknowledging the right answer. Please could y'al

Re: [Tutor] Generating Deck Combinations

2009-06-20 Thread Dave Angel
Michael Morrissey wrote: I need to generate all possible deck combinations given two different lists as input. The Input: List 1 has Card names listed inside it. List 2 has Maximum Quantities for each Card name. For example: List1[0] would be: "Aether Vial" List2[0] would be: "4" List1[1]

[Tutor] short circuiting

2009-06-25 Thread Dave C
Hi I've read that the builtin all() function stops evaluating as soon as it hits a false item, meaning that items after the first false one are not evaluated. I was wondering if someone could give an example of where all()'s short circuiting is of consequence, akin to: False and produces_side_eff

Re: [Tutor] newton's method for system of nonlinear equations

2009-06-26 Thread Dave Angel
kgotlele...@galmail.co.za wrote: Hi, I am trying to write a program in python that solves a system of nonlinear equations using newton's method. I don't know what I am doing wrong. Please help First thing wrong is posting two messages in the mailing list in rapid succession (7 minutes) wit

Re: [Tutor] Very basic Python question

2009-06-27 Thread Dave Angel
Daniel Sato wrote: Hi, Let me preface this by saying that I purchased O'Reilly's "Learn Python" yesterday and have no programming experience (I am a photographer by trade) except for a semester of what I think was BASIC on some old apple back in elementary school (circa 1992). I am not sure w

Re: [Tutor] intefaces in python

2009-06-29 Thread Dave Angel
Amit Sethi wrote: Well I want to implement plug-in like mechanism for an application . I want to define some minimum functions that any body writing a plugin has to implement. For that i thought an interface would be best because in a scenario where the function is not implemented some kind of

Re: [Tutor] Tutor Digest, Vol 64, Issue 128

2009-06-29 Thread Dave Angel
Amit Sethi wrote: . On Mon, Jun 29, 2009 at 5:01 PM, Dave Angel wrote: > > Amit Sethi ?wrote: > >> Well I want to implement plug-in like mechanism for an application . I want >> to define some minimum functions that any body writing a plugin has to >> imple

Re: [Tutor] About the vertical bar input

2009-06-29 Thread Dave Angel
"hyou" wrote: Hello, I'm trying to write a script that simply execute a command line like: C:\...(path)..\Devenv solution /build "Debug|Win32" However, in Python the "|" symbol is reserved thus I just can't make the command line above working once I added the "|" sign in it. How

Re: [Tutor] Need help with python game program

2009-06-30 Thread Dave Angel
jonathan wallis wrote: My problem is simple, is their a way to make a variable equal multiple numbers? Such as X = 5 through 10, and then the program makes x equal something random 5 through 10, or something similar. For a short question, why did you quote an entire mailing list digest?

Re: [Tutor] Python Programming exercise

2009-07-01 Thread Dave Angel
Daniel Sato wrote: I have been going through some Python Programming exercises while following the MIT OpenCourseWare Intro to CS syllabus and am having some trouble with the first "If" exercise listed on this page: http://en.wikibooks.org/wiki/Python_Programming/Conditional_Statements#If_Ex

Re: [Tutor] printing tree structure

2009-07-03 Thread Dave Angel
karma wrote: Hi all , I have a nested list in the structure [root,[leftSubtree],[RightSubtree]] that I want to print out. I was thinking that a recursive solution would work here, but so far I can't quite get it working. This is what I have so far: Can someone suggest whether this is suited to

Re: [Tutor] thesaurus

2009-07-10 Thread Dave Angel
Alan Gauld wrote: "Angus Rodgers" wrote parsing these two sentences: Time flies like an arrow. Fruit flies like a banana. Or the translation program that translated the expression Out of sight, out of mind from English to Russian and back with the result: Invisible, lunatic Alan G.

Re: [Tutor] thesaurus

2009-07-10 Thread Dave Angel
Kent Johnson wrote: On Fri, Jul 10, 2009 at 7:08 AM, Dave Angel wrote: Alan Gauld wrote: Or the translation program that translated the expression Out of sight, out of mind from English to Russian and back with the result: Invisible, lunatic Or the expression: &quo

Re: [Tutor] thesaurus

2009-07-11 Thread Dave Angel
Pete Froslie wrote: thanks for the advice Alan.. I am wondering about the following: new_word = response3[2] old_word = response[word_number] #this works but adds carriage returns* for line in fileinput.FileInput("journey_test.txt",inplace=1): line = line.replace(old_word, new_word)

Re: [Tutor] thesaurus

2009-07-11 Thread Dave Angel
Pete Froslie wrote: the trailing comma is getting me much closer right away! -- will read about the other options you suggest (rstrip(); stdout: write()) I clearly have a few other issues I need to sort out now. i guess I've been assuming that print was a good way to trace what is happening rathe

Re: [Tutor] String manipulation: Pig latin translator

2009-07-12 Thread Dave Angel
Eddie wrote: Hi guys, What I have here is more of a logic problem that I can't get my head around than a programming problem. I am trying to program an English to Pig Latin translator. I've got the English to Pig Latin part down and its working great. The part I am having difficulty with is the

Re: [Tutor] thesaurus

2009-07-12 Thread Dave Angel
Pete Froslie wrote: so, I've been playing with the functions a bit-- took a little time to get the hang of them after I started that other mess. Initially, I've done the opposite suggested here by creating functions without the input values. I do see the where it will pay off in re-usability that

Re: [Tutor] Pythonify this code!

2009-07-13 Thread Dave Angel
Muhammad Ali wrote: Hi, This is my first attempt at python. I tried my hand at steganography for fun. The code includes separate, combine, encode, decode functions. The separate function takes a number and it's base and returns a list containing each digit of the number in a list, vice versa for

Re: [Tutor] thesaurus

2009-07-13 Thread Dave Angel
Pete Froslie wrote: The url function btw: def url(): fin = open("journey_test.txt", "r") response = re.split(r"[/|/,\n, , ,:\"\"\.?,)(\-\<>\[\]'\r']", fin.read()) thesaurus = API_URL + response[word_number] + '/' #API_URL is established at the start of the code return thesaurus

Re: [Tutor] for statement with addition ...

2009-07-13 Thread Dave Angel
Markus Hubig wrote: Hi @all, within diveintopython I often found a for-statement like this: f for f in bla: print f So what actually is the first f for ... is it just to declare f before starting the for loop? I can't find any information on python.org and it's hard to google this kinda st

Re: [Tutor] Pythonify this code!

2009-07-14 Thread Dave Angel
A.T.Hofkamp wrote: Muhammad Ali wrote: def separateToList(num): """ changes an integer into a list with 0's padded to the left if the number is in tens or units """ assert(num <= 255) s = str(num) li = [] if len(s) > 2: li = [s[0:1], s[1:2], s[2:3]]

Re: [Tutor] unittests, testing a type

2009-07-14 Thread Dave Angel
On Tue, Jul 14, 2009 at 9:59 AM, Todd Matsumoto wrote: The reason why is I'm receiving the Decimal value from another program, if I already know that the value will be a Decimal why test it? How are you receiving it? File, pickle, pipe, socket, exit() return value? When I first read

Re: [Tutor] unittests, testing a type

2009-07-16 Thread Dave Angel
if I don't have a value that is a Decimal object something is wrong. Cheers, T Original-Nachricht Datum: Tue, 14 Jul 2009 22:36:14 -0400 Von: Dave Angel An: CC: Todd Matsumoto , tutor@python.org Betreff: Re: Re: [Tutor] unittests, testing a type On T

Re: [Tutor] objects becoming pointers

2009-07-16 Thread Dave Angel
chris Hynes wrote: That's just it, you won't know in advance what names the user will type in. Maybe I mean to say dynamically create pointers. For instance, In the morning, I might be working with data regarding methanol and do several iterations and save those iterations in separate arrays wi

Re: [Tutor] python interpreter vs bat file

2009-07-19 Thread Dave Kuhlman
sked several times for more information. You really need to read: http://catb.org/~esr/faqs/smart-questions.html There are people on this list who are very generous with their time. It's a valuable resource. Please don't waste it. I don't mean to be rude. But, you will help

Re: [Tutor] demo/turtle

2009-07-22 Thread Dave Angel
roberto wrote: On Wed, Jul 22, 2009 at 7:06 PM, Alan Gauld wrote: "roberto" wrote i'd like to download the demo/turtle directory but i could not find the correct link; i need it to run the exampled cited in http://docs.python.org/library/turtle.html can you tell me where to find it ?

[Tutor] Bouncing mail

2009-07-22 Thread Dave Angel
Geneviève DIAGORN wrote: Bonjour, Je suis absente jusqu'au 23/07 inclus. Je prendrai connaissance de votre mail vendredi. En cas d'urgence Soprane, contacter Benoît Tottereau ou William Dibas. Cordialement. Geneviève If you must use an "out of office" auto-reply, then unsubscribe to the ma

Re: [Tutor] Reading text until a certain point

2009-07-24 Thread Dave Angel
vince spicer wrote: you can build a dictionary and keep the active key, again this would only work in predictable data users = {} name = None for line in file: key, value = [x.strip() for x in line.split(":")] if key == "name": name = data[1] users[name] = {} else:

Re: [Tutor] What kind of number is this

2009-07-25 Thread Dave Angel
Emad Nawfal (9E'/ FHAD) wrote: Hi Tutors, I have a bunch of text files that have many occurrences like the following which I believe, given the context, are numbers: ١٨٧٢ ٥٧ ٢٠٠٨ etc. So, can somebody please explain what kind of numbers these are, and how I can get the original numbers bac

Re: [Tutor] Syntax Problem

2009-07-25 Thread Dave Angel
Jesse Harris wrote: for d in Decks.all(): #loop thru all available decks self.response.out.write(''+d.name) self.response.out.write(''+d.description) self.response.out.write('') self.response.out.write('') : invalid syntax (main.py, line 206) args = ('invalid syntax'

Re: [Tutor] Reading Data From File

2009-07-25 Thread Dave Angel
Chris Castillo wrote: Okay I really need help with the program I am writing. I've can't seem to figure out what I need to do and have tried several different methods. I need to read in a text file in python that contains the following: Student Name ( could be unknown amount in file ) Numeric G

Re: [Tutor] Reading Data From File

2009-07-25 Thread Dave Angel
ling the loop that a new student and his or her grades are about to follow) By the way I'm not worrying about determining the letter grade average right now, i'm importing a module I wrote after I figure this part out. On Jul 25, 2009 8:34am, bob gailer wrote: I concur with wesley

Re: [Tutor] Reading Data From File

2009-07-26 Thread Dave Angel
ll wouldn't be right because I'm processing everything all at once with no way to reference any of the grades with the student. How do I structure this differently to do that? That's what I'm having trouble with. On 7/25/09, Dave Angel wrote: ctc...@gmail.com wrote:

Re: [Tutor] First code snipet

2009-07-26 Thread Dave Angel
Darth Kaboda wrote: Subject: Re: [Tutor] First code snipet From: andr...@kostyrka.org To: darthkab...@msn.com CC: tutor@python.org Date: Sun, 26 Jul 2009 03:02:27 +0200 Some things: 1) It's Python, not Phython. 2) Slightly shorter solution to your problem: import random input = range(53

Re: [Tutor] simple text replace

2009-07-26 Thread Dave Angel
j booth wrote: Hello, I am scanning a text file and replacing words with alternatives. My difficulty is that all occurrences are replaced (even if they are part of another word!).. This is an example of what I have been using: for line in fileinput.FileInput("test_file.txt",inplace=1):

Re: [Tutor] simple text replace

2009-07-27 Thread Dave Angel
Albert-Jan Roskam wrote: Hi! Did you consider using a regex? import re re.sub("python\s", "snake ", "python is cool, pythonprogramming...") Cheers!! Albert-Jan --- On Mon, 7/27/09, Dave Angel wrote: From: Dave Angel Subject: Re: [Tutor] simple text re

Re: [Tutor] First code snipet

2009-07-27 Thread Dave Angel
= min(len(inpile1), self.rgen.randint(1,4)) At the end of the function, the if pile1c: elif ... logic could be replaced by rpile.extend(inpile1).extend(inpile2) as there's no harm in extending with an empty list. HTH, DaveA Dave and Alan, Thank you for the advice and showin

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Dave Angel
davidwil...@safe-mail.net wrote: Here is the updated viersion: --- import glob import csv from os import rename countries =} reader =sv.reader(open("countries.csv")) for row in reader: code, name =ow countries[name] =ode files =et([file for file in glob.glob('Flag_of_*.svg')]) for f

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dave Angel
Gregor Lingl wrote: Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the command line shows I'm using 2.62: C:\Documents and Settings\R

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dave Angel
Dick Moores wrote: On Mon, Jul 27, 2009 at 04:27, Gregor Lingl wrote: Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the comm

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dave Angel
Dick Moores wrote: On Mon, Jul 27, 2009 at 04:27, Gregor Lingl wrote: Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the comm

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread Dave Angel
Chris Castillo wrote: so I have a string: 1 4|-| 50 |_33+. I love [#ick3n 4nd ch3353. Don't you love +|_|2|\e7 \/\/1+# the |#a|-|i|_7? and I am trying to turn it into english with the following code: fileIn = open("encrypted.txt", "r").read() def eng2leet(astring): astring = astring.re

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-28 Thread Dave Angel
Dick Moores wrote: I'm not sure how to edit it. What's required for Ulipad is quite different, I believe. This is what I got from Dave Angel: e: cd \Python26\Lib\idlelib\ ..\..\pythonw.exe idle.pyw %* And I can't decipher it. What is the "..\..\"? Just ask.

Re: [Tutor] Help...

2009-07-28 Thread Dave Angel
Ryan V wrote: For this source code, i am getting some errors, and not sure how to fix it, as i am returning all the values. it is telling me that there is no value for the variables i am returning. any help is greatly appreciated! Source #main function def main(): print 'The menu is:' pr

Re: [Tutor] self.name vs. passing a name

2009-07-28 Thread Dave Angel
Che M wrote: This is another very basic structural question, related to one I asked last week, and again is not necessarily germane only to Python. Let's say you have a sequence of two calculations or manipulations you need to do, each one done as a function called by an overall calculate_some

Re: [Tutor] how to get blank value

2009-07-28 Thread Dave Angel
amr...@iisermohali.ac.in wrote: It is not giving any value, without any error ph08...@sys53:~> python trial.py ph08...@sys53:~> it is coming out from shell. Thanks for help. Amrita amr...@iisermohali.ac.in wrote: Sorry to say, but till now I have not got the solution of my problem, I

Re: [Tutor] concerning help() function

2009-07-29 Thread Dave Angel
David wrote: Dear Tutors, whenever I make use of the help() function, I have a good chance of getting an error. I have not yet understood this tool very well. Take the modules operator and random as examples. The former is built-in, the latter not. Do I wish to see the help files, I have to use

Re: [Tutor] manipulating lists

2009-07-29 Thread Dave Angel
(You omitted a title, so I made one up. Hope it's okay) Chris Castillo wrote: # Module demonstrates use of lists and set theory principles def Unite(set1, set2): # evaluate 2 lists, join both into 1 new list newList = [] for item in set1: newList.append

Re: [Tutor] flag to call methods on objects?

2009-07-30 Thread Dave Angel
prasad rao wrote: hello I wanted to prevent other users of my computers to read my files. So tried to creat a module to achieve it. I used a flag to deside which methods to be called on the object. somehow it is not working.I realise after 2 days of struggle that as it is usuel , I am blind

Re: [Tutor] flag to call methods on objects?

2009-07-30 Thread Dave Angel
prasad rao wrote: On 7/30/09, Dave Angel wrote: prasad rao wrote: hello "it is not working." is not very descriptive. DaveA Hello! Sorry, I forgot to mention the problem. It simply wipes clean the file,resulting in empty file. Yes

Re: [Tutor] Assigning each line of text to a separate variable

2009-07-30 Thread Dave Angel
Marv Boyes wrote: Hello, all. This is probably embarrassingly basic, but I haven't been able to find something that works. I'm working on a script that needs to manipulate a list (not 'list' in the Python sense) of URLs returned in a server response. Right now, I'm stripping the XML tags fro

Re: [Tutor] Assigning each line of text to a separate variable

2009-07-30 Thread Dave Angel
Marv Boyes wrote: I'm very sorry; I should have been more explicit in what it is I'm working with. The response from the server consists of a pair of hashes and a list of URLs for doing different things with the file the hashes represent. So the full response is like this: file_hash

Re: [Tutor] flag to call methods on objects?

2009-07-31 Thread Dave Angel
prasad rao wrote: hello I removed the bugs.But still getting error report. import mcript Traceback (most recent call last): File "", line 1, in import mcript File "C:\Python26\mcript.py", line 78, in a.main() File "C:\Python26\mcript.py", line 58, in main nl=__

Re: [Tutor] mnemonics to better learn Python

2009-07-31 Thread Dave Angel
Eduardo Vieira wrote: Hello, would anybody have a good memorization technique for boolean results? Like when using 'or'/'and' what it returns when both are false, the last is false, etc? I find it so hard to remember that... Eduardo I don't blame you for finding it hard to remember. The

Re: [Tutor] flag to call methods on objects?

2009-08-01 Thread Dave Angel
(You replied off-list, so I'm copying your email, plus my response, to the list) prasad rao wrote: >I still see four problems. Hello Dave.I made modification as suggested by you. You made the first three. But the problem of zlib.compress() producing a string with an embedded (0a) sti

<    1   2   3   4   5   6   7   8   9   10   >