Re: dictionary that discards old items

2005-07-23 Thread Bengt Richter
On Sat, 23 Jul 2005 20:07:25 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >[Raymond Hettinger] >>>class Cache(dict): >>> def __init__(self, n, *args, **kwds): >>> self.n = n >>> self.queue = collections.deque() >>> dict.__init__(self, *args, **kwds) > >[Bengt Richter] >> Mi

Re: is this pythonic?

2005-07-23 Thread Eric Pederson
"Caleb Hattingh" <[EMAIL PROTECTED]> wrote: >In another > newsgroup, I could have been flamed for letting Simon know he helped > more > than just the OP with his post :) +1 OP asks, thousands are educated (perhaps). The group's generosity is greatly appreciated, even if that appreciation

How do i do this

2005-07-23 Thread Amit Regmi
For some commad Linux like (pdbedit) its not possible to supply password in the command line itself while we add a samba user account into the SAM database .. Now I want' to design an AddAccount() method in Python i.e when we can't do "pdbedit -adduser x%password" How do I ma

Re: Filtering out non-readable characters

2005-07-23 Thread Bengt Richter
On Sun, 17 Jul 2005 15:42:08 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> Thanks for the nudge. Actually, I know about generator expressions, but >> at some point I must have misinterpreted some bug in my code to mean >> that join in particular didn't like generator ex

Re: Filtering out non-readable characters

2005-07-23 Thread Bengt Richter
On Sat, 16 Jul 2005 23:28:02 -0400, "George Sakkis" <[EMAIL PROTECTED]> wrote: >"Peter Hansen" <[EMAIL PROTECTED]> wrote: > >> George Sakkis wrote: >> > "Peter Hansen" <[EMAIL PROTECTED]> wrote: >> Where did you learn that, George? >> > >> > Actually I first read about this in the Cookbook; t

Re: Filtering out non-readable characters

2005-07-23 Thread Bengt Richter
On 17 Jul 2005 18:32:28 -0700, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >[George Sakkis] >> It's only obvious in the sense that _after_ you see this idiom, you can go >> back to the docs and >> realize it's not doing something special; OTOH if you haven't seen it, it's >> not at all the ob

Re: "Aliasing" an object's __str__ to a different method

2005-07-23 Thread Bengt Richter
On Sat, 23 Jul 2005 10:59:56 -0400, "Jeffrey E. Forcier" <[EMAIL PROTECTED]> wrote: >Thanks for all the additional replies thus far! > >Apparently the issue, as stated implicitly or explicitly by most of >you, is that new-style class instances essentially defer their magic >methods to the cla

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 17:51:31 -0600, John Roth wrote: > I also like to know the number of elements, which seems to make > sense as len(path). Again, the number of characters in the path seems > to be utterly useless information - at least, I can't imagine a use for > it. There are (were?) operatin

Re: Getting a dictionary from an object

2005-07-23 Thread Steven D'Aprano
On Sun, 24 Jul 2005 02:09:54 +0300, Thanos Tsouanas wrote: > On Sat, Jul 23, 2005 at 11:22:21PM +1000, Steven D'Aprano wrote: >> On Sat, 23 Jul 2005 11:48:27 +0300, Thanos Tsouanas wrote: >> > Hello. >> > >> > I would like to have a quick way to create dicts from object, so that a >> > call to fo

Re: consistency: extending arrays vs. multiplication ?

2005-07-23 Thread Dan Bishop
Soeren Sonnenburg wrote: > Hi all, > > Just having started with python, I feel that simple array operations '*' > and '+' don't do multiplication/addition but instead extend/join an > array: > > a=[1,2,3] > >>> b=[4,5,6] > >>> a+b > [1, 2, 3, 4, 5, 6] > > instead of what I would have expected: > [5

Re: consistency: extending arrays vs. multiplication ?

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 18:30:02 +0200, Soeren Sonnenburg wrote: > Hi all, > > Just having started with python, I feel that simple array operations '*' > and '+' don't do multiplication/addition but instead extend/join an > array: * and + are not array operations, they are list operations. Lists in

