Re: Lambda alternative?

2009-04-15 Thread Caleb Hattingh
On Wed, 15 Apr 2009 15:47:05 +0200, wrote: But, lambda functions can't be pickled. I would like to pickle my objects, and i would really like to use parallel python (which requires pickling). If you are fixated on using lambda, you could probably use Recipe 7.6: Pickling Code Objects in the

Re: No speedup on multi-processor machine?

2007-04-21 Thread Caleb Hattingh
On Apr 21, 11:02 pm, [EMAIL PROTECTED] wrote: > Hi, > I am using Python Thread library for my parallel processing course > project. I am doing matrix convolution on a multi-processor machine > running Solaris. I just found out that no speed-up is obtained with > threading. It is probably because of

Re: I need suggests

2007-01-23 Thread Caleb Hattingh
Pat wrote: > I have to do a big programm. Could someone give me some suggests about > IDE (on Linux) and books to learn. http://groups.google.com/groups/search?q=python+ide&qt_s=Search Lots and lots to read :) Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: rsync for python?

2006-12-22 Thread Caleb Hattingh
> I want to build rsync server that can run in linux and windows, and > configure by python. So I'm looking for something like rsync for python. > I find rsync.py and pysync. But rsync.py looks like a client mode, > it can't be a rsync server, is it? Can pysync be a rsync server? Hi nienfe

Re: Is there a way to push data into Microsoft Excel & Word from Python ?

2006-12-21 Thread Caleb Hattingh
Hi Paul > Thanks for the kind words! No, thank _you_ for taking the time to write such a useful document. regards Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary, iterate & update objects

2006-12-16 Thread Caleb Hattingh
jansenh wrote: > hi comp.lang.python. > > I need some newbe advice on idiomatic use of Python dictionaries. > > I have service with a dictionary which holds a bunch of objects as > values, and an ID as key to each object. Then I want to change an > objects state based on its key. The way I am doin

Re: Is there a way to push data into Microsoft Excel & Word from Python ?

2006-12-16 Thread Caleb Hattingh
The Night Blogger wrote: > Is there a way to push data to Microsoft Excel & Word from a Python > Application On Windows, it's easy after you install the win32 extensions. For example, for python: import win32com.client xl = win32com.client.Dispatch('Excel.Application') after which you can oper

Re: concatenating strings

2006-12-15 Thread Caleb Hattingh
Hi Erich If you're going to be doing a lot of string substitution, you should look at the Templating support in the library: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304005 and (a little bit fancier): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/335308 Regards Caleb

Re: Writing and reading variables to/from flat file

2006-12-15 Thread Caleb Hattingh
Hi Kevin The other posters helped you with configParser, which is what you wanted, i.e. text file access. However, you can also get persistance really cheaply with pickling, if you don't need the saved data to be text-editable: (from memory) verboseSettings = {} verboseSettings['Detailed'] = '-

Re: automatically grading small programming assignments

2006-12-15 Thread Caleb Hattingh
Hi Brian You could make great use of XML-RPC here. XML-RPC is /really/ easy to use. Here is a simple example: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81549 You put procedures on the server that will check the args against a the required result, and report back to the student w

And now for something completely different...

2006-12-12 Thread Caleb Hattingh
I spent way too much time reading the recent massive ">500-messages" thread, and then spent even more time (perhaps better spent) reading wider on some aspects of the debate. This recently-found link sets out (from one possibly-biased POV, I guess) how the rift between GNU Emacs and XEmacs occurre

Re: looking for a simple way to load a program from another python program..

2006-08-13 Thread Caleb Hattingh
Hi Eric Check that ".py" and ".pyw" are in your PATHEXT environment variable (are you using Windows?). Then, if the folder that cabel is in is in your PATH environment variable, and the correct association for .py files is set up (i.e. they get run by python.exe), either os.system('cabel') or o

Re: ConfigParser and multiple option names

2006-05-03 Thread Caleb Hattingh
I have had this same problem before, and what I ended up doing was writing my own far more limited config parser that would create lists for repeated named assignments. Who is the maintainer of ConfigParser? Perhaps a keyword option can be added so that this kind of behaviour can be added at cre

Re: Can one query full name (or version) of selected packages at pypi?

2006-04-25 Thread Caleb Hattingh
Hi Martin Pretty much exactly what I wanted :) How up-to-date does Debian keep its package list for python addons, or are you running Unstable? My big problem, being in South Africa, is that I have to get any distros on cover CDs or order from distro-resellers, and they never have Testing or Un

Can one query full name (or version) of selected packages at pypi?

