Re: Loop until condition is true

2005-06-23 Thread Roy Smith
Michael Hoffman <[EMAIL PROTECTED]> wrote: > I count at least 4 different modules in the Python 2.4 standard > library that assign to True or False, mainly as a compatibility > measure for the days before they were built-ins. Hopefully, none of them as creative as http://thedailywtf.com/forums/36

Re: Favorite non-python language trick?

2005-06-24 Thread Roy Smith
Tom Anderson <[EMAIL PROTECTED]> wrote: > The one thing i really do miss is method overloading by parameter > type. I used this all the time in java You do things like that in type-bondage languages like Java and C++ because you have to. Can you give an example of where you miss it in Python?

Re: Office COM automatisation - calling python from VBA

2005-06-24 Thread Chris Smith
> "guy" == guy lateur <[EMAIL PROTECTED]> writes: guy> Hi all, I am trying to write some code (macro's, if you like) guy> to glue together our Office applications (mainly Word, Excel guy> and Outlook). We have a lot of different projects going on guy> simultaneously. The idea i

Re: a dictionary from a list

2005-06-25 Thread Roy Smith
Terry Hancock <[EMAIL PROTECTED]> wrote: > Before the dict constructor, you needed to do this: > > d={} > for key in alist: > d[key]=None I just re-read the documentation on the dict() constructor. Why does it support keyword arguments? dict(foo="bar", baz="blah") ==> {"foo":"bar", "baz

Re: Favorite non-python language trick?

2005-06-25 Thread Roy Smith
Steve <[EMAIL PROTECTED]> wrote: > One thing that I miss every once in a while is "pre-processing". There are so many things wrong with preprocessing, at least if you're thinking of the way C/C++ implements it (cpp). Cpp a number of things. 1) It does file inclusion. Pythons "import" serves th

Re: Favorite non-python language trick?

2005-06-26 Thread Roy Smith
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Using := and = for assignment and equality is precisely as stupid as using > = and == for assignment and equality. On the other hand, == is easier to type than := (two taps on the same key vs two different keys, and at least on a US/English keyboard, n

Re: Which kid's beginners programming - Python or Forth?

2005-06-27 Thread Roy Smith
"BORT" <[EMAIL PROTECTED]> wrote: > So, that said... In ~simplest~ terms for the stated goal -- Forth or > Python? > ...the goal is NOT the spelling tutor... it is learning how to use a > tool to solve a problem. I am asking which tool is more suited to an > otherwise arbitrary direction of "spe

Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Roy Smith
Ivan Van Laningham <[EMAIL PROTECTED]> wrote: > In which case, you should start with PostScript;-) I learned it by > plugging a glass tty into the serial port on one of the very first > AppleWriters and typing away. Same here. I had the RedBook and remember reading it and not quite believing it

Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Roy Smith
"Adriaan Renting" <[EMAIL PROTECTED]> wrote: > In addition, for and while loops are pretty universally found in all > program languages. It is therefore an essential part of material > supposed to teach programming. And, even if they're not called "for" or "while" (they might be "do", "foreach",

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-29 Thread Roy Smith
Andrew Durdin <[EMAIL PROTECTED]> wrote: > Corrected version: > > result = [(lambda: expr0), lambda: expr1][bool(cond)]() I'd go one step further. Most people expect the first item to correspond to True and the second one to correspond to False. So: result = [(lambda: expr0), lambda: expr

Re: Programmers Contest: Fit pictures on a page

2005-06-29 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Don <[EMAIL PROTECTED]> wrote: > Chung Leong wrote: > > > Isn't that an NP-complete problem or am I crazy? > > It is NP complete. Its known as the "cutting stock problem" (aka "Knapsack > problem"). Here's a Wikipedia page that describes it: > > http://en.wikipe

Re: Add methods to string objects.

2005-06-30 Thread Roy Smith
[EMAIL PROTECTED] (Negroup) wrote: > I was just asking if it is possible to "extend" string objects' > behaviour so that it becomes possible to invoke something like > 'anystring'.my_method(). You can't quite do that, but you can get close. You can define your own class which inherits from str,

Re: Which kid's beginners programming - Python or Forth?

2005-06-30 Thread Roy Smith
Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > In FORTH you don't generally use variables unless you really have to - > that is what the stack is for Exactly. Every language has its natural way of doing things. You can usually bludgeon a language into doing things some other way, and newcomers t

Re: Add methods to string objects.

2005-06-30 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > You can even get closer, but it is NOT recommended > > class foostr(str): > def plural (self): > if self.value[-1] in "sz": > return self.value + "es" > else: > return se

Re: Which kid's beginners programming - Python or Forth?

2005-06-30 Thread Roy Smith
There's a reprint this morning on slashdot of a 1984 review Byte did on the brand-new Macintosh (executive summary: cool machine, needs more memory). The first four software packages available for the new machine? MacWrite/MacPaint (they seem to count this as one package) Microsoft Multiplan Micr

Re: Python for everything?

2005-06-30 Thread Roy Smith
<[EMAIL PROTECTED]> wrote: > I have read in the old days that C was used for everything. It was a > systems programming language, and also did a lot of the same stuff > Bash scripts and perl do now. I learned C in "the old days" (1977 or maybe 78). We had plenty of other tools for scripting. Bef

Re: Python for everything?

2005-06-30 Thread Roy Smith
Ivan Van Laningham <[EMAIL PROTECTED]> wrote: > It really was used "for everything"; C compilers have *always* let you > include assembler, with the "asm" keyword. Unless you're talking about > the early days of DOS/Windows compilers, about which I know little, but > all *K&R* compilers had asm.

Re: map vs. list-comprehension

2005-06-30 Thread Roy Smith
Terry Hancock <[EMAIL PROTECTED]> wrote: > One of the strengths of Python has been that the language itself is > small (which it shares with C and (if I understand correctly, not being > a lisp programmer?) Lisp), but with all the syntax enhancements going > on, Python is getting pretty complica

Re: map vs. list-comprehension

2005-06-30 Thread Roy Smith
Terry Hancock <[EMAIL PROTECTED]> wrote: > One of the strengths of Python has been that the language itself is > small (which it shares with C and (if I understand correctly, not being > a lisp programmer?) Lisp), but with all the syntax enhancements going > on, Python is getting pretty complica

Re: map vs. list-comprehension

2005-06-30 Thread Roy Smith
Robert Kern <[EMAIL PROTECTED]> wrote: > Looks like the PSU got to yoNO CARRIER No, the trackpad on my PowerBook seems to have gone a little haywire and I'm getting the occasional random mouse click. In that case, it seemed to have clicked the "Post" button. -- http://mail.python.org/mailman/

Re: Assigning to None

2005-07-01 Thread Roy Smith
>Peter Hansen <[EMAIL PROTECTED]> writes: > >> Mike Meyer wrote: >>> Yes. I once grabbed an old program that did assignments to None. But >>> that's always been a bad idea. >> What was the use case!? > >Unpacking a tuple. Something like this: > > (foo, bar, None) = gen_tuple(stuff) I can

Re: Re:

2005-07-01 Thread Roy Smith
Skip Montanaro <[EMAIL PROTECTED]> wrote: >Adriaan> - strong type checking > >Python has strong type checking, it's just dynamic. Writing proper test >cases (which you should be doing anyway) will catch most issues. Not to mention that it's almost farcical for a language which supports reint

Re: map vs. list-comprehension

2005-07-01 Thread Roy Smith
Scott David Daniels <[EMAIL PROTECTED]> wrote: >Roy Smith wrote: >> Look at what happened to C when it mutated into C++. In isolation, most of >> the features of C++ seem like good ideas. Taken together, it's a huge >> hairy mess that most people only understan

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-01 Thread Chris Smith
> "Devan" == Devan L <[EMAIL PROTECTED]> writes: Devan> None of them are really indispensible. Map and filter cab Devan> be replaced with list comprehensions. reduce is redundant Devan> except when multiplying a series; there's a sum function Devan> for a reason. Lambda looks c

Re: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Roy Smith
"Ralf W. Grosse-Kunstleve" <[EMAIL PROTECTED]> wrote: > class grouping: > > def __init__(self, .keep_this, .and_this, but_not_this, > .but_this_again): > # real code right here I'm really torn about this. On the one hand, my first thought was "you shouldn't be writing constru

Re: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Roy Smith
"Andrew Koenig" <[EMAIL PROTECTED]> wrote: > In Python, unlike many other languages, the names of formal parameters are > part of a function's interface. For example: > > def f(x, y): > return x-y > > Now f(3, 4) is -1 and f(y=3,x=4) is 1. > > The names of instance variables are gen

Re: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Walter Brunswick" <[EMAIL PROTECTED]> wrote: > Why not just update the local dictionary? > > class Grouping: > def __init__(self,x,y,z): > self.__dict__.update(locals()) That's pretty clever. The only minor annoyance is that it creates a self.self

Re: Determining actual elapsed (wall-clock) time

2005-07-02 Thread Roy Smith
Peter Hansen <[EMAIL PROTECTED]> wrote: > I would like to determine the "actual" elapsed time of an operation > which could take place during a time change, in a platform-independent > manner (at least across Linux/Windows machines). > > Using time.time() doesn't appear to be suitable, since tim

Re: Determining actual elapsed (wall-clock) time

2005-07-02 Thread Roy Smith
Peter Hansen <[EMAIL PROTECTED]> wrote: > I guess as long as the NTP client is set up to ensure the time > adjustments are smaller than some value X, it would be acceptable. NTP is generally capable of keeping the various system clocks on a LAN within a few ms of each other, and within a few 10'

Re: Python for everything?

2005-07-02 Thread Roy Smith
Christos "TZOTZIOY" Georgiou <[EMAIL PROTECTED]> wrote: > Were there other Unix C compilers before K&R wrote one? Considering that K&R (along with T) invented both Unix and C, I would say that the answer to the above has to be "No". -- http://mail.python.org/mailman/listinfo/python-list

Re: need to get an index for an item in a list

2005-07-03 Thread Roy Smith
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > hey there, > i need to be able to get the index for an item in a list. > the list is a list of lines read from a text file. > > like this: > > file = open("/home/somefile.text", "r") > lines = file.readlines() > file.close() > > now, i

Re: need to get an index for an item in a list

2005-07-03 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > i need to be able to get the index for an item in a list. > > > any ideas? > > Fire up the interactive interpreter and learn to use it to help > yourself. In this case, the most useful thing

Re: looping over a big file

2005-07-03 Thread Roy Smith
"martian" <[EMAIL PROTECTED]> wrote: > 1) how does python handle: > > > for line in big_file: > > is big_file all read into memory or one line is read at a time or a buffer > is used or ...? The "right" way to do this is: for line in file ("filename"): whatever The file object returned by f

Re: looping over a big file

2005-07-03 Thread Roy Smith
Jp Calderone <[EMAIL PROTECTED]> wrote: > Yes, but you need to do it like this: > > fileIter = iter(big_file) > for line in fileIter: > line_after = fileIter.next() That's better than the solution I posted. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you program in Python?

2005-07-04 Thread Roy Smith
bruno modulix <[EMAIL PROTECTED]> wrote: > Try Emacs + python-mode. Emacs surely has a lot of warts, but I'm still > looking for a better and more versatile code editor/IDE - specially when > it comes to languages with REPL (-> Read-Eval-Print Loop). When you build Python, make sure you build it

Re: Determining actual elapsed (wall-clock) time

2005-07-04 Thread Roy Smith
Peter Hansen <[EMAIL PROTECTED]> wrote: > As it turns out, Windows XP already has support (via NTP > I presume, though of course since this is Microsoft they try to keep the > user base ignorant by making no mention of that even in the help page) > for keeping the clock accurate, right on the la

Re: Existance of of variable

2005-07-04 Thread Roy Smith
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Should we *really* be encouraging newbies to mess with globals() and > locals()? Isn't that giving them the tools to shoot their foot off before > teaching them how to put shoes on? Why risk damaging perfectly good footwear? But, seriously, I agree wit

Re: How do you program in Python?

2005-07-04 Thread Chris Smith
>> My question isn't as all-encompassing as the subject would >> suggest... >> >> I am almost a Python newbie, but I have discovered that I don't >> get along with IDLE, as i can't work out how to run and rerun a >> routine without undue messing about. >> >> What I

Re: f*cking re module

2005-07-07 Thread Chris Smith
> "Michael" == Michael Hoffman <[EMAIL PROTECTED]> writes: Michael> Greg Lindstrom wrote: >> I hear that Perl 6 is going to have a rewrite of regular >> expressions; it will be interesting to see what their hard work >> produces. Michael> From what I saw a while ago, it d

Re: Use cases for del

2005-07-08 Thread Roy Smith
Daniel Dittmar <[EMAIL PROTECTED]> wrote: > In a SQL database, NULL = NULL will always return NULL, which is prety > much the same as FALSE. Except for NOT, AS NOT NULL is NULL. SQL's NULL is very much akin to the IEEE NaN (not quite, but close). -- http://mail.python.org/mailman/listinfo/pytho

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-09 Thread Roy Smith
Steve Juranich <[EMAIL PROTECTED]> wrote: > Without fail, when I start talking with some of the "old-timers" > (people who have written code in ADA or Fortran), I hear the same > arguments that using "if" is "better" than using "try". Well, you've now got a failure. I used to write Fortran on pun

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-10 Thread Roy Smith
Thomas Lotze <[EMAIL PROTECTED]> wrote: > Basically, I agree with the "make it run, make it right, make it fast" > attitude. However, FWIW, I sometimes can't resist optimizing routines that > probably don't strictly need it. Not only does the resulting code run > faster, but it is usually also shor

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-10 Thread Roy Smith
[EMAIL PROTECTED] (Aahz) wrote: > Using ``in`` saves a bytecode of method lookup on ``has_key()`` (which is > the correct spelling). You are right. My example is somewhat out of date w/r/t newer language features, and writing hasKey() instead of has_key() was just plain a mistake. Thanks for t

Creating anonymous functions using eval

2005-07-12 Thread Julian Smith
I've been playing with a function that creates an anonymous function by compiling a string parameter, and it seems to work pretty well: def fn( text): exec 'def foo' + text.strip() return foo This can be used like: def foo( x): print x( 2, 5) foo( fn( '''

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Roy Smith
Christopher Subich <[EMAIL PROTECTED]> wrote: >try: >f = file('file_here') >do_setup_code >do_stuff_with(f) >except IOError: # File doesn't exist >error_handle It's also a good idea to keep try blocks as small as possible, so you know exactly where the error happened. Imagine if

Re: all possible combinations

2005-07-13 Thread Duncan Smith
rbt wrote: > On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: > >>Say I have a list that has 3 letters in it: >> >>['a', 'b', 'c'] >> >>I want to print all the possible 4 digit combinations of those 3 >>letters: >> >>4^3 = 64 >> >> >>abaa >>aaba >>aaab >>acaa >>aaca >>aaac >>... >> >>What is the

Re: all possible combinations

2005-07-13 Thread Duncan Smith
rbt wrote: > On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: > >>On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: >> >>>Say I have a list that has 3 letters in it: >>> >>>['a', 'b', 'c'] >>> >>>I want to print all the possible 4 digit combinations of those 3 >>>letters: >>> >>>4^3 = 64 >>> >>> >>>a

Re: all possible combinations

2005-07-13 Thread Duncan Smith
Jack Diederich wrote: > On Wed, Jul 13, 2005 at 05:07:33PM +0100, Duncan Smith wrote: > >>rbt wrote: >> >>>On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: >>> >>> >>>>On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: >>>> >>&

Newbie question: Explain this behavior

2005-07-14 Thread David Smith
Why does code snippet one work correctly, but not two. The only difference is the placement of the "else". I know that indentation affects execution, but how does it change behavior in the following examples? Thank you. 1. for n in range(2, 10): for x in range(2, n): if n % x =

Re: Newbie question: Explain this behavior - a followup

2005-07-15 Thread David Smith
First, thanks to those who offered answers. They didn't really answer my question, only because I had not worked through the example sufficiently well. Doing this, I believe I understand what is happening, and, if my understanding is correct, have discovered that for other beginning and ending va

Re: OO design

2005-07-19 Thread Chris Smith
> "chris" == chris <[EMAIL PROTECTED]> writes: chris> I have no problem writing bits of functional code to do any chris> of the above. But for the life of me I can't see how I can chris> hook them altogether in an OO based framework that I can chris> build and extend (with mo

Re: Newbie question: Explain this behavior - a followup

2005-07-20 Thread David Smith
max wrote: > David Smith <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > > >>range statements, the example doesn't work. >> >>Given that the beginning and ending values for the inner range >>statement are the same, the inner range stateme

Re: return None

2005-07-22 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Ximo <[EMAIL PROTECTED]> wrote: >Can I do a function which don't return anything? > >The question is that, if I do a function that have a return or without >return, it returns always "None", but i want that it doesnt return me >nothing What do you mean by "don't r

Need to understand python license

2005-07-27 Thread Roy Smith
I'm looking into the possibility of getting my employer to use Python as an embedded scripting language. A big issue is licensing; we can't use anything that's GPL-like, because that would make us release our source code. Obviously, our lawyers will have the final say, but I'm looking for a rough

Re: Need to understand python license

2005-07-27 Thread Roy Smith
Benji York wrote: > > See http://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq > Thanks, that's exactly what I needed. -- http://mail.python.org/mailman/listinfo/python-list

startfile problems

2005-08-01 Thread Timothy Smith
hello i have a very odd issue with os.startfile() ok basicly my app works perfectly on every single other pc todate. i cannot recreate this issue on any system. so i've already ruled out any obvious coding issues, such as wrong file names etc. this issue only occurs on this one old pc. upon tr

Re: startfile problems

2005-08-02 Thread Timothy Smith
Dennis Lee Bieber wrote: >On Tue, 02 Aug 2005 15:10:23 +1000, Timothy Smith ><[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > >>i'm very curious as to what everyone thinks >> >> > > I suspect most of us think:

Re: startfile problems

2005-08-02 Thread Timothy Smith
Dennis Lee Bieber wrote: >On Tue, 02 Aug 2005 17:35:27 +1000, Timothy Smith ><[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > >>it's iterally just >> >>PDFname = 'tmp.pdf' >>os.startfile(PDFname) >> &

Re: startfile problems

2005-08-02 Thread Timothy Smith
Michael Hoffman wrote: >Timothy Smith wrote: > > > >>yep the program is executed in the same dir as the pdf file. like i said >>it actually opens it, but throws up an exception as well. >> >> > >You are far more likely to get informed help if

Re: Using win32com for web automation

2005-08-02 Thread Chris Smith
> "calfdog" == calfdog <[EMAIL PROTECTED]> writes: calfdog> ina wrote: >> Look up pamie it should do all the work you need. If it dosn't >> I can send you ishyBrowser but pamie has more comunity support. calfdog> # wait for the document to fully load calfdog> while ie.R

Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Roy Smith
Kevin <[EMAIL PROTECTED]> wrote: >The problem is that it's difficult to find hosting services with Python >installed and supported. I just googled for ["web hosting" python] and got 1,250,000 hits. I can personally recommend panix.com, but there's plenty of other choices too. -- http://mail.pyth

Re: Python -- (just) a successful experiment?

2005-08-07 Thread Roy Smith
"Paul Boddie" <[EMAIL PROTECTED]> wrote: > Perl had the "cool tool" buzz a good ten years ago. That's true, but I think it understates just how important a development Perl really was. Before Perl, unix scripting consisted of awk, sed, grep, tr, a random assortment of incompatible shells, and l

Bizarre error from help()

2005-08-09 Thread Roy Smith
Can anybody explain this bizarre behavior: - Roy-Smiths-Computer:play$ py Python 2.3.4 (#3, Jun 29 2004, 21:48:03) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> help (isinstance) foos b

Re: Python supports LSP, does it?

2005-08-09 Thread Roy Smith
Andy Leszczynski writes: > Is not LSP more a quality of the desing of class hierachy rather then > language itslef? Comments? I do agree that LSP is more a class hierarchy thing than a language thing. For example, it's easy in Python to write a LSP-violating set of classes: class base: de

Re: Recommendations for CVS systems

2005-08-09 Thread Roy Smith
Mike Meyer <[EMAIL PROTECTED]> wrote: > My current client uses subversion, and I generally wind up cursing at it > at least once a day. What makes you curse at it? I've never actually used it, just been watching the project for several years. I'd be interested to hear your experiences. -- ht

Re: Recommendations for CVS systems

2005-08-09 Thread Roy Smith
Mike Meyer <[EMAIL PROTECTED]> wrote: > Well, the only thing that subversion does that I'd call bad is leave > turds in my development directory. I'm tired of having to tell > commands to ignore .svn files. Of course, Perforce is the only source > control system I know of that doesn't do this. My

Re: Bizarre error from help()

2005-08-09 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> wrote: > Roy Smith wrote: > > > Traceback (most recent call last): > > File "", line 1, in ? > > File "/usr/local/lib/python2.3/site.py", lin

Re: Bizarre error from help()

2005-08-09 Thread Roy Smith
Roy Smith <[EMAIL PROTECTED]> wrote: > No, that works fine. But, now I can't even reproduce the error I reported > earlier (when I try, I get the help message as expected). And, yes, that > was with a brand new interpreter session. Strange. I got it now! Oh, this i

Re: What is Python?!

2005-08-10 Thread Roy Smith
Robert Wierschke <[EMAIL PROTECTED]> wrote: > a scripting language or a "normal" language like C++ etc. It is difficult to define exactly what a "scripting language" is and isn't, but I think most people would classify it as a scripting language. > So please tell me what python is, what ar

Re: PEP 328, absolute/relative import (was: Re: Bizarre error from help())

2005-08-10 Thread Roy Smith
Ben Finney <[EMAIL PROTECTED]> wrote: > Once PEP 328 is fully implemented, all bare 'import foo' statements > specify absolute imports (i.e. from sys.path only). To perform a > relative import (e.g. from current directory) will require different > syntax. It seems like this will break lots of exis

Re: What is Python?!

2005-08-10 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Jason Drew" <[EMAIL PROTECTED]> wrote: > Roy Smith wrote: "there's a system called Jython, which lets you > compile Java source to Python byte code." > > Don't you have that the wrong way 'round?

Re: How do these Java concepts translate to Python?

2005-08-12 Thread Roy Smith
"Ray" <[EMAIL PROTECTED]> wrote: > I've been learning Python in my sparetime. I'm a Java/C++ programmer by > trade. So I've been reading about Python OO, and I have a few questions > that I haven't found the answers for :) > > 1. Where are the access specifiers? (public, protected, private) Quick

Re: Binary Trees in Python

2005-08-20 Thread Roy Smith
In article <[EMAIL PROTECTED]>, [diegueus9] Diego Andrés Sanabria <[EMAIL PROTECTED]> wrote: > Hello!!! > > I want know if python have binary trees and more? Python does not come with a tree data structure. The basic data structures in Python are lists, tuples, and dicts (hash tables). Peopl

Re: Creating anonymous functions using eval

2005-08-22 Thread Julian Smith
On 12 Jul 2005 08:28:45 -0700 "Devan L" <[EMAIL PROTECTED]> wrote: [ here's some context: > > I've been playing with a function that creates an anonymous function by > > compiling a string parameter, and it seems to work pretty well: > > > > def fn( text): > > exec 'def foo' + text.st

Re: The ONLY thing that prevents me from using Python

2005-08-23 Thread Chris Smith
> "Kevin" == Kevin <[EMAIL PROTECTED]> writes: Kevin> I have been using java (jsp/servlets), vb/asp and perl for Kevin> a few years. Almost all my projects are web site Kevin> development related, and many of my clients' web sites are Kevin> hosted on those shared web hosting

Re: Binary Trees in Python

2005-08-24 Thread Chris Smith
> "[diegueus9]" == [diegueus9] Diego Andrés Sanabria writes: [diegueus9]> Hello!!! I want know if python have binary trees and [diegueus9]> more? The latest boost, 1.33, says it has a python wrapper for the boost graph library. Boost explicitely states that it's experimental, but my

Re: Decorator and Metaclasses Documentation

2005-08-24 Thread Chris Smith
> "Michele" == Michele Simionato <[EMAIL PROTECTED]> writes: Michele> There are also my lectures at Oxford: Michele> http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip Michele>Michele Simionato You really need to get O'Reilly to publish your s

Re: trictionary?

2005-08-28 Thread Roy Smith
Steven Bethard <[EMAIL PROTECTED]> wrote: > In Python, pairs are usually handled with tuples[2], but tuples would be > inconvenient in this case, since the first value must be modified. Instead of modifying the tuple (which you can't do), you can create a new one: a, b = myDict[key] myDict[key]

Re: how to join two Dictionary together?

2005-08-30 Thread Roy Smith
In article <[EMAIL PROTECTED]>, DENG <[EMAIL PROTECTED]> wrote: > >dict1={...something...} > >dict2={...somethind else ..} > >dict1 + dict2 > > >that's does works ..:(, it's not like List... > > >anyone can tell me how to get it? > >thanks in advance First, you have to tell us what you want to hap

Re: Python versus Perl

2005-09-10 Thread Roy Smith
Dieter Vanderelst <[EMAIL PROTECTED]> wrote: > 1 - How does the speed of execution of Perl compares to that of Python? To a first-order approximation, Perl and Python run at the same speed. They are both interpreted languages with roughly the same kind of control flow and data structures. The

OCR librarys

2005-09-12 Thread Timothy Smith
i'm looking for ocr librarys with reasonably free licensing and the ablity to use python with them. c library's that i can call from python are acceptable. so far all i have run into is voodoo and wild claims. i've tried gocr, and it wasn't very impressive. i'm like to be able to ocr handwriting

Re: OCR librarys

2005-09-12 Thread Timothy Smith
Larry Bates wrote: >You need to specify a "platform" you will be running on. I've had >good experience with ExperVision's RTK toolkit on Windows. It is not >free, but it is very, very good. Sometimes software is actually >worth paying for ;-). > &g

Re: No newline using printf

2005-09-15 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Samuel" <[EMAIL PROTECTED]> wrote: > How can I print a word without appending a newline character? Appending > a "," to the print statement only substitutes the newline for a space, > which is not what I am looking for. For closer control over output, use the wr

Re: services on linux

2005-09-20 Thread Timothy Smith
Martin Franklin wrote: >Christoph Haas wrote: > > >>On Tue, Sep 20, 2005 at 02:57:26AM -0500, pt python wrote: >> >> >> >>>im moving from the windows world to the linux world and i need to make >>>a python script to see if a service is instaled (ex: apache), if it is >>>running or stoped and

Re: Python versus Perl ?

2005-02-06 Thread Roy Smith
"EP" <[EMAIL PROTECTED]> wrote: > There are very very few cases where anyone is going to require > you to use Python Conversely, it pays to understand when you are likely to be permitted to use it (or any new technology), and when you are likely to be forbidden. Companies are generally the most

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

2005-02-08 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "John M. Gabriele" <[EMAIL PROTECTED]> wrote: > I recently posted this sort of question to the c.l.p.m but > didn't get much of a response. I know a little Perl and a > little Python, but master neither at the moment. > > I see that Python is a general purpose OO

Re: Loop in list.

2005-02-08 Thread Roy Smith
Jim <[EMAIL PROTECTED]> wrote: >Where did this type of structure come from: > >mat = ['a' for i in range(3)]? > >This will produce a list of three elements but >I don't see reference for it in any of the books. It's a list comprehension. Unfortunately, this is a bad example of one, since a mu

Re: Loop in list.

2005-02-08 Thread Roy Smith
Jim <[EMAIL PROTECTED]> wrote: > Thanks for the help. Python is somewhat mysterious to an old fortan > programer. You might appreciate http://www.python.org/doc/Humor.html#habits -- http://mail.python.org/mailman/listinfo/python-list

Re: WYSIWYG wxPython "IDE"....?

2005-02-08 Thread Jim Smith
Simon John wrote: I'm writing my 2nd large wxPython program, and after the problems I found doing the first's layout in code, I'd like to look at using a 'WYSIWYG' IDE, like VisualStudio does for MFC. I've tried a few that I found, wxGlade is probably the best, although it seems to be not 100% WYSI

Re: Which IDE supports python and wxpython?

2005-02-08 Thread Jim Smith
Selfimprover wrote: Hello all, Is there a good IDE on the market which supports python and wxpython. Goal is to use it in a big distributed project. Greetings Try wxDesigner! http://www.roebling.de/ -- http://mail.python.org/mailman/listinfo/python-list

ANN: Constrict 0.1.0 DNS message parsing library

2005-02-08 Thread Jason Smith
ew is quite intuitive for day-to-day queries and responses. Constrict is known to work with Python 2.3 and BIND 9 on Linux/i386 and Linux/ppc. -- Jason Smith Open Enterprise Systems Bangkok, Thailand http://www.oes.co.th -- http://mail.python.org/mailman/listinfo/python-list

Re: Name of type of object

2005-02-08 Thread Randall Smith
Jive Dadson wrote: The traceback routine prints out stuff like, NameError: global name 'foo' is not defined NameError is a standard exception type. What if I want to print out something like that? I've determined that "global name 'foo' is not defined" comes from the __str__ member of the

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

2005-02-09 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Max M <[EMAIL PROTECTED]> wrote: > Jeff Epler wrote: > > No. > > > > Unlike Perl, Python implements only a *finite turning machine* model of > > computation. An easy way to see this limitation is in the following > > code: > > >>> 1.0 / 10.0 > > 0.100

lambda and for that matter goto not forgetting sugar

2005-02-10 Thread Philip Smith
I've read with interest the continuing debate about 'lambda' and its place in Python. Just to say that personally I think its an elegant and useful construct for many types of programming task (particularly number theory/artificial intelligence/genetic algorithms) I can't think why anyone woul

Re: Unit Testing in Python

2005-02-10 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "rhat" <[EMAIL PROTECTED]> wrote: > Hi Everyone, > I've recently been reading some articles about unit-testing in Python > [1] [2], but I am a bit confused: where do I go to get started with > this? I tried googling for "unittest" but all I've found are some old >

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Roy Smith
In article <[EMAIL PROTECTED]>, David Eppstein <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Leo Breebaart <[EMAIL PROTECTED]> wrote: > > > What I can't find an explanation for is why str.join() doesn't > > automatically call str() on its arguments, so that e.g. > > str.join([1

Derived class and deepcopy

2005-02-16 Thread Philip Smith
Hi If I derive a class (eg Matrix) from list I presume this implies the classic OOP 'is a' relation between the derived and super class. I therefore presume I can use a derived class in any context that I can use the superclass. In the given example I want to apply deepcopy() to the Matrix ins

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Paul Moore <[EMAIL PROTECTED]> wrote: > I have a class with a read-only attribute, and I want to add a unit > test to ensure that it really *is* read-only. I can do this as > > def test_readonly(self): > """Value and multiplier must be readonly""" >

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Roy Smith
Paul Rubin wrote: > The example I quoted used an assignment expression inside a > lambda. The person who posted it, That was me. > and the person who followed it up > with the setattr alternative, both didn't notice that the assignment > expression wasn't valid Python

Re: wanted: C++ parser written in Python

2005-02-25 Thread Chris Smith
> "Franz" == Franz Steinhaeusler <[EMAIL PROTECTED]> writes: Franz> On 25 Feb 2005 12:38:53 +0200, Ville Vainio <[EMAIL PROTECTED]> wrote: Franz> Hello Ville, >>> "Franz" == Franz Steinhaeusler >>> <[EMAIL PROTECTED]> writes: >> Franz> Thank you, but it is to

<    5   6   7   8   9   10   11   12   13   14   >