how do you use a closure in a class

2005-03-29 Thread erinhouston
I have several functions that are almost the same in one class I would like to use a closure to get rid of the extra code how would I do this? -- http://mail.python.org/mailman/listinfo/python-list

Re: PyParsing module or HTMLParser

2005-03-29 Thread Paul McGuire
La - In general, I have shied away from doing general-purpose HTML parsing with pyparsing. It's a crowded field, and it's likely that there are better candidates out there for your problem. I've heard good things about BeautifulSoup, but I've also heard from at least one person that they prefer

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Bill Mill
> >> > >> Fred = 5 > >> John = 8 > >> Winner = John > >> > >> Both John and Winner are pointing to the literal '8'. > > > >ummm, yes, of course they are. What's your point? > > Hi Bill, > > My point is if you look up the name and print it, you may get. > > Instead of: > > Fred has 5 points

Re: cgi and multipart/form-data?

2005-03-29 Thread Chris Curvey
Chris Curvey wrote: I have a form like this: When I submit this form to my Python script using the CGI module, I seem to get the "myFile" variable, but I don't seem to the "foo" variable. Interestingly, if I take out the "myFile" variable (or specify a much smaller file) I do ge

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Patrick Useldinger
cjl wrote: I've found a third open source implementation in pascal (delphi), and was wondering how well that would translate to python? Being old enough to have programmed in UCSD Pascal on an Apple ][ (with a language card, of course), I'd say: go for Pascal! ;-) -- http://mail.python.org/mailma

RE: Optimisation Hints (dict processing and strings)

2005-03-29 Thread Peter Hansen
Thanks for the correction. I didn't pause to think as I wrote that... -Peter > -Original Message- > From: Aaron Bingham [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 29, 2005 11:24 > To: Peter Hansen > Cc: python-list@python.org > Subject: Re: Optimisation Hints (dict processing an

Re: Problem in designing a global directory in python

2005-03-29 Thread Tian
I googled about how to write singleton in python, but even if I use Singleton, in which module's namespace should I keep the instance of this singleton? suppose I have a singleton class definiton in "utils.py", how should I import and where should I make instance and initialize? Thanks!! -- http:

Re: Connecting to a SQL Server

2005-03-29 Thread Jarek Zgoda
ttmi napisał(a): Ok. Understood we can interface ADO from python and connect to MS SQL. But still not so clear where SSH comes in? Can elaborate more? No SSH is involved in this case -- MSSQL OLEdb provider offers SSL encrypted connection out of the box, just set appropriate property to true and

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Bill Mill
On 29 Mar 2005 11:02:38 -0800, cjl <[EMAIL PROTECTED]> wrote: > Hey all: > > Thanks for the responses... > > I've found a third open source implementation in pascal (delphi), and > was wondering how well that would translate to python? cjl, I think that the responses on the list so far collectiv

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Michael Spencer
Steven Bethard wrote: Ville Vainio wrote: "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: Raymond> If the experience works out, then all you're left with is Raymond> the trivial matter of convincing Guido that function Raymond> attributes are a sure cure for the burden of ty

Re: Who Knows of a Good Computational Physics Textbook?

2005-03-29 Thread James Stroud
Look into "Game Physics" by Eberly (Elsevier). On Sunday 13 March 2005 07:27 pm, [EMAIL PROTECTED] wrote: > There is some info on teaching computational physics at Rubin Landau's > site http://www.physics.orst.edu/~rubin/ . > > Springer recently published the book "Python Scripting for > Computati

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Ron_Adam
On Tue, 29 Mar 2005 11:23:45 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: >On Tue, 29 Mar 2005 14:34:39 GMT, Ron_Adam <[EMAIL PROTECTED]> wrote: >> On 28 Mar 2005 23:01:34 -0800, "Dan Bishop" <[EMAIL PROTECTED]> wrote: >> >> def print_vars(vars_dict=None): >> >...if vars_dict is None: >>

Need Help: Server to pass py objects

2005-03-29 Thread Sells, Fred
I have a legacy system with data stored in binary files on a remote server. I need to access and modify the content of those files from a webserver running on a different host. (All Linux) I would like to install a server on the legacy host that would use my python code to translate between the l

