Re: Emacs skeletons

2005-07-26 Thread Caleb Hattingh
Since you are on this topic, do you (or anyone else) have any type of code-completion mode for python in emacs? Thanks -george For what its worth, Vim has a generic type of code-completion that uses the file being edited to check for completion options within a word. It's not true

Re: is this pythonic?

2005-07-22 Thread Caleb Hattingh
Terry Yes, I must agree with you that it is something I should know. I do try to keep with things but there are always some things that slip through the cracks, like enumerate, in this case. That is why I am extremely grateful the for the activity, generosity and pure knowledge on this

Re: is this pythonic?

2005-07-20 Thread Caleb Hattingh
Wow, I didn't know about enumerate. Many thanks Caleb On Wed, 20 Jul 2005 15:19:50 +0200, Simon Brunning [EMAIL PROTECTED] wrote: On 7/20/05, Mage [EMAIL PROTECTED] wrote: Or is there better way? for (i, url) in [(i,links[i]) for i in range(len(links))]: for i, url in enumerate(links):

Re: OO design

2005-07-19 Thread Caleb Hattingh
Chris 1. get arbitrary numerical data (typically large data sets in columnar format or even via COM from other packages. I generally have to deal with one or more sets of X,Y data) 2. manipulate the data (scaling, least squares fitting, means, peaks, add/subtract one XY set from another etc)

Re: Finding # prefixing numbers

2005-07-19 Thread Caleb Hattingh
You really owe it to yourself to try the PyParsing package, if you have to do this kind of thing with any frequency. The syntactic difference between PyParsing and regular expressions is greater than the syntactic difference between Python and C. thx Caleb On Tue, 19 Jul 2005 13:35:02

Re: Opinions on KYLIX 3 (Delphi 4 Linux)

2005-07-18 Thread Caleb Hattingh
Hi Doug Not only was Kylix a letdown, there is talk also of it being discontinued. To be fair though, it is easy to see the difficulty for Borland to deploy a Linux IDE of the same quality as Delphi when so much in different Linux distributions is variable, the widget set being a prime

Re: large dictionary creation takes a LOT of time.

2005-04-29 Thread Caleb Hattingh
In fact, as one of the Peter's (either Otten or Hansen) explained to me, for line in open(file): is actually both faster (being buffered) and generally better for very large files because it doesn't read the whole file into memory, like readlines does (if you have a memory limitation). On

Re: python open source charting solutions ?

2005-03-08 Thread Caleb Hattingh
I have had good success with pygnuplot. On Tue, 8 Mar 2005 20:45:22 +0200, ionel [EMAIL PROTECTED] wrote: i need some pointers. so far i've tryed matplotlib ... -- http://mail.python.org/mailman/listinfo/python-list

Re: some qustions on python

2005-02-15 Thread Caleb Hattingh
http://www.python.org On Tue, 15 Feb 2005 13:16:53 -0500, samar bazied [EMAIL PROTECTED] wrote: Hi.. plz can u help me?? I am very new in python and I have some qustions about it. can u give me design process of python and their related langauges? and I will be very habby if u give me small

Re: Python versus Perl ?

2005-02-09 Thread Caleb Hattingh
anyways. Thanks again Caleb On Wed, 09 Feb 2005 12:38:37 -0500, Joe Francia [EMAIL PROTECTED] wrote: Caleb Hattingh wrote: As you might imagine, I think about this constantly. However, there are many other issues that make it complicated, such as having to work in a team where the average guy knows

Re: Python and version control

2005-02-09 Thread Caleb Hattingh
Carl What is the ultimate version control tool for Python if you are working in a Windows environment? We use JEDI VCS (open source, free). To be fair, JEDI VCS actually integrates into the Delphi IDE, which is what we use mostly. However, the standard installation also installs a

Re: Is Python as capable as Perl for sysadmin work?

2005-02-09 Thread Caleb Hattingh
Roy How about the Yoda version: do: statement do not do: statement The Yoda version actually goes statement :do statement :not do Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: SWIG or SIP?

2005-02-09 Thread Caleb Hattingh
Brent Google python ctypes. ctypes is cool :) keep well Caleb On Wed, 9 Feb 2005 13:44:44 -0700, Brent W. Hughes [EMAIL PROTECTED] wrote: I have a third-party DLL and it's associated .h file. The DLL was written in C. I have neither the associated .c files nor the .obj files for the DLL.

Pypy - Which C modules still need converting to py?

2005-02-08 Thread Caleb Hattingh
Hi all I saw it on a webpage a few days ago, can't seem to find it again. Tried a google search for pypy needed translate C modules but that didn't turn up what I was looking for. Anyone have that page ref handy listing the C modules that the pypy team need translated into python?

Re: Python versus Perl ?

2005-02-08 Thread Caleb Hattingh
Hi m Speed is a contentious issue here. Point is, if you really need raw speed, why stop only at Perl and Python? There are plenty of statically compiled languages that will produce native binaries. The relative difference in speed between Perl and Python, whatever it is, is completely

Re: python code with indention

