Re: help in algorithm

2005-08-11 Thread Paolino
Bengt Richter wrote: > On Wed, 10 Aug 2005 16:51:55 +0200, Paolino <[EMAIL PROTECTED]> wrote: > > >>I have a self organizing net which aim is clustering words. >>Let's think the clustering is about their 2-grams set. >>Words then are instances of this class. >> >>class clusterable(str): >> def

Re: What are modules really for?

2005-08-11 Thread Terry Reedy
"Brian Quinlan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > There is a difference between everything being an object and everything > being an instance of a class. In Python, every runtime entity is an > object but not everything is a class instance. However, everything is an i

Re: how to write thread-safe module ? and pytz

2005-08-11 Thread Cantankerous Old Git
Daniel Dittmar wrote: > Dictionaries (and probably most other Python types that are implemented > in C) are inherently thread safe. That sounds like a dangerous assumption to me. Are you relying on the Global Interpreter Lock? Is is guaranteed? Does that safety transfer to Jython? How can I tel

Re: help in algorithm

2005-08-11 Thread Bill Mill
On 10 Aug 2005 12:46:08 -0700, gene tani <[EMAIL PROTECTED]> wrote: > this sounds like LSI / singular value decomposition (?) Why do you think so? I don't see it, but you might see something I don't. LSI can be used to cluster things, but I see no reason to believe that he's using LSI for his clus

Re: Bug in slice type

2005-08-11 Thread Steven Bethard
Bryan Olson wrote: > > class BuggerAll: > > def __init__(self, somelist): > self.sequence = somelist[:] > > def __getitem__(self, key): > if isinstance(key, slice): > start, stop, step = key.indices(len(self.sequence)) >

Re: epyDoc Questions