2006-04-20 Thread Caleb Hattingh
Hi everyone I suspect this has come up before, but google and group searches for "python package index query" or "pypi query" and the like haven't turned anything up. I want to monitor the versions of the list of packages I like having around, and I expect that the python package index might be a

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Caleb Hattingh
WAIT- Did I just get caught by an April Fools Joke? I have a nasty feeling about this :)) C -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Caleb Hattingh
Steve I agree with you. If my vote means anything, I vote against it. >> The Board realises that this change will be >> contentious. There are many advantages >> to making it, however, which we feel will >> benefit the Python community at large >> and the PSF membership in particular. >> Users w

Re: Matplotlib: How to set number of ticks on an axis?

2006-03-30 Thread Caleb Hattingh
John, Thank you. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple py script to calc folder sizes

2006-03-30 Thread Caleb Hattingh
Ben, Thank you. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert Word .doc to Acrobat .pdf files

2006-03-30 Thread Caleb Hattingh
If you can find some API documentation for PDFMWord.dll, you can call its methods with the ctypes python module. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Matplotlib: How to set number of ticks on an axis?

2006-03-30 Thread Caleb Hattingh
Hi I tried several Google searches to no avail. I read through pretty much most of the online docs at the matplotlib sourceforge site, but didn't find what I was looking for. I went through the axis.py and ticker.py code today, trying to find out how to set the number of points (ticks) on an axi

Re: python challenge question (string manipulation)

2006-03-30 Thread Caleb Hattingh
Felipe I get the same results as you. You make a good point about not iterating when it's not needed. I played around with your test code and found some interesting things: 1. enumerate vs. range(len()) has very little overhead (something I have wondered about) In my code, making the change c

Re: Simple py script to calc folder sizes

2006-03-29 Thread Caleb Hattingh
Hi John Your code works on some folders but not others. For example, it works on my /usr/lib/python2.4 (the example you gave), but on other folders it terminates early with StopIteration exception on the os.walk().next() step. I haven't really looked at this closely enough yet, but it looks as

Re: python challenge question (string manipulation)

2006-03-29 Thread Caleb Hattingh
Terry That is very succint. Rewriting my shift function given earlier: >>> import string >>> alpha = string.ascii_lowercase >>> print alpha abcdefghijklmnopqrstuvwxyz >>> def shift(lst, n): return [lst[(i+len(lst)-n)%len(lst)] for i,item in enumerate(lst)] >>> print shift(alpha,2) ['y',

Re: python challenge question (string manipulation)

2006-03-29 Thread Caleb Hattingh
John In python, strings are immutable - you have to create a new string no matter what you do. Also, I suspect you meant to say: >>> alphabet = string.ascii_lowercase >>> code = alphabet[2:] + alphabet[:2] I had a similar need recently for a guitar chord generator program I've been working on.

Re: Free Python IDE ?

2006-03-29 Thread Caleb Hattingh
Hi Ernesto SPE, or Stani's python editor is actually a decent IDE that can lauch the winpdb debugger to step through code, with side windows for locals, and watches and so on. It's not exactly integrated debugging a la Delphi, but in general my need for debugging is much less with python; the fe

Re: operation complexities of lists and dictionaries

2006-03-29 Thread Caleb Hattingh
Hi Use the "timeit" module, like so: >>> from timeit import Timer >>> t = Timer('[i for i in range(1)]') # The string is code to execute >>> (for timing) >>> print t.timeit(100) # execute it 100 times and print the result 0.222389936447 I would appreciate it if you could present your resul

Re: Multiplying sequences with floats

2006-03-29 Thread Caleb Hattingh
Hi Dennis Sure, I get it. I do most of my work in Delphi, which is, shall we say, not lax about floating-point types. Thinking about this more, I realise my initial interest was in looking at the // operator as something new, whereas I now see it probably just wraps math.floor(); obviously then

Re: Multiplying sequences with floats

2006-03-28 Thread Caleb Hattingh
Christoph I understand the explanation regarding the underlying math.floor() call. Were I using this functionality in my code, int(a//b)* some_list would not be something I consider a big deal. However, I see what you're saying: The multiplcation by list can only work with an int, and you hav

Re: Multiplying sequences with floats

2006-03-28 Thread Caleb Hattingh
Hi Fredrik Fair enough; I wasn't precise. Upon further reflection, I actually meant floor division, via the // operator. In the following snippet: >>> 4/2 2 >>> 4//2 2 >>> 4.0/2.0 2.0 >>> 4.0//2 2.0 >>> 4.0//2.0 2.0 We know the last two operations can only return what are effectively integer n

Re: Simple py script to calc folder sizes

2006-03-28 Thread Caleb Hattingh
Thanks John I will use your code :) 30% improvement is not insignificant, and that's what I was looking for. I find the log function a little harder to read, but I guess that is a limitation of me, not your code. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying sequences with floats

2006-03-24 Thread Caleb Hattingh
Hi Christoph On my linux py-2.4.1: >>> 4.0//2 # Integer division, but still returns a float. 2.0 >>> 4.0//2 == 2 True >>> 4.0//2 doesn't return an integer, but the equality against an integer still holds. I agree that integer division should return an integer, because using the operator at all

Re: New development windows, IronPython or PythonWin

2006-03-24 Thread Caleb Hattingh
Hi Dan Pythonwin just adds support for specifically MS Windows features, most prominently COM; writing Excel scripts in python is so cool. The standard python distribution for windows runs perfectly on windows. I'm not sure whether this was clear to you or not. Also, Thomas ctypes and comtypes

Simple py script to calc folder sizes

2006-03-21 Thread Caleb Hattingh
Hi everyone [Short version: I put a some code below: what changes can make it run faster?] Unless you have a nice tool handy, calculating many folder sizes for clearing disk space can be a click-fest nightmare. Looking around, I found Baobab (gui tool); the "du" linux/unix command-line tool; th

Re: Python vs. Java gzip performance

2006-03-21 Thread Caleb Hattingh
Hi Peter Clearly I misunderstood what Martin was saying :)I was comparing operations on lines via the file generator against first loading the file's lines into memory, and then performing the concatenation. What does ".readlines()" do differently that makes it so much slower than ".read().sp

