Re: [Tutor] Configuaration files and paths?

2009-08-05 Thread Dave Angel
Allen Fowler wrote: What is the recommended way to configure my application find the various database and/or configuration files it needs? Recommemded by whom? A lot depends on the OS. Apple for example have one set of recommendations for MacOS, Windows has another and Linux has several

Re: [Tutor] noob question (Windows, Python 3.1)

2009-08-06 Thread Dave Angel
Michael Connors wrote: 2009/8/6 Joshua Harper Ok, so I am trying to learn python, and I am reading many tutorial type things and I am kind of stuck with implementing some of the code... so for example the tutorial says "*To get the examples working properly, write the programs in a text fil

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Dave Angel
pedro wrote: On 2009-08-06 15:49:35 -0400, Wayne said: On Thu, Aug 6, 2009 at 2:33 PM, pedro wrote: Hi I am rendering image sequences on a basic render farm that I am building. Once all the files in the sequence have been rendered I would like to make a quicktime of the sequence automat

Re: [Tutor] Noobish Syntay Error?

2009-08-06 Thread Dave Angel
Anna - Sophie Maeser wrote: Hi! I want to ask you a quick question.. when I type in print '' hello world'' and then press enter, it says there is a syntax error... I really don't know what im doing wrong. I downloaded python 3.1 and am using IDLE with it.. im using mac. Please help me findt he

Re: [Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread Dave Angel
chase pettet wrote: I am trying to write a script to work our LVS implementation. I want to be able to have user do something like this "./script SITE SERVER" and have the script look up the ip value of the site on that server and issue the command to pull the status from LVS. I am almost ther

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Dave Angel
Sander Sweers wrote: 2009/8/6 Dave Angel : You have to choose your poison. I prefer no poison. This is exactly what inotiy was made for and although I never used it there is a python module for it [1]. It would be great if you can post your experience with it. Greets Sander [1] http

Re: [Tutor] this module

2009-08-08 Thread Dave Angel
Mark Young wrote: Hi, I was reading a tutorial, and it mentioned the "import this" easter egg. I was curious, and looked up the contents of the module, and dscovered that it had attributes c, d, i, and s. I was wondering if anyone had any clue what these attributes were supposed to mean. I think

Re: [Tutor] droplet like behaviour in Python

2009-08-10 Thread Dave Angel
bob gailer wrote: Alan Gauld wrote: "pedro" wrote Well I made a script called droplet.py which looks like this: #!/usr/bin/env python # encoding: utf-8 import sys theFilePath = sys.argv[1] print theFilePath But when I try to drop something on it nothing happens. Sorry I guess there is some

Re: [Tutor] To write data in two different fonts?

2009-08-11 Thread Dave Angel
prasad rao wrote: Hello I am wtriting some dat on to a file in which headings should be of different size than other data. Is it possible?If possible please tell me how to do it. def sc(adir): import os,myfiles dest=open('C:/scripts.txt','w') s=myfiles.myfiles(adir)

Re: [Tutor] list question

2009-08-11 Thread Dave Angel
Wayne wrote: On Tue, Aug 11, 2009 at 7:17 AM, wrote: hi i am currently doing the 'livewires' python tutorial lesson 5. i am making a little game that makes a few squares chase a circle around a little grid. i can get the 1 square acting on 1 variable to come up, but the tutorial now wants

Re: [Tutor] To write data in two different fonts?

2009-08-11 Thread Dave Angel
prasad rao wrote: Hello I modified my code.But I am gettingmy my lines stripped of indentation. What should I do to avoid it?Sorry if it is not about Python. def sc(adir): import os,myfiles dest=open('C:/scripts.html','w') s=myfiles.myfiles(adir) dest.write('')

Re: [Tutor] To write data in two different fonts?

2009-08-11 Thread Dave Angel
Michael M Mason wrote: Dave Angel wrote on 11 August 2009 at 16:42:- The brute-force way might be to replace each space in "l" with   which is a "nonbreaking space." But I think you want the tag, which means the text is pre-formatted. And you could

Re: [Tutor] To write data in two different fonts?

2009-08-12 Thread Dave Angel
prasad rao wrote: But I think you want the tag, which means the text is pre-formatted. And you could >put that around the whole sorce file, instead of doing for each line. See http://www.w3schools.com/tags/tag_pre.asp Thank you Dave. I put in tag and it worked.

Re: [Tutor] To write data in two different fonts?

2009-08-12 Thread Dave Angel
alues must all be >strings; each key will be replaced with its corresponding value. The >characters '&', '<' and '>' are always escaped, even if /entities/ >is provided. Let us know if that doesn't do the trick. DaveA T

Re: [Tutor] To write data in two different fonts?

2009-08-13 Thread Dave Angel
Nick Raptis wrote: Dave Angel wrote: As I said, you'd probably get in trouble if any of the lines had '&' or '<' characters in them. The following function from the standard library can be used to escape the line directly, or of course you coul

Re: [Tutor] Dynamic Function Calls

2009-08-14 Thread Dave Angel
bob gailer wrote: Megan Land wrote: All three methods are defined below the snippet I provided. In Python names must be defined before they are referenced. Put these defs above the snippet. def func(): code... def func0(): do stuff def func1(): do stuff def func2(): do stuff Megan Land

Re: [Tutor] Dynamic Function Calls

2009-08-14 Thread Dave Angel
Megan Land wrote: From: Dave Angel

Re: [Tutor] write program to extract data

2009-08-14 Thread Dave Angel
Michael Miesner wrote: Hi- I work in a research lab and part of the lab I'm not usually associated with uses a program that outputs data in a .txt file for each participant that is run. The participant # is the title of the text document (ie E00343456.txt) style and I'd like to be able to take th

Re: [Tutor] Dynamic Function Calls

2009-08-14 Thread Dave Angel
Megan Land wrote: I tried what you said. I can call the function by itself (not within the dictionary). I also printed the help(__name__). All of my functions were listed. Here's a more representative example of my code (I doing this for work so I don't want to give my entire program away):