2005-08-11 Thread Jeffrey E. Forcier
Neil Benn wrote: >1. I want to document the attributes (instance and also class) of a > class and or module, I know the tags are there - where does they > go (before/after theclass decleration, top of the module, if > someone puts in the class doc but misses out the module stu

adding standard types to new type

2005-08-11 Thread kman3048
I've created a new type using the API and want to add not only methods (which is easy with PyMethodDef structure) but also insert several Python standard type variables. Is there some equivalent to PyModule_AddObject - just working on the new type instead Module? Or do I have to add a dictionary t

Re: command line reports

2005-08-11 Thread Darren Dale
Peter Hansen wrote: > Darren Dale wrote: >> Is there a module somewhere that intelligently deals with reports to the >> command line? I would like to report the progress of some pretty lengthy >> simulations, and currently I have the new reports written on a new line >> rather rather than overwrit

breaking a loop

2005-08-11 Thread el chupacabra
Hi, I'm just learning Pythonthanks in advance... Do you get out of this loop? Problem: When I type 'exit' (no quotes) the program doesn't quit the loop...it actually attemps to find entries that containt the 'exit' string. Desired behavior: when I type 'exit' the program should quit. def s

Re: what's the exactly newsgroup url of python-list?

2005-08-11 Thread Terry Reedy
"Grant Edwards" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2005-08-11, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> for an excellent way to read the python mailing list via a news- >> reader even if you don't have access to a "real" NNTP server, >> see http://gmane.org/ > > U

Python interpreter error: unsupported operand type(s) for |:

2005-08-11 Thread yaffa
hey folks i get this error: Python interpreter error: unsupported operand type(s) for |: when i run this line of code: for incident in bs('tr', {'bgcolor' : '#ee'} | {'bgcolor' : 'white'} ): any idea what i'm doing wrong here? thanks yaffa -- http://mail.python.org/mailman/listinfo/

Re: "Compile time" checking?

2005-08-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Qopit wrote: > I'm > a big fan of Python's ability to easily rebind everything in sight, but > this particular usage seems like a strange abuse I wouldn't expect a > code-checker to be able to figure out. I'll just avoid writing > confusing code like that... it's not only

hotmail filter question with list

2005-08-11 Thread Ivan Shevanski
Just a quick mailing question for anyone who uses hotmail and gets this. Im having problems with my filters =/ i have a filter for mails with python-list@python.org in to or cc, but i still get some in my inbox. anyone? -Ivan _

Re: Pre-PEP Proposal: Codetags

2005-08-11 Thread Bengt Richter
On Thu, 11 Aug 2005 08:47:37 +0200, =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= <[EMAIL PROTECTED]> wrote: >Micah Elliott wrote: >> I also have this living as a wiki >> if people would like to add comments there. I might try to capture there >> feedback from th

Python Challenge on BBC

2005-08-11 Thread Magnus Lie Hetland
Just saw this on the BBC World program Click Online: http://bbcworld.com/content/template_clickonline.asp?pageid=665&co_pageid=6 I must say, I think this is the first time I've heard Python discussed on TV at all... Cool :) (Now maybe I'll have to finish the rest of those P.C. levels... ;) --

Re: performance of recursive generator

2005-08-11 Thread Steven Bethard
aurora wrote: > I love generator and I use it a lot. Lately I've been writing some > recursive generator to traverse tree structures. After taking closer > look I have some concern on its performance. > > Let's take the inorder traversal from > http://www.python.org/peps/pep-0255.html as an

Re: Python interpreter error: unsupported operand type(s) for |:

2005-08-11 Thread Szabolcs Nagy
you cannot use | with two dict (dict has no .__or__ method) what are you trying to do? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to quit a Windows GUI program gracefully with Python under Cygwin?

2005-08-11 Thread ina
Send the active program an alt-f4. I do this through shell.send keys. Hope this was of help. KB wrote: > Hi, > > I want to write a Python script that controls and automates a Windows > GUI computation program. > > My problem is that I do not know how to quit the Windows GUI program > gracefully w

Re: breaking a loop

2005-08-11 Thread [EMAIL PROTECTED]
What you do is asking for a string, and then embed the result in '%' characters, as this is what you do in the sql statement (btw: where is the cursor defined?) It is probably a better idea to construct the sql statement with the direct result of raw_input, instead of format it straight away - see

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Jeff Schwab wrote: > John Machin wrote: > >> Search for r'^something' can never be better/faster than match for >> r'something', and with a dopey implementation of search [which >> Python's re is NOT] it could be much worse. So please don't tell >> newbies to search for r'^something'. > > > H

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Duncan Booth wrote: > John Machin wrote: > > >>>Alternatively for C style #includes search for r'^\s*#\s*include\b'. >> >>Search for r'^something' can never be better/faster than match for >>r'something', and with a dopey implementation of search [which >>Python's re is NOT] it could be much wor

Re: breaking a loop

2005-08-11 Thread infidel
> Desired behavior: when I type 'exit' the program should quit. def search(): user_input = '' while True: user_input = raw_input('Search for: ') if user_input == 'exit': break print 'processing', user_input Note that putting user input directly into SQL statements

Re: command line reports

2005-08-11 Thread Bengt Richter
On Thu, 11 Aug 2005 15:43:23 -0400, Darren Dale <[EMAIL PROTECTED]> wrote: >Peter Hansen wrote: > >> Darren Dale wrote: >>> Is there a module somewhere that intelligently deals with reports to the >>> command line? I would like to report the progress of some pretty lengthy >>> simulations, and cur

Re: Why does __init__ not get called?

2005-08-11 Thread Steven Bethard
Rob Conner wrote: > By chance... does anyone know, if I wrote a class, and just wanted to > override __new__ just for the fun of it. What would __new__ look like > so that it behaves exactly the same as it does any other time. Simple: class C(object): def __new__(cls, *args, **kwargs):

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Aahz wrote: > In article <[EMAIL PROTECTED]>, > John Machin <[EMAIL PROTECTED]> wrote: > >>Search for r'^something' can never be better/faster than match for >>r'something', and with a dopey implementation of search [which Python's >>re is NOT] it could be much worse. So please don't tell newbi

Re: Python interpreter error: unsupported operand type(s) for |:

2005-08-11 Thread Bruno Desthuilliers
Szabolcs Nagy a écrit : > you cannot use | with two dict (dict has no .__or__ method) > > what are you trying to do? > read the post: "need help with python syntax"... (posted one hour sooner) -- http://mail.python.org/mailman/listinfo/python-list

Re: Gotchas in user-space matplotlib install?

2005-08-11 Thread John Hunter
> "Matt" == Matt Feinstein <[EMAIL PROTECTED]> writes: Matt> Hi all-- I'm planning to try to do a completely local Matt> install of matplotlib (in Fedora Core 1)-- the system Matt> administrator isn't going to stop me-- but he isn't going to Matt> cooperate either. I've got the

Re: Python interpreter error: unsupported operand type(s) for |:

2005-08-11 Thread Bruno Desthuilliers
yaffa a écrit : > hey folks i get this error: Python interpreter error: unsupported > operand type(s) for |: > > when i run this line of code: > > for incident in bs('tr', {'bgcolor' : '#ee'} | {'bgcolor' : > 'white'} ): > > any idea what i'm doing wrong here? yes: trying to do a bitwis

Python Wireless Extension Module (pyiw)

2005-08-11 Thread Jeremy Moles
I am mostly done with writing an extension module in C that wraps (and makes easier) interfacing with libiw (the library that powers iwconfig, iwlist, and friends on Linux). We're using this internally for a tool to manage wireless connectivity. This is a million times better than hundreds of invoc

Printing literal text of an argument

2005-08-11 Thread Rex Eastbourne
Hi all, I've written the following simple macro called debug(aname, avalue) that prints out the name of an expression and its value: def debug(aname, avalue): print aname, 'is': pprint.pprint(avalue) An example call is: debug('compose(f1,f2)', compose(f1,f2)) Writing the exact same thi

Re: Python supports LSP, does it?

2005-08-11 Thread Kay Schluehr
[EMAIL PROTECTED] wrote: > On Thu, 11 Aug 2005 01:19:19 +0100 > phil hunt wrote: > > > According to Wikipedia, the Liskov substitution principle is: > > > > Let q(x) be a property provable about objects x of type T. Then > > q(y) should be true for objects y of type S where S is a subtype of T

Re: python2.4/site-packages

2005-08-11 Thread Lucas Raab
Michael Hoffman wrote: > Srinivasan TK wrote: > >> Now ,Is it mandatory that I build the third-party >> packages ( python2.4/site-packages) . > > > Only if you want to use them. Really, no. > >> If so is there a >> list that needs to be built and installed . > > > There is a list of them pack

Re: need help with python syntax

2005-08-11 Thread Bengt Richter
On 11 Aug 2005 11:56:49 -0700, "yaffa" <[EMAIL PROTECTED]> wrote: >dear python gurus, > >quick question on syntax. > >i have a line of code like this > >for incident in bs('tr', {'bgcolor' : '#ee'}): > > >what i want it to do is look for 'bgcolor' : '#ee' or 'bgcolor' : >'white' and then

Re: regex help

2005-08-11 Thread Shantanoo Mahajan
John Machin wrote: > jeff sacksteder wrote: >> Regex questions seem to be rather resistant to googling. >> >> My regex currently looks like - 'FOO:.*\n\n' >> >> The chunk of text I am attempting to locate is a line beginning with >> "FOO:", followed by an unknown number of lines, terminating wit

Re: need help with python syntax

2005-08-11 Thread Bruno Desthuilliers
yaffa a écrit : > dear python gurus, One effectively needs to have some guru-powers to answer you question... > quick question on syntax. > > i have a line of code like this > > for incident in bs('tr', {'bgcolor' : '#ee'}): > > > what i want it to do is look Where ? > for 'bgcolor' :

Re: performance of recursive generator

2005-08-11 Thread aurora
On Thu, 11 Aug 2005 01:18:11 -0700, Matt Hammond <[EMAIL PROTECTED]> wrote: > >> Is it an inherent issue in the use of recursive generator? Is there any >> compiler optimization possible? > > Hi, I could be misunderstanding it myself, but I think the short answer > to your question is that i

Re: need help with python syntax

2005-08-11 Thread Cyril Bazin
I think bs = BeautifulSoup.BeautifulSoup( oFile) but I don't understand what you are doing... (I never used BeautifulSoup...) Maybe It is somthing like: import itertools for incident in itertools.chain(bs('tr',  {'bgcolor' : '#ee'}), bs('tr',  {'bgcolor' : 'white'})):     do_something() Look

Re: performance of recursive generator

2005-08-11 Thread aurora
> You seem to be assuming that a yield statement and a function call are > equivalent. I'm not sure that's a valid assumption. I don't know. I was hoping the compiler can optimize away the chain of yields. > Anyway, here's some data to consider: > > test.py -

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

2005-08-11 Thread John Machin
bruno modulix wrote: > Daniel Schüle wrote: > >>Hello >> >>I wrote a simple module, which is also supposed to be used as standalone >>program >>after considering how to avoid multiple if's I came up with this idea >> >>if __name__ == "__main__": >>if len(sys.argv) not in (3,4): >>prin

Re: Python Wireless Extension Module (pyiw)

2005-08-11 Thread Peter Decker
On 8/11/05, Jeremy Moles <[EMAIL PROTECTED]> wrote: > Anyway, I am just curious... we plan on using it, at any rate. It's > already made the code easier to read, faster, and more reliable. Looks pretty useful to me! -- # p.d. -- http://mail.python.org/mailman/listinfo/python-list

Re: about coding

2005-08-11 Thread John Machin
Paul Watson wrote: > cantabile wrote: > >> Hi, being a newbie in Python, I'm a bit lost with the '-*- coding : >> -*-' directive. >> >> I'm using an accented characters language. Some of them are correctly >> displayed while one doesn't. I've written : >> -*- coding: utf-8 -*- >> >> Is this wron

Re: PEP 328, absolute/relative import

2005-08-11 Thread Bengt Richter
On Thu, 11 Aug 2005 14:55:57 -0400, Peter Hansen <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> Will/should an __init__.py in the current directory be required, >> to control what happens (and lessen the probability of accidental >> collision from a random working directory)? > >I don't think

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

2005-08-11 Thread Bruno Desthuilliers
John Machin a écrit : > bruno modulix wrote: > (snip) >> >> Nope. But since you're running this on a very peculiar OS, I just can >> guess that this very peculiar OS consider all args to be one same >> string... > > > NOT SO: Your cap key got stuck ? (snip) > For *any* OS: More than one CLI

Re: Regular expression to match a #

2005-08-11 Thread Devan L
John Machin wrote: > Aahz wrote: > > In article <[EMAIL PROTECTED]>, > > John Machin <[EMAIL PROTECTED]> wrote: > > > >>Search for r'^something' can never be better/faster than match for > >>r'something', and with a dopey implementation of search [which Python's > >>re is NOT] it could be much wor

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Devan L wrote: > John Machin wrote: > >>Aahz wrote: >> >>>In article <[EMAIL PROTECTED]>, >>>John Machin <[EMAIL PROTECTED]> wrote: >>> >>> Search for r'^something' can never be better/faster than match for r'something', and with a dopey implementation of search [which Python's re is

Re: Printing literal text of an argument

2005-08-11 Thread Jeremy Moles
def debug(s): print "s" exec(s) The line thing i'm not so sure about. Er. Hmmm. On Thu, 2005-08-11 at 14:04 -0700, Rex Eastbourne wrote: > Hi all, > > I've written the following simple macro called debug(aname, avalue) > that prints out the name of an expression and its value: >

Re: Regular expression to match a #

2005-08-11 Thread Devan L
John Machin wrote: > Devan L wrote: > > John Machin wrote: > > > >>Aahz wrote: > >> > >>>In article <[EMAIL PROTECTED]>, > >>>John Machin <[EMAIL PROTECTED]> wrote: > >>> > >>> > Search for r'^something' can never be better/faster than match for > r'something', and with a dopey implementa

Re: Regular expression to match a #

2005-08-11 Thread John Machin
John Machin wrote: > Devan L wrote: > >> John Machin wrote: >> >>> Aahz wrote: >>> In article <[EMAIL PROTECTED]>, John Machin <[EMAIL PROTECTED]> wrote: > Search for r'^something' can never be better/faster than match for > r'something', and with a dopey implementatio

Re: Python supports LSP, does it?

2005-08-11 Thread Mike Meyer
Gregory Bond <[EMAIL PROTECTED]> writes: > phil hunt wrote: >> Let q(x) be a property provable about objects x of type T. Then >> q(y) should be true for objects y of type S where S is a subtype of T >> To me, this is nonsense. Under this definition any subtype must >> behave the same as its pa

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Devan L wrote: > John Machin wrote: > >>Devan L wrote: >> >>>John Machin wrote: >>> >>> Aahz wrote: >In article <[EMAIL PROTECTED]>, >John Machin <[EMAIL PROTECTED]> wrote: > > > >>Search for r'^something' can never be better/faster than match for >>r'som

Re: Why is this?

2005-08-11 Thread John Hazen
> [[]]*2 > > [[], []] > [[], []] == [[]]*2 > > True > > Same effect. But try the 'is' operator, to see if they are actually the > same instances of 'empty list': > > [[], []] is [[]]*2 > > True Just curious, did you actually cut and paste this from a real interactive session? (

The python license model

2005-08-11 Thread Ramza Brown
Can you distribute a python system with only a couple of libraries that you plan to use. For example, I generally avoid having a system with hundreds of loose scripts(ie python library). So, I have considered only taking the libraries I need. My question, is python license friendly for doing

Re: command line reports

2005-08-11 Thread Darren Dale
Bengt Richter wrote: > On Thu, 11 Aug 2005 15:43:23 -0400, Darren Dale <[EMAIL PROTECTED]> wrote: > >>Peter Hansen wrote: >> >>> Darren Dale wrote: Is there a module somewhere that intelligently deals with reports to the command line? I would like to report the progress of some pretty >

Can't start new thread

2005-08-11 Thread Hughes, Chad O
Title: Can't start new thread I am trying to understand what is causing python to raise this error when I create a number of threads: thread.error: can't start new thread I have been told that it is due to the default thread size (1 MB), but I have recompiled python defining an alternate

Re: performance of recursive generator

2005-08-11 Thread Steven Bethard
aurora wrote: > This test somehow water down the n^2 issue. The problem is in the depth > of recursion, in this case it is only log(n). It is probably more > interesting to test: > > def gen(n): > if n: > yield n > for i in gen(n-1): > yield i You should be

Re: The python license model

2005-08-11 Thread Ramza Brown
Ramza Brown wrote: > Can you distribute a python system with only a couple of libraries that > you plan to use. For example, I generally avoid having a system with > hundreds of loose scripts(ie python library). So, I have considered > only taking the libraries I need. My question, is python

Re: Why does __init__ not get called?

2005-08-11 Thread Steven Bethard
Steven Bethard wrote: > def __call__(cls, *args, **kwargs): > obj = cls.__new__() > if not isinstance(obj.__class__, cls): ^^ issubclass > return obj > obj.__class__.__init__(obj, *args, **kwargs) > return obj STeVe -- http://mail.pytho

Help sorting a list by file extension

2005-08-11 Thread Peter A.Schott
Trying to operate on a list of files similar to this: test.1 test.2 test.3 test.4 test.10 test.15 test.20 etc. I want to sort them in numeric order instead of string order. I'm starting with this code: import os for filename in [filename for filename in os.listdir(os.getcwd())]: print

Printing to printer

2005-08-11 Thread Steve M
Hello, I'm having problems sending information from a python script to a printer. I was wondering if someone might send me in the right direction. I wasn't able to find much by Google TIA Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: The python license model

2005-08-11 Thread Aahz
In article <[EMAIL PROTECTED]>, Ramza Brown <[EMAIL PROTECTED]> wrote: > >Can you distribute a python system with only a couple of libraries that >you plan to use. For example, I generally avoid having a system with >hundreds of loose scripts(ie python library). So, I have considered >only ta

pcapy help

2005-08-11 Thread billiejoex
Hi man! I found a post of yours in wich you tell that you use pcapy python module to capture packets. I need to do something similar but unfortunately I can't find too much domentation (and example codes) about this library.   Can you paste me a simple code in wich you use this module for

Re: Printing to printer

2005-08-11 Thread Kristian Zoerhoff
On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote: > Hello, > >I'm having problems sending information from a python > script to a printer. I was wondering if someone might send me > in the right direction. I wasn't able to find much by Google Which platform? Directions will vary wildly. --

Re: Printing to printer

2005-08-11 Thread Steve M
Kristian Zoerhoff wrote: > On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote: >> Hello, >> >>I'm having problems sending information from a python >> script to a printer. I was wondering if someone might send me >> in the right direction. I wasn't able to find much by Google > > Which platfo

Re: Help sorting a list by file extension

2005-08-11 Thread Bengt Richter
On Fri, 12 Aug 2005 00:06:17 GMT, Peter A. Schott <[EMAIL PROTECTED]> wrote: >Trying to operate on a list of files similar to this: > >test.1 >test.2 >test.3 >test.4 >test.10 >test.15 >test.20 > >etc. > >I want to sort them in numeric order instead of string order. I'm starting >with >this code:

Jargons of Info Tech industry

2005-08-11 Thread Xah Lee
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like extraneous jargons, such as in the Unix & Perl community. Unlike mathematicians, where in mathematics there a

Re: Jargons of Info Tech industry

2005-08-11 Thread Erik Max Francis
Xah Lee wrote: > Jargons of Info Tech industry > > (A Love of Jargons) > > Xah Lee, 2002 Feb Congratulations, this time you managed to get to your second paragraph before your Tourette's kicked in. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 3

keywords for optional args in extension modules

2005-08-11 Thread Sean Richards
Python 2.3.4 (#1, May 29 2004, 17:05:23) [GCC 3.3.3] on linux2 Getting some strange behaviour with keyword arguments for optional arguments in extension modules. See the simple test case below 8<-- #include "Python.h" static PyObject * ke

Re: Jargons of Info Tech industry

2005-08-11 Thread Ivan Van Laningham
Hi All-- Erik Max Francis wrote: > > Xah Lee wrote: > > > Jargons of Info Tech industry > > > > (A Love of Jargons) > > > > Xah Lee, 2002 Feb > > Congratulations, this time you managed to get to your second paragraph > before your Tourette's kicked in. > You made it that far? Congratulations

Re: Writing a small battleship game server in Python

2005-08-11 Thread Mike Meyer
Dan <[EMAIL PROTECTED]> writes: >> The server should accept connections from new players and be able to handle >> multiple games concurrently. > > Multiple threads would be the way to go for a real application. But if > you want to avoid the complexity involved in threading and > synchronization

Re: thread limit in python

2005-08-11 Thread Bryan Olson
[EMAIL PROTECTED] wrote: > disregard the C example. wasn't checking the return code of > pthread_create. the C program breaks in the same place, when creating > the 1021st thread. So that's pretty good evidence that it's an OS limit, not a Python limit. The most likely problem is that the sta

Re: command line reports

2005-08-11 Thread Peter Hansen
Darren Dale wrote: > Thanks, I didnt realize that \r is different from \n. \r has is a byte with value 13, which is the Carriage Return (CR) control character in ASCII. \n has value 10 and is the Line Feed (LF) character. CR is named after the old teletypewriter operation involving moving the

Re: Jargons of Info Tech industry

2005-08-11 Thread Jürgen Exner
Xah Lee wrote: > Jargons of Info Tech industry > > (A Love of Jargons) > > Xah Lee, 2002 Feb > > People in the computing field like to spur the use of spurious > jargons. The less educated they are, the more they like extraneous [...] Just for the records at Google et.al. in case someone stumbles

Re: Printing literal text of an argument

2005-08-11 Thread Mike Meyer
[Format recovered from top posting] Jeremy Moles <[EMAIL PROTECTED]> writes: > On Thu, 2005-08-11 at 14:04 -0700, Rex Eastbourne wrote: >> Hi all, >> >> I've written the following simple macro called debug(aname, avalue) >> that prints out the name of an expression and its value: >> >> def debug

Re: Bug in slice type

2005-08-11 Thread Bryan Olson
Steven Bethard wrote: > I suspect there's a reason that it's done this way, but I agree with you > that this seems strange. Have you filed a bug report on Sourceforge? I gather that the slice class is young, so my guess is bug. I filed the report -- my first Sourceforge bug report. > BTW, a s

Re: Help sorting a list by file extension

2005-08-11 Thread George Yoshida
Bengt Richter wrote: [name for dec,name in sorted((int(nm.split('.')[1]),nm) for nm in namelist)] > > ['test.1', 'test.2', 'test.3', 'test.4', 'test.10', 'test.15', 'test.20'] Giving a key argument to sorted will make it simpler:: >>> sorted(namelist, key=lambda x:int(x.rsplit('.')[-1])) --

Re: FTP over SSL (explicit encryption)

2005-08-11 Thread David Isaac
> David Isaac wrote: > > I am looking for a pure Python secure ftp solution. > > Does it exist? "Andrew MacIntyre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I recall coming across an extension package (pretty sure it wasn't pure > Python anyway, certainly not for the SSL bits)

Re: Printing literal text of an argument

2005-08-11 Thread Gregory Bond
Rex Eastbourne wrote: > def debug(aname, avalue): > print aname, 'is': > pprint.pprint(avalue) > use eval: def debug(s): print s, 'is' pprint.pprint(eval(s)) (it does mean the arg is a string not code..) > On a > slightly different topic, is it also possible to ma

Re: Printing literal text of an argument

2005-08-11 Thread Rex Eastbourne
Thanks. I adapted it a bit: def debug(foo): print foo, 'is:' exec('pprint.pprint(' + foo + ')') But I'm getting "NameError: name 'foo' is not defined," since foo is not defined in this scope. (The function works beautifully when I'm dealing with global variables, which is very rarely). A

Re: Bug in slice type

2005-08-11 Thread John Machin
Steven Bethard wrote: > Bryan Olson wrote: > >> >> class BuggerAll: >> >> def __init__(self, somelist): >> self.sequence = somelist[:] >> >> def __getitem__(self, key): >> if isinstance(key, slice): >> start, stop, step = key.indices(len(

NEWB: General purpose list iteration?

2005-08-11 Thread Donald Newcomb
I'm a real Python NEWB and am intrigued by some of Python's features, so I'm starting to write code to do some things to see how it works. So far I really like the lists and dictionaries since I learned to love content addressability in MATLAB. I was wondering it there's a simple routine (I think

How do these Java concepts translate to Python?

2005-08-11 Thread Ray
Hello, 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) 2. How does Python know whether a class i

Re: Jargons of Info Tech industry

2005-08-11 Thread Roedy Green
On 11 Aug 2005 18:23:42 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote or quoted : >The Jargons of >marketing came from business practice, and they can be excusable >because they are kinda a necessity or can be considered as a naturally >evolved strategy for attracting attention in a laissez-faire eco

Psyco & Linux

2005-08-11 Thread Fausto Arinos Barbuto
Hi All; I have Psyco (on Windows XP) and now I want to install it on Linux, too. I FTP'd the tarball (tar.gz) from Psyco's site but can't get it compiled. First, I tried the usual "python setup.py install" but that did not work. I later found a RPM for Psyco but it wasn't suitable

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Fausto Arinos Barbuto
Ray wrote: > 1. Where are the access specifiers? (public, protected, private) AFAIK, there is not such a thing in Python. ---Fausto -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing to printer

2005-08-11 Thread Kristian Zoerhoff
On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote: > Kristian Zoerhoff wrote: > > > On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote: > >> Hello, > >> > >>I'm having problems sending information from a python > >> script to a printer. I was wondering if someone might send me > >> in the right dir

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Devan L
Fausto Arinos Barbuto wrote: > Ray wrote: > > > 1. Where are the access specifiers? (public, protected, private) > > AFAIK, there is not such a thing in Python. > > ---Fausto Well, technically you can use _attribute to mangle it, but technically speaking, there are no public, protected, or pr

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Ray
Fausto Arinos Barbuto wrote: > Ray wrote: > > > 1. Where are the access specifiers? (public, protected, private) > > AFAIK, there is not such a thing in Python. So everything is public? I know that you can prefix a member with underscores to make something private, but how about protected, for

Re: NEWB: General purpose list iteration?

2005-08-11 Thread Devan L
def descend(iterable): if hasattr(iterable, '__iter__'): for element in iterable: descend(element) else: do_something(iterable) This will just do_something(object) to anything that is not an iterable. Only use it if all of your nested structures are of the same

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Ray
Devan L wrote: > Fausto Arinos Barbuto wrote: > > Ray wrote: > > > > > 1. Where are the access specifiers? (public, protected, private) > > > > AFAIK, there is not such a thing in Python. > > > > ---Fausto > > Well, technically you can use _attribute to mangle it, but technically > speaking, th

SSL postgresql & pgdb

2005-08-11 Thread James Saker
Just curious if anyone's aware of a good recipe for setting up SSL access to postgresql for pgdb (or another appropriate db-sig 2 compliant module). Or any good recommendations/considerations e.g. m2crypto with pgdb. jamie -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Challenge on BBC

2005-08-11 Thread Jeff Schwab
Magnus Lie Hetland wrote: > Just saw this on the BBC World program Click Online: > > http://bbcworld.com/content/template_clickonline.asp?pageid=665&co_pageid=6 > > I must say, I think this is the first time I've heard Python discussed > on TV at all... Cool :) > > (Now maybe I'll have to fini

Re: Psyco & Linux

2005-08-11 Thread Steve M
> First, I tried the usual "python setup.py install" but that did not work. How exactly did it fail? Perhaps you can paste the error output from this command. -- http://mail.python.org/mailman/listinfo/python-list

any multi-pattern mathching for python

2005-08-11 Thread [EMAIL PROTECTED]
as I know , agrep can handle this , at least the newer version from http://www.tgries.de/agrep/index.html with a -f property. here is a agrep port to python http://www.bio.cam.ac.uk/~mw263/pyagrep.html, but it is some out of date, and in it's discription "matching of multiple input patterns is def

list to tuple

2005-08-11 Thread zxo102
Hi, I got several dynamic lists a1, b1, c1, from a python application such as a1 = [1,5,3,2,5,...], the len(a1) varies. Same to b1, c1, With python, I would like to reorganize them into a tuple like t1 = ((a1[0],b1[0],c1[0],...),(a1[1],b1[1],c1[1],...),...) Anybody knows

Re: Bug in slice type

2005-08-11 Thread Bryan Olson
John Machin wrote: > Steven Bethard wrote: [...] >> BTW, a simpler example of the same phenomenon is: >> >> py> range(10)[slice(None, None, -2)] >> [9, 7, 5, 3, 1] >> py> slice(None, None, -2).indices(10) >> (9, -1, -2) >> py> range(10)[9:-1:-2] >> [] >> > > >>> rt = range(10) > >>>

Re: Python Challenge on BBC

2005-08-11 Thread could ildg
But when I can't find a way for a long time, I'll be upset. On 8/12/05, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Magnus Lie Hetland wrote: > > Just saw this on the BBC World program Click Online: > > > > > > http://bbcworld.com/content/template_clickonline.asp?pageid=665&co_pageid=6 > > > > I m

Re: Jargons of Info Tech industry

2005-08-11 Thread Keith Thompson
Roedy Green <[EMAIL PROTECTED]> writes: > On 11 Aug 2005 18:23:42 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote or > quoted : [ the usual nonsense ] > > Jargon [...] [snip] Take a look at the Newsgroups: line. Then look for other articles Xah Lee has posted, and see if you can make sense of any of t

constructing bytestrings

2005-08-11 Thread Lenny G.
I use 's = os.read(fd, 12)' to grab 12 bytes from a file. Now, I want to create a string, s1, which contains 16-12=4 bytes: 4,0,0,0, followed by the contents of s. I know how to 's1 = "\x04\x00\x00\x00"' and how to 's3 = s1+s', but I don't know how to construct s1 dynamically (i.e., given N, cons

How to Adding Functionality to a Class by metaclass(not by inherit)

2005-08-11 Thread Kyo Guan
How to Adding Functionality to a Class by metaclass(not by inherit) #example: import inspect class Foo(object): def f(self): pass def g(self): pass class MetaFoo(type): def __init__(cls, name, bases, dic):

Re: Pre-PEP Proposal: Codetags

2005-08-11 Thread mdelliot
Wow, thanks for all the quick responses! Martin wrote: > the PEP author is typically expected to implement the proposed > functionality (in many cases, having a draft implementation is > prerequisite to accepting it). Fuzzyman wrote: > ...you could take your proposal forward by developing a set o

<    1   2   3   >