Re: Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Caleb Hattingh
Hi The documentation for the python profiler in the python library reference is extremely readable (well done James Roskin!?). Profile your code, and when you find where the speed problem occurs, try pitching just that section of code in comp.lang.python. You will likely get much feedback. Ever

Re: Python vs. Java gzip performance

2006-03-17 Thread Caleb Hattingh
I tried this: from timeit import * #Try readlines print Timer('import gzip;lines=gzip.GzipFile("gztest.txt.gz").readlines();[i+"1" for i in lines]').timeit(200) # This is one line # Try file object - uses buffering? print Timer('import gzip;[i+"1" for i in gzip.GzipFile("gztest.txt.gz")]').time

Re: Binary python extensions with Free Pascal Compiler

2006-03-16 Thread Caleb Hattingh
Well, there it is: * Added support for Free Pascal Compiler (http://www.freepascal.org/) and Lazarus Project (http://www.lazarus.freepascal.org/) Thanks to Michiel du Toit ([EMAIL PROTECTED]) That was easy. I just saw the new support for D2k6 recently. thx Ravi Caleb -- http://mail.python.or

Re: Counting nested loop iterations

2006-03-16 Thread Caleb Hattingh
Hi Derek I went for an embarrassingly long time without knowing about "enumerate()". It doesn't directly answer your question about counting *within* nests, but I am going to tell you this on the off chance you don't know yet (and apologies if you do): This: count = 0 for animal in zoo: a =

Binary python extensions with Free Pascal Compiler

2006-03-16 Thread Caleb Hattingh
Hi all I want to write python extensions with FPC (Free Pascal Compiler, http://www.freepascal.org). In Delphi, this is trivially easy due to the great work of the P4D (Python-for-Delphi, http://mmm-experts.com/) guys; however, when aiming for cross-platform binary extensions, that strategy nat

Re: Python IDE: great headache....

2006-03-13 Thread Caleb Hattingh
Hi Being a Delphi user at work, I know what you mean :) The best python IDE I have found is Stani's Python Editor (SPE), and I think Stani himself replied to your message as well. It integrates wxGlade, which is nice for form-building, although I don't really do much of that with the python co

Re: Is this possible in Python?

2006-03-13 Thread Caleb Hattingh
Hi I don't think this is what you want (a string representation of the argument passed to a function as that argument is at runtime is way beyond my abilities), but this can retrieve the literal text in the function call as it appears in the .py file, assuming you have the .py file available a

mathschallenge.net WAS Brute force sudoku cracker

2005-09-19 Thread Caleb Hattingh
Very interesting that sudoku solving appears on the python group - there is a programming competition at mathschallenge.net (euler) where one of the puzzles is developing a sudoku solving algorithm... Actually the python entrants are giving the C guys a good run! On Mon, 19 Sep 2005 09:12:54

Re: p2exe using wine/cxoffice

2005-09-19 Thread Caleb Hattingh
The other thing (and this is always true) is that "better" needs definition. On purely technical grounds, on average, MSOffice is better than OO. However, holistically, OO is probably better (no lock-in, open standards, multiplatform and so on). Those soft issues do matter. On Mon, 19 Sep

Re: very high-level IO functions?

2005-09-19 Thread Caleb Hattingh
York Short answer: yes We use python and R at work, and in general you will find python syntax a little cleaner for functionality they have in common. R is better for some of the more hard-wired stats stuff, though. On Mon, 19 Sep 2005 20:04:37 +0200, York <[EMAIL PROTECTED]> wrote: > Hi,

Re: Python IDE's

2005-08-01 Thread Caleb Hattingh
You know, for several years I was one of those people who simply ignored posts like this about Vi/Vim because I happened to come across it once on a sparc machine and thought it was ridiculous that I couldn't figure out how to type a simple note. I thought that Vi (Vim) was some kind of w

Re: Is this Pythonic?

2005-08-01 Thread Caleb Hattingh
Peter To my mind, this kind of setup (interface class, or abstact class) is more usually used in static languages to benefit polymorphism - but python is dynamically typed, so in which situations would this setup be useful in a python program? You see, I expected your post to say that it wo

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

Re: GUI - Windows: Where to get started

2005-07-26 Thread Caleb Hattingh
Probably, the best place for learning how to build GUI's for Windows, in general, is to get hold the personal edition of Delphi from the Borland website. If you want something more specific to Python, it is likely to be much tougher. You would, for example, have to decide which widget too

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 new

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 enumer

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 +0200,

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

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 ex

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 Fri,

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 ev

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 DL

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: 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 standalon

Re: Python versus Perl ?

2005-02-09 Thread Caleb Hattingh
uld give it some more thought 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 w

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 the

Re: Python versus Perl ?

2005-02-08 Thread Caleb Hattingh
Hi Adam Thanks for your comments. > I think the expression you seek is "comparing virtue among whores." Sure, that's what I was saying, but not quite in as colourfil a manner :) > > > > The problem domains in which I do most of my work (chemical process > > modelling and simulation) really do

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 foreve

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) '> l

