Re: [Tutor] extracting phrases and their memberships from syntax trees

2009-02-12 Thread A.T.Hofkamp
Emad Nawfal (عماد نوفل) wrote: just want to be able to do this myself. My question is: what tools do I need for this? Could you please give me pointers to where to start? I'll then try to do it myself, and ask questions when I get stuck. I'd start with parsing (reading) the tree to a generic ab

Re: [Tutor] Accessing callers context from callee method

2009-02-24 Thread A.T.Hofkamp
mobiledream...@gmail.com wrote: when i call a method foo from another method func. can i access func context variables or locals() from foo so def func(): i=10 foo() in foo, can i access func's local variables on in this case i As others have already pointed out, this is a really bad idea.

Re: [Tutor] overwriting input file

2009-02-25 Thread A.T.Hofkamp
Bala subramanian wrote: Hello all, query 1) How should i overwrite the input file I want to open 5 files one by one, do some operation on the lines and write the modified lines on the same file (overwritting). Can some please tell me how to do it. You cannot write output to a file if you need

Re: [Tutor] Convert a string of numbers to a list

2009-02-26 Thread A.T.Hofkamp
kkwai...@umich.edu wrote: Hi, I am trying to convert an output from subprocess.Popen() from a byte string to a list of numbers. This is what Popen returns: print SAL.stdout.readlines() ['[335, 180, 201, 241, 199]\r\n'] Except the string will be much longer in practice. I've experimented w

Re: [Tutor] re.format a file

2009-02-26 Thread A.T.Hofkamp
prasad rao wrote: helloThank you Lie and Kent. I forgot about newline character and the fact that string can be sliced. Thanks for your timely help BTW I have gone through the Python library reference and find no examples in fileinput module. The fileinput module only deals with reading and w

Re: [Tutor] creating new dictionary based on membership testing

