Re: What are modules really for?

2005-08-12 Thread Magnus Lycka
bruno modulix wrote: Magnus Lycka wrote: N.Davis wrote: Functions existing in a module? Surely if everything is an object (OK thats Java-talk but supposedly Python will eventually follow this too) int too? ;) Yes, int too. I was talking about everything being an object in Java

Re: What are modules really for?

2005-08-12 Thread Magnus Lycka
Terry Reedy wrote: However, everything is an instance of a class or type. Except whitespace, comments, operators and statements! (Did I miss anything?) You can obviously argue whether a variable (or name if you like) is an object, or just refers to an object, but then we're getting

Re: len(sys.argv) in (3,4)

2005-08-12 Thread Magnus Lycka
Daniel Schüle wrote: I just tried the same code at home and it worked fine it has to do with windows .. some settings or whatever (python 2.4.1 installed on both) maybe someone have experienced the same problem and had more luck in solving the puzzle First of all: Windows is a whole family

Re: What are modules really for?

2005-08-11 Thread Magnus Lycka
N.Davis wrote: Functions existing in a module? Surely if everything is an object (OK thats Java-talk but supposedly Python will eventually follow this too) int too? ;) Actaully, I think Python and Java are fairly much on equal footing here, with Java possibly being slightly behind rather

Re: python for microcontrollers

2005-08-10 Thread Magnus Lycka
Peter Hansen wrote: (Not trying to argue, just understand, because it looks like you're conflating Forth programs with Forth implementations, or perhaps I'm even more ignorant than noted above and am missing a key point. :-) It's decades since I coded Forth, but I suspect that Forth

Re: time.clock() or time.time()

2005-08-05 Thread Magnus Lycka
Shane Hathaway wrote: However, isn't this thoroughly un-Pythonic? No wonder people have to ask. Only if they've never read KR, and I thought that was compulsory! ;^) There are a few python libraries, such as time and math, that are basically just thin wrappers around standard C libraries. In

Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Magnus Lycka
Martin P. Hellwig wrote: Kevin wrote: cut, can't get as many python web hosters as I want Well, for some strange reason I have never found that to be a problem. If you develop software for an external customer, and they have an existing web site run by some ISP that you have no control over,

Re: a pickle's pickle

2005-08-02 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: class TrainingMatrix: matrix = [] estimator = {} wordInfo = {} contextInfo = {} totalWordsProcessed = 0 numWords = 0 numContexts = 0 matrixWords = 0 Is there some confusion between the scope of the class object and the scopes of

Re: time.clock() or time.time()

2005-08-02 Thread Magnus Lycka
Shane Hathaway wrote: time.time() measures real time, while time.clock() measures the time the CPU dedicates to your program. I suppose that varies with the platform... help(time.clock) says: Help on built-in function clock: clock(...) clock() - floating point number Return the

Re: Database recommendations for Windows app

2005-06-30 Thread Magnus Lycka
Thomas Bartkus wrote: I was thinking of Win32com which I expect lets you put a wrapper around ADO and work the ADO (or any other ActiveX) object model from within Python. Sure, but since others have made wrappers around ADO for Python before, you'd either reivent the wheel or or use e.g.

Re: Boss wants me to program

2005-06-30 Thread Magnus Lycka
I think Python works on fairly antique hardware, whatever OS you use (as long as the OS works ok). You can get a DOS version of Python 2.2 at http://www.caddit.net/ , but I don't have any good suggestions for a UI then. This might work after some tweaking:

Re: Add methods to string objects.

2005-06-30 Thread Magnus Lycka
Negroup wrote: Hi all. I'm writing a simple Python module containing functions to process strings in various ways. Actually it works importing the module that contains the function I'm interested in, and calling my_module.my_function('mystring'). I was just asking if it is possible to

Re: Database recommendations for Windows app