2005-02-08 Thread Caleb Hattingh
is it possible to write python code without any indentation? Xah You can, of course, write a silly little inline script without any control structures that will all line up at the left margain. So what? John Roth I agree, John, I don't get it. The vast majority of programmers (albiet from my

Re: Loop in list.

2005-02-08 Thread Caleb Hattingh
Jim Someone on this list (SteveB) helped me quite a bit with a list comprehension on a recent thread. Roy said it can be hard to read, and I agree in part because I always thought they were hard to read, when in actual fact I had just never bothered to learn properly. Here is a

Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Caleb Hattingh
Jean, Paddy I use pym to extract bits of pascal out of delphi code for documentation purposes. You have to add some stuff to the delphi code (in your case, C header), but these are added within comment blocks, and the interesting thing is that you add python code(!) as a kind of dynamic

Re: Basic file operation questions

2005-02-08 Thread Caleb Hattingh
Marc I don't know how it is handled, but I expect also that there is an implied close(). thanks Caleb When you read a file with that method, is there an implied close() call on the file? I assume there is, but how is that handled? -- http://mail.python.org/mailman/listinfo/python-list

Re: variable declaration

2005-02-08 Thread Caleb Hattingh
Alexander PowerOfGenerator=TakeFromSensor() if PowerOfGeneratorxxx: RecalcPower(PowerOfGenerator) PutToTheDatabase(PowerOfGenerator) Here, python will not help you. The worst thing is that in such calculations you often receive plausible results. (I think PyChecker has

Re: Loop in list.

2005-02-08 Thread Caleb Hattingh
Stephen You're gonna have to help me here.what is the effective difference? Thanks Caleb ' a = [] ' for b in range(4): ' for i in range(3): ' a.append(i*2*b) There is a subtle error in this explanation. The equivilence actually looks like: ' a = [] ' l1 = range(4) ' l2 = range(3) '

Re: variable declaration

2005-02-08 Thread Caleb Hattingh
Jeff I fully agree. As I stated in a message to alexander, it is quick and easy even to write a simple project-specific tool for checking that only allowed variable names exist in all the project files. Compared to having to work with tons of effectively useless variable declarations

Re: Loop in list.

2005-02-08 Thread Caleb Hattingh
Hi Fredrik *sigh* I think I will stop writing mini-tutorials :) You are, of course, correct. And I really like your method of explaining how to mentally juggle the LC into explicit loops. I shudder to think how mnay people I confused with my incorrect examples - I really should have tested

Re: loops - list/generator comprehensions

2005-02-07 Thread Caleb Hattingh
Wow, Steve, thanks, you went to some effort here. I prefer to give names to the values produced by os.walk -- I think it makes the usage much clearer. However, since I don't use 'dirnames', I use '_' to indicate this: Actually, I feel silly for not recognising this - I read about the Python3

Re: Basic file operation questions

2005-02-07 Thread Caleb Hattingh
Peter, that was very clear, thanks. So not only is for line in file(...): # do stuff the most elegant, it is also the fastest. file.readlines() comes close, but is only viable for small files. -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie wants to compile python list of filenames in selected directories

2005-02-06 Thread Caleb Hattingh
Hi Anthony Here is some stuff to get you started (this is from memory, I'm not checking it, but should be mostly helpful): *** import os os.chdir('C:\My Documents') # Can use this to jump around to different folders fileNames = os.listdir('.') # Checks the now current folder namesToMatch =

Re: loops - list/generator comprehensions

2005-02-06 Thread Caleb Hattingh
I would be interested to see an example of code that is more concise but yet as *clear* as the one you already have. I can actually read and understand what you've got there. That's cool :) On 6 Feb 2005 11:28:37 -0800, [EMAIL PROTECTED] wrote: I wrote this little piece of code to get a

Re: Multiple constructors

2005-02-06 Thread Caleb Hattingh
Hi Philip C++ to Python is a steep 'unlearning' curve... That's worthy of QOTW. I decided not to reply to this thread earlier, but you just convinced me otherwise :) I work in Delphi a lot, which is in a lot of respects very similar to C. I have come to the conclusion that function

Re: Python versus Perl ?

2005-02-06 Thread Caleb Hattingh
Hi Surfunbear I don't know about the stuff regarding jobs, resumes, etc, but I will tell you the same thing I tell everyone I meet regarding python: Set aside a morning, and work through the python tutorial that comes with the documentation. People like me are going to tell you this and

Re: loops - list/generator comprehensions