Re: variable declaration

2005-02-08 Thread Caleb Hattingh
Alexander PowerOfGenerator=TakeFromSensor() if PowerOfGenerator>xxx: 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 co

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: 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 ma

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 mini-tutor

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 l

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 was

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? than

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: Multiple constructors

2005-02-07 Thread Caleb Hattingh
Sure, Nick, I agree with you completely. I generally try to make sure that my classes are limited in what they do/provide, so it is not often a problem that a class may need to be instantiated in several very different ways. But your point is well taken. Thanks Caleb -- http://mail.python.org/

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: 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, whats

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 that,

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 overloadi

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 l

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: 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: *** cl

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 Ca

Re: Basic file operation questions

2005-02-03 Thread Caleb Hattingh
Peter Yes, you can even write f = open("data.txt") for line in f: # do stuff with line f.close() This has the additional benefit of not slurping in the entire file at once. Is there disk access on every iteration? I'm guessing yes? It shouldn't be an issue in the vast majority of cases,

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 insta

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 with

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
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 refe

Re: Calling a C program from a Python Script

2004-12-09 Thread Caleb Hattingh
Hi Brad Not that I'm an expert but note: 1. If you already know C, fair enough. You should know what you are getting into then. I sure as heck don't know it very well at all and I'm not gonna make that time investment now. MAYBE if I really really needed the extra speed (but this seems to

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

2004-12-09 Thread Caleb Hattingh
Jeff I do the same thing in Delphi -> prepend "Self" before all the members in class methods even though its not required. I do it partially for the same reason as you - so I can grok which variables are local and which are global (well, global within the class, anyway). The other reason is

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 wo

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 -- http://mail.python.org/mai

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 -- http://mail.python.org/mailma

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

2004-12-09 Thread caleb . hattingh
ave 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

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

2004-12-08 Thread Caleb Hattingh
lso be nice if globals and locals behaved the same, differing 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 u

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

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 t

Re: sys.stdin.read question

2004-12-08 Thread Caleb Hattingh
he IDLE 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 Lar

Re: sys.stdin.read question

2004-12-07 Thread Caleb Hattingh
that I am only taking 5 characters, but where does the newline (\n) come from? Is that a remnant from when I terminated the previous 'g' input? Thanks Caleb On Tue, 07 Dec 2004 23:36:56 -0500, Caleb Hattingh <[EMAIL PROTECTED]> wrote: Hi You are probably typing this within

Re: sys.stdin.read question

2004-12-07 Thread Caleb Hattingh
Hi You are probably typing this within IDLE. Try it after starting python in a shell like DOS or Bash. Should work then (works for me, and I also get the AttributeError in IDLE. Thanks Caleb On Tue, 07 Dec 2004 21:15:51 GMT, It's me <[EMAIL PROTECTED]> wrote: Why do I get an "AttributeError:

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

  1   2   >