Re: [Tutor] saving output data in a file

2009-12-06 Thread Dave Angel
spir wrote: class Out(file): def __init__(self, filename, toconsole=True, numberlines=True): file.__init__(self, filename, 'r') print self # debug output to console self.toconsole = toconsole # line numberi

Re: [Tutor] loops

2009-12-08 Thread Dave Angel
Richard Hultgren wrote: a = 0 b = 1 count = 0 max_count = 20 while count < max_count: count = count + 1 # we need to keep track of a since we change it old_a = a# especially here old_b = b a = old_b b = old_a + old_b # Notice that the , at the end of a

Re: [Tutor] File renaming using os.rename problem

2009-12-08 Thread Dave Angel
spir wrote: Roy Hinkelman dixit: I can't find anything on this error I am getting when renaming some files. I'm pulling info from a csv file and parsing it to build new file names. Any pointers appreciated Roy My code: # RENAME FILES using META file - new name = [place]_[state]_[sku].tif

Re: [Tutor] duplication in unit tests

2009-12-08 Thread Dave Angel
Serdar Tumgoren wrote: Hi Kent and Lie, First, thanks to you both for the help. I reworked the tests and then the main code according to your suggestions (I really was muddling these TDD concepts!). The reworked code and tests are below. In the tests, I hard-coded the source data and the expect

Re: [Tutor] Sound problems

2009-12-10 Thread Dave Angel
Tim Goddard wrote: I'm still learning, and this may be better served on a pygame mailing list but I thought I'd try here first. I'm following the python programming for absolute beginners which uses livewires and pygame to do some simple games. My difficulty comes from not using the module vers

Re: [Tutor] typerror