2005-02-06 Thread Caleb Hattingh
Sure Steve Lemme see ... (indentation changed so comments associate with correct bits) Out of curiosity, do you find: filenames = [os.path.join(dirpath, filename) # This is cool for dirpath, _, filenames in os.walk('.') # This is getting tricky,

Re: python and visual C++

2005-02-03 Thread Caleb Hattingh
Olivier But the problem is about modules thats are developped from others with distutils... Yes, sorry, I reread your original post and now realise that you were referring to other people's modules. And with your comments there, I agree with you - MSVC as a requirement is unfortunate. thx

Re: Two classes problem

2005-02-03 Thread Caleb Hattingh
Gurpreet You can manage the namespace more formally. Or to put it another way, global gives me the heebie-jeebies. I recently worked on a project replacing a legacy reactor model in FORTRAN, and between COMMON blocks, and GOTO statements, I didn't know up from down. How about this: ***

Re: Two classes problem

2005-02-02 Thread Caleb Hattingh
Hi It would help if you could describe the purpose you have in mind for doing this. There is a cute way of doing what you want: ===file: a.py=== # module a.py test = 'first' class aclass: def __init__(self, mod, value): mod.test = value# Is there another way to

Re: python and visual C++

2005-02-02 Thread Caleb Hattingh
Olivier If you consider using the ctypes module, you can write a dll (windows) or a shared object (linux) using anything that can make one of those. For example, I have successfully used FreePascal to make a dynamic library on both windows and linux and use that library within python on both

Re: Two classes problem

2005-02-02 Thread Caleb Hattingh
Steven, thanks for your help once again :) so you could write the code like: test = 'first' class aclass: def __init__(self, value): mod = __import__(__name__) mod.test = value This is sweet. I really like this technique for manipulating module-scope identifiers (from

Re: Basic file operation questions

2005-02-02 Thread Caleb Hattingh
Hi Alex Assuming you have a file called data.txt: *** f = open('data.txt','r') lines = f.readlines() f.close() for line in lines: print line *** Will print each line of the file. You can make a huge investment by setting 2 or 3 hours aside to go through the Python tutorial, which gets

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread caleb . hattingh
a clear idea of how to play nice with locals(). thx Caleb Peter Otten wrote: Caleb Hattingh wrote: I am convinced now that locals() doesn't work as (I) expected. Steven says there was some or other reason why locals() as used in this context is not writable - Do you know why this is? I

Re: dictionary initialization

2004-12-09 Thread caleb . hattingh
Hi Dan I must confess that upon rereading my words, there is some irony there (but not really sarcasm, is there?). However, I *really* tried to keep my tone, well, professional. I realise I didn't do a good job and apologise. I hope that's ok. Keep well Caleb --

Re: Pictograms and Python

2004-12-09 Thread caleb . hattingh
Diez Ya got me there! I have a sript that downloads a webpage. According to the picture on this webpage I need to pass a parameter to this , running script a few lines later. Err, ya, I guess I would be suspicious too.Sorry about that! Keep well Caleb --

Re: Ideas for projects

2004-12-09 Thread Caleb Hattingh
Here is something I would try but don't have the guts for: If you could write an extension to idle (yes, idle, not Boa, not Eric, etc) that pops up a small list of possible completions in a listbox when you type a '.' (period) after any object name or module name (including builtins), that

Re: sys.stdin.read question

2004-12-08 Thread Caleb Hattingh
and with popen it comes with an error. I haven't been able to read the stdin either so the problem so far is unsolved for my point. But the newline command would explain my problems with the program. Can it be a problem under windows since I'm using XP and the winpython Hopefully Lars Caleb Hattingh [EMAIL

Re: How do I do this? (eval() on the left hand side)

2004-12-08 Thread Caleb Hattingh
Peter, I second that. Nick In what way is it unreliable? I can't seem to create a situation where the update through globals and locals doesn't work. Are you referring perhaps to the possibility of variables being garbage collected and then not being around later when one tries to access

Re: updating locals() and globals() (WAS: How do I do this? (eval() on the left hand side))

2004-12-08 Thread Caleb Hattingh
Steve, I don't think I understand. Here is what I just tried: ' def f(): x = 3 d = locals() print x print d['x'] d['x'] = 5 print x ' f() 3 3 3 ' In your example, x had not yet been initialised, maybe. What I am seeing is that x does not

Re: How do I do this? (eval() on the left hand side)

2004-12-08 Thread Caleb Hattingh
only in scope (which is what I expected originally anyway). But we can't have everything, I guess :) Caleb On Wed, 08 Dec 2004 20:49:53 +0100, Peter Otten [EMAIL PROTECTED] wrote: Caleb Hattingh wrote: In what way is it unreliable?Ican'tseemtocreateasituationwhere the update through globals

Re: How do I do this? (eval() on the left hand side)

2004-12-07 Thread Caleb Hattingh
Sure, ok, I think I am with you now. You get a (e.g.) variable name as a string, and you KNOW how to evaluate it with eval, but you also want to be able to assign back to (through) the string representation? One way (if I understand you correctly) is with the globals or locals dicts. Try

Re: PIL 1.1.4 paste PNG's with transparency problem

2004-11-30 Thread Caleb Hattingh
Wow, that was pretty clueless of me...right there on the *next* page of the manual (I thought im.paste(image, box) and im.paste(image, color) were the general forms for paste, apparently didn't look further) thx Caleb On 29 Nov 2004 22:17:36 -0800, Tom Hanks [EMAIL PROTECTED] wrote: Caleb

Re: asynchat and threading

2004-11-29 Thread Caleb Hattingh
I heartily support something like this, but alas I have not the time to help out with it. I like the Enthought python distribution because it installs several packages in one shot. A pity there isn't a similar thing for python addons in Linux (or is there?). Something apt-get-like would

<    1   2