2005-06-23 Thread Magnus Lycka
Cameron Laird wrote: OK, I'm with you part of the way. Typical Access developers are *always* involved with DLL hell, right? You're surely not saying that Python worsens that frustration, are you? I think Dan was commenting on flaws in Microsoft's products, not in Python. As I understand

Re: create a pdf file

2005-06-23 Thread Magnus Lycka
Alberto Vera wrote: Hello: I found a script that convert a file to PDF format , but it was made in PHP Do you know any script using Python? What do you mean by convert a file to PDF format? The solution obviously depends on what the file you start with looks like. If you want to create PDF

Re: Database recommendations for Windows app

2005-06-23 Thread Magnus Lycka
Thomas Bartkus wrote: Magnus Lycka [EMAIL PROTECTED] wrote in message The O.P. wanted a database for his Python app, and Thomas Bartkus suggested Access. Not exactly! Sorty, I meant Jet or whatever the backend is called these days. I suggested the built in Microsoft DAO or ADO

Re: Loop until condition is true

2005-06-22 Thread Magnus Lycka
Remi Villatel wrote: Erm... You totally missed the point. I wrote it this way because, first, it's perfectly valid Python code and, second and most important, it's also a valid english sentence. Remi, I think you have failed to understand what Fredrik was telling you. I can understand that,

Re: Database recommendations for Windows app

2005-06-22 Thread Magnus Lycka
Will McGugan wrote: Hi, I'd like to write a windows app that accesses a locally stored database. There are a number of tables, the largest of which has 455,905 records. Can anyone recommend a database that runs on Windows, is fast / efficient and can be shipped without restrictions or

Re: Database recommendations for Windows app

2005-06-22 Thread Magnus Lycka
Thomas Bartkus wrote: If you are writing strictly for the MS Windows platform And If the database is running single user with a locally stored database on a Windows workstation. Then The MS Access file based (.mdb) system is hard to argue with. I disagree. What does .mdb/jet without

Re: Database recommendations for Windows app

2005-06-22 Thread Magnus Lycka
Gregory Piñero wrote: I always figured a problem with using MySQL was distribution. Would you have to tell your users to install MySQL and then to leave the service running? I've never found an easy way to embed MySQL into a python app, and even if you could, would you then have to pay for

Re: strxfrm works with unicode string ?

2005-06-21 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: Gruëzi, Gerald ;-) Well, ok, but I don't understand why I should first convert a pure unicode string into a byte string. The encoding ( here, latin-1) seems an arbitrary choice. Yes. The correct choice would be 'cp1252', not 'latin-1', since that's what your locale

Re: Loop until condition is true

2005-06-21 Thread Magnus Lycka
Remi Villatel wrote: while True: some(code) if final_condition is True: break # # What I don't find so nice is to have to build an infinite loop only to break it. This is a common Python idiom. I think you will get used to it. Is there a better recipe?

Re: OO approach to decision sequence?

2005-06-21 Thread Magnus Lycka
Chinook wrote: I understand what you are saying. The point I'm messing up my head with though, is when the entity (tree node in my case or variable record content deconstructing in the aspect example I noted) is not an instance of a class already - it is obtained from an external source

Re: Loop until condition is true

2005-06-21 Thread Magnus Lycka
Benji York wrote: If by economy you mean optimization, then I would suggest that the difference would be unnoticeable. If there is a measurable performance gain in skipping the runtime test in while True, then this is a compiler issue, not a language issue. I don't know anything about the

Re: Loop until condition is true