2009-12-11 Thread Dave Angel
Roshan S wrote: class Student: print"We have a new student " def __init__(self,name='',credit=0,grade=0,quality=0): self.name=name self.credit=credit self.grade=grade self.quality=quality def inputstudent(self): self.name=raw_input("Enter stu

Re: [Tutor] Need a better name for this function

2009-12-15 Thread Dave Angel
Richard D. Moores wrote: def float_to_exact_number_stored_in_computer(f): """ Given a float, return the exact number stored in computer. See http://docs.python.org/3.1/tutorial/floatingpoint.html#representation-error """ from decimal import Decimal return Decimal.from_float(f)

Re: [Tutor] Need a better name for this function

2009-12-15 Thread Dave Angel
Richard D. Moores wrote: On Tue, Dec 15, 2009 at 15:05, Dave Angel wrote: Richard D. Moores wrote: If I keep the function, renamed to Allan's suggested float2Decimal(), then that's all I'll have to remember. But I see yours and Hugo's point. Just remember, if th

Re: [Tutor] Need a better name for this function

2009-12-16 Thread Dave Angel
Richard D. Moores wrote: On Tue, Dec 15, 2009 at 23:30, Hugo Arts wrote: On Wed, Dec 16, 2009 at 5:12 AM, Richard D. Moores wrote: Before I can go below I need to know if you are saying that the relevant doc is wrong. I took the original name for my function almost directly from it. N

Re: [Tutor] faster substring replacement

2009-12-16 Thread Dave Angel
R. Alan Monroe wrote: I'm wondering whether text.replace has to shove oodles of text to the right in memory when you replace a shorter word with a longer word. Someone else on the list may know. Alan Since a string is immutable, replace() has to copy the string. So it doesn't need to

Re: [Tutor] Need a better name for this function

2009-12-16 Thread Dave Angel
Richard D. Moores wrote: On Wed, Dec 16, 2009 at 14:48, Richard D. Moores wrote: I just realized that my question was absurd, in that given real numbers n and x there is no x such that both x < n and x is greater than all other numbers less than n. So after inserting "(in 14 hex digits)" at 2

Re: [Tutor] Need a better name for this function

2009-12-17 Thread Dave Angel
Richard D. Moores wrote: On Wed, Dec 16, 2009 at 20:23, Dave Angel wrote: Richard D. Moores wrote: There are conceivably better ways to get at the mantissa of the fp number, but you can simply parse the hex digits as I did manually, and add one and subtract one from the given

Re: [Tutor] Please take a look at this function

2009-12-17 Thread Dave Angel
Richard D. Moores wrote: def prestrings2list(a_str): word = "" list_of_strings = [] length_of_a_string = len(a_str) for i, char in enumerate(a_str): if i == length_of_a_string - 1: word += char word = word.rstrip() list_of_strings.append

Re: [Tutor] Field/Variable References

2009-12-18 Thread Dave Angel
John Filben wrote: Can someone please let me know how to read a file one record at a time (just say fixed block for now - see small example below) and assign columns to fields. Then reference the field names with if-then-else logic. Sample Fixed Block File: John98762 John82634 John11234 Tha

Re: [Tutor] print IP address range to stdout

2009-12-22 Thread Dave Angel
MK wrote: Hi there, i have some logical problem. I dont get it done to write my for loops in that way that the ip address range which is given as arguments are correct processed. Meaning that only the ips are printed which the user defines as argument. I tried to make an if statement to stop a

Re: [Tutor] print IP address range to stdout

2009-12-22 Thread Dave Angel
#x27; for exp in [3,2,1,0]: octet = octet + str(intip / (256 ** exp)) + "." intip = intip % ( 256 ** exp) return (octet.rstrip(".")) Am Dienstag, den 22.12.2009, 06:32 -0500 schrieb Dave Angel:

Re: [Tutor] try and except

2009-12-31 Thread Dave Angel
spir wrote: Lie Ryan dixit: class Error(Exception): def __init__(self, value): self.value = value def printer(self, value): print self.value You can also use __str__ instead of printer. This will give a standard output form for your error automatically use

Re: [Tutor] using re to match text and extract info

2009-12-31 Thread Dave Angel
Norman Khine wrote: hello, import re line = "ALSACE 67000 Strasbourg 24 rue de la Division Leclerc 03 88 23 05 66 strasbo...@artisansdumonde.org" m = re.search('[\w\-][\w\-\...@[\w\-][\w\-\.]+[a-za-z]{1,4}', line) emailAddress .search(r"(\d+)", line) phoneNumber = re.compile(r'(\d{2}) (\d{2

Re: [Tutor] Finding a repeating sequence of digits

2010-01-02 Thread Dave Angel
Robert Berman wrote: Hi, I am trying to build an algorithm or methodology which will let me tell if a decimal has a repeating sequence of digits and if it does have that attribute, what is the sequence of digits. For example, 1/3.0 = 0.3..By eyeballing we know it has a repeating sequence

Re: [Tutor] How to open the closed file again?

2010-01-05 Thread Dave Angel
Alan Gauld wrote: "朱淳" wrote fileList = [] def openFiles(): for i in range(0,2): fname = "file%s"%i f = open(fname,"a") fileList.append(f) def closeFiles(): for f in fileList: f.close() if __name__=="__main__": openFiles() print "fileList closeFiles() print fileList openFiles() print fileL

Re: [Tutor] How to open the closed file again?

2010-01-05 Thread Dave Angel
Andre Engels wrote: On Tue, Jan 5, 2010 at 1:46 PM, 朱淳 wrote: I've token a dictionary to save filenames, and write it into "constant.py". And I think it's a good method to create a class as Andre wrote. Thank you all! By the way, if I close a open file object, will the closed file object st

Re: [Tutor] (no subject)

2010-01-09 Thread Dave Angel
sudhir prasad wrote: hi, iam a beginner. sample_file = file("/home/ee08m082/Desktop/python/123.txt","w") sample_file.write("About Pythons\n") in the above two line code,123.txt is being created but "About Pythons" is not being written in the file. my OS is redhat linux and python version is 2

Re: [Tutor] If os.path.lexists() isn't working properly

2010-11-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Susana Iraiis Delgado Rodriguez wrote: Hello Peter! I added the line you suggested me and found out that I was just searching for the filenames without pointing to a specific directory, so Python took its directory (Python26) as default. After that I need to add a '\'

Re: [Tutor] If os.path.lexists() isn't working properly

2010-11-25 Thread Dave Angel
On 11/25/2010 09:20 AM, Susana Iraiis Delgado Rodriguez wrote: Hi Dave! Thank you for your suggestion I haven't prevent the problems you're describing, but I'm newbie in this stuff so, where should I repalce the code? Thank you again! 2010/11/24 Dave Angel On 01/-10/-28163 0

Re: [Tutor] Question about the "main" Python help list

2010-12-04 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Joel Schwartz wrote: I meant the Python-Help mailing list (http://mail.python.org/mailman/listinfo/python-help), which is described on the Python mailing list page (http://mail.python.org/mailman/listinfo) as "Expert volunteers answer Python-related questions." I guess

Re: [Tutor] Feedback on coding style

2010-12-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, howit...@archlinux.us wrote: Hi. For the past week, I've been following an online Python guide named: 'Learn Python the Hard Way'. I'm very happy with it as it gives a lot of freedom to explore. However, due to this I have no idea if I'm thinking the right way. That's

Re: [Tutor] permutations?

2010-12-14 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Francesco Loffredo wrote: On 03/12/2010 1.32, Steven D'Aprano wrote: mylist = [x for x in mylist if x != "something"] Up to this point, I share experiences and solution. But the next point did thrill me: If you really need to modify the list in place, and not just

Re: [Tutor] doing maths on lists

2010-12-20 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Chris Begert wrote: Bonjour I have three lists with 65 float items and would like to do the following sum: L0 = ([sum(L0A[i]*cos(L0B[i]+L0C[i]*JME) for i in range(0,64,1))]) So it just should do a sum across all the items in the list: L0A[0]*cos(L0B[0]+L0C[0]*JME)+

Re: [Tutor] Weighted Random Choice - Anyone have an efficient algorithm?

2010-12-23 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Modulok wrote: Does anyone know of an efficient way of doing a weighted random choice? (I don't even know what algorithms like this would be called.) Preferably, something that doesn't grow exponentially with the number of elements in the list, or the size of their resp

Re: [Tutor] Weighted Random Choice - Anyone have an efficient algorithm?

2010-12-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Albert-Jan Roskam wrote: Hi Steven, Doesn't this qualify as 'monkeying with the loop index'? [*] import random weights = [5, 20, 75] counts = {0:0, 1:0, 2:0} for i in xrange(100): ... i = weighted_choice(weights) #<--- monkeying right here (?) ... counts

Re: [Tutor] A class list

2010-12-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Robert Berman wrote: I am working on the second part of the 'Bingo' problem defined at the Bingo Praxis web page, http://programmingpraxis.com/2009/02/19/bingo/. My notes as how to best define and build the problem: 'In a large game with five hundred cards in play, wh

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Tommy Kaas wrote: Steven D'Aprano wrote: But in your case, the best way is not to use print at all. You are writing to a file -- write to the file directly, don't mess about with print. Untested: f = open('tabeltest.txt', 'w') url = 'http://www.kaasogmulvad.dk/unv/

Re: [Tutor] Print Help

2010-12-29 Thread Dave Angel
On 01/-10/-28163 02:59 PM, delegb...@dudupay.com wrote: #§¶Ú%¢Šh½êÚ–+-jwm…éé®)í¢ëZ¢w¬µ«^™éí¶­qªë‰ë–[az+^šÈ§¶¥ŠË^×Ÿrœ’)à­ë)¢{°*'½êí²ËkŠx,¶­–Š$–)`·...@Ý"žÚ Not sure why the quoting of this particular message didn't work. Since I have no problem with anyone else's message, I suggest i

Re: [Tutor] How does it work?

2011-01-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Patty wrote: for c in 'abcd': .. When I first looked at this - I thought that the variable 'c' would have had to be initialized first earlier in the program. And I thought that the programmer would input a single char or a single space. I wasn't thinking counti

Re: [Tutor] regex question

2011-01-04 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Richard D. Moores wrote: On Tue, Jan 4, 2011 at 11:57, Richard D. Moores wrote: On Tue, Jan 4, 2011 at 10:41, Richard D. Moores wrote: Please see http://tutoree7.pastebin.com/z9YeSYRw . I'm actually searching RTF files, not TXT files. I want to modify this script t

Re: [Tutor] range function and floats?

2011-01-05 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Wayne Werner wrote: On Wed, Jan 5, 2011 at 10:43 AM, Steven D'Apranowrote: Wayne Werner wrote: The decimal module allows you to get rid of those pesky floating point errors. See http://docs.python.org/library/decimal.html for more info. That's a myth. Decimal s

Re: [Tutor] Open a text file, read and print pattern matching

2011-01-09 Thread Dave Angel
(Don't top-post. You keep putting your responses out of order.) On 01/-10/-28163 02:59 PM, tee chwee liong wrote: i modified the code to be: fname = "sampledata.txt" pattern = "-1" failed = False for line in open(fname): data=line.split() if len(data)==4: port, channel, lane

Re: [Tutor] how come this doesnt work

2011-01-14 Thread Dave Angel
On 01/-10/-28163 02:59 PM, walter weston wrote: I generate a random number(supposedly a password, in my case its just a long floating point lol),I want the user to reinput that number and I want to print a string if the number entered is correct. so if m==num(num is the number generated and m

Re: [Tutor] defining functions and classes

2011-01-15 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Brett Murch wrote: Hi everyone, I'm just starting to learn Python and am starting by creating a text game but am having trouble with classes and funtions. I want to create a class or function where someone creates a charater and has a choice of their name or os. This i

Re: [Tutor] Why super does not work !

2011-01-17 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Karim wrote: Hello, I implemented Observer DP on a listbox (Tkinter) as follows and I don't understand why super() is not working and Observable.__init__(self) is working, cf below: class ListObservable(Listbox, Observable): """Creation de widget Listbox""" def __in

Re: [Tutor] Problems passing a parameter in a GUI

2011-01-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, David Holland wrote: Hi All, I hope this makes sense I am trying to write a GUI where you click on a button and each time you click on the button it shows in the entry text how many times you have clicked. However when I changed an earlier version of the code to pass

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: Hello again: I have never seen this message before. I am pulling xml from a site's api and printing it, testing the wrapper I am writing for the api. I have never seen this error until just now, in the twelfth result of my search: UnicodeEncodeError: 'A

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something about not supporting convertion from unicode. I finally ended up doing this: self.title�ta.find("title").text.encode("utf-8"

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Dave Angel
On 01/28/2011 08:02 AM, Alex Hall wrote: On 1/28/11, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Alex Hall wrote: I tried both of those and got a different error. I have since fixed it so I no longer have the exact text, but it was something about not supporting convertion from unicode. I

Re: [Tutor] Wrapping my head around global variables!!

2011-01-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Nevins Duret wrote: Hello Python collective, I am trying to wrap my head around what exactly is causing me not to get any output or error message in the following code: #!/usr/bin/env python3.1 import random def main(): def chosen_letter(): chosen_letter = Conson

Re: [Tutor] pywin32 help

2011-01-30 Thread Dave Angel
(please don't top-post. Insert the ">" symbol in front of whatever lines you're quoting, and put your response under the quote. Most email programs can be configured to do this easily, or even automatically.) On 01/-10/-28163 02:59 PM, Elwin Estle wrote: I'm not 100% sure, but I think the Ac

Re: [Tutor] RE module is working ?

2011-02-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip> *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix

Re: [Tutor] process and modify a list of strings, in place

2011-02-10 Thread Dave Angel
On 01/-10/-28163 02:59 PM, John Martinetti wrote: Hello - Welcome, # - create a record from all the fields linedata = (vendornum, vendorname, ordernum, ordersuffix, orderdate, buyer, partnum, qty, comment) # - append the record to the list of records representing the CQ report

Re: [Tutor] Python + Sound

2011-02-12 Thread Dave Angel
On 01/-10/-28163 02:59 PM, David Hutto wrote: On Sat, Feb 12, 2011 at 4:43 AM, Alan Gauld wrote: "David Hutto" wrote and what is sound, electromagnetically transmitted, then turned into ones and zeroes. Just to be picky sound is mechanical waves not electromagnetic. The ear is primarily a

Re: [Tutor] How to group data?

2011-02-13 Thread Dave Angel
On 01/-10/-28163 02:59 PM, tee chwee liong wrote: hi, i'm using Python 2.5 and Win XP. i want to extract the last column of the attached text file and group 128 characters to each row. want the result to look like: Row1=X.1XXX (total of 128 char) Row2=11XX.

Re: [Tutor] How to group data?

2011-02-13 Thread Dave Angel
On 02/13/2011 07:03 PM, tee chwee liong wrote: How about some clues as to what you're trying to accomplish? This code is surprisingly verbose, and probably totally wrong. Anyway, each time you pop an item from the list, all the following ones change their index. So presumably there weren't stil

Re: [Tutor] Concatenating string

2011-02-22 Thread Dave Angel
On 01/-10/-28163 02:59 PM, tee chwee liong wrote: hi Francesco, couldnt get hex of bin working on IDLE Python 2.5 when i type: hex(0b1001001001001001001) SyntaxError: invalid syntax bin(0x49249) Traceback (most recent call last): File "", line 1, in bin(0x49249) NameError: name 'bi

Re: [Tutor] comparing strings

2011-02-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Edward Martinez wrote: On 02/23/11 19:29, Corey Richardson wrote: On 02/23/2011 10:22 PM, Edward Martinez wrote: Hi, I'm new to the list and programming. i have a question, why when i evaluate strings ie 'a'> '3' it reports true, how does python come up with that? W

Re: [Tutor] Help on Python Looping Please

2011-02-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, pyhx0r wrote: Dear All, multiple = 1024 if a_kilobyte_is_1024_bytes else 1000 for suffix in SUFFIXES[multiple]: size /= multiple if size< multiple: return '{0:.1f} {1}'.format(size, suffix) I’ve shorted the code be:

Re: [Tutor] Help on Python Looping Please

2011-02-24 Thread Dave Angel
On 02/24/2011 11:55 AM, Walter Prins wrote: On 24 February 2011 16:22, Dave Angel wrote: (Is there a reason you double-spaced all that code? It makes it very hard to read, and quite difficult to quote, since I had to delete every other line.) For what it's worth the code cam

Re: [Tutor] Running Existing Python

2011-02-26 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Justin Bonnell wrote: Okay. When I try to run the script from the terminal, it still doesn't work. Here is a screenshot. What am I doing wrong? 1) You're top-posting. Put your responses after the quote you're responding to. 2) You're trying to include graphic

Re: [Tutor] accessing another system's environment

2011-02-26 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Steve Willoughby wrote: On 26-Feb-11 01:19, ALAN GAULD wrote: Bill, That's the same thing we are talking about. The problem is those environment variables are highly variable so you can't talk about a machine's environment. Two users on the same machine (at the same t

Re: [Tutor] Running Existing Python

2011-02-26 Thread Dave Angel
On 02/26/2011 04:10 PM, Justin Bonnell wrote: On Feb 26, 2011, at 4:49 AM, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Justin Bonnell wrote: Okay. When I try to run the script from the terminal, it still doesn't work. Here is a screenshot. What am I doing wrong? 1) You&#

Re: [Tutor] Running Existing Python

2011-02-27 Thread Dave Angel
On 02/27/2011 02:50 AM, Justin Bonnell wrote: On Feb 26, 2011, at 10:51 PM, Dave Angel wrote: On 02/26/2011 06:03 PM, Justin Bonnell wrote: On Feb 26, 2011, at 4:05 PM, Dave Angel wrote: As for cd not working, someone else has pointed out that in the shell, you need to escape

Re: [Tutor] very odd math problem

2011-03-11 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alan Gauld wrote: "Steven D'Aprano" wrote The right way is to do it like this: >>> x = 0.0 >>> for i in range(1, 11): ... x = i*0.1 ... >>> x == 1.0 True But this I don't understand. Why would you use a loop when the final value is just the final multiplicati

Re: [Tutor] very odd math problem

2011-03-11 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Steven D'Aprano wrote: Alan Gauld wrote: Why would you use a loop when the final value is just the final multiplication. Since you know the final value in advance (you need it to create the loop!) why not just do the final multiplication directly: x = 10*0.1 I think

Re: [Tutor] binary, ascii, steganography

2011-03-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, jaco erasmus wrote: Hi there, list The other day I got bored at work and decided to give this programming thing a try, since Rick Romero said it's becoming all the rage these days. Eventually, I want to end up writing a steganography program, but for now I am still an i

Re: [Tutor] Need some clarification on this

2011-03-19 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Joel Goldstick wrote: 2011/3/19 Yaşar Arabacı a=5 b=5 a == b True a is b True My question is, why "a is b" is true. What I expected it to be is that, a and b are different things with same value. ___ Tutor maillist -

Re: [Tutor] lambda

2011-03-19 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Ajit Deshpande wrote: I am trying to figure out where lambda functions can be useful. Has anyone used them in real world? From my reading so far, I hear people claim that lambda can be a useful replacement for small functions. Most examples didn't make much sense to

Re: [Tutor] a function I fail to understand

2011-03-21 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: On 3/21/11, David wrote: Hello list, I am having trouble understanding the following function. What trips me up is the "letter = letter.lower()" line. As I understand, the function takes a letter and assigns True to a letter if it is upper case. No

Re: [Tutor] Recursively flatten the list

2011-03-26 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Prasad, Ramit wrote:" >A more important problem is that it is flattening only one level. >Multi-level flattening is I think not possible without using some kind >of recursion." > >Not true, just requires more iterations to check each element. Each >iteration could chec

Re: [Tutor] Python closes out on attempt to run script

2011-03-26 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Matthew Speltz wrote: I'm trying to teach myself python and have run across a rather annoying error. I'm not sure exactly where the fault lies, so please pardon me for posting too much information, I'm not sure what would be relevant. I'm running the Python 3.2 Window

Re: [Tutor] Need help with the property function

2011-04-13 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Jim Byrnes wrote: I'm trying to teach myself OOP in python (again). The following code from Dawson's book runs fine, unaltered [1]. class Critter(object): """ A virtual pet """ def __init__(self, name): print "A new critter is born" self.name = name def get_name(self)

Re: [Tutor] data validation logic

2011-04-17 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Rance Hall wrote: Hey gang: I need some help trying to pythonize (sp?, if this is even a word?) an idea. I'd like to define a datavalidation function that returns true if data is valid, and false if it isn't. I need a way to store the pass fail values of each of th

Re: [Tutor] NameError?

2011-04-27 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Brad Desautels wrote: Hello, I am working on a problem for my computer science class. This program is supposed to change the expression of the face when the appropriate button is clicked. It seems logical that it should work, however, when I click one of the buttons, I

Re: [Tutor] Help with sys.argv

2011-04-29 Thread Dave Angel
On 01/-10/-28163 02:59 PM, monkey...@aim.com wrote: Hello, I am trying to learn how to use python with Facebook's Open Graph API. I am getting my feet wet with the following code authored by Matthew A. Russell. I copied it line for line for learning purposes, but I am getting the following

Re: [Tutor] Dictionary File character reader

2011-05-10 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Clara Mintz wrote: Sorry I am completely new at python and don't understand why this function is returning an empty dictionary. I want it to take a list of files open them then return the number of characters as the value and the file name as the key. def fileLengths

Re: [Tutor] create an xls file using data from a txt file

2011-05-11 Thread Dave Angel
On 01/-10/-28163 02:59 PM, tax botsis wrote: I have the following txt file that has 4 fields that are tab separated: the first is the id and the other three show the results per test. 152 TEST1 valid TEST3 good TEST2 bad 158 TEST2 bad TEST1 bad TEST4 valid . . . Based on the above txt I need to

Re: [Tutor] can I walk or glob a website?

2011-05-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alan Gauld wrote: "Albert-Jan Roskam" wrote How can I walk (as in os.walk) or glob a website? I don't think there is a way to do that via the web. Of course if you have access to the web servers filesystem you can use os.walk to do it as for any other filesystem, b

Re: [Tutor] Sequencing

2011-05-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Cindy Lee wrote: Hi Pyton Tutors thanks for adding me, I am new to Python and missed one of my classes and am not sure of my homework. We are currently on sequencing and are being asked to make a function that receives text as an argument and returns the same text, b

Re: [Tutor] Structured files?

2011-06-02 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Válas Péter wrote: 2011. június 2. 9:29 Simon Yan írta,: Yes you can. I guess the question is how you want the information to be structured. IMHO, everything in Python can be "string-lized". What is the syntax then? I have Windows XP. The code is: f=open("xxx.dat",

Re: [Tutor] Copying a mutable

2011-06-07 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Válas Péter wrote: Hi, let X be a mutable container, such as dict/set/list=bytearray, and Y=X, When I change X, Y will follow it, having always the same value, although id(X)!=id(Y). How is that, what is the explanation? Meanwhile the same for immutable types results a

Re: [Tutor] Python Beginners

2011-06-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Vincent Balmori wrote: Hello. Right now I am learning the python language through Python Programming for the Absolute Beginner 3rd Edition. I am having trouble with one question in Ch. 4 #3, which says "Improve 'WordJumble so that each word is paired with a hint. The pl

Re: [Tutor] using configobj package to output quoted strings

2011-06-19 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Alex Hall wrote: On 6/18/11, Steven D'Aprano wrote: Alex Hall wrote: Hello all, I am using the configobj package to handle a ridiculously simple ini What's configobj? >>> import configobj Traceback (most recent call last): File "", line 1, in ImportError: N

Re: [Tutor] BF Program hangs

2011-06-19 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Kaustubh Pratap chand wrote: > Hello i made this program which interprets brainf*** > > But i don't understand why it doesn't endsand also it doesn't print anything > > import sys > > cell=[0] * 3 > code_pointer=0 > cell_pointer=0 > close_brace_pos=

Re: [Tutor] Blackjackbetting

2011-07-04 Thread Dave Angel
On 01/-10/-28163 02:59 PM, David Merrick wrote: HI. I feel I'm starting to go round in circles solving this problem. I feel I made significant progress. Can someone help me iron out the bugs please # Blackjack # From 1 to 7 players compete against a dealer import cards, games class BJ_Card(car

Re: [Tutor] compare and arrange file

2011-07-11 Thread Dave Angel
On 07/11/2011 06:39 PM, Emile van Sebille wrote: On 7/11/2011 3:16 PM Edgar Almonte said... hello , i have a file this a structure like this X | 0.00| 88115.39| X | 90453.29| 0.00| X | 0.00| 90443.29|

Re: [Tutor] compare and arrange file

2011-07-12 Thread Dave Angel
On 07/12/2011 12:56 AM, Edgar Almonte wrote: thanks emile i understand exactly what you explain me but i was unable to accomplish it ( too noob in python ) but i solved the problem with this code http://pastebin.com/4A6Jz4wZ (When you post on this list, your comments should follow the pieces yo

Re: [Tutor] compare and arrange file

2011-07-12 Thread Dave Angel
On 07/12/2011 08:25 AM, Edgar Almonte wrote: On Tue, Jul 12, 2011 at 7:28 AM, Dave Angel wrote: On 07/12/2011 12:56 AM, Edgar Almonte wrote: thanks emile i understand exactly what you explain me but i was unable to accomplish it ( too noob in python ) but i solved the problem with this code

Re: [Tutor] Descriptors and type declaration order

2011-07-14 Thread Dave Angel
On 07/14/2011 05:44 AM, Knacktus wrote: Hi guys, I've got the following (not working) code: class Attribute(object): def __init__(self, attribute_name, att_type_name): self._attribute_name = attribute_name try: self._attribute_type = globals()[att_type_name]

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Dave Angel
On 07/15/2011 07:39 PM, Richard D. Moores wrote: On Fri, Jul 15, 2011 at 16:21, xDog Walker wrote: I believe on Windows, you can almost always use a forward slash in a path: C:/somewhere/somewhereelse/ with open("C:/test/test.txt", "a") as file_object: print("Hello, world!", file=file_o

Re: [Tutor] what is 'doubleword alignment'?

2011-07-16 Thread Dave Angel
--- On Sat, 7/16/11, Albert-Jan Roskam wrote: From: Albert-Jan Roskam Subject: [Tutor] what is 'doubleword alignment'? To: "Python Mailing List" Date: Saturday, July 16, 2011, 8:23 PM Hello, What is 'doubleword alignment'? It is used in the following sentence: "Fill up the buffer with the c

Re: [Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread Dave Angel
On 07/16/2011 05:32 PM, B G wrote: Thanks, Emile-- although I'm not sure I was completely clear about my objective. What I really meant is that is there a way (via machine learning) to give the computer a list of rules and exceptions, and then have it predict based on these rules the ionization e

Re: [Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread Dave Angel
On 07/16/2011 07:21 PM, Christopher King wrote: Actually maybe not, depending on the complexity of the pattern, but it would be difficult. You would have to know how much it decreases for every time you go down or to the right. If its more complex than that, you may have to program each rule in,

Re: [Tutor] little/big endian was Re: what is 'doubleword alignment'?

2011-07-20 Thread Dave Angel
On 07/19/2011 05:43 PM, Alan Gauld wrote: Albert-Jan Roskam wrote: > and ctypes to process the data in python. It works now, although I > still want to read more about this. Where does the distinction > little/big endian enter this story? That's to do with which bit in a byte/word is most signif

Re: [Tutor] Removing characters in a string using format()

2011-07-21 Thread Dave Angel
On 07/21/2011 01:53 PM, Ryan Porter wrote: Hi there, In one part of a program I'm writing, I want a list to be printed to the string. Here's my code: # Begin snippet listString = input('Please enter a single item: >').strip(); /print(); itemList.append(listString); / /... /

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-22 Thread Dave Angel
On 07/22/2011 06:40 PM, dave wrote: Hello, I'm trying to work on GNU Radio and having trouble understanding some of the Python code. I have a C/C++ coding background. I'm looking at the ieee802.15.4 code found on CGRAN. It's about 4 years old and runs but doesn't function anymore so I'm tryin

Re: [Tutor] how to temporarily disable a function

2011-07-28 Thread Dave Angel
On 07/27/2011 09:58 PM, Pete O'Connell wrote: Hi I was wondering if there is a way to disable a function. Hi have a GUI grid snapping function that I use in a program called Nuke (the film compositing software) Here is the function (which loads when Nuke loads): ### def theAu

Re: [Tutor] Sorting lists both ways at once and programmatically loading a variable.

2011-07-28 Thread Dave Angel
On 07/28/2011 07:05 PM, Prasad, Ramit wrote: I have 2 questions. 1. Is there a way to do a reverse and a normal sort at the same time? I have a list of tuples (there are more than 2 elements in the tuples but I only want to sort by the first two). I want to sort in reverse for the first elemen

Re: [Tutor] Mainloop conflict

2011-07-28 Thread Dave Angel
On 07/28/2011 08:32 PM, Christopher King wrote: Dear Tutor Dudes, I have a socket Gui program. The only problem is that socket.recv waits for a response, which totally screws Tkinter I think. I tried making the timeout extremely small (it was alright if I didn't receive anything, I was excep

Re: [Tutor] Running files from command prompt

2011-07-28 Thread Dave Angel
On 07/28/2011 09:58 PM, Alexander Quest wrote: I downloaded the google's python exercise files from their website ( http://code.google.com/edu/languages/google-python-class/set-up.html), unzipped them, and placed them in C. I then added the following to the PATH variable under system settings so

Re: [Tutor] Mainloop conflict

2011-07-29 Thread Dave Angel
y, July 28, 2011, Dave Angel wrote: On 07/28/2011 08:32 PM, Christopher King wrote: Dear Tutor Dudes, I have a socket Gui program. The only problem is that socket.recv waits for a response, which totally screws Tkinter I think. I tried making the timeout extremely small (it was alright i

Re: [Tutor] Mailing list documentation

2011-07-31 Thread Dave Angel
On 07/31/2011 08:42 PM, Christopher King wrote: Wow wow, way is a ser...@might.co.za person doing a tutor response. And why can I see it if it isn't to me.. I'm sorry Sergey if this isn't something malicious, it just seems suspicious. (You could try reading it, instead of just getting suspicious

Re: [Tutor] Puzzled again

2011-08-02 Thread Dave Angel
On 08/02/2011 10:36 PM, Richard D. Moores wrote: Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path): """ Given a path with backslashes, return that p

Re: [Tutor] Puzzled again

2011-08-03 Thread Dave Angel
On 08/03/2011 02:07 AM, Richard D. Moores wrote: On Tue, Aug 2, 2011 at 21:59, Dave Angel wrote: When I paste that from your email into a file and run Python 2.7 on it, it behaves fine with no errors. That's in Linux. I should have said that I'm using Wing IDE Professional 4.

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