Re: [Tutor] python's database

2009-08-15 Thread Dave Angel
davidwil...@safe-mail.net wrote: Hello, I seem to remember that python had a native database, can someone remind me which this was. Dave Check out module sqlite3 http://docs.python.org/library/sqlite3.html ___ Tutor maillist - Tutor

Re: [Tutor] Loop help

2009-08-16 Thread Dave Angel
Nathan Wing wrote: Hello All,I've been racking my brain trying to figure out, what I imagine to be, a very simple problem. I found the Intro to comp science MIT open course ( http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-00Fall-2007/CourseHome/index.htm) and was working

Re: [Tutor] yet another question on OO inheritance

2009-08-18 Thread Dave Angel
Serdar Tumgoren wrote: Thanks to you both for the suggestions. I think I'll try the approach below. But just one follow-up: should I be setting "self.tablename", or is a static attribute ("tablename") the correct approach? A nice way to do this is with a class attribute. For example: class C

Re: [Tutor] handling a textfile

2009-08-19 Thread Dave Angel
Alan Gauld wrote: "Olli Virta" wrote I have a textfile (job.txt) that needs modifying. The structure of this file is like this: AAA1... BBB1... CCC1... AAA2... BBB2... CCC2... etc... Question is how can I turn this all to a textfile (done.txt) that is suppose to look like this: AAA1...BB

Re: [Tutor] how do we represent left arrow key in python programming.

2009-08-21 Thread Dave Angel
Ajith Gopinath wrote: Hi Folks, how do we represent left arrow key in a python program? Can anybody help? || a j i t || Be more specific. Are you writing your gui in wxpython, in gtk, in tkinter? Or are you writing a console program? In what Python version? Are you looking to see how an

Re: [Tutor] Template long text substitution