Re: Problem in designing a global directory in python

2005-03-29 Thread Bruno Desthuilliers
Tian a écrit : I want to create a object directory called Context in my program, which is based on a dict to save and retrieve values/objects by string-type name. I have the definition like this: utils.py global sysctx class Context: def __init__(self): def set(self, na

cgi and multipart/form-data?

2005-03-29 Thread Chris Curvey
I have a form like this: When I submit this form to my Python script using the CGI module, I seem to get the "myFile" variable, but I don't seem to the "foo" variable. Interestingly, if I take out the "myFile" variable (or specify a much smaller file) I do get the value for "foo

Re: truncating a file from the top down

2005-03-29 Thread rbt
Mike Rovner wrote: Right. Thanks for the correction. Fredrik Lundh wrote: Mike Rovner wrote: if os.stat says the_file is too big: fh = open(the_file, 'rb') fh.seek(2008, 2) should be fh.seek(-2008, 2) right? data = fh.read() fh.close() assert len(data)==2008 # you may want some error pr

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread cjl
Hey all: Thanks for the responses... I've found a third open source implementation in pascal (delphi), and was wondering how well that would translate to python? -cjl -- http://mail.python.org/mailman/listinfo/python-list

Re: good design & method calls

2005-03-29 Thread Ron_Adam
On Tue, 29 Mar 2005 09:09:37 -0500, Charles Hartman <[EMAIL PROTECTED]> wrote: >I know the answer to this is going to be "It depends . . .", but I want >to get my mind right. In Fowler's *Refactoring* I read: "Older >languages carried an overhead in subroutine calls, which deterred >people from

Re: Problem in designing a global directory in python

2005-03-29 Thread Tian
I have tried using "sysctx=None" instead of "global sysctx", but it doesn't work either. It seems my initialization work in the previous calling of init() has no persistent effect when "utils" is imported using "from myproj.utils import getContext". What's weird, when a module is in the same direc

Re: xml marshal of general (but non Python standard) class

2005-03-29 Thread "Martin v. Löwis"
syd wrote: But for my identifiedPeaks class (for instance), it has trouble. This class contains a list of "peak" classes IdentifiedPeaks.Peak... What precisely is the name of the class. You say it is IdentifiedPeaks.Peak, but... from IdentifiedPeaks import IdentifiedPeaks Here you import Identifie

Re: code for Computer Language Shootout

2005-03-29 Thread igouy
We've made it somewhat easier to contribute programs. No need to subscribe to the mailing-list. No need for a user-id or login. See the FAQ "How can I contribute a program?" http://shootout.alioth.debian.org/faq.php -- http://mail.python.org/mailman/listinfo/python-list

Re: modes for AES encryption?

2005-03-29 Thread Chris Curvey
Chris Curvey wrote: I'm trying to use the AES module in the Python Cryptography Toolkit. I need to set the mode to "ECB/NoPadding", and there's a reference to a "Mode" parameter in the new() function, but no examples for AES. Who can point me in the right direction? Answering my own question f

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Bill Mill
On Tue, 29 Mar 2005 18:08:04 GMT, Cameron Laird <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Bill Mill <[EMAIL PROTECTED]> wrote: > . > . > . > >(i.e. I respectfully disagree that mixing data with program cod

Re: truncating a file from the top down

2005-03-29 Thread Mike Rovner
Right. Thanks for the correction. Fredrik Lundh wrote: Mike Rovner wrote: if os.stat says the_file is too big: fh = open(the_file, 'rb') fh.seek(2008, 2) should be fh.seek(-2008, 2) right? data = fh.read() fh.close() assert len(data)==2008 # you may want some error processing here fh =

Re: Finding attributes in a list

2005-03-29 Thread Steven Bethard
infidel wrote: You can use the new 'sorted' built-in function and custom "compare" functions to return lists of players sorted according to any criteria: players = [ ... {'name' : 'joe', 'defense' : 8, 'attacking' : 5, 'midfield' : 6, 'goalkeeping' : 9}, ... {'name' : 'bob', 'defense'

Re: [Newbie] How do I get better at Python programming?

2005-03-29 Thread Tim Jarman
Roy Smith wrote: > keep in mind, however, that not all problems in life can be solved with > software. +1 QOTW -- Website: www DOT jarmania FULLSTOP com -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Steven Bethard
Ville Vainio wrote: "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: Raymond> If the experience works out, then all you're left with is Raymond> the trivial matter of convincing Guido that function Raymond> attributes are a sure cure for the burden of typing Raymond> impo

Re: Problem in designing a global directory in python

2005-03-29 Thread F. Petitjean
Le 29 Mar 2005 09:50:46 -0800, Tian a écrit : > I want to create a object directory called Context in my program, which > is based on a dict to save and retrieve values/objects by string-type > name. I have the definition like this: > > utils.py > > global sysctx # you are in

Automatic response to your mail (Error)

2005-03-29 Thread Webmaster
The automatic reply to this e-mail which you should have received in response to your e-mail to [EMAIL PROTECTED] has not been defined. Please contact [EMAIL PROTECTED] for assistance. -- http://mail.python.org/mailman/listinfo/python-list

Re: Get document as normal text and not as binary data

2005-03-29 Thread Markus Franz
Kent Johnson wrote: My guess is the html is utf-8 encoded - your sample looks like utf-8-interpreted-as-latin-1. Try contents = f.read().decode('utf-8') YES! That helped! I used the following: ... contents = f.read().decode('utf-8') contents = contents.encode('iso-8859-15') ... That was the perfec

Re: Get document as normal text and not as binary data

2005-03-29 Thread Markus Franz
Diez B. Roggisch wrote: Addendum: If you give us the url you're fetching data from, we might be able to look at the delivered data ourselves. To guess my problem please have a look at the document title of Markus -- http://mail.python.org/mailman/l

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Bill Mill <[EMAIL PROTECTED]> wrote: . . . >(i.e. I respectfully disagree that mixing data with program code is a bad idea) . .

Re: Distributing closed source modules

2005-03-29 Thread Dave Brueck
Fuzzyman wrote: Dave Brueck wrote: By "futile" I meant that, if the code ends up running on a user's machine, then a sufficiently motivated person could crack it wide open, regardless of implementation language - the only way to truly protect the code is to never let it out of your hands (i.e. it's

Problem in designing a global directory in python

2005-03-29 Thread Tian
I want to create a object directory called Context in my program, which is based on a dict to save and retrieve values/objects by string-type name. I have the definition like this: utils.py global sysctx class Context: def __init__(self): def set(self, name, obj, over

Wanted: New Python Success Stories

2005-03-29 Thread Stephan Deibel
Hi, O'Reilly Associates is going to be printing volume III of the Python Success Stories series in June and I'm looking for submissions of new stories. The stories have been quite valuable for people introducing Python to new users and companies. The deadline for me to receive stories for

problem with tkinter

2005-03-29 Thread max(01)*
hello. the following code: 1 from Tkinter import * 2 3 class MiaApp: 4 def __init__(self, genitore): 5 self.mioGenitore = genitore 6 self.i = IntVar() 7 self.i.set(42) 8 self.s = StringVar() 9 self.s.set("Baobab") 10

Re: truncating a file from the top down

2005-03-29 Thread Fredrik Lundh
Mike Rovner wrote: > if os.stat says the_file is too big: > fh = open(the_file, 'rb') > fh.seek(2008, 2) should be fh.seek(-2008, 2) right? > data = fh.read() > fh.close() > assert len(data)==2008 # you may want some error processing here > fh = open(the_file, 'wb') > fh.writ

problem with tkinter

2005-03-29 Thread max(01)*
hello. the following code: 1 from Tkinter import * 2 3 class MiaApp: 4 def __init__(self, genitore): 5 self.mioGenitore = genitore 6 self.i = IntVar() 7 self.i.set(42) 8 self.s = StringVar() 9 self.s.set("Baobab") 10

Re: good design & method calls

2005-03-29 Thread Charles Hartman
On Mar 29, 2005, at 10:36 AM, Peter Hansen wrote: Sorry for the rant... I didn't intend it to head that way when I started out, but I seem to be on a bit of an anti-optimization bent today. :-) No, that's very helpful; thanks. Charles Hartman -- http://mail.python.org/mailman/listinfo/python-list

Re: xml marshal of general (but non Python standard) class

2005-03-29 Thread syd
Thank you Martin. I had not considered pickle, and I've done my research. However, I'm still having problems: Your foo class (for pickle and xml dumps) works fine for me. >>> f=Foo() >>> f.thanksTo='Martin' >>> f.howMany=100 >>> pickle.dumps(f) "(i__main__\nFoo\np0\n(dp1\nS'thanksTo'\np2\nS'Mart

Re: Finding attributes in a list

2005-03-29 Thread infidel
You can use the new 'sorted' built-in function and custom "compare" functions to return lists of players sorted according to any criteria: >>> players = [ ... {'name' : 'joe', 'defense' : 8, 'attacking' : 5, 'midfield' : 6, 'goalkeeping' : 9}, ... {'name' : 'bob', 'defense' : 5, 'attacking

Python performance tips page moved to wiki

2005-03-29 Thread Skip Montanaro
I dumped my old fastpython.html web page: http://manatee.mojam.com/~skip/python/fastpython.html in favor of a page on the Python wiki: http://www.python.org/moin/PythonSpeed/PerformanceTips Now everybody can help fix warts, add content, etc, etc, etc. References to the old page are red

Re: newbie question

2005-03-29 Thread shama . bell
Whats the file that has to be mapped? Can this be a list? Can this list be initialized to 512? Thanks, -SB -- http://mail.python.org/mailman/listinfo/python-list

Re: serial module NEWBE HELP!

2005-03-29 Thread Peter Hansen
Ron wrote: Is this built into any of the python versions? Need it! Using 2.3.5 and doesn't seem to have it.Newbe needs help!email[EMAIL PROTECTED] Thanks Ron PySerial has never been built in to any standard v distribution of Python, but it's an easy download and the web page is the first hit

Re: Max files in unix folder from PIL process

2005-03-29 Thread Kane
Yes I'm talking Linux not BSD so with any luck you won't have the same 'ls' issue; it is not a crash but painfully slow. The only other issue I recall is wildcards fail if they encompass too many files (presumably a bash/max command line size). I would expect the various GUI file managers may giv

Re: Numarray newbie question

2005-03-29 Thread ChinStrap
Oh well. I am downloading all the things to build it, but in the mean time I just did: def get_y_mat(x_ind,y_ind): return self.y_min + y_ind*self.dy def get_x_mat(x_ind,y_ind): return self.x_min + x_ind*self.dx self.x_mat=fromfunction(get_x_mat,m

Re: [Catalog-sig] Table of Python Packages, updated

2005-03-29 Thread Ian Bicking
Seo Sanghyeon wrote: Hello, comp.lang.python, and catalog-sig, Some of you may remember my mail with the very same subject last year. :-) I have continued to maintain the table, and here's the updated result: http://sparcs.kaist.ac.kr/~tinuviel/pypackage/list.cgi 304 Python projects indexed, with l

Re: truncating a file from the top down

2005-03-29 Thread Mike Rovner
rbt wrote: if os.stat says the file is too big: read the file trim = only keep the last 2008 bytes (This is where I get stuck) write trim back out to the original file Would someone demonstrate the *best* most efficient way of doing this? if os.stat says the_file is too big: fh = open

Re: Numarray newbie question

2005-03-29 Thread Robert Kern
ChinStrap wrote: Are there no windows binaries for SciPy for python 2.4 yet? I try to run the installer and it complains that it can't find python 2.3. No, not yet. Besides that, vectorize is exactly what i want. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high A

truncating a file from the top down

2005-03-29 Thread rbt
Hi guys, I need to truncate a file from the top down. I imagine doing something like this: if os.stat says the file is too big: read the file trim = only keep the last 2008 bytes (This is where I get stuck) write trim back out to the original file Would someone demonstrate the *best*

Re: Numarray newbie question

2005-03-29 Thread ChinStrap
Are there no windows binaries for SciPy for python 2.4 yet? I try to run the installer and it complains that it can't find python 2.3. Besides that, vectorize is exactly what i want. -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Bill Mill
On Tue, 29 Mar 2005 14:34:39 GMT, Ron_Adam <[EMAIL PROTECTED]> wrote: > On 28 Mar 2005 23:01:34 -0800, "Dan Bishop" <[EMAIL PROTECTED]> wrote: > > def print_vars(vars_dict=None): > >...if vars_dict is None: > >... vars_dict = globals() > >...for var, value in vars_dict.items():

Re: Optimisation Hints (dict processing and strings)

2005-03-29 Thread Aaron Bingham
Peter Hansen <[EMAIL PROTECTED]> writes: > You've misunderstood the comments about this area. > String concatenation is *not* "time consuming". > *Repeated* concatenations *will become very time > consuming*, along an exponential curve. That's > what the discussions about O(n^2) are referring > t

Re: Table of Python Packages, updated

2005-03-29 Thread Skip Montanaro
>> Would it make sense to add a "distutils" column for those packages >> that can be installed from source using "python setup.py install" or >> do you assume that all the listed packages have that capability? Seo> Are you suggesting linking to the project's homepage, or upstream

Re: Table of Python Packages, updated

2005-03-29 Thread Seo Sanghyeon
http://sparcs.kaist.ac.kr/~tinuviel/pypackage/list.cgi On Tue, Mar 29, 2005 at 09:30:24AM -0600, Skip Montanaro wrote: > Very nice. I have a couple questions. What do the pink/grey cell > backgrounds mean? Pink background is "not packaged", grey background is "in progress". For "in progress"

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Patrick Useldinger
[EMAIL PROTECTED] wrote: Patrick Useldinger wrote: Depends on what language you know best. But Java is certainly easier to read than C++. There's certainly some irony in those last two sentences. However, I agree with the former. It depends on which you know better, the style of those who develope

serial module NEWBE HELP!

2005-03-29 Thread Ron
Is this built into any of the python versions? Need it! Using 2.3.5 and doesn't seem to have it.Newbe needs help!email[EMAIL PROTECTED] Thanks Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieve Icons Associated To An Extension?

2005-03-29 Thread Will McGugan
[EMAIL PROTECTED] wrote: Hello NG, I have searched everyweher, and I am not able to find a solution... basically, I am constructing a GUI with wxPython, in which I have a list. In this list control, I have some file. I would like to associate (to every file) its icon (on Windows). I have sear

Re: passing keyword args as a parameter

2005-03-29 Thread max(01)*
Fredrik Lundh wrote: "max(01)*" <[EMAIL PROTECTED]> wrote: see what i mean? not really, but maybe arg = {"pc2": 666, "pc1": "Addio..."} fun_con_pc(**arg) is what you want? precisely! thanks a lot! macs -- http://mail.python.org/mailman/listinfo/python-list

Re: hiding a frame in tkinter

2005-03-29 Thread Fredrik Lundh
"faramarz yari" wrote: > def do_unpack(f): >f.pack_forget() > ... > b=Button(f3,text="hello",command=do_unpack(f3)) > > it does not work & the interpreter does not claim any error. it works perfectly fine, but it doesn't do what you want. do_unpack(f3) is a function call, so you're call

Re: tkinter destroy()

2005-03-29 Thread max(01)*
Eric Brunel wrote: On Tue, 29 Mar 2005 10:37:10 GMT, max(01)* <[EMAIL PROTECTED]> wrote: hi people. when i create a widget, such as a toplevel window, and then i destroy it, how can i test that it has been destroyed? the problem is that even after it has been destroyed, the instance still exists an

Re: Table of Python Packages, updated

2005-03-29 Thread Skip Montanaro
Seo> Hello, comp.lang.python, and catalog-sig, Some of you may remember Seo> my mail with the very same subject last year. :-) I have continued Seo> to maintain the table, and here's the updated result: Seo> http://sparcs.kaist.ac.kr/~tinuviel/pypackage/list.cgi Very nice. I hav

Retrieve Icons Associated To An Extension?

2005-03-29 Thread andrea . gavana
Hello NG, I have searched everyweher, and I am not able to find a solution... basically, I am constructing a GUI with wxPython, in which I have a list. In this list control, I have some file. I would like to associate (to every file) its icon (on Windows). I have searched about the use of Ma

Re: good design & method calls

2005-03-29 Thread Peter Hansen
Charles Hartman wrote: I know the answer to this is going to be "It depends . . .", but I want to get my mind right. In Fowler's *Refactoring* I read: "Older languages carried an overhead in subroutine calls, which deterred people from small methods" (followed by the basic "Extract Method" advic

Re: Optimisation Hints (dict processing and strings)

2005-03-29 Thread Daniel Dittmar
OPQ wrote: for (1): longone=longone + char # where len(char)== 1 I known that string concatenation is time consuming, but a small test on timeit seems to show that packing and creating an array for those 2 elements is equally time consuming - use cStringIO instead - or append all chars to a list

Table of Python Packages, updated

2005-03-29 Thread Seo Sanghyeon
Hello, comp.lang.python, and catalog-sig, Some of you may remember my mail with the very same subject last year. :-) I have continued to maintain the table, and here's the updated result: http://sparcs.kaist.ac.kr/~tinuviel/pypackage/list.cgi 304 Python projects indexed, with links to PyPI, Free

Re: Optimisation Hints (dict processing and strings)

2005-03-29 Thread Peter Hansen
OPQ wrote: I'd happy to have you share some thougts about ultimate optimisations on those 2 topics: (1)- adding one caractere at the end of a string (may be long) longone=longone + char # where len(char)== 1 I known that string concatenation is time consuming, but a small test on timeit seems to sh

Re: Secure scripts variables

2005-03-29 Thread Serge Orlov
Florian Lindner wrote: > Hello, > given the following situation: > > I have a script which is readable and executable by a user, but not > writable. > The users executes the scripts, it reads in a value and based on this > value it computes a result and stores it in a variable. > Can the user read

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Ron_Adam
On 28 Mar 2005 23:01:34 -0800, "Dan Bishop" <[EMAIL PROTECTED]> wrote: def print_vars(vars_dict=None): >...if vars_dict is None: >... vars_dict = globals() >...for var, value in vars_dict.items(): >... print '%s = %r' % (var, value) >... myPlace = 'right here' my

Re: [Newbie] How do I get better at Python programming?

2005-03-29 Thread Larry Bates
1) If you write for MS Windows Get a copy of Python Programming on Win32. 2) Get a copy of Python Cookbook (2nd Edition just shipped). It has 100's of examples with detailed explanations of what the code does. It starts out with very simple recipes but by the end of the book you are covering ver

Optimisation Hints (dict processing and strings)

2005-03-29 Thread OPQ
Hi all, I'd happy to have you share some thougts about ultimate optimisations on those 2 topics: (1)- adding one caractere at the end of a string (may be long) (2)- in a dict mapping a key to a list of int, remove every entrie where the list of int have of length < 2 So far, my attempts are fo

Re: Why tuple with one item is no tuple

2005-03-29 Thread Ville Vainio
> "Ville" == Ville Vainio <[EMAIL PROTECTED]> writes: Ville> To me, nothing is more natural than "ab" + "cd" == Ville> "abcd". Also [1,2] + [3,4] == [1,2,3,4]. "Dot product" is Ville> not really too useful in real world (non-mathematical) Ville> apps. ... and of course by "dot

Re: convert user input to Decimal objects using eval()?

2005-03-29 Thread Julian Hernandez Gomez
On Tuesday 29 March 2005 03:04, Raymond Hettinger wrote: > from decimal import Decimal > import re > > number = re.compile(r"((\b|(?=\W))(\d+(\.\d*)?|\.\d+)([eE][+-]?\d{1,3})?)") > deciexpr = lambda s: number.sub(r"Decimal('\1')", s) > > for s in ('1.0001+0.111', >    '+21.3e-5*85-.1234/81.

good design & method calls

2005-03-29 Thread Charles Hartman
I know the answer to this is going to be "It depends . . .", but I want to get my mind right. In Fowler's *Refactoring* I read: "Older languages carried an overhead in subroutine calls, which deterred people from small methods" (followed by the basic "Extract Method" advice). In Skip Montanaro'

Re: Max files in unix folder from PIL process

2005-03-29 Thread Ivan Van Laningham
Hi All-- Rowdy wrote: > > FreeDB (CD database) stores one file per CD in one directory per > category. The "misc" category/directory on my FreeBSD 5.3 system > currently contains around 481,571 small files. The "rock" > directory/category contains 449,208 files. > > As some have said, ls is *v

Re: Why tuple with one item is no tuple

2005-03-29 Thread Ville Vainio
> "Antoon" == Antoon Pardon <[EMAIL PROTECTED]> writes: Antoon> Op 2005-03-27, Joal Heagney schreef <[EMAIL PROTECTED]>: >> Antoon Pardon wrote: >> >>> So python choose a non-deterministic direction. To me (2,3) + (4,5) >>> equals (6,8). I don't dispute that having an oper

Re: passing keyword args as a parameter

2005-03-29 Thread Fredrik Lundh
"max(01)*" <[EMAIL PROTECTED]> wrote: > see what i mean? not really, but maybe arg = {"pc2": 666, "pc1": "Addio..."} fun_con_pc(**arg) is what you want? -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Roy Smith
Antoon Pardon <[EMAIL PROTECTED]> wrote: > 1) The stuff doesn't has to be spread over multiple pages. One >can have 2 functions, each about three quarter of a page. >The second function will then cross a page boundary. The advice "don't write a function longer than a page" is as good advic

BF interpreter in Python

2005-03-29 Thread Will McGugan
Hi, Python is my favorite language, but I rarely get the opertunity to use it at work, so I find myself actively looking for problems to solve with it. Consequently while waiting for C++ build to finish, I wrote a BrainF*** interpreter. If you are not familiar with the BF language see the follo

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Roy Smith
[EMAIL PROTECTED] wrote: > There is a difference between theory and practice. You know the difference between theory and practice? Well, in theory, there is no difference :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble with RC2

2005-03-29 Thread Anthony Baxter
On Mon, 28 Mar 2005 21:32:07 +0200, Do Re Mi chel La Si Do <[EMAIL PROTECTED]> wrote: > Hi ! > > I have sevral problems with P4-RC2. > > Typical case, I have a script who run OK with P4 "standard" ; but, on a new > install, with P4-RC2, I obtain : > > Traceback (most recent call last): >

Re: [Newbie] How do I get better at Python programming?

2005-03-29 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Paul Rubin wrote: > Anon <[EMAIL PROTECTED]> writes: > > I'd like to get to the next level, but I'm not sure how. Are there > > any suggestions for continuing to learn? How did you guys learn? > > I'd say look at some more general comp

Finding attributes in a list

2005-03-29 Thread Ben
Hi In a list I have a number of soccer players. Each player has a different rating for attacking, defending, midfield fitness and goalkeeping. I have devised a while loop that goes through this list to find the best player at defending, attacking, midfield and goalkeeping. However there is more t

Secure scripts variables

2005-03-29 Thread Florian Lindner
Hello, given the following situation: I have a script which is readable and executable by a user, but not writable. The users executes the scripts, it reads in a value and based on this value it computes a result and stores it in a variable. Can the user read out the value of this variable? If yes

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-29, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> I'm not going to call my solution simple, but it wastes very few >> cycles. if no thread is blocked on a lock, the select will just >> block until that changes. No need for some kind of polling loop. > > I think I un

MAC changing

2005-03-29 Thread ias0nas
Hello, Is it possible to change the MAC address of a packet after I have builded it? I used impacket to build a packet that does not provide the function to change the MAC. Is it possible to set the bytes of the packet where the MAC is stored? I don't want to use system calls to bring the card dow

Re: Dumb*ss newbie Q

2005-03-29 Thread Captain Dondo
On Mon, 28 Mar 2005 08:42:22 -0600, Larry Bates wrote: > Others have answered your specific question, I thought I > would add some suggestions (not tested): > > 1) You don't need a separate set_title method. You can > change the title attribute at any time by just saying > m.title="new title".

Re: tkinter destroy()

2005-03-29 Thread Eric Brunel
On Tue, 29 Mar 2005 10:37:10 GMT, max(01)* <[EMAIL PROTECTED]> wrote: hi people. when i create a widget, such as a toplevel window, and then i destroy it, how can i test that it has been destroyed? the problem is that even after it has been destroyed, the instance still exists and has a tkinter nam

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > I'm not going to call my solution simple, but it wastes very few > cycles. if no thread is blocked on a lock, the select will just > block until that changes. No need for some kind of polling loop. I think I understand. My original idea was to use a hea

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-29, Antoon Pardon schreef <[EMAIL PROTECTED]>: > Op 2005-03-29, Paul Rubin schreef : >> Antoon Pardon <[EMAIL PROTECTED]> writes: >>> Well have a look at what I have written over the weekend. It uses >>> a seperate thread with one pipe for a wakeup mechanisme. >> >> Thanks, I'll look at

Re: Calling __init__ with multiple inheritance

2005-03-29 Thread Axel Straschil
Hello! >> Also, lool at that: >> class Mother(object): >> def __init__(self, param_mother='optional', **eat): >> print 'Mother' >> class Father(object): >> def __init__(self, param_father='optional', **eat): >> print 'Father' >> class Child(Mother, Father): >> def __init__(self, **ham): >> super(C

Actor pattern in GUI

2005-03-29 Thread M Ali
Hi, I am trying to grok using actor patterns in a gui as explained here by Andrew Eland: http://www.andreweland.org/code/gui-actor.html The short article explains it using java with which i am not used to at all. But he does provide a python example using pygtk: http://www.andreweland.org/code/g

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-29, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> Well have a look at what I have written over the weekend. It uses >> a seperate thread with one pipe for a wakeup mechanisme. > > Thanks, I'll look at it. Why don't you use usleep instead of a pipe? Because with th

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread TZOTZIOY
On 28 Mar 2005 22:06:44 -0800, rumours say that "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> might have written: Read about locals() and globals() in the Python documentation. These provide the information you request (ie what names are bound to what objects). -- TZOTZIOY, I speak England very best

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > Well have a look at what I have written over the weekend. It uses > a seperate thread with one pipe for a wakeup mechanisme. Thanks, I'll look at it. Why don't you use usleep instead of a pipe? I decided over the weekend that using a separate thread wit

Re: Why tuple with one item is no tuple

2005-03-29 Thread Antoon Pardon
Op 2005-03-27, Joal Heagney schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >> So python choose a non-deterministic direction. To me (2,3) + (4,5) >> equals (6,8). I don't dispute that having an operator to combine >> (2,3) and (4,5) in (2,3,4,5) is usefull, but they should never have >> used

tksnack and socket to real time sampling and playing sound

2005-03-29 Thread didifouke
Hi, I try to sample and playback speech using snack. My idea is to have a socket based server that plays back the sound and a client that samples the input from the sound card and sends it to the server using the socket connection. On the snack page there is a tutorial showing a socket server imp

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Antoon Pardon
Op 2005-03-25, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> Well maybe you could use an os.pipe as a timeout lock then. When the lock is >> instantiated you put one byte in it. Aquiring the lock is implemented by >> reading one byte, releasing the lock is implemented by writi

tkinter destroy()

2005-03-29 Thread max(01)*
hi people. when i create a widget, such as a toplevel window, and then i destroy it, how can i test that it has been destroyed? the problem is that even after it has been destroyed, the instance still exists and has a tkinter name, so testing for None is not feasible: >>> import Tkinter >>> fin

passing keyword args as a parameter

2005-03-29 Thread max(01)*
hi there! this post is somewhat a generalization of one previous question. i was wondering if it is possible to pass an argument list as a parameter to a function. example: def fun_con_pc(pc1 = "Ciao!", pc2 = 42): print pc1 print pc2 fun_con_pc() fun_con_pc(pc1 = "Addio...") fun_con_pc(pc2 = 66

<    1   2   3   >