2005-06-21 Thread Magnus Lycka
Konstantin Veretennicov wrote: On 6/21/05, Magnus Lycka [EMAIL PROTECTED] wrote: I don't know anything about the Python compiler internals, but it doesn't seem very hard to identify simple literals following while and if, and to skip the runtime test. (Perhaps it's done already?) True

Re: UML to Python/Java code generation

2005-06-20 Thread Magnus Lycka
James wrote: The brain may be fine for generating Python from UML but it is MANY MANY orders of magnitude harder to generate UML from code with just your brain than using a tool (usually zero effort and error free) no matter how good you are at Python. I've really only used Rational Rose, but

Re: Strange socket problem

2005-06-15 Thread Magnus Lycka
huy wrote: Hi, I'm using cherrypy to provide a user interface for users to start a linux server program eg. os.system(nohup myserver.py ). The problem is that if I stop cherrypy server and restart, I get the Address Already In Use problem until I stop myserver.py. Can someone shed some

Re: circular import Module

2005-06-14 Thread Magnus Lycka
Greg Ewing wrote: Magnus Lycka wrote: Due to the cycle, you can never use file1 without file2 or vice versa. Why do you then want it to be two different modules instead of one? Perhaps because it would then be too big and unwieldy to maintain? Sometimes there are legitimate reasons

Re: python bytecode grammar

2005-06-14 Thread Magnus Lycka
M1st0 wrote: Ops yes is BNF :P Bacus Normal Form if I am not wrong... Backus Naur Form. John Backus and Peter Naur first used it to describe ALGOL around 1960. See e.g. http://cui.unige.ch/db-research/Enseignement/analyseinfo/AboutBNF.html --

Re: Generating HTML from python

2005-06-14 Thread Magnus Lycka
Philippe C. Martin wrote: I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have a title followed by lines of text that do not look too ugly. If possible I would like to use an existing module. How to do this really depends on what your data looks like, and how you get

Re: What is different with Python ? (OT I guess)

2005-06-14 Thread Magnus Lycka
Scott David Daniels wrote: Magnus Lycka wrote: It seems to me that *real* computer scientists are very rare. I suspect the analysis of algorithms people are among that group. It is intriguing to me when you can determine a lower and upper bound on the time for the best solution

Re: What is different with Python ?

2005-06-14 Thread Magnus Lycka
Peter Maas wrote: Learning is investigating. By top-down I mean high level (cat, dog, table sun, sky) to low level (molecules, atoms, fields ...). Aha. So you must learn cosmology first then. I don't think so. ;) I don't know if you really think that you learn things top down, but I doubt that

Re: DB API 2.0 and transactions

2005-06-13 Thread Magnus Lycka
I'm CC:ing this to D'Arcy J.M. Cain. (See comp.lang.python for prequel D'Arcy.) Christopher J. Bottaro wrote: Check this out... code import pgdb import time print time.ctime() db = pgdb.connect(user='test', host='localhost', database='test') time.sleep(5) db.cursor().execute('insert

Re: DB API 2.0 and transactions

2005-06-10 Thread Magnus Lycka
You might have spotted a fairly nasty bug there! Christopher J. Bottaro wrote: Hi, Why is there no support for explicit transactions in the DB API? I mean like transaction() to start the trans and commit() and rollback() would end the trans or something. To quote from Date Darwen A Guide

Re: different time tuple format

2005-06-10 Thread Magnus Lycka
Maksim Kasimov wrote: hi all, sorry if i'm reposting why time.strptime and time.localtime returns tuple with different DST (9 item of the tuple)? I've been bitten by the quirks in the time modules so many times that I would advice against using it for any date handling. It's ok for time

Re: programmnig advise needed

2005-06-10 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: Hi, I am writing a Python program that needs to read XML files and contruct a tree object from the XML file (using wxTree). The XML however is not an hiearchical XML file. It contains elements and association tags. The assiociation tags link the elements together.

Re: circular import Module

2005-06-10 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: Hello, I have two modules (file1.py and file2.py) Is that ok in python (without any weird implication) if my module import each other. I mean in module file1.py there exist command import file2 and in module file2.py there exist command import file1? Even if it

Re: optparse.py: FutureWarning error

2005-06-09 Thread Magnus Lycka
John Abel wrote: Magnus Lycka wrote: As a programmer on Win32, and *nix platforms, I agree with needing better tools. however, I find cygwin a pita. For tools such as grep and find, try this http://unxutils.sourceforge.net/. No need for cygwin ( though that's not say cygwin isn't

Re: Python as client-side browser script language

2005-06-09 Thread Magnus Lycka
Paul Rubin wrote: Magnus Lycka [EMAIL PROTECTED] writes: Of course, one might suggest that it's the task of the browser, and not of the scripting language, to provide a safe sandbox where scripts can mess around and without causing havoc on your computer. Such a system in the browser could

Re: optparse.py: FutureWarning error

2005-06-08 Thread Magnus Lycka
Terry Reedy wrote: This should REALLY be on the doc page of the Python site. Agreed. It is really time to stop pretending that the only Python users that count have a *nix on their desk. I agree with this too, but if you're a programmer on the Windows platform with possibility to install

Re: calling ksh script from python

2005-06-08 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: thanks for your input... well I just find out that modifying environment through ksh call is not possible (can't get the new evironment back to python). I thought about this a few days ago. Can't you copy it like this: import os env_rows = os.popen('. some.script

Re: Destructive Windows Script

2005-06-08 Thread Magnus Lycka
rbt wrote: data = ['0', 'a', '1', 'b', '2', 'c',\ '3', 'd', '4', 'e', '5', 'f',\ '6', 'g', '7', 'h', '8', 'i',\ '9', 'j', '~', '!', '@', '#',\ '$', '%', '^', '', '*', ';'] Note that the backslashes

Re: reg php.ini equivalent file in python

2005-06-08 Thread Magnus Lycka
praba kar wrote: Dear All, I have one doubt. Is there python.ini file like php.ini in Php? There is no such thing in Python. Python is a programming language. It doesn't try to be an operating system or a web server. There are a number of web application toolkits written in Python, but

Re: anygui,anydb, any opinions?

2005-06-03 Thread Magnus Lycka
Skip Montanaro wrote: Glade is fine for building Gtk user interfaces. I have no idea if there are similar tools for other widget sets, though I wouldn't be surprised if such tools existed. Once the GUI is fairly stable, most of the development after that occurs in the underlying functional

Re: Seti-like program

2005-06-01 Thread Magnus Lycka
GMane Python wrote: I'd like to consider making a program which is 'seti-like' where I could run a command-line Python script to just 'do something', and then be able to launch a viewer program (maybe linux x11 or Windows, possibly over a network socket) using wxPython to be able to inter-act

Re: Python as client-side browser script language

2005-06-01 Thread Magnus Lycka
Rune Strand wrote: What would it take to create a Firefox extension that enables Python as a script language in the browser - just like Javascript? Is it at all possible? Are the hundred good reasons not to bother? There are certainly security issues. A simple implementation that started a

Re: xml processing

2005-06-01 Thread Magnus Lycka
Jeff Elkins wrote: I've like to use python to maintain a small addressbook which lives on a Sharp Zaurus. This list will never grow beyond 200 or so entries. I've installed pyxml. Speaking generally, given a wxpython app to do data entry, I'm planning to: 1. parse the addressbook

Re: eric3 question

2005-05-31 Thread Magnus Lycka
Gerrit van Dyk wrote: Try using raw_input() instead of the sys.stdin.readline(). raw_input() is the preferred way of getting console input. Is it? Guido's Python Regrets slides (Google for them) seems to say the opposite. Besides, that's not the problem here... Alexander Zatvornitskiy wrote:

Re: Exiting SocketServer: socket.error: (98, 'Address already in use')

2005-05-31 Thread Magnus Lycka
Thank's a lot Andrew and Dennis. Andrew Dalke wrote: You can set the class variable allow_reuse_address = True in your derived ExitableSocketServer to get the behaviour you expect, at the expense of some problems mentioned in the above URL. Ok. I added a STOP message to my protocol, so now

Re: Report generator for object databases.

2005-05-31 Thread Magnus Lycka
Mir Nazim wrote: Hi, I m planning to use ZODB for an applicaton. Is any one aware of report generators like Data Vision, Crystal Reports, fo python object databases. ZODB isn't like a relational database. It doesn't have a query language etc. In other words, a report generator for a ZODB

Re: Newbie Here

2005-05-31 Thread Magnus Lycka
Mark Sargent wrote: A question I have, is, those of you who use it for the same things, what do you primarily use it for. Erh, I'm sure different people use it for very different things. In contrast to e.g. PHP or bash, Python is a very generic language usable for most preogramming tasks. My

Re: regexp for sequence of quoted strings

2005-05-30 Thread Magnus Lycka
gry@ll.mit.edu wrote: I have a string like: {'the','dog\'s','bite'} or maybe: {'the'} or sometimes: {} ... I want to end up with a python array of strings like: ['the', dog's, 'bite'] Assuming that you trust the input, you could always use eval, but since it seems fairly easy to

Re: Get number of lines in file

2005-05-30 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: Thanks! I was trying len(cpn_version) and that didn't work. What's your problem? You get a value that's one more than you expected? You should use splitlines() instead of split('\n'), or easier, use readlines() instead of read(). Of course, with a modern python you can

Re: Determine if windows drive letter is hard drive or optical from python?

2005-05-30 Thread Magnus Lycka
Wolfgang Strobl wrote: ... for drive in string.letters[len(string.letters)/2:]: Or better... ..for drive in string.ascii_uppercase: string.letters differ with locale, but Windows drives are always only A-Z (right?) and just iterating over upper case (or lower) seems more clear than

Re: Is there a better way of doing this?

2005-05-30 Thread Magnus Lycka
Steven D'Aprano wrote: print is a statement, not a function. The brackets are syntactically correct, but pointless. Remove them. ... On Sat, 28 May 2005 13:24:19 +, Michael wrote: while( newNS ): Guido (our Benevolent Dictator For Life and creator of Python) hates seeing whitespace

Re: Threading questions

2005-05-30 Thread Magnus Lycka
Antal Rutz wrote: Hi, All! I'm new to threading. I have some design questions: Task: I collect data and store them in an RDBMS (mysql or pgsql) The question is how to do that with threading? The data-collecting piece of the code runs in a thread. 1. Open the db, and each thread writes

Exiting SocketServer: socket.error: (98, 'Address already in use')

2005-05-30 Thread Magnus Lycka
I have a socket server like below which I want to exit when it's out of data. If I interrupt the client, I'll get a broken pipe on the server side, and after a Ctrl-C, I can restart the server again, but if I let it run out of data, and exit via handle_error as can be seen below, I will get a

Re: Case Sensitive, Multiline Comments

2005-05-30 Thread Magnus Lycka
Terry Reedy wrote: Difference annoyances for different folks, I guess. IN MY EXPERIENCE, MANY PEOPLE ON THE INTERNET ARE ANNOYED BY PEOPLE WHO DON'T USE CASE THE WAY THEY ARE EXPECTED. IT ALSO SEEMS TO ME THAT LOWER CASE TEXT IS OFTEN MORE EASY TO READ, AND ALSO THAT IT IS EASIER TO SCAN TEXTS

Re: Is Python suitable for a huge, enterprise size app?

2005-05-19 Thread Magnus Lycka
john67 wrote: The company I work for is about to embark on developing a commercial application that will cost us tens-of-millions to develop. When all is said and done it will have thousands of business objects/classes, Ok, that sounds like a big app, but does it really have to be like that,

Re: newbie file/DB processing

2005-05-19 Thread Magnus Lycka
len wrote: I am an old time cobol programmer from the IBM 360/370 eria and this ingrained idea of file processing using file definition (FD's) I believe is causing me problems because I think python requires a different way of looking at datafiles and I haven't really gotten my brain around

<    1   2   3   4   5