2009-08-24 Thread Dave Angel
Stefan Lesicnik wrote: Hi Guys, I am trying to do the following, and im not sure how to deal with a blob of text. I have the following file i am using as a template %%NAME%% %%NUMBER%% %%REPORT%% and i have a corresponding file with values name="bob" number="123" report="report is long and s

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-26 Thread Dave Angel
Kent Johnson wrote: On Wed, Aug 26, 2009 at 12:25 PM, Mac Ryan wrote: Hello everybody, I am using "storm" (https://storm.canonical.com/) to manage my database. In storm, relationships between tables (each table is represented by a class) are expressed like this (line #4): 1 >>> class

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-26 Thread Dave Angel
Mac Ryan wrote: On Wed, 2009-08-26 at 15:46 -0400, Dave Angel wrote: So define a classmethod to finish the job, and invoke it later class Employee(object): @classmethod def finish(cls): cls.__storm_table__ = "employee" cls.company_id = [] c

Re: [Tutor] how do I post event to thread?

2009-08-26 Thread Dave Angel
Jeff Peery wrote: hello, I've read a bit about multi thread communication, and found that most people use a queue, which makes sense. however in my case I simply have two threads, a main thread and one other. the main thread is doing many different things and the second thread is receiving num

Re: [Tutor] design advise

2009-08-27 Thread Dave Angel
Alan Gauld wrote: wrote The thing that bothers me is that I ma have 10 users or 100,000 users and really wanted to get an opinion as to which option would scale better, leaving aside the relational DB approach. If you have to cater for 100,000 users all with different views on a common se

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-28 Thread Dave Angel
Mac Ryan wrote: On Wed, 2009-08-26 at 21:32 -0400, Dave Angel wrote: Now there are a couple of decorators that are in the standard library that everyone should know about:classmethod() and staticmethod(). They wrap a method in a new one (which ends up having the same name), such that

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-28 Thread Dave Angel
Mac Ryan wrote: On Fri, 2009-08-28 at 08:55 -0400, Dave Angel wrote: Mac Ryan wrote: On Wed, 2009-08-26 at 21:32 -0400, Dave Angel wrote: Now there are a couple of decorators that are in the standard library that everyone should know about:classmethod() and staticmethod

Re: [Tutor] Callbacks in Python

2009-08-28 Thread Dave Angel
Jramak wrote: Thanks everyone for your excellent insights. I think I understand the callback concept better. So, it is like passing a function as an argument to another function. I am interested in learning more about how callbacks can be applied in GUIs, using wxPython as an example. Would appr

Re: [Tutor] What does it mean to create separate applications?

2009-08-28 Thread Dave Angel
Kristina Ambert wrote: Hi, I'm new to python and frankly new to programming. This is my first question post, so I hope everyone could bear with me. I'm working on a small database application which basically handles a store inventory, it's my internship project for the semester. My boss asked me

Re: [Tutor] packing a list of lists

2009-08-28 Thread Dave Angel
kevin parks wrote: Back to python after a long long layoff. So i am running into some beginner's confusion... I am trying to plot a list of numbers in gnuplot.py. To do that I am trying to pack the list with an index by iterating over the list so i can get something like: foo = [12, 11, 9,

Re: [Tutor] Easy Problem

2009-09-01 Thread Dave Kuhlman
ight want to know about the textwrap module in the standard library: http://docs.python.org/library/textwrap.html#module-textwrap - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] working with multiple sets

2009-09-05 Thread Dave Angel
kevin parks wrote: I am doing some simple things with sets and so far have had a lot of success with python's built-in sets, which is such a great new(ish) "batteries included" type python data type. [snip] [snip] -- [snip] [snip] -- #!/usr/bin/env

Re: [Tutor] How to print the next line in python

2009-09-12 Thread Dave Angel
ranjan das wrote: Hi, I am new to python and i wrote this piece of code which is ofcourse not serving my purpose: Aim of the code: To read a file and look for lines which contain the string 'CL'. When found, print the entry of the next line (positioned directly below the string 'CL') conti

Re: [Tutor] New guy question...

2009-09-14 Thread Dave Angel
(You're top-posting, which makes the message flow very confusing) Warren wrote: Well, I thought that as well but I took it out which makes it run under 2.6.1 and I get similar, but not exactly the same, output: Type integers, each followed by ENTER; or just ENTER to finish EOFError: EOF wh

Re: [Tutor] Executing a command from a specific directory

2009-09-16 Thread Dave Angel
(Don't top-post; it makes reading the thread quite confusing) Ansuman Dash wrote: Hi, Thank you very much for the quick response. Code is working fine. Now I am trying to validate that the command is executed successfully. I have written following script to validate the log file which is cr

Re: [Tutor] IDLE colon = syntax error

2009-09-16 Thread Dave Angel
Carnell, James E wrote: I searched through archives and wasn't able to find the solution. Using IDLE, python 3, Ubuntu (default installations). Using command line: > if 1 == 1: print "equal" > equal Using IDLE: >if 1 == 1: print "equal"

Re: [Tutor] Problem running visual python files at home

2009-09-19 Thread Dave Angel
shsu012 shsu012 wrote: Hi Tutor, After installing python 2.6.2, there was no problem running it and completing the simple maths operations at home. However, a Microsoft Visual C++ Runtime library error keeps turning up whenever I tried to run the files which use functions imported from the visual

Re: [Tutor] list sort problem

2009-09-19 Thread Dave Angel
Rayon wrote: ok so here it is I think this one should be very clear: I have some data in a list, the data in question: 0.0046,0.095,0.0904,521456,['MCI 521456 0.0904'],['ATT 521 0.0919'],['IDT 521 0.095'],['None'] 0.0083,0.0192,0.0109,39023821,['MCI 39023821 0.0109'],['ATT 39 0.012'],['IDT

Re: [Tutor] list sort problem solved

2009-09-20 Thread Dave Angel
Rayon wrote: list = bigMethod() # this method makes the list list.sort() # here is the sort thanks for x in list: # out put the sort print x it all works Thanks a lot -- From: "Dave Angel" Sent: Saturday, September 19, 2009 7:46 PM

Re: [Tutor] python win32 drive mapping help

2009-09-22 Thread Dave Angel
Vineet Kothari wrote: Hi Everyone I saw alot of responses for python on this mailing list. I thought any python guru might wish to help me with little code to map two network drives on windows systems I have 3computers at different locations in a network A,B,C I want to ma

Re: [Tutor] calling a superclass method after overriding it

2009-09-22 Thread Dave Angel
Serdar Tumgoren wrote: def result_of_SPECIALIZED_SQLcall_for_child(): name =None return name class Child(Parent): def __init__(self): super(Child, self).__init__() def add_name(self): name = result_of_SPECIALIZED_SQLcall_for_child() try:

Re: [Tutor] how to define a function with multple parameters

2009-09-22 Thread Dave Angel
shellc...@juno.com wrote: I want to know how to use multiple parameters for 1 function def display(message): print message def rate_score(): score =ate_score if rate_score <=99: print "that's nothing." elif rate_score <=: print "ok." elif rate_score >=:

Re: [Tutor] calling a superclass method after overriding it

2009-09-22 Thread Dave Angel
Serdar Tumgoren wrote: An "if" test would be more readable, I agree. But I was trying to apply the "Easier to Ask Permission Forgiveness" style, discussed in the Python Cookbook: , Err..."Easier to Ask Forgiveness than Permission" approach is what I meant (perhaps proving my point about n

Re: [Tutor] calling a superclass method after overriding it

2009-09-22 Thread Dave Angel
Serdar Tumgoren wrote: def add_name(self): try: self.name = SPECIALIZED_SQLcall_for_child() except SpecialSQLError: #default to the superclass's add_name method super(Child, self).add_name() That certainly is a lot easier to read. So if I were to

Re: [Tutor] python win32 drive mapping help

2009-09-25 Thread Dave Angel
Vineet Kothari wrote: Can you also help me out with the way to delete the mapped drive I know in command line it is net use [DRIVE:] /delete but I am unable to figure out how I can do it from python Since I am trying to make sure that the drive name I am giving in my code: impo

Re: [Tutor] Super class

2009-09-25 Thread Dave Angel
Katt wrote: As I am a beginner I am constantly assimilating new python code and vocabulary associated with it. Could someone please explain to me what a super class is, its importance and what level of python programming it is(beginner,intermediate,advanced programming technique)? This would

Re: [Tutor] python win32 drive mapping help

2009-09-25 Thread Dave Angel
Vineet Kothari wrote: So What should be the attributes for the command? I tried this: win32net.NetUseDel(None, 1,{'local':'k:'}) but I got this error: Traceback (most recent call last): File "test.py", line 33, in win32net.NetUseDel(None, 1,{'local':'k:'}) TypeError: an intege

Re: [Tutor] Handling missing fields in a csv file

2009-09-29 Thread Dave Angel
Eduardo Vieira wrote: Hello, I have a csv file, a broken csv file using the ";" as a delimiter. This file contains addresses. My problem is that some fields are missing in some rows and I would like to normalize the rows for a smoother import into Excel, for example. Here is an example. This i

Re: [Tutor] help with alternate execution

2009-09-29 Thread Dave Angel
wrobl...@cmich.edu wrote: I'm trying to make a very simple example to show alternate execution... if a number is divisible by 3 it will say so and if it isnt, it will say so. Heres my program n= raw_input("enter a number= ") def divisible(n): if n%3 == 0: print n, "is divisibl

Re: [Tutor] UnboundLocalError and Break

2009-09-30 Thread Dave Angel
Corey Richardson wrote: Luke Paireepinart wrote: If your code's more than 10 lines long or so, put it on pastebin.com and send us the link rather than inlining the whole thing. You could also send it as an attachment. Your formatting is all screwed up and I can't read

Re: [Tutor] help with alternate execution

2009-10-01 Thread Dave Angel
You top-posted, and sent the mail to me privately (off-list). That's not how mailing lists work. wrobl...@cmich.edu wrote: Thank you for the reply.. I tried putting the print repr(n) before I defined 'n' with raw_input. My script looks like this-- def divisible(n): if n%3 == 0:

Re: [Tutor] help with alternate execution

2009-10-01 Thread Dave Angel
You sent the mail to me privately (off-list). That's not how mailing lists work. wrobl...@cmich.edu wrote: Thank you for the reply.. I tried putting the print repr(n) before I defined 'n' with raw_input. My script looks like this-- def divisible(n): if n%3 == 0: print n, "is di

Re: [Tutor] if n == 0 vs if not n

2009-10-05 Thread Dave Angel
Vern Ceder wrote: Hi Sander, PEP 8, the "Style Guide for Python Code" http://www.python.org/dev/peps/pep-0008/ is pretty clear that the shorter version is preferable: if s: if n: if b: if not b: and so on... Cheers, Vern Sander Sweers wrote: Hi Tutors, I am going through someone's pytho

Re: [Tutor] if n == 0 vs if not n

2009-10-06 Thread Dave Angel
Wayne wrote: On Mon, Oct 5, 2009 at 3:37 PM, Sander Sweers wrote: Thanks Wesly/Vern for the replies. On Mon, 2009-10-05 at 21:56 +0200, Luke Paireepinart wrote: if not n == 0 if b == True can be written as if b. However, if not n == 0 can be written as if n != 0 but NOT as

Re: [Tutor] Checking for Python version

2009-10-06 Thread Dave Angel
Didar Hossain wrote: Hi, I am using the following code to check for the Python version - import os t = os.sys.version_info[0:2] if (t[0] + t[1]) < 6: os.sys.exit("Need at least Python 2.4") del t This snippet is put at the beginning of the single script file before the rest of the code. I

Re: [Tutor] What language should I learn after Python?

2009-10-06 Thread Dave Angel
Mark Young wrote: I have no real need to learn anything for a job, it's just a hobby right now. I mostly just want "a programming language that has a different philosophy or approach than Python". However, you guys are right, if I just learn a language without a reason, it will be worthless. W

Re: [Tutor] Wrapper of C++

2009-10-08 Thread Dave Angel
Lizhi Yang wrote: Since the memory usage for saving huge data using python is not efficent at all(12 bytes per int). if I want to implement algorithms and load the huge amount of data using C++, but using Python as the glue language to implement other functionality such as Gui and txt processing,

Re: [Tutor] If you don't close file when writing, do bytes stay in memory?

2009-10-10 Thread Dave Angel
xbmuncher wrote: Which piece of code will conserve more memory? I think that code #2 will because I close the file more often, thus freeing more memory by closing it. Am I right in this thinking... or does it not save me any more bytes in memory by closing the file often? Sure I realize that in

Re: [Tutor] If you don't close file when writing, do bytes stay in memory?

2009-10-10 Thread Dave Angel
Kent Johnson wrote: 2009/10/10 Xbox Muncher : What does flush do technically? "Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on some file-like objects." The reason I thought that closing the file after I've written about 500MB file data to it, was smart -> was becau

Re: [Tutor] Python 3 and tkinter Radiobuttons

2009-10-11 Thread Dave Angel
(Don't top-post. It confuses everything. Put your reply at the bottom, or maybe inline) bob smith wrote: Thanks for the reply. Unfortunately, even when I include a variable, all of the buttons start out selected. I noticed that this is the case when I create a StringVar (rathe

Re: [Tutor] Carriage return

2009-10-12 Thread Dave Angel
Alan Gauld wrote: "Vineet Kothari" wrote I see that python IDLE add ^M as carriage return while programming in windows machine. Thats just the Windows line ending. If you want to use the same file on both Windowscand Linux then you will need to either get used to it or run the DOS2Unix tool

Re: [Tutor] Automaton/transitional grammar query

2009-10-12 Thread Dave Angel
kevin parks wrote: I posted about this a couple weeks back, but then got horribly ill and dropped the ball so i was hoping to revisit. I am not sure if this is and example of Finite Automaton or a Finite State Machine or perhaps it is related to a transition table or markov process. I think

Re: [Tutor] Automaton/transitional grammar query

2009-10-12 Thread Dave Angel
kevin parks wrote: On Oct 12, 2009, at 8:02 PM, Dave Angel wrote: Often, when a combination of existing stdlib collection types gets too confusing, it's time to consider classes and objects. Not necessarily to make the program "object oriented," but to make the program

Re: [Tutor] Help on python file extension windows vista recognition

2009-10-12 Thread Dave Angel
Victor Binns wrote: Please, I need help. I installed python on my gateway windows vista laptop computer. This is with the latest version of python (Python 2.6.3 Windows installer) Python 2.6.3 Windows installer It's not the latest, but no problem. It's probably a good choice. I have s

Re: [Tutor] Shebang (#!) in the first line of a python script

2009-10-13 Thread Dave Angel
Alan Gauld wrote: "Katt" wrote Okay. So if I were to place the following in my Windows XP py v.2.6.2 : $ (name of python script) Then as long as python was in my path I would be able to type the name of the script like a Dos batch file (ex: lowertoupper.py or lowertoupper) instead of havi

Re: [Tutor] Changing text colors on WinXP py2.6.2

2009-10-13 Thread Dave Angel
Tim Golden wrote: Alan Gauld wrote: "Tim Golden" wrote No. ANSI escapes don't work on Windows. Wouldn't the ANSI codes work if ANSI.SYS were loaded? I thought you could still load ANSI.SYS it just wasn't normally there? The help system says you should load it in config.nt with: device=c

Re: [Tutor] writing sample program that zips files and saves in a backup directory

2009-10-13 Thread Dave Angel
David Eric wrote: doing a python tutorial and one of the assignments says to develop a program that backsup files to zip files into a backup directory im using Darwin 10.0.0 unix version: this is what i came up with thus far, i did copy the sample program given but made changes for my unix OS:

Re: [Tutor] writing sample program that zips files and saves in a backup directory

2009-10-13 Thread Dave Angel
an example of an innoucuous script? On Tue, Oct 13, 2009 at 3:23 PM, Dave Angel wrote: David Eric wrote: doing a python tutorial and one of the assignments says to develop a program that backsup files to zip files into a backup directory im using Darwin 10.0.0 unix version: this

Re: [Tutor] Shebang (#!) in the first line of a python script

2009-10-13 Thread Dave Angel
Katt wrote: You were right. I did not have .PY/.PYW in my PATHEXT. I have put it in as suggested. I do have python.exe in my path so that should take care of things. Messing around with the windows registry isn't something I want to tackle just yet so I will save that for later. Thank

Re: [Tutor] Recursive user input collection problem

2009-10-13 Thread Dave Angel
William Witteman wrote: I need to collect a couple of integers from a user, but I want to make sure that I actually get integers. I tried this, but subsequent calls to the function don't update variable. I'm not sure this is terribly clear - here's the code: num_of_articles = 0 num_of_reviewer

Re: [Tutor] Shebang (#!) in the first line of a python script

2009-10-13 Thread Dave Angel
Scott Markwell wrote: On Tue, Oct 13, 2009 at 1:54 PM, Dave Angel wrote: Katt wrote: You were right. I did not have .PY/.PYW in my PATHEXT. I have put it in as suggested. I do have python.exe in my path so that should take care of things. Messing around with the windows

Re: [Tutor] namespaces and global

2009-10-15 Thread Dave Angel
Jose Amoreira wrote: Alan, Kent, hello! Thanks for your help. As for your "curiosity", I'm teaching elementary physics to undergraduates in computer engineering. Trying to speak my students' language, I wanted to show them simple applications that compute numerical values for the kinematics fo

Re: [Tutor] Recursive user input collection problem

2009-10-15 Thread Dave Angel
William Witteman wrote: Thanks to all who responded. There were several good points about the code itself, all of which both helped and work. I will likely use Alan's example because I find it the most lucid, but the other suggestions are good signposts to other ways to do the same thing (but r

Re: [Tutor] Putting a variable into a statement

2009-10-16 Thread Dave Angel
bob gailer wrote: GoodPotatoes wrote: : for x in myuser.properties:# "myuser.properties" returns a tuple of properties associated with the myuser AD object print myuser.x Traceback (most recent call last): File "", line 2, in print myuser.x File "build\bdist.win32\egg\active_

Re: [Tutor] Understanding what the code does behind the scenes

2009-10-16 Thread Dave Angel
Katt wrote: The textcolor() function returns None. so you need to keep it out of your print statement:. This means you need to split your print into multiple separate statements. (This will also be true for the pywin32 version) print "There are", textcolor(4) print apples_left, textcolor(7) pri

Re: [Tutor] Most pythonic input validation

2009-10-16 Thread Dave Angel
Kent Johnson wrote: Is this the way to define my own error and to use it: class MyValueError(Exception): define initialization and printing You usually don't need to define anything extra, the Exception methods are fine. I think there could be confusion over what you meant w

Re: [Tutor] Testing for empty list

2009-10-19 Thread Dave Angel
Wayne wrote: Hi, I think I recall seeing this here, but I wanted to make sure I'm correct. Is the best way to test for an empty list just test for the truth value? I.e. mylist = [1,2,3] while mylist: print mylist.pop() Thanks, Wayne My take is simple: Use the above form if you *know*

Re: [Tutor] Python List Help

2009-10-19 Thread Dave Angel
Mike Sweany wrote: Hi all, I am a PHP developer that just started learning Python for a specific application and the transition has been pretty easily assisted by google, but I just don’t see the issue with this one? I’ve got a list that created and populate in a loop that shows the cor

Re: [Tutor] updating Unix config file

2009-10-20 Thread Dave Angel
Matt Herzog wrote: On Tue, Oct 20, 2009 at 02:49:53PM +, Tiago Saboga wrote: On Tue, Oct 20, 2009 at 2:44 PM, Matt Herzog wrote: Yes, thanks. What failed was the invocation of PIPE. Apparently I had to explicitly import PIPE from subprocess or python had no clue as to what PIPE

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Dave Angel
Tom Green wrote: Alan, Thanks for your response and hopefully I can clear things up. I apologize for not being more clear. I obtain the HEX encoded data from Winhex i.e. copy Hex values. The HEX encode data is very large and I simply paste it into my Python script along with the XOR key. The

Re: [Tutor] Pack as HEX question

2009-10-24 Thread Dave Angel
Tom Green wrote: Thanks for your reply Dave. I am capturing the data off the network (wireshark) and saving it in WinHex for testing. I am actually building a socket to decrypt the data, so prior to implementing my logic in the socket, I figured I would write the algorithm in a quick script

Re: [Tutor] Reading information from a text file into a list of lists (WinXP/py2.6.2)

2009-10-25 Thread Dave Angel
Katt wrote: Hello all, Currently I am working on a program that reads text from a text file. I would like it to place the information int a list and inside the information would have sublists of information. The text file looks like this: "Old Test","2009_10_20" "Current Test","2009_10_25"

Re: [Tutor] HttpResponse error

2009-10-26 Thread Dave Angel
Vincent Jones wrote: SyntaxError at / ("'return' outside function", ('c:\\Users\\Vincent\\Documents\\django_bookmarks\\..\\django_bookmarks\\boo kmarks\\views.py', 15, None, 'return HttpResponse(output)\n')) from django.http import HttpResponse def main_page(request) : output = '''

Re: [Tutor] Function design

2009-10-26 Thread Dave Angel
Luke Paireepinart wrote: On Mon, Oct 26, 2009 at 2:08 PM, Eduardo Vieira wrote: Hello, I need your help in designing a function. I have created this script to check out if certain column in some csv files has value "0": import csv def zerofound(csvfile, outputfile, lastcolumn ): """Find

Re: [Tutor] Function design

2009-10-27 Thread Dave Angel
Benno Lang wrote: On Tue, Oct 27, 2009 at 8:21 AM, Dave Angel wrote: I agree with Luke's comments. But I'd like to point out an apparent bug (I haven't tried the code, this is just by inspection). You use the test if '0' in row[.] that's not going t

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Dave Angel
(For some reason you keep top-posting. Add your comments to the end, or inline if appropriate) bibi midi wrote: Yep it works! I understand now it iterates on each line and replaces the old elements with the new ones. In the end you get the latest date of the last line of log. I will work on t

Re: [Tutor] New to Python

2009-10-28 Thread Dave Angel
Remember to hit Reply to all - Forwarding your message onto the list -- Forwarded message -- From: Date: Wed, Oct 28, 2009 at 1:00 AM Subject: Re: [Tutor] New to Python To: sri...@gmail.com Hi Wayne, I will try as best to explain what I need to do. I have a log file. In t

Re: [Tutor] How to manipulate a variable whose value depends on next values of list using LC or reduce()

2009-10-30 Thread Dave Angel
Shashwat Anand wrote: Shashwat Anand to Bangalore show details 5:31 AM (2 minutes ago) I wrote an LCM function of mine as follows: import fractions def lcm(mylist): # lcm by defination is Lowest Common Multiple # lcm (a*b) = a*b / gcd(a*b) # lcm (a, b, c) = lcm(lcm(a, b), c) #

Re: [Tutor] unicode: % & __str__ & str()

2009-10-30 Thread Dave Angel
spir wrote: [back to the list after a rather long break] Hello, I stepped on a unicode issue ;-) (one more) Below an illustration: class U(unicode): def __str__(self): return self # if you can't properly see the string below, # 128 ===

Re: [Tutor] problem adding Tkinter

2009-10-30 Thread Dave Angel
Kristin Wilcox wrote: I apologize in advance for asking such a simple question! I first tried looking through Google, and through the last couple months of this list's archives, and I found some talk about my issue out there but not a detailed enough answer to help someone as new as me. This is

Re: [Tutor] Accessing variables in main from functions in a module

2009-10-30 Thread Dave Angel
Kent Johnson wrote: On Fri, Oct 30, 2009 at 6:39 PM, Robert Lummis wrote: I want to move some functions from my "main" program file to a module file because the main file is getting too big for convenience. The functions access arrays (lists of lists) that are defined and initialised in the

Re: [Tutor] class attribute to initiate more classes

2009-10-31 Thread Dave Angel
Vincent Davis wrote: I have a program that generates many instances of a class with an attribute self.x = random.gauss(10, 2). So each instance has a different value for self.x. This is what I want. Now I want to make a class that starts my program and sets the attributes. class people: def _

Re: [Tutor] class attribute to initiate more classes

2009-10-31 Thread Dave Angel
(You top-posted, which confuses the sequence of message text. So I clipped it off and posted my message at the bottom, which is the convention on this newsgroup) Vincent Davis wrote: DaveA posted import random, functools class Person: def __init__(self, size): self.size = size

Re: [Tutor] Structure of my simulation / monte-carlo

2009-11-01 Thread Dave Angel
Vincent Davis wrote: I ask this question in part because of a fee remarks from another question I ask "class attribute to initiate more classes" Basically I am simulation the process of applicants to schools and trying to ask/answer some questions like "what conditions do you need to have an opt

Re: [Tutor] Adding Value to CSV

2009-11-01 Thread Dave Angel
Paras K. wrote: I have some code that is going through a number of test. When I have the line that has been read I need to add another value at the end of it, or write the information into another csv file Example of my code: for line in fh.readlines(): readline = line

Re: [Tutor] Structure of my simulation / monte-carlo

2009-11-01 Thread Dave Angel
(This is too hard to follow, so I'm just going to respond to Kent's subsequent email. If I missed anything from here, please quote it more reasonably) Vincent Davis wrote: Kent Johsnon writes "This class has a lot of responsibilities: - create applicants - create institutions - run a single m

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