Re: A question about unicode() function

2006-12-31 Thread Tim Roberts
"JTree" <[EMAIL PROTECTED]> wrote: > >Hi,all > I encountered a problem when using unicode() function to fetch a >webpage, I don't know why this happenned. > My codes and error messages are: > > >Code: >#!/usr/bin/python >#Filename: test.py >#Modified: 2006-12-31 > >import cPickle as p >impo

Re: A question about unicode() function

2006-12-31 Thread JTree
Hi, I changed my codes to: #!/usr/bin/python #Filename: test.py #Modified: 2007-01-01 import cPickle as p import urllib import htmllib import re import sys funUrlFetch = lambda url:urllib.urlopen(url).read() objUrl = raw_input('Enter the Url:') content = funUrlFetch(objUrl) content = content.

Re: C app and Python

2006-12-31 Thread Ravi Teja
Vertilka wrote: > Hi, > I need to create an application that the user ask for python script to > run. > this script will call the C application functions (in my app. the > function will draw on screen). > > Do I need to create an extension ? Note that this is not a DLL, but a C > application. > or

Re: Easiest way to print from XP/DOS.

2006-12-31 Thread Tim Roberts
jim-on-linux <[EMAIL PROTECTED]> wrote: > >Thanks, >The client is in a one printer office. If the >output file is opened with note and then sent to >the printer everything is fine but it defeats the >purpose of the utility. Also tried > lpt1 but >the same results. Is it a USB printer? Re

Re: OO question

2006-12-31 Thread Paddy
Steven D'Aprano wrote: > On Sun, 31 Dec 2006 19:47:12 -0800, fejkadress wrote: > > > I want to make an addressbook and I'm new to OO programming, so I > > wonder if this sounds reasonable. > > > > I think of making a class Address which contains all data about one > > person, that class can have

Re: OO question

2006-12-31 Thread Paddy
[EMAIL PROTECTED] wrote: > I want to make an addressbook and I'm new to OO programming, so I > wonder if this sounds reasonable. > > I think of making a class Address which contains all data about one > person, that class can have UserDict as baseclass so I can access data In Python 2.4 or 2.5 yo

Re: I want to see all the variables

2006-12-31 Thread Steven D'Aprano
On Sun, 31 Dec 2006 21:23:03 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> > At the same time, you should ponder very >> > carefully the reasons why the original author deemed it important to >> > make those attributes private in the first place. >> >> In my experience

Re: OO question

2006-12-31 Thread Steven D'Aprano
On Sun, 31 Dec 2006 19:47:12 -0800, fejkadress wrote: > I want to make an addressbook and I'm new to OO programming, so I > wonder if this sounds reasonable. > > I think of making a class Address which contains all data about one > person, that class can have UserDict as baseclass so I can access

Re: I want to see all the variables

2006-12-31 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > > At the same time, you should ponder very > > carefully the reasons why the original author deemed it important to > > make those attributes private in the first place. > > In my experience, it is mostly because they come from > bondage-and-domination

Re: I want to see all the variables

2006-12-31 Thread Steven D'Aprano
On Sun, 31 Dec 2006 19:48:55 -0800, Tom Plunket wrote: > Steven D'Aprano wrote: > >> What does the author of the original class know about *my* needs and >> requirements? > > The only thing that the original class author might know is that mucking > with data marked private may well cause proble

Re: looking for a better way to call a file.

2006-12-31 Thread [EMAIL PROTECTED]
Thanks I will give that a try.. should clean up my code quite a bit. James Thiele wrote: > This probably will meet your needs: > > import os > os.system("csound play.orc play.sco") > > If you need more control try the subprocess module. > > [EMAIL PROTECTED] wrote: > > I have been auto-generatin

Re: I want to see all the variables

2006-12-31 Thread Tom Plunket
Steven D'Aprano wrote: > What does the author of the original class know about *my* needs and > requirements? The only thing that the original class author might know is that mucking with data marked private may well cause problems, and hiding it therefore prevents those problems. > It may turn

OO question

2006-12-31 Thread fejkadress
I want to make an addressbook and I'm new to OO programming, so I wonder if this sounds reasonable. I think of making a class Address which contains all data about one person, that class can have UserDict as baseclass so I can access data like object['name'], etc.. Then maybe I can have a class Ad

Re: Why does Python never add itself to the Windows path?