Re: Getting a dictionary from an object

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 13:50:36 -0400, Mike Meyer wrote: >> I don't think this is particularly useful behaviour. How do you use it? > > def __str__(self): > return self._format % self That doesn't work. It calls self.__str__ recursively until Python halts the process. >>> class Thing(d

Re: Lists & "pointers"

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 17:03:08 +0200, Jan Danielsson wrote: > The problem is that I have initialized the list like this: > > self.drawAttr = { blah, blah, blah.. } > self.storedAttr = [ ] > for i in range(0, 10): >self.storedAttr.append(self.drawAttr) > >I know what the problem is; they ar

what's wrong with my code using subprocess?

2005-07-23 Thread Qiangning Hong
I decide to seperate my data collection routine from my data analysis and storage program to a seperate process, so I try to use the new subprocess model in Python 2.4. The main program spawns the subprocess and receives data from the pipe. When some event occurs (e.g. the user clicks the 'Stop'

Re: return None

2005-07-23 Thread Christopher Subich
Christopher Subich wrote: > print '%s returns:', retval Not that it matters, but this line should be: print '%s returns:' % func.__name__, retval -- http://mail.python.org/mailman/listinfo/python-list

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Peter Hansen
Reinhold Birkenfeld wrote: [on comparing Paths and stings] > Do you have a use case for the comparison? Paths should be compared only > with other paths. I can think of lots, though I don't know that I've used any in my existing (somewhat limited) code that uses Path, but they all involve cases

Re: tuple to string?

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 23:31:04 +1000, John Machin wrote: >>>You don't need the sissy parentheses; '%c' * len(t) % t works just fine :-) >> >> >> Ah, ok. Didn't want to lookup the precedence rules... > > > Look up the precedence rules? Are you aware of any language where * / > and % _don't_ have

Re: tuple to string?

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 23:26:19 +1000, John Machin wrote: > Steven D'Aprano wrote: > >> >> >''.join(map(lambda n: chr(n), (0x73, 0x70, 0x61, 0x6D))) >> >> 'spam' > > Why the verbal diarrhoea? One line is hardly verbal diarrhoea. > What's wrong with the (already posted) > > ''.join(map(ch

Re: dictionary that discards old items

2005-07-23 Thread Steven Bethard
[Raymond Hettinger] >>class Cache(dict): >> def __init__(self, n, *args, **kwds): >> self.n = n >> self.queue = collections.deque() >> dict.__init__(self, *args, **kwds) [Bengt Richter] > Minor comment: There is a potential name collision problem for keyword > n=something, >

Re: is this possible?

2005-07-23 Thread Terry Hancock
On Saturday 23 July 2005 03:26 am, Steven D'Aprano wrote: > On Fri, 22 Jul 2005 07:59:42 -0700, scrimp wrote: > As others have suggested, if you have to deal with PDF files without > Acrobat, you could use ghostscript. Also pre-installed on many versions > of Linux, and probably other Unixes as wel

Re: Copying attributes

2005-07-23 Thread Bengt Richter
On Sat, 23 Jul 2005 18:30:29 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote: [...] >Did it work on a quad face? What about putting in a debug print before places >you use >f.normal, e.g. >assert hasattr(f, 'normal'), 'This "f"\n\n%r\n\ndid not have a > normal attribute!!' % f > >If f.re

Re: PostgreSQL & Python vs PHP

2005-07-23 Thread Ivan Voras
Luis P. Mendes wrote: > I need to build it from the server and also client side. > > For the client side I'll be using Python. > > But for the server side, I would like to hear some opinions. Is it worth > learning Php? If you know Python and don't know PHP, there's little benefit from spend

Re: Getting a dictionary from an object

2005-07-23 Thread Steven Bethard
Thanos Tsouanas wrote: > I would like to have a quick way to create dicts from object, so that a > call to foo['bar'] would return obj.bar. > > The following works, but I would prefer to use a built-in way if one > exists. Is there one? Maybe I'm not understanding your problem, but have you look

Re: "Aliasing" an object's __str__ to a different method

2005-07-23 Thread Christopher Subich
Paolino wrote: > Little less ugly: > In [12]:class A(object): >: def __str__(self):return self.__str__() >: def str(self):return 'ciao' >: def setStr(self):self.__str__=self.str >: > > In [13]:a=A() > > In [14]:a.setStr() > > In [15]:str(a) > Out[15]:'

Re: return None

2005-07-23 Thread Christopher Subich
Grant Edwards wrote: > Personally, I don't really like the idea that falling off the > botton of a function implicitly returns None. It's just not > explicit enough for me. My preference would be that if the > function didn't execute a "return" statement, then it didn't > return anyting and attem

Re: wxPython - DB Form generator unit

2005-07-23 Thread Peter Decker
On 7/19/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Is anyone know about a DB form generator unit under wxPython ? > What that's means ? > > I add information about a Query, or a ListOfDict, I set some other infos > (Lookups, others), and it is generate a Form with edit boxes, listboxes, >

Re: dictionary that discards old items

2005-07-23 Thread Bengt Richter
On 21 Jul 2005 19:29:32 -0700, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >[Will McGugan] >> I need a collection class that behaves like a dictionary but when it >> reaches 'n' items it discards the oldest item so that the length never >> goes above 'n'. (Its for caching search results) > > >i

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread John Roth
"Reinhold Birkenfeld" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I'll look into it. What about iteration and indexing? Should it support > "for element in path" or "for char in path" or nothing? I frankly can't think of a use for iterating over the characters in the path, b

Re: PyGTK or wxPython (not a flame war) on Windows

2005-07-23 Thread Marek Kubica
Hello! > How well does PyGTK run on Windows (98, 2K, XP)? How stable is it? Will > I be able to make an executable (using Py2Exe) of an application that > uses PyGTK? I _do_ like PyGTK on Windows. It works without problems. You can find a ready to use py2exe script on http://www.pythonwiki.de/PyG

Re: Getting a dictionary from an object

2005-07-23 Thread Thanos Tsouanas
On Sat, Jul 23, 2005 at 11:22:21PM +1000, Steven D'Aprano wrote: > On Sat, 23 Jul 2005 11:48:27 +0300, Thanos Tsouanas wrote: > > Hello. > > > > I would like to have a quick way to create dicts from object, so that a > > call to foo['bar'] would return obj.bar. > > That looks rather confusing to

Re: PEP on path module for standard library

2005-07-23 Thread Bengt Richter
On Sat, 23 Jul 2005 07:05:05 +1000, John Machin <[EMAIL PROTECTED]> wrote: >Daniel Dittmar wrote: >> Duncan Booth wrote: >> >>> I would have expected a path object to be a sequence of path elements >>> rather than a sequence of characters. >> >> >> Maybe it's nitpicking, but I don't think th

Re: consistency: extending arrays vs. multiplication ?

2005-07-23 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Soeren Sonnenburg wrote: > Just having started with python, I feel that simple array operations '*' > and '+' don't do multiplication/addition but instead extend/join an > array: > > a=[1,2,3] b=[4,5,6] a+b > [1, 2, 3, 4, 5, 6] Both operate on the lists themselv

Re: How can I get an sha1 hash in base32?

2005-07-23 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Elmo Mäntynen wrote: > I know how to make a hash(using mhash), but instead of encoded as hex I > want it in base32 for use with the bitzi catalog. python-bitzi is useful > but way too slow for just getting the hash of a file(am going to use it > elsewhere). Thanks. Doesn't

Re: Lists & "pointers"

2005-07-23 Thread André Malo
* Kay Schluehr wrote: > you might initialize self.storedAttr with empty dicts and fill them > later: > > self.soredAttr = [{}]*10 > for entry in self.storedAttr: > entry.update(self.drawAttr) As a matter of fact, you're doing the same ;-) In [1]: x = [{}] * 10 In [2]: x[0]['a'] = 1 In [3]

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Reinhold Birkenfeld wrote: >> Peter Hansen wrote (on Paths not allowing comparison with strings): >>>Could you please expand on what this means? Are you referring to doing >>>< and >= type operations on Paths and strings, or == and != or all those >>>or something else entir

How can I get an sha1 hash in base32?

2005-07-23 Thread Elmo Mäntynen
I know how to make a hash(using mhash), but instead of encoded as hex I want it in base32 for use with the bitzi catalog. python-bitzi is useful but way too slow for just getting the hash of a file(am going to use it elsewhere). Thanks. Elmo -- http://mail.python.org/mailman/listinfo/python-list

Re: Friend wants to learn python

2005-07-23 Thread Martin P. Hellwig
EnderLocke wrote: > I have a friend who wants to learn python programming. I learned off > the internet and have never used a book to learn it. What books do you > recommend? > > Any suggestions would be appreciated. > I recommend "Learning Python 2nd Edition" by Mark Lutz & David Ascher (O'Rei

Re: consistency: extending arrays vs. multiplication ?

2005-07-23 Thread Robert Kern
Soeren Sonnenburg wrote: > Hi all, > > Just having started with python, I feel that simple array operations '*' > and '+' don't do multiplication/addition but instead extend/join an > array: > > a=[1,2,3] This isn't an array. It is a list. If you want an array, use Numeric/numarray. If you want

Re: Lists & "pointers"

2005-07-23 Thread Kay Schluehr
Jan Danielsson wrote: > Hello all, > >I have written a simple whiteboard application. In my application, I > want to be able to set draw attributes. This part works. I have a > dictionary object which contains stuff like: > self.attr['Pen.Color'] = ... > self.attr['Pen.Thickness'] = ... > >

Re: Copying attributes

2005-07-23 Thread Bengt Richter
On Thu, 21 Jul 2005 00:45:12 +0200, red <[EMAIL PROTECTED]> wrote: >Hi, > >I'm writing a script for Blender and need to build a face array. My >engine needs that all faces must be triangles, so I convert quads to >triangles by dividing them into two triangles. Here is the function: > >def build_f

Re: PostgreSQL & Python vs PHP

2005-07-23 Thread Luis P. Mendes
gene tani wrote: > ok, to make this less open-ended, you should mention what O/S and web > server you have in mind, whether the web and DB servers will be under > your admin (big diff betw python and PHP, as far as finding shared > server accounts at web hosts), what kinds of queries, concurrent >

Re: unit test nested functions

2005-07-23 Thread Benji York
Raymond Hettinger wrote: > [Benji York] > >>Note that when using this technique, f.g will not be bound until after >>you call the function: > > > That is a feature, not a bug. The inner function isn't even created > until the outer function is run. I'm fully aware of that. I just didn't want

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Mike Meyer
Peter Hansen <[EMAIL PROTECTED]> writes: >> * staticmethod Path.getcwd() -> Path.cwd() >> * bytes() / lines() / text() -> read_file_{bytes,lines,text} methods >> * write_{bytes,lines,text} -> write_file_{bytes,lines,text} methods > Under Linux isn't it possible to open and read from directories mu

Re: PostgreSQL & Python vs PHP

2005-07-23 Thread Luis P. Mendes
gene tani wrote: > To be honest, this is a pretty open-ended question. Are there specific > issues (SQL injection/security, minimizing db connections, simplest > code, etc, your'e concerned with?) Simplest code with be an important factor, since the db will be used far from max capabilities. Eas

Re: PostgreSQL & Python vs PHP

2005-07-23 Thread gene tani
ok, to make this less open-ended, you should mention what O/S and web server you have in mind, whether the web and DB servers will be under your admin (big diff betw python and PHP, as far as finding shared server accounts at web hosts), what kinds of queries, concurrent read/write volumes, transac

Re: Getting a dictionary from an object

2005-07-23 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Sat, 23 Jul 2005 11:48:27 +0300, Thanos Tsouanas wrote: >> Hello. >> >> I would like to have a quick way to create dicts from object, so that a >> call to foo['bar'] would return obj.bar. > > That looks rather confusing to me. Why not just call obj.

Re: PostgreSQL & Python vs PHP

2005-07-23 Thread gene tani
To be honest, this is a pretty open-ended question. Are there specific issues (SQL injection/security, minimizing db connections, simplest code, etc, your'e concerned with?) To be more honest, googline "Python vs. PHP" raises lots of hits http://wiki.w4py.org/pythonvsphp.html http://www.redcor.ch

Re: time.time() under load between two machines

2005-07-23 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I am seeing negative latencies of up to 1 second. I am using ntp to > synchronize both machines at an interval of 2 seconds, so the clocks > should be very much in sync (and are from what I have observed). I > agree that it is probably OS, perhaps I should hop over t

How to realize ssh & scp by Python

2005-07-23 Thread 刚 王
I would like to write a Python code like this:It can login a host by SSHafter login the host, use SCP to get a remote file, so it can deliver file to the host.then execute the programthen leave the hostFor example :STEP 1. ssh _yyy at 123.45.67.89STEP 2. Enter the password automatically STEP 3.

Re: Friend wants to learn python

2005-07-23 Thread Pietro Campesato
Maybe diveintopython.org can help -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists & "pointers"

2005-07-23 Thread George Sakkis
<[EMAIL PROTECTED]> wrote: > Jan Danielsson wrote: > > Hello all, > > > >I have written a simple whiteboard application. In my application, I > > want to be able to set draw attributes. This part works. I have a > > dictionary object which contains stuff like: > > self.attr['Pen.Color'] = ...

How to realize ssh & scp in Python

2005-07-23 Thread 陈阳
I would like to write a Python code like this:It can login a host by SSHafter login the host, use SCP to get a remote file, so it can deliver file to the host.then execute the programthen leave the hostFor example :STEP 1. ssh [EMAIL PROTECTED]STEP 2. Enter the password automatically STEP 3. run "

Friend wants to learn python

2005-07-23 Thread EnderLocke
I have a friend who wants to learn python programming. I learned off the internet and have never used a book to learn it. What books do you recommend? Any suggestions would be appreciated. -- http://mail.python.org/mailman/listinfo/python-list

Re: unit test nested functions

2005-07-23 Thread Raymond Hettinger
> > [Andy] > >>How can you unit test nested functions? [Raymond Hettinger] > > For whitebox testing, you could make an inner function visible by > > binding it to the enclosing function's attribute namespace. > > > >def f(x): > >def g(y): > > . . . > >f.g = g#

PostgreSQL & Python vs PHP

2005-07-23 Thread Luis P. Mendes
Hi, I don't know anything about PHP and I'm initiating right now with PostgreSQL. Could someone tell me the pros and cons of assessing the PostgreSQL databases with Python vs. PHP? I will need to build a database that has to be assessed by a dozen clients via a web page in an intranet (possibly

Re: PEP on path module for standard library

2005-07-23 Thread Duncan Booth
Peter Hansen wrote: > Just a note, though you probably know, that this is intended to be > written this way with path: > > >>> p / q > path(u'a/b/c/d') I know, but it really doesn't look right to me. I think that my fundamental problem with all of this is that by making path a subclass of str/

Re: Python vs. Access VBA

2005-07-23 Thread Dark Cowherd
> better to go with SQLite. Its cross platform and well proven. I think > Firebird will give you that too, though I have never used it. > Firebird is a great option, cross platform, it can work like access without any server running, using embedded mode to a full blown server which can handle t

consistency: extending arrays vs. multiplication ?

2005-07-23 Thread Soeren Sonnenburg
Hi all, Just having started with python, I feel that simple array operations '*' and '+' don't do multiplication/addition but instead extend/join an array: a=[1,2,3] >>> b=[4,5,6] >>> a+b [1, 2, 3, 4, 5, 6] instead of what I would have expected: [5,7,9] or >>> 2*a [1, 2, 3, 1, 2, 3] Well it i

Re: list implementation

2005-07-23 Thread Raymond Hettinger
> > [sj] > >> Thus, random access is an O(1) operation while insertion/deletion is an > >> O(n) operation. [Raymond Hettinger] > > Yes. [Heikki Orsila aka host.invalid] > Unfortunately no. Check Terry Reeds answer. Random access is O(1), > insertion/deletion to front is O(n), and i/d to back is O

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Peter Hansen
Reinhold Birkenfeld wrote: > Peter Hansen wrote (on Paths not allowing comparison with strings): >>Could you please expand on what this means? Are you referring to doing >>< and >= type operations on Paths and strings, or == and != or all those >>or something else entirely? > > All of these. Do

Friend wants to learn python

2005-07-23 Thread EnderLocke
I have a friend who wants to learn python programming. I learned off the internet and have never used a book to learn it. What books do you recommend? Any suggestions would be appreciated. -- http://mail.python.org/mailman/listinfo/python-list

Re: smtplib

2005-07-23 Thread Dark Cowherd
On 7/19/05, Alberto Vera <[EMAIL PROTECTED]> wrote: > Hello: > > Do you know If the smtplib routine have been changed in last releases? > > I used this script: > > http://docs.python.org/lib/SMTP-example.html > > but it didn't work with the last release. > > Do you know any idea about thi

Re: unit test nested functions

2005-07-23 Thread Benji York
Raymond Hettinger wrote: > [Andy] >>How can you unit test nested functions? > For whitebox testing, you could make an inner function visible by > binding it to the enclosing function's attribute namespace. > >def f(x): >def g(y): > . . . >f.g = g# make g vis

Re: unit test nested functions

2005-07-23 Thread Raymond Hettinger
[Andy] > How can you unit test nested functions? Or do you have to pull them out to > unit test them, which basically means I will never use nested functions. Several commons use cases (closures and factory functions) ultimately expose the inner function through the return value. If that is the

Re: What is your favorite Python web framework?

2005-07-23 Thread Benji York
Dark Cowherd wrote: > My applications would be data entry heavy. Think inventory and accounting > apps. > > Would going past the [Zope] learning curve allow me to write applications > like that. You might want to look at Zope 3, there are several niceties for automatically (or semi-automatica

Re: Lists & "pointers"

2005-07-23 Thread [EMAIL PROTECTED]
Jan Danielsson wrote: > Hello all, > >I have written a simple whiteboard application. In my application, I > want to be able to set draw attributes. This part works. I have a > dictionary object which contains stuff like: > self.attr['Pen.Color'] = ... > self.attr['Pen.Thickness'] = ... > >

problem with property docstrings

2005-07-23 Thread Michael Muller
I've observed something strange about property docstrings and I'm wondering if anyone here can clarify what's going on: if I create a class derived from property, the docstrings of the instances end up being that of the derived class, not the docstring passed into the property constructor. Examp

Re: What is your favorite Python web framework?

2005-07-23 Thread Dark Cowherd
Hi, I have also been looking around to start web development. Almost everybody says - "Zope h steep learning curve", so looking at alternatives. But to people have got past that curve. Is Zope worth it. My applications would be data entry heavy. Think inventory and accounting apps. Would goi

Re: Neat access to db query results

2005-07-23 Thread gene tani
There's a few places to stash apps, libraries, or small code snippets so they can be search engined, if you provide some inline comments, unit/functional tests, and examples of how to use/known limitations: Vaults Parnassus, dmoz, ActiveState cookbook http://aspn.activestate.com/ASPN/Cookbook/Pyth

Regarding Webbrowser Module in Python

2005-07-23 Thread M Kamran Azam
Hi all, My query goes like this. I have two htm files.One is media_try_home.htm and the second one is media_try.htm.I am attaching these files to my mail so that you guys can understand the problem. Now, first simply open the media_try_home.htm and press "PLAY THE FILE" button.A video clip

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Reinhold Birkenfeld wrote: >> One thing is still different, though: a Path instance won't compare to a >> regular >> string. > > Could you please expand on what this means? Are you referring to doing > < and >= type operations on Paths and strings, or == and != or all thos

Lists & "pointers"

2005-07-23 Thread Jan Danielsson
Hello all, I have written a simple whiteboard application. In my application, I want to be able to set draw attributes. This part works. I have a dictionary object which contains stuff like: self.attr['Pen.Color'] = ... self.attr['Pen.Thickness'] = ... Now, the problem is that I want to be

Re: Using python to runother programs

2005-07-23 Thread gene tani
this isn't really enough data to go on. What operating system (sounds like win2k/XP), does Crystal reports and unnamed accounting software have COM hooks? Look at Simon Brunning posts: http://www.brunningonline.net/simon/blog/archives/000652.html http://aspn.activestate.com/ASPN/Cookbook/Python/

Re: "Aliasing" an object's __str__ to a different method

2005-07-23 Thread Jeffrey E. Forcier
Thanks for all the additional replies thus far! Apparently the issue, as stated implicitly or explicitly by most of you, is that new-style class instances essentially defer their magic methods to the class's static versions of same. This is good to know :) Ironically, the reason I'm using new

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Robert Kern
Peter Hansen wrote: > Under Linux isn't it possible to open and read from directories much as > with files? Not really, no. Python 2.3.4 (#2, Jan 5 2005, 08:24:51) [GCC 3.3.5 (Debian 1:3.3.5-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d = open('/us

Re: PEP on path module for standard library

2005-07-23 Thread Peter Hansen
George Sakkis wrote: > "Andrew Dalke" <[EMAIL PROTECTED]> wrote: >>I think that the string representation of a path is so important that >>it *is* the path. > > There are (at least) two frequently used path string representations, > the absolute and the relative to the working directory. Which o

Re: [path-PEP] Path inherits from basestring again

2005-07-23 Thread Peter Hansen
Reinhold Birkenfeld wrote: > One thing is still different, though: a Path instance won't compare to a > regular > string. Could you please expand on what this means? Are you referring to doing < and >= type operations on Paths and strings, or == and != or all those or something else entirely?

Re: tuple to string?

2005-07-23 Thread Robert Kern
John Machin wrote: > Reinhold Birkenfeld wrote: >>Ah, ok. Didn't want to lookup the precedence rules... > > Look up the precedence rules? Are you aware of any language where * / > and % _don't_ have the same precedence?? Given that % is somewhat more esoteric, I certainly have never committed

Re: tuple to string?

2005-07-23 Thread John Machin
Reinhold Birkenfeld wrote: > John Machin wrote: > >>Reinhold Birkenfeld wrote: >> >>>Berthold Höllmann wrote: >>> >>> Francois De Serres <[EMAIL PROTECTED]> writes: >hiho, > >what's the clean way to translate the tuple (0x73, 0x70, 0x61, 0x6D) >to the string 'spa

Re: tuple to string?

2005-07-23 Thread John Machin
Steven D'Aprano wrote: > > ''.join(map(lambda n: chr(n), (0x73, 0x70, 0x61, 0x6D))) > > 'spam' Why the verbal diarrhoea? What's wrong with the (already posted) ''.join(map(chr, (0x73, 0x70, 0x61, 0x6D))) ??? -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP on path module for standard library

2005-07-23 Thread paul
Michael Hoffman wrote: > Reinhold Birkenfeld wrote: > > Probably as Terry said: a path is both a list and a string. [...] > One way to divide this is solely based on path separators: > > ['c:', 'windows', 'system32:altstream', 'test.dir', > 'myfile.txt.zip:altstream'] I would argue that any prop

Re: find a specified dictionary in a list

2005-07-23 Thread Steven D'Aprano
On Fri, 22 Jul 2005 12:42:04 +, Odd-R. wrote: > On 2005-07-22, John Machin <[EMAIL PROTECTED]> wrote: >> Odd-R. wrote: >>> I have this list: >>> >>> [{'i': 'milk', 'oid': 1}, {'i': 'butter', 'oid': 2},{'i':'cake','oid':3}] >>> >>> All the dictionaries of this list are of the same form, and a

Re: Getting a dictionary from an object

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 11:48:27 +0300, Thanos Tsouanas wrote: > Hello. > > I would like to have a quick way to create dicts from object, so that a > call to foo['bar'] would return obj.bar. That looks rather confusing to me. Why not just call obj.bar, since it doesn't look like you are actually usi

Windows Porting Help Requested

2005-07-23 Thread Raymond L. Buvel
I am preparing to release an extension module that interfaces Python to the Class Library for Numbers (http://www.ginac.de/CLN/). This module will provide Python types for arbitrary precision floating point numbers, rational numbers, and their complex counterparts. The module also includes most o

Re: Reading network interface data in linux

2005-07-23 Thread Jorgen Grahn
On Wed, 13 Jul 2005 11:09:57 +0300, Edvard Majakari <[EMAIL PROTECTED]> wrote: > > Suppose one wants to fetch the following data from given network interface, > say, eth0: > Ethinf('eth0').addr() > '192.168.1.42/24' ... Ethstat('eth0').rx_bytes() > 14325235341223 ... > One could implement

Re: Getting a dictionary from an object

2005-07-23 Thread Bruno Desthuilliers
Thanos Tsouanas a écrit : > On Sat, Jul 23, 2005 at 12:06:57PM +0200, Paolino wrote: > >>use getattr(self.obj,key) possibly, as __getattribute__ gets total >>control on attribute access > > > Thanks, but what do you mean by 'total control'? __getattribute__ is really some kind of an evil blac

Re: "Aliasing" an object's __str__ to a different method

2005-07-23 Thread Scott David Daniels
Jeffrey E. Forcier wrote: > ... > However, you appear to be correct, and the docs appear to be confused: > class MyClass(object): > def edit(self): > return "I'm in edit mode" > def setEdit(self): > MyClass.__str__ = self.edit > ... > Either way, gues

Re: Getting a dictionary from an object

2005-07-23 Thread Paolino
Thanos Tsouanas wrote: > On Sat, Jul 23, 2005 at 12:06:57PM +0200, Paolino wrote: > >>use getattr(self.obj,key) possibly, as __getattribute__ gets total >>control on attribute access > > > Thanks, but what do you mean by 'total control'? > Probably nothing to do with your question :( But: >>>

Re: tuple to string?

2005-07-23 Thread Scott David Daniels
Steven D'Aprano wrote: > On Fri, 22 Jul 2005 06:07:28 -0700, Robert Kern wrote: > ... or even: > ''.join(map(lambda n: chr(n), (0x73, 0x70, 0x61, 0x6D))) > > 'spam' This is exactly what is wrong with lambda. It yearns for over-use. This last should be: >>>''.join(map(chr, (0x73, 0x70, 0x6

Retrive file name from the window's file path

2005-07-23 Thread praba kar
Dear All, I am using Python 2.4 in the linux platform. At present I am working on webbased file manager. When I try to upload a file from the linux cgi script easily fetch the file name by the filefield.filename. But When I try to upload a file from the windows machine It won't retrieve the

Returned mail: see transcript for details

2005-07-23 Thread Mail Administrator
The original message was included as attachment This part of message has been infected and was deleted! Dr.Web(R) Daemon report: infected with Win32.HLLM.MyDoom.49 --- Dr.Web(R) Antivirus Service: http://www.drweb.com/ -

Re: Getting a dictionary from an object

2005-07-23 Thread Thanos Tsouanas
On Sat, Jul 23, 2005 at 11:30:19AM +0200, Bruno Desthuilliers wrote: > Thanos Tsouanas a écrit : > > class dictobj(dict): > > """ > > class dictobj(dict): > > A dictionary d with an object attached to it, > > which treats d['foo'] as d.obj.foo. > > """ > > def __init__(self,

Re: Getting a dictionary from an object

2005-07-23 Thread Thanos Tsouanas
On Sat, Jul 23, 2005 at 12:06:57PM +0200, Paolino wrote: > use getattr(self.obj,key) possibly, as __getattribute__ gets total > control on attribute access Thanks, but what do you mean by 'total control'? -- Thanos Tsouanas .: My Music: http://www.thanostsouanas.com/ http://thanos.sian

[path-PEP] Path inherits from basestring again

2005-07-23 Thread Reinhold Birkenfeld
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS: /python/nondist/sandbox/path/{path.py,test_path.py} One thing is still different, though: a Path instance won't compare to a regular string. O

Re: "Aliasing" an object's __str__ to a different method

2005-07-23 Thread Paolino
Little less ugly: In [12]:class A(object): : def __str__(self):return self.__str__() : def str(self):return 'ciao' : def setStr(self):self.__str__=self.str : In [13]:a=A() In [14]:a.setStr() In [15]:str(a) Out[15]:'ciao' The point is str(ob) builtin l

Re: Separation of Code in CGI App

2005-07-23 Thread Bruno Desthuilliers
Rob Cowie a écrit : > Hi, > > I need to create a planner/calendar system using python cgi scripts. It > is my first CGI app (beyond a few tutorial examples). > (snip) You may want to have a look at the cgi_app mini-framework: -> http://thraxil.org/code/cgi_app/ It's a port of a Perl framework,

SPE Ide Crash

2005-07-23 Thread linuxfreak
Hi Stani, Downloaded your latest SPE editor 0.7.4.m . I'm running wxPython 2.6.1 on a Fedora Core 4 machine. The IDE is great but guess what it crashes without warning. Was typing some code and boom the whole thing disappeared without a trace. Thought should let you know All you guys using this I

Re: Getting a dictionary from an object

2005-07-23 Thread Paolino
Thanos Tsouanas wrote: > Hello. > > I would like to have a quick way to create dicts from object, so that a > call to foo['bar'] would return obj.bar. > > The following works, but I would prefer to use a built-in way if one > exists. Is there one? > > class dictobj(dict): > """ > class

Re: Getting a dictionary from an object

2005-07-23 Thread Bruno Desthuilliers
Thanos Tsouanas a écrit : > Hello. > > I would like to have a quick way to create dicts from object, so that a > call to foo['bar'] would return obj.bar. > > The following works, but I would prefer to use a built-in way if one > exists. Is there one? > > Thanks in advance. > > class dictobj(di

Getting a dictionary from an object

2005-07-23 Thread Thanos Tsouanas
Hello. I would like to have a quick way to create dicts from object, so that a call to foo['bar'] would return obj.bar. The following works, but I would prefer to use a built-in way if one exists. Is there one? Thanks in advance. class dictobj(dict): """ class dictobj(dict): A dict

  1   2   >