2009-03-09 Thread A.T.Hofkamp
ski wrote: hello, i have this list which contains a number of dictionaries. >>>d1 = [{'is_selected': False, 'id': 'AAC', 'title': 'Association of Airline Cons.'}, {'is_selected': False, 'id': 'AALA', 'title': 'Adv. Activity Licence. Auth.'}, {'is_selected': False, 'id': 'ABPCO', 'title': 'A

Re: [Tutor] Binary to Decimal conversion

2009-03-10 Thread A.T.Hofkamp
Hello, Chris Castillo wrote: Thanks for clearing that up. I knew it was much simpler than I was trying to make it I just couldn't quite see the logic that I needed for the problem clearly. Thanks for the elegant code. On Mon, Mar 9, 2009 at 10:53 PM, Moos Heintzen wrote: binnum = raw_input("

Re: [Tutor] TypeError: dict objects are unhashable

2009-03-16 Thread A.T.Hofkamp
Lie Ryan wrote: Emile van Sebille wrote: Mark Tolonen wrote: [dict(n) for n in set(tuple(n.items()) for n in l1)] Anyone know if the ordered items for two different dicts where dicta == dictb is guaranteed the same? I know the ordering is unspecified but you can depend on the sequence of k

Re: [Tutor] memory error files over 100MB

2009-03-16 Thread A.T.Hofkamp
Cheetah1000 wrote: I can't speak for Python 2.6, but using Jython 2.1 (Python 2.1 for Java), the code only looks at the file you are trying to extract()/read(). Near the end of the zip archive is a directory of all the files in the archive, with the start position and length of each file. Jytho

Re: [Tutor] memory error files over 100MB

2009-03-17 Thread A.T.Hofkamp
Kent Johnson wrote: On Mon, Mar 16, 2009 at 12:30 PM, A.T.Hofkamp wrote: I don't know what code is executed in an assignment exactly, but **possibly**, first the 'read()' is executed (thus loading a very big string into memory), before assigning the value to the variable (whi

Re: [Tutor] list.replace -- string.swap

2009-03-17 Thread A.T.Hofkamp
Hello Denis, spir wrote: Is there a list.replace builtin I cannot find? Or a workaround? You didn't find it because it does not exist. You should do something like [f(x) for x in old_lst] where f(x) implements the replacement. Also: How would perform string.swap(s1, s2) in the following c

[Tutor] escaping newline (was: (no subject))

2009-03-17 Thread A.T.Hofkamp
OkaMthembo wrote: Doesn't backslash also escape the newline? Thought i saw something to that effect in the tutorial. It does, but only inside the .py file. It has no effect when you run the program. Its purpose is to allow you to break long lines, for example if long_function_name(a) == long

Re: [Tutor] HI, #Include like in python

2009-03-20 Thread A.T.Hofkamp
wesley chun wrote: import listen You can use the __import__ function if you want, but generally you want the import statement as above. The equivalent to 'import listen' is: listen = __import__('listen') See the tutorial here: http://docs.python.org/tutorial/modules.html you also hav

Re: [Tutor] Executing a C Program from RH Linux in Python for Win

2009-03-20 Thread A.T.Hofkamp
Wayne Watson wrote: Good. Thanks. Here's my code. == # Executing a Linux program under Win XP from subprocess import call myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) You must always escape \ characters in a string. do r"C:\Sandia_Meteors\Various\FuzzyLogic\wolf"

Re: [Tutor] Executing a C Program from RH Linux in Python for Win

2009-03-20 Thread A.T.Hofkamp
Wayne Watson wrote: Yes, good, but I tried myProg = call([r"C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]), and get exactly the same results. So the next step is to find out what is wrong. In other words, experiment with the problem to get an understanding what is not working. Once you ge

Re: [Tutor] dynamically creating list

2009-03-23 Thread A.T.Hofkamp
Bala subramanian wrote: 1) Now my question is, how to make this list creation dynamics, say if user enter number of clusters = 4, i would create four list. If the user enter 3, then i shd create three lists inside my program. How to do this dynamic creation of list depending on user input. Use

Re: [Tutor] text editor and debugger for python

2009-03-24 Thread A.T.Hofkamp
Bala subramanian wrote: Friends, I do the scripting in Linux. I use vi editor to code. It is not very convenient for me. Kindly suggest me a best free *text editor* ( i can code and debug the code simultaneously ) *for python* based on your experience. *best* means something different for ever

Re: [Tutor] Question about Python.

2009-03-25 Thread A.T.Hofkamp
T wrote: Hi. I'm working on Paper, Rock, Scissors in Python. I need to make it a loop, and test the values (1, 2, 3, /Rock/Paper/Scissors) yet, but i'm kind of stuck. Could you help me? import random #Imports the random modual from the library. def main(): #First function. print 'Lets p

Re: [Tutor] importance of Docstring

2009-04-16 Thread A.T.Hofkamp
mbikinyi brat wrote: Dear ALL, What is really the importance of Docstring in Python??? Regards, Henry The same as comments, except at function, class, and module level. In addition, Python provides hooks for extracting that information, and eg put it in a document such as the standardlib docu

Re: [Tutor] Looping

2009-04-20 Thread A.T.Hofkamp
Matt wrote: Hey everyone, First post to this list. I hope I'm doing it right. Let's say I want to run func 10 times Is there a more pythonic way to do it than this: for i in xrange(10): func() no, that looks fine for your requirement. What may be a bit weird here is the requirement to run

Re: [Tutor] how to compile python3.0

2009-04-24 Thread A.T.Hofkamp
Shaofeng NIu wrote: I tried to compile and install python3.0 from source,but after "make",it shows: Python build finished, but the necessary bits to build these modules were not found: _dbm _gdbm _hashlib _sqlite3 _ssl _tkinter bz2

Re: [Tutor] Threading...

2009-04-26 Thread A.T.Hofkamp
Spencer Parker wrote: Would the best route for this be threading? or is there another way to go about it? At #python, you'd quickly get redirected away from threading (you are making a IO-bound app, so threading doesn't buy you anything in performance and gives a big headache in data protecti

Re: [Tutor] Threading...

2009-04-27 Thread A.T.Hofkamp
Kent Johnson wrote: On Mon, Apr 27, 2009 at 2:46 AM, A.T.Hofkamp wrote: you are making a IO-bound app, so threading doesn't buy you anything in performance and gives a big headache in data protection Please explain. Presumably the single-threaded app is not IO-bound. Adding threads can

Re: [Tutor] finding mismatched or unpaired html tags

2009-04-28 Thread A.T.Hofkamp
Dinesh B Vadhia wrote: I'm processing tens of thousands of html files and a few of them contain mismatched tags and ElementTree throws the error: "Unexpected error opening J:/F2/663/blahblah.html: mismatched tag: line 124, column 8" I now want to scan each file and simply identify each mismat

Re: [Tutor] loops

2009-04-29 Thread A.T.Hofkamp
Norman Khine wrote: hello, i have the following code: if unique_id is not None: training = self.get_site_root() from training import Training # link back to news item root = context.root formats = ['itinerary', 'news'] for document in formats: results = root.searc

Re: [Tutor] Add newline's, wrap, a long string

2009-04-29 Thread A.T.Hofkamp
David wrote: I am getting information from .txt files and posting them in fields on a web site. I need to break up single strings so they are around 80 characters then a new line because when I enter the info to the form on the website it has fields and it errors out with such a long string.

Re: [Tutor] Guidance needed for script

2009-05-10 Thread A.T.Hofkamp
rony dsouza wrote: Hi Al, My name is Rony, I am new to python. Welcome to the list. Need your help and guidance for developing a python script with the below details: Using GnuPG to encrypt a file(s) on linux. Essentially two modes of operation would be ideal: 1. Running something

Re: [Tutor] Import package module problem

2009-05-12 Thread A.T.Hofkamp
man...@themacaque.com wrote: Hello there, I have just started working with python and I have some issues understanding how I should be importing modules from packages. Curretly I have the following tree structure: general/ __init__.py address_book.py groups/ __init__.py contact_

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-15 Thread A.T.Hofkamp
MK wrote: Ok. I explain it once more. Its not about reading the console output of the command. Its that i want to put a empty file in my subdirectories so that the name of the file is a message or url or something else. And if you want an empty file you can do that with "cat > IAmAnEmptyFileWith

Re: [Tutor] Replacement for __del__

2009-05-19 Thread A.T.Hofkamp
Strax-Haber, Matthew (LARC-D320) wrote: A folder is created during object instantiation. This is necessary because multiple other methods depend on the existence of that folder, and in the future things may be running in parallel so it has to be there for the entire life of the object. Before the

Re: [Tutor] clean text

2009-05-19 Thread A.T.Hofkamp
spir wrote: def _cleanRepr(text): ''' text with control chars replaced by repr() equivalent ''' chars = [] for char in text: n = ord(char) if (n < 32) or (n > 126 and n < 160): char = repr(char)[1:-1]

Re: [Tutor] ?????

2009-05-25 Thread A.T.Hofkamp
prasad rao wrote: hello I get a problem while trying to print non callable items in dir(module).May be as the items are strings. It is much easier to read about the contents of the sys module in the documentation: http://docs.python.org/library/sys.html#module-sys Not only is the conte

Re: [Tutor] ?????

2009-05-25 Thread A.T.Hofkamp
Alan Gauld wrote: Even if you use the other suggestions to prove its callable that doesn't mean you can do this: print sys.x() If the callable takes parameters then this will fail. You need to know quite a lot more about what you are calling and that is a non trivial task in the gener

Re: [Tutor] missing first argument on subprocess.Popen w/ executable

2009-05-29 Thread A.T.Hofkamp
Lie Ryan wrote: I'm wondering whether I have misunderstood the documentation or this is a bug in either the documentation or the python: Python 2.5.4 (r254:67916, May 18 2009, 20:53:31) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. import subproces

Re: [Tutor] question about class

2009-06-09 Thread A.T.Hofkamp
Vincent Davis wrote: Accidentally sent I have added the rest (by the way I refrain from using the terms attribute, method, as I will likely miss use them) I am reading several tutorials about classes and trying to figure out how to apply it to my project. I have a working program that basic

Re: [Tutor] smptlib question

2009-06-09 Thread A.T.Hofkamp
Albert-jan Roskam wrote: Hi David and Tino, Thanks! I will try this tonight when I'm back home from the office. It's interesting to see how you split up the code into several little functions. Maybe it's typical for a newbie (like myself) to have the tendency to put everything into one function,

Re: [Tutor] gui further explained

2009-06-10 Thread A.T.Hofkamp
Jacob Mansfield wrote: does anyone know how to make a parallel or serial interface with respective software, i would prefer parallel because it is easy to utilise Both the serial and the parallel interface seem to be covered by pyserial http://pyserial.wiki.sourceforge.net and http://pyserial.

Re: [Tutor] How do I do this in python?

2009-06-11 Thread A.T.Hofkamp
Robert Lummis wrote: I want to write a function that I can use for debugging purposes that prints the values of whatever list of object references it is given as arguments, without knowing in advance how many object references it will be called with or what they might be. For example, the call: s

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread A.T.Hofkamp
eShopping wrote: import subprocess x = subprocess.Popen(args="poly.exe",stdin=subprocess.PIPE) for item in ["polyin.dat", "polyout.dat", "polyout.plt"]: x.stdin.write('%s\n' % item) but got the same error message Above code would seem to be correct. Are you sure the Fortran program ac

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread A.T.Hofkamp
eShopping wrote: At 13:26 11/06/2009, you wrote: Are you sure the Fortran program accepts the names? One easy way to test this is to try C:\> poly.exe < poly_files.txt in a CMD program (or COMMAND or whatever the console program is called nowadays at Win* systems). Tried piping the input as

Re: [Tutor] use of __new__

2009-06-12 Thread A.T.Hofkamp
spir wrote: Hello, I have (again) some issue using __new__. What I need is basically to catch an object creation and yield an object of an alternate type, when a condition is met. Basically, the outline looks like: class Normal(object): def __new__(cls, arg): if cond(arg):

[Tutor] difflib (was: (no subject))

2009-06-26 Thread A.T.Hofkamp
Febin Ameer Ahsen wrote: how to implement diff command showing difference in box Don't implement diff yourself, use the difflib module instead. Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

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

2009-06-26 Thread A.T.Hofkamp
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 In general, it helps for both you and us if you show what happens when you run the program, and how

Re: [Tutor] freeze

2009-06-29 Thread A.T.Hofkamp
col speed wrote: HI Guys, I have a small programme, called shop.py, that I wish to make into a "frozen binary" ( I think that's right - I'm using Linux Ubuntu 9.04 and I want the programme to work on a windows computer that doesn't have Python installed). I used freeze.py from examples/Tools and

Re: [Tutor] does python have something like "#include" in C?

2009-06-29 Thread A.T.Hofkamp
Robert Lummis wrote: ... or any pre-processing at all? I'm looking for a way to get boiler plate code into the main program file. Of course I could copy and paste it with an editor but I was hoping for something more pythonic. I know about import but that's not the same. Python is very good at

Re: [Tutor] window graphics

2009-07-02 Thread A.T.Hofkamp
David H. Burns wrote: I am new to Python and I'm looking for help on graphics in Python3.0. All the graphics libraries I've seen are far to complex (and don't seem compatible with 3. What I really need to know is two things (1) how to set up a graphic window and (2)how to plot a pixel. Basicall

Re: [Tutor] HI

2009-07-07 Thread A.T.Hofkamp
Vishnu S wrote: Sir/Madame, i'm a begginner to Python help me in putting the first step to this world Welcome! A useful first page may be http://wiki.python.org/moin/BeginnersGuide for an overview, and http://wiki.python.org/moin/BeginnersGuide/NonProgrammers where you can find a lot of link

Re: [Tutor] setup.py to Makefile

2009-07-09 Thread A.T.Hofkamp
Brummelen, M. van (ICT) wrote: Hi, What would be the best way to convert a setup.py file to a Makefile? Don't convert, simply run the setup.py from the Makefile Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/

Re: [Tutor] find and replace relative to an nearby search string in a file

2009-07-13 Thread A.T.Hofkamp
Pete O'Connell wrote: Write { file /Volumes/raid0/Z353_002_comp_v27.%04d.cin file_type cin name Write1 xpos 13762 ypos -364 } The simplest approach imho is to parse the input with a proper parser, eg PLY or pyparsing. If you want to do the parsing manually, I'd start by classifying eac

Re: [Tutor] Why is there no uninstall option for setup.py?

2009-07-13 Thread A.T.Hofkamp
Hai, Welcome to the complexities of package management :) wcyee wrote: Hi, When I am able to find and install a windows package distributed as an exe file, I can just go to "Add & Remove Programs" in the "Control Panel" and uninstall it. That's what I call an OS package manager. My Linux on

Re: [Tutor] While and for loops

2009-07-14 Thread A.T.Hofkamp
Todd Matsumoto wrote: while True: for i in items: if i > 10: break else: > Okay, > > So how would you break out from this situation? > finished = False while not finished: for i in items: if i > 10: finished =

Re: [Tutor] While and for loops

2009-07-14 Thread A.T.Hofkamp
Todd Matsumoto wrote: Okay, I'm not sure if this is good practice, but I could assign a variable within the while loop, that is assigned something that will then break the outer loop. while True: breakout = True for i in items: if i > 10: breakout = False

Re: [Tutor] Pythonify this code!

2009-07-14 Thread A.T.Hofkamp
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]] elif len(s) > 1:

Re: [Tutor] Pythonify this code!

2009-07-14 Thread A.T.Hofkamp
Dave Angel wrote: def separateToList(num): """ changes an integer 0-255 into a list of ints, size exactly 3 """ return map(int, list(format(num, "03d"))) Nice! Note that the "list" conversion is not needed; when you iterate over a string you automatically get each character in

Re: [Tutor] unittests, testing a type

2009-07-14 Thread A.T.Hofkamp
Todd Matsumoto wrote: Hi, Does anyone know how to do a unittest assert for a type? So If you have a program returning a Decimal, lets say Decimal("1"), and you want to make sure that what is returned is a Decimal object. At first I thought of importing Decimal and making my own Decimal("1")

Re: [Tutor] XML parsing with SAX

2008-10-22 Thread A.T.Hofkamp
amit sethi wrote: Sorry , I didn't follow the format of posting to the group. Well I am new to xml and python . What I basically want to do is to read elements from the xml which is by the way large ~2GB and read the attributes and make a decision as to whether i want to keep that element or not

Re: [Tutor] Iterate over multiple objects

2008-10-29 Thread A.T.Hofkamp
W W wrote: Hi, I'm trying to compare two strings because I want to find the difference. i.e. string1 = "foobar" string2 = "foobzr" is there a simple way to do this with a for loop? This is the method I tried, but it gives me an error: In [14]: for x, y in bar[0], bar[1]: : print x,

Re: [Tutor] csv manipulation

2008-10-29 Thread A.T.Hofkamp
[EMAIL PROTECTED] wrote: hello, i have the follwoing csv file: "Berat","Berat","Kuçovë","Skrapar" "Dibër","Bulqizë","Dibër","Mat" "Durrës","Durrës","Krujë" "Elbasan","Elbasan","Gramsh","Librazhd","Peqin" "Fier","Fier","Lushnjë","Mallakastër" "Gjirokastër","Gjirokastër","Përmet","Tepelenë" "Korçë

Re: [Tutor] class/type methods/functions

2008-10-30 Thread A.T.Hofkamp
spir wrote: Q: Is there a way to write /type/ (class) functions, meaning methods not bound to an instance, in python? As Bob Gailer already said, staticmethod seems to do what you want. After reading your mail, I cannot help wondering that something crucial seems to be missing in your class s

Re: [Tutor] [Re: class/type methods/functions]

2008-10-31 Thread A.T.Hofkamp
spir wrote: After reading your mail, I cannot help wondering that something crucial seems to be missing in your class structure. (I get the impression that you are trying to squeeze object information and object meta information together in one class definition.) Yes. This is a consequence of

Re: [Tutor] string.join()

2008-11-03 Thread A.T.Hofkamp
Monte Milanuk wrote: Hello again, Just looking for clarification on a point: the book I'm using is written around Python v.2.3, and has an exercise using string.join(). Specifically, it said to use string.join(msgList, ""), the object of which was to take the list items in msgList and concatena

Re: [Tutor] serial port, revisited, but closer

2008-11-05 Thread A.T.Hofkamp
shawn bright wrote: Hey all, I am back again with the serial port stuff, i have verified that all the baud rate and settings are ok, had my unit talk directly to a serial port reader and it is looking good, however, i still am not seeming to be able to read this. I had a question that might mak

Re: [Tutor] validating decimal class

2008-11-06 Thread A.T.Hofkamp
John Fouhy wrote: 2008/11/6 Brian Lane <[EMAIL PROTECTED]>: But you could also compare it to a known type: if not type(price) is type(decimal.Decimal(0)): print "Not Decimal" Easier to just compare with decimal.Decimal: import decimal d = decimal.Decimal(13) type(d) == decimal.Decimal Tru

Re: [Tutor] Dictionary of dictionaries issue

2008-11-13 Thread A.T.Hofkamp
Pablo Englebienne wrote: Hi, I'm trying to work with a dictionary of dictionaries and I'm having trouble accessing a specific element of it: $ python Python 2.6 (trunk:66714:66715M, Oct 1 2008, 18:36:04) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin Type "help", "copyright", "credits

Re: [Tutor] list output -- float output

2008-11-14 Thread A.T.Hofkamp
spir wrote: # By the way, I do not understand at all the behaviour of repr on rounded floats: x = round(1.1,1) print x, repr(x), "%s" %x 1.1 1.1001 1.1 This is a FAQ question: http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate Sincerely, Albe

Re: [Tutor] referencing external functions

2008-11-14 Thread A.T.Hofkamp
Robert Berman wrote: I have a number of functions written in a python script called script1.py. In another script, script2.py, I need to use a number of the functions residing in script1.py. How do I make these functions known to script2.py. Thank you, script1.py: def f(n): return n + 1

Re: [Tutor] List of lists help

2008-11-20 Thread A.T.Hofkamp
[EMAIL PROTECTED] wrote: Hello, I am completely baffled by this action and would appreciate any help. My problem is occurring within a class which is within a larger program; if I need to post the entire program let me know and I will. It's only about 250 lines so far. Anyways, I am using a l

Re: [Tutor] import data (txt/csv) into list/array and manipulation

2008-11-20 Thread A.T.Hofkamp
trias wrote: Hi, so for this part of the problem it goes a bit like this: I have a CSV file (file1) that contains three columns, column one contains a unique ID type str, columns two and three contain start and stop coordinates type int. the other file (file2) contains two columns, column

Re: [Tutor] first python program to find citeulike duplicates

2008-11-20 Thread A.T.Hofkamp
Suresh Krishna wrote: it works (i think), but since this is my very first python program, i would really appreciate feedback on how the program could be improved.. First of all, welcome, new Python programmer, My main trouble with the program is lack of structure, some lines deal with indivi

Re: [Tutor] accessing list from a string

2008-11-25 Thread A.T.Hofkamp
Bryan Fodness wrote: I have a list in a text file that is in the python format., Positions = [2.5,2.8] Why do you use Python format for storing data? (Python format is for storing programs, usually) and would like to grab the values. for line in file('list.txt'): if line ==

Re: [Tutor] To print docstrings

2008-12-04 Thread A.T.Hofkamp
prasad rao wrote: Hello friends. I am new to programing.I am learning Python. I failed in my attempts to retrive doc strings of methods in a module. """ for x in dir(logging): print x,x.__doc__ = for x in dir(collections): print x,collections.x.__doc__ == I am n

Re: [Tutor] extreme basics

2009-01-05 Thread A.T.Hofkamp
Mr Gerard Kelly wrote: This is extremely weird, I think. Here is a tiny program: from math import * from Numeric import * x=[0]*10 for counter in rangelen((x)): x[counter]=counter*0.1 print x Here is what I get: [0.0, 0.10001, 0.20001, 0.30004, 0.

Re: [Tutor] Usage of for loop

2009-01-05 Thread A.T.Hofkamp
vanam wrote: Hi all, i am beginner to this python language and slowing learning the language by referring docs.I am trying to understand the for loop i.e., usage of for loop in python,unlike c where i can give condition in python it is simple In C, the for-loop is just a hidden 'while'. You can

Re: [Tutor] Wayne's waning list.

2009-01-05 Thread A.T.Hofkamp
WM. wrote: As a BASIC, hobby programmer, (long since), I get so jargonized here that I seldom ask about anything any more. The only useful bit I have gleaned from reading many, many posts is the URL for projecteuler. Maybe, after I get past the baby steps and start using the libraries, I will

Re: [Tutor] Interactive programming.

2009-01-07 Thread A.T.Hofkamp
WM. wrote: Norman Khine wrote: >>> i = 5 >>> j = 7 >>> if i <= j: ... print 'nudge', 'nudge' ... else: ... print 'whatever' ... nudge nudge >>> Yes, I understand how your program works. What I do not understand is how you got it. My program came out in IDLE as you see it. No ..

Re: [Tutor] good day

2009-01-07 Thread A.T.Hofkamp
Kgotlelelo Legodi wrote: good day I just started using python and i want to know how can i solve a boundary value problem for ordinary differential equations using shooting method in python.use the general equation to demonstrate the python code. I have no background in numeric calculations,

Re: [Tutor] SMTP Module Help

2009-01-07 Thread A.T.Hofkamp
Marco Petersen wrote: I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send an email through my Gmail account but it keeps saying that the connection was refused. This is the code that I used : import smtplib msg = 'Test' server = smtplib.SMTP('smtp.gmail.com') server

Re: [Tutor] linked list with cycle structure

2009-01-07 Thread A.T.Hofkamp
David Hláčik wrote: Hello guys, I have a linked list where *number of elements is unlimited* and **last element points on random (can be first, last, in middle , anywhere) element within linked list** - this is important . My goals is to create an architecture /scheme for **algoritmus which will

Re: [Tutor] Interactive programming.

2009-01-07 Thread A.T.Hofkamp
Kent Johnson wrote: On Wed, Jan 7, 2009 at 5:28 AM, A.T.Hofkamp wrote: WM. wrote: Norman Khine wrote: >>> i = 5 >>> j = 7 >>> if i <= j: ... print 'nudge', 'nudge' ... else: ... print 'whatever' ... nudge nudge &

Re: [Tutor] traceback

2009-01-13 Thread A.T.Hofkamp
spir wrote: Hello, is there a way to read an exception's traceback? Cannot find it in object attributes. [dir() shows no traceback, __dict__ is empty.] You should be able to do that with the traceback module. Sincerely, Albert ___ Tutor maillist

Re: [Tutor] Sort of database & "family tree" question

2009-01-26 Thread A.T.Hofkamp
Timo wrote: Hello, I'm writing an application that stores people with some info. I'm doing this with ConfigParser and it works, but currently (for testing), there are only 10 persons in it. What if I add, let's say, about 500-600 or even more? Is this still a good choice? Last week, I creat

Re: [Tutor] [Python-ideas] import imports

2009-01-27 Thread A.T.Hofkamp
Hai Denis, spir wrote: "Secure import" means that I, as client of the imported module, know that this module defines __all__. I can then safely import all. I can even precisely know which names are defined simply by reading __all__. The common practice of defining __all__ on top of a module hel

Re: [Tutor] Defining "bit" type -- why not '!' ?

2009-01-29 Thread A.T.Hofkamp
spir wrote: Le Tue, 27 Jan 2009 11:26:06 -0200, Ricardo Aráoz a écrit : Operation Result Notes |x | y| bitwise /or/ of x and y |x ^ y| bitwise /exclusive or/ of x and y |x & y| bitwise /and/ of x and y |x << n| x shifted left by n bits

Re: [Tutor] non-greedy matching

2009-01-30 Thread A.T.Hofkamp
spir wrote: Hello, imagine you need to match such a pattern: pat : (@@ [charset]* @@) | [charset]* ... where [charset] has to include '@' My questions are: * Is there any other way than using a non-greedy form of [charset]* ? Something like this? (in pseudo-RE syntax) "(@@" ( [...@]* "@" [.

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread A.T.Hofkamp
Wayne Watson wrote: mask file: c:\operation/horizon.jpg latitutde: -140.22 longitude 38.22 start time: 18:25:00 stop time: 06:30:00 event directory: d:\events_2009 grey scale: yes autoexpose format: gif I suspect there may be a standard way of doing this in Python that relies on more complex o

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread A.T.Hofkamp
Kent Johnson wrote: Another way is to use a .ini file. The ConfigParser module can read ini files but not write them. http://docs.python.org/library/configparser.html What do you mean 'not write them'? from the Python docs: RawConfigParser.write(fileobject) Write a representation of the

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread A.T.Hofkamp
David wrote: line = infile.readline()# Invokes readline() method on file while line: outfile.write(line),# trailing ',' omits newline character line = infile.readline() The 'while' loop can be replaced by a 'for' loop, like for line in infile: outfile.write(line) infile.cl