2006-12-31 Thread Tom Plunket
vbgunz wrote: > I don't understand what all the fuss is about. Add a single page to the > installer and on it, have 3 radio buttons. I don't understand what the fuss is about, and would not give that recommendation based on my not understanding it! I have never ever needed or wanted to launch th

Re: DOS, UNIX and tabs

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Tom Plunket wrote: > Perhaps interestingly, for development I have my editor set to show tabs > as fairly short, but my diff program shows them as eight characters. I > find that makes indentation changes easier to spot in the diffs. I think there should be a sing

Re: Help with small program

2006-12-31 Thread Tom Plunket
Paul Watson wrote: > > It is certainly possible to construct a set of denominations for which the > > algorithm occasionally chooses badly. For example, if you give it the set > > (40,35,10) and ask it to make change for 70, it will be suboptimal. > > Unless I am missing the point, the minimum n

Re: a question on python dict

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Tim Peters wrote: > [Tim Peters] > You should also note that copying a dict key or value (no matter of > what type) consists in its entirety of copying one machine address (a > 4- or 8-byte pointer, depending on platform). > > [Lawrence D'Oliveiro]

Just TOO easy.... Re: Q: a simple(?) raw-utf-8 conversion to internal type unicode "\304\246\311\231\316\257\316\271\303\222"

2006-12-31 Thread NevilleDNZ
It was just TOO easy... on posting my message to google groups, and when I re-read the posting on groups I found that google had pointed me to a python-unicode tutorial... www.reportlab.com/i18n/python_unicode_tutorial.html - exercise one :-) Gosh sometime a google is worth so much more then ₁₀¹⁰⁰

Q: a simple(?) raw-utf-8 conversion to internal type unicode "\304\246\311\231\316\257\316\271\303\222"

2006-12-31 Thread NevilleDNZ
Hi, Apologies first as I am not a unicode expert indeed I the details probably totally elude me. Not withstanding: how can I convert a binary string containing UTF-8 binary into a python unicode string? cutdown example: $ cat ./uc.py #!/usr/bin/env python imported="\304\246\311\231\316\257\

Re: Wow, Python much faster than MatLab

2006-12-31 Thread sturlamolden
Klaas wrote: > C/C++ do not allocate extra arrays. What you posted _might_ bear a > small resemblance to what numpy might produce (if using vectorized > code, not explicit loop code). This is entirely unrelated to the > reasons why fortran can be faster than c. Array libraries in C++ that use o

Re: find login name of user?

2006-12-31 Thread Brian Beck
Martin P. Hellwig wrote: > Speaking of that, is there any reason why there isn't any syntactic > sugar that gives the illusion of platform neutral fetching of the user > name? getpass.getuser() might come the closest: http://docs.python.org/lib/module-getpass.html -- Brian Beck Adventurer of t

Re: Managing a queue of subprocesses?

2006-12-31 Thread Tom Plunket
cypher543 wrote: > That was a very good answer, and it sure sounds like it would work. > However, I failed at implementing it. :( My updated runQueue() function > is: > > def runQueue(self): > self.buildProcess = None > count = 1 # current position in the queue > while True: >

Re: DOS, UNIX and tabs

2006-12-31 Thread Tom Plunket
Marc 'BlackJack' Rintsch wrote: > >> Did you try to open your code files with another editor, which has a > >> different length for tabulator chars? It would look quite ugly, I > >> guess... > > > > Actually, no. Everyone can choose their own number of spaces-per-tab and > > it'll look right, as

Re: Help with small program

2006-12-31 Thread Paul Watson
Tim Roberts wrote: > [EMAIL PROTECTED] wrote: >> Interesting impl in Python! I am wondering what if the requirement is >> to find the minimum number of coins which added to the "fin" sum... > > Given the set of coins in the original problem (100, 10, 5, 1, 0.5), the > solution it provides will alw

Re: Wow, Python much faster than MatLab

2006-12-31 Thread Klaas
sturlamolden wrote: > as well as looping over the data only once. This is one of the main > reasons why Fortran is better than C++ for scientific computing. I.e. > instead of > > for (i=0; i array1[i] = (array1[i] + array2[i]) * (array3[i] + array4[i]); > > one actually gets something like thre

Re: Missing erf()

2006-12-31 Thread skip
rrenaud> Is there a reason why erf() is not included in the math rrenaud> package? According to the following URL it looks like it has rrenaud> been standard C since 1999. Python is implemented in the C89 dialect. Maybe Python 3.0 will be implemented using C99. Skip -- http://mail

Re: looking for a better way to call a file.

2006-12-31 Thread James Thiele
This probably will meet your needs: import os os.system("csound play.orc play.sco") If you need more control try the subprocess module. [EMAIL PROTECTED] wrote: > I have been auto-generating .bat files and then running > os.startfile('whatever.bat'). I don't > seem to be having much luck when I

Missing erf()

2006-12-31 Thread [EMAIL PROTECTED]
Is there a reason why erf() is not included in the math package? According to the following URL it looks like it has been standard C since 1999. http://www.opengroup.org/onlinepubs/95399/functions/erf.html -- http://mail.python.org/mailman/listinfo/python-list

simple ftputil ssl client

2006-12-31 Thread Croteam
Hello, I trying to make ftputil client that uses ssl security.First I was try to make that with M2Crypto,but when I use it, I get the error: Traceback (most recent call last): File "", line 1, in -toplevel- import M2Crypto File "C:\Python24\lib\site-packages\M2Crypto\__init__.py", line 15

Re: Question concerning this list [WebCrawler]

2006-12-31 Thread Thomas Ploch
John Nagle schrieb: > > Very true. HTML is LALR(0), that is, you can parse it without > looking ahead. Parsers for LALR(0) languages are easy, and > work by repeatedly getting the next character and using that to > drive a single state machine. The first character-level parser > yields toke

Re: Question concerning this list [WebCrawler]

2006-12-31 Thread John Nagle
Thomas Ploch wrote: > Marc 'BlackJack' Rintsch schrieb: > >>In <[EMAIL PROTECTED]>, Thomas Ploch >>wrote: >>>Alright, my prof said '... to process documents written in structural >>>markup languages using regular expressions is a no-no.' Very true. HTML is LALR(0), that is, you can parse it

trees, iterations and adding leaves

2006-12-31 Thread vertigo
Hello I have trees like this: >>> from nltk_lite.parse.tree import Tree >>> tree6 = Tree('main', ['sub1', 'sub2']) >>> tree6 ('main': 'sub1' 'sub2') I use nltk package - but it should not matter here. I could change it's lafes (add node) like this: >>> tree6[0] = Tree('newsub',[]) >>> tree6 ('ma

Re: PEP 3107 Function Annotations for review and comment

2006-12-31 Thread John Roth
Tony Lownds wrote: > > First, it only handles functions/methods. Python FIT needs > > metadata on properties and assignable/readable attributes > > of all kinds. So in no sense is it a replacement. Parenthetically, > > neither is the decorator facility, and for exactly the same reason. > > > > I c

Re: PEP 3107 Function Annotations for review and comment

2006-12-31 Thread Tony Lownds
On Dec 31, 2006, at 7:54 AM, John Roth wrote: > Tony Lownds wrote: >> Perhaps you are right and intersecting libraries will become an >> issue. >> Designing a solution in advance of the problems being evident seems >> risky to me. What if the solution invented in a vacuum really is more >> of a

Re: Progress Box or Bar in Windows

2006-12-31 Thread tubby
cyberco wrote: > Go for wxPython, it'll fulfill all your GUI needs. Handsdown the best > GUI toolkit I ever ran into. Thanks a lot! I had no idea wxPython was so easy to use. I added a progress bar from wx to the app. Less than 20 lines of code and it only took about 5 minutes! -- http://mail.p

Re: PEP 3107 Function Annotations for review and comment

2006-12-31 Thread John Roth
Tony Lownds wrote: > > First, it only handles functions/methods. Python FIT needs > > metadata on properties and assignable/readable attributes > ... > > > Third, it's half of a proposal. Type checking isn't the only use > > for metadata about functions/methods, classes, properties > > and ot

Re: PEP 3107 Function Annotations for review and comment

2006-12-31 Thread Tony Lownds
On Dec 31, 2006, at 4:26 AM, Kay Schluehr wrote: > I have two questions: > > 1) I don't understand the clause ('*' [tname] (',' tname ['=' test])* > in the grammar rule of typedargslist. Does it stem from another PEP? > Yes, PEP 3102 Keyword-only Arguments. > 2) Is the func_annotation informati

C app and Python

2006-12-31 Thread Vertilka
Hi, I need to create an application that the user ask for python script to run. this script will call the C application functions (in my app. the function will draw on screen). Do I need to create an extension ? Note that this is not a DLL, but a C application. or I need to embed Python in my C ap

Python embedded interpreter: how to initialize the interpreter ?

2006-12-31 Thread ycollet
Hello, I've written a C embedded application. I want to open a python gui application in my C program but when I do : PyRun_String( "import gui.py", file_input, pDictionary, pDictionary ); the interpreter emits an error: tkinter module not defined What script must I load to initialize the embed

request for code : Py Tic Tac Toe in action

2006-12-31 Thread Furman Smith
Hi elainejackson7355_at_home.com, I read "I played against your script and got a win, which, as you know, is not possible with optimal play by the opponent. A while ago I wrote a script that plays optimal tic-tac-toe. Let me know if you want to look at it." I would certainly appreciate the co

py2exe 0.6.6 released

2006-12-31 Thread Jimmy Retzlaff
py2exe 0.6.6 released = py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported

Re: Are all classes new-style classes in 2.4+?

2006-12-31 Thread Steven D'Aprano
On Sun, 31 Dec 2006 03:57:04 -0800, Isaac Rodriguez wrote: > Hi, > > This is probably a very basic question, but I've been playing with new > style classes, and I cannot see any difference in behavior when a > declare a class as: > > class NewStyleClass(object): > > or > > class NewStyleClass:

Re: A question about unicode() function

2006-12-31 Thread Felipe Almeida Lessa
On 31 Dec 2006 05:20:10 -0800, JTree <[EMAIL PROTECTED]> wrote: > def funUrlFetch(url): > lambda url:urllib.urlopen(url).read() This function only creates a lambda function (that is not used or assigned anywhere), nothing more, nothing less. Thus, it returns None (sort of "void") no matter wha

Re: WebCrawler (was: 'Question concerning this list')

2006-12-31 Thread Thomas Ploch
Marc 'BlackJack' Rintsch schrieb: > In <[EMAIL PROTECTED]>, Thomas Ploch > wrote: > >> This is how my regexes look like: >> >> import re >> >> class Tags: >> def __init__(self, sourceText): >> self.source = sourceText >> self.curPos = 0 >> self.namePattern = "[A-Za-z_][

A question about unicode() function

2006-12-31 Thread JTree
Hi,all I encountered a problem when using unicode() function to fetch a webpage, I don't know why this happenned. My codes and error messages are: Code: #!/usr/bin/python #Filename: test.py #Modified: 2006-12-31 import cPickle as p import urllib import htmllib import re import sys def

Re: Are all classes new-style classes in 2.4+?

2006-12-31 Thread Felipe Almeida Lessa
On 31 Dec 2006 03:57:04 -0800, Isaac Rodriguez <[EMAIL PROTECTED]> wrote: > I am using Python 2.4, and I was wondering if by default, all > classes are assumed to be derived from "object". This won't tell you advantages or disadvantages, but will show you that the default still is the old-style:

Re: Question concerning this list [WebCrawler]

2006-12-31 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Thomas Ploch wrote: > This is how my regexes look like: > > import re > > class Tags: > def __init__(self, sourceText): > self.source = sourceText > self.curPos = 0 > self.namePattern = "[A-Za-z_][A-Za-z0-9_.:-]*" > self.tagPattern = re

Re: Are all classes new-style classes in 2.4+?

2006-12-31 Thread Rene Fleschenberg
Isaac Rodriguez wrote: > I declare property members in both and it seems to work the exact same > way. I am using Python 2.4, and I was wondering if by default, all > classes are assumed to be derived from "object". No, they are not. It's just that the "basic functionality" seems to work the same

Re: Are all classes new-style classes in 2.4+?

2006-12-31 Thread Bjoern Schliessmann
Isaac Rodriguez wrote: > This is probably a very basic question, but I've been playing with > new style classes, and I cannot see any difference in behavior > when a declare a class as: > > class NewStyleClass(object): > > or > > class NewStyleClass: Try multiple inheritance (the order of supe

Re: a question on python dict

2006-12-31 Thread Tim Peters
[Tim Peters] You should also note that copying a dict key or value (no matter of what type) consists in its entirety of copying one machine address (a 4- or 8-byte pointer, depending on platform). [Lawrence D'Oliveiro] >>> Actually, no. It also consists of updating reference counts

Re: PEP 3107 Function Annotations for review and comment

2006-12-31 Thread Kay Schluehr
I have two questions: 1) I don't understand the clause ('*' [tname] (',' tname ['=' test])* in the grammar rule of typedargslist. Does it stem from another PEP? 2) Is the func_annotation information for def foo(*c: list) stored as {"*c": list} preserving optional argument information or {"c":list

Are all classes new-style classes in 2.4+?

2006-12-31 Thread Isaac Rodriguez
Hi, This is probably a very basic question, but I've been playing with new style classes, and I cannot see any difference in behavior when a declare a class as: class NewStyleClass(object): or class NewStyleClass: I declare property members in both and it seems to work the exact same way. I am

Re: python , Boost and straight (but complex) C code

2006-12-31 Thread Roman Yakovenko
On 12/31/06, Osiris <[EMAIL PROTECTED]> wrote: > In short: it's all rather confusing > > I think it must be like this: > > To use my C/C++ code with Python, add some stuff in the C/C++ source > and compile it into a DLL, that must be combined with some boost-DLL > to make it accessible to Pytho

Re: Progress Box or Bar in Windows

2006-12-31 Thread cyberco
Go for wxPython, it'll fulfill all your GUI needs. Handsdown the best GUI toolkit I ever ran into. It can't get much simpler than: wx.MessageBox('hi') And there are tons of readymade dialogs and progressbars in the library. Check out the demo.py under the wxPython installation dir to see demos (a

Re: DOS, UNIX and tabs

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Paul McNett > wrote: > >> Everyone can choose their own number of spaces-per-tab and >> it'll look right, as long as everyone uses a monospace font. > > You never tried that with tabs plus additional spaces

Re: Question concerning this list [WebCrawler]

2006-12-31 Thread Thomas Ploch
Marc 'BlackJack' Rintsch schrieb: > In <[EMAIL PROTECTED]>, Thomas Ploch > wrote: > >> Alright, my prof said '... to process documents written in structural >> markup languages using regular expressions is a no-no.' (Because of >> nested Elements? Can't remember) So I think he wants us to use rege

Re: a question on python dict

2006-12-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Tim Peters wrote: > [Tim Peters] >>> You should also note that copying a dict key or value (no matter of >>> what type) consists in its entirety of copying one machine address (a >>> 4- or 8-byte pointer, depending on platform). > > [Lawrence D'Oliveiro] >> Actuall

Re: python , Boost and straight (but complex) C code

2006-12-31 Thread Osiris
On Sat, 30 Dec 2006 23:35:22 +0200, "Roman Yakovenko" <[EMAIL PROTECTED]> wrote: >On 12/30/06, Osiris <[EMAIL PROTECTED]> wrote: >> Visual C++ build log at: >> >> http://213.10.133.192/BuildLog.htm > >It is better to ask Boost.Python related questions on it mailing list: >http://mail.python.org/ma

Re: DOS, UNIX and tabs

2006-12-31 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Paul McNett wrote: >> Did you try to open your code files with another editor, which has a >> different length for tabulator chars? It would look quite ugly, I >> guess... > > Actually, no. Everyone can choose their own number of spaces-per-tab and > it'll look right, as l

Re: Question concerning this list

2006-12-31 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Thomas Ploch wrote: > Alright, my prof said '... to process documents written in structural > markup languages using regular expressions is a no-no.' (Because of > nested Elements? Can't remember) So I think he wants us to use regexes > to learn them. He is pointing to HTML

Re: python , Boost and straight (but complex) C code

2006-12-31 Thread Osiris
On Sun, 31 Dec 2006 01:01:29 +0100, Christophe Cavalaria <[EMAIL PROTECTED]> wrote: >Osiris wrote: > >> On Sat, 30 Dec 2006 13:19:28 -0800, Erik Max Francis <[EMAIL PROTECTED]> >> wrote: >> >>>Osiris wrote: >>> I have these pieces of C-code (NOT C++ !!) I want to call from Python. I fou

Re: a question on python dict

2006-12-31 Thread Tim Peters
[Tim Peters] >> You should also note that copying a dict key or value (no matter of >> what type) consists in its entirety of copying one machine address (a >> 4- or 8-byte pointer, depending on platform). [Lawrence D'Oliveiro] > Actually, no. It also consists of updating reference counts as well.

Re: Progress Box or Bar in Windows

2006-12-31 Thread dkinakin
Not that I want to suggest a completely different solution; however, I have used: http://www.averdevelopment.com/python/EasyDialogs.html to add simple file open dialogs, message boxes, and progress bars to many of my scripts. You may want to have a look at it. It's easy to install and really sim