Re: securely getting the user's password

2008-03-08 Thread Paul Rubin
Chick <[EMAIL PROTECTED]> writes: > So I guess it is not possible in pure Python to lock the memory from > being swaped? Even if you can lock the memory, python strings are immutable and can be copied around by the runtime system at any time. You're better off using the C API to encapsulate the p

Re: securely getting the user's password

2008-03-08 Thread Chick
> But a far bigger security hole is that the password is sitting there in > your securePass variable in plain text. What are you doing about that? Precisely why I though to use wipe() that way. The password is there in plain text as long as it has to and then one call of securePass.wipe() and its

Re: Regarding coding style

2008-03-08 Thread [EMAIL PROTECTED]
On Mar 9, 12:09 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 08 Mar 2008 20:45:25 -0800, [EMAIL PROTECTED] wrote: > > On Mar 8, 7:34 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > >> On Sat, 08 Mar 2008 19:31:47 +, Grant Edwards wrote: > >

Re: What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Kay Schluehr
On 9 Mrz., 06:30, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Hard Exceptions: terminate the program unless explicitly silenced > Soft Exceptions: pass silently unless explicitly caught > > In this case, I agree with the Zen of Python ("import this"): > > Errors should never pa

RE: SV: Regarding coding style

2008-03-08 Thread Ryan Ginstrom
> On Behalf Of Grant Edwards > I think docstrings are a great idea. What's needed is a way > to document the signature that can't get out-of-sync with > what the fucntion really expects. Like doctests? (I know, smart-ass response) Regards, Ryan Ginstrom -- http://mail.python.org/mailman/list

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 21:32:04 -0800, Paul Rubin wrote: > I should have mentioned (a+b-1)//b expects a and b to be positive > integers. Oh, I don't think that would have made any difference. I think I'm seeing floats everywhere today, including coming out of the walls. -- Steven -- http://mail

Re: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sun, 09 Mar 2008 05:29:42 +, Grant Edwards wrote: >> Sure, but really, adding ONE LINE to the start of a file is hardly >> "cluttering up" anything. Especially if it is in the doc string, like >> this: >> >> """widgets.py: create, manage and destroy widgets. >> >> blah blah blah blah..."""

Re: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-09, Dan Bishop <[EMAIL PROTECTED]> wrote: > On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > ... >> >> What I really can't stand are the pointy-haired comment blocks >> at the beginnings of C/C++ functions that do things like tell >> you the name and return type of the func

Re: securely getting the user's password

2008-03-08 Thread Paul Rubin
Chick <[EMAIL PROTECTED]> writes: > I'm writing a security tool which requies wiping off the memory of > certain string after being used, which I've done by implementing it as > a mutable list as follow: You really can't do that reliably in Python and for that matter you can't really do it reliabl

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Unfortunately that doesn't work reliably. > > >>> a, b = 9007199254741000.0, -3.0 > >>> a/b > -3002399751580333.5 > >>> (a+b-1)//b # should be -3002399751580333 > -3002399751580332.0 I should have mentioned (a+b-1)//b expects a and b to be positive i

Re: SV: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 08 Mar 2008 21:21:48 +0100, K Viltersten wrote: > >> Coming from C++/Java camp i can't help noticing that in most cases, when >> i'm using a class written by somebody else, i don't want to see his/her >> code. I only want to know W

Re: What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 19:51:24 -0800, Lie wrote: > Soft Exception > What is "Soft Exception"? > Soft Exception is an exception that if is unhandled, pass silently as if > nothing happened. For example, if a variable turns into NoneType, it'll > raise Soft Exception that it have become NoneException,

Re: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> The only times I can recall printing source were in college >> classes where I was required to hand in a hardcopy with the >> assignment and code samples for job interviews. In the real >> world the code base tends to be too huge to con

Re: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-09, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Even in the early 1990s the moral equivalent of enscript (I think it > was a2ps) I still use a2ps occasionally, but rarely for printing out source code. I occasionally print out hex dumps that I need to markup to figure out what's goi

Re: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 08 Mar 2008 19:31:47 +, Grant Edwards wrote: > >> I'm also a bit baffled by people who put a comment at the top of every >> file that tells you what the filename is. > [snip rant] > > You've never printed out a source file on p

Re: SV: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-09, K Viltersten <[EMAIL PROTECTED]> wrote: >>> /** Projects an object from 3D to 2D using >>> the method of Alexander The Great. >>> \param 3D structure to be projected >>> \returns 2D projection >>> */ >>> public Proj2D get2Dfrom3D(Proj3D param); >>> >>> The above is, to me

Re: SV: SV: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-08, K Viltersten <[EMAIL PROTECTED]> wrote: >> If you can't/don't look at the source file, >> then comments aren't going to help (except >> in the case of something like docstrings in >> Python). > > I strongly disagree. Now, perhaps we're > talking about different things, here? > Us

Re: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 20:45:25 -0800, [EMAIL PROTECTED] wrote: > On Mar 8, 7:34 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Sat, 08 Mar 2008 19:31:47 +, Grant Edwards wrote: >> > I'm also a bit baffled by people who put a comment at the top of >> > every file that t

Re: Python installation problem

2008-03-08 Thread Lie
On Mar 9, 11:42 am, [EMAIL PROTECTED] wrote: > Hi Folks, > > I downloaded a pre-compiled version 2.5, and intalled it without any > error message; and I can command line playing on Python through firing > up IDLE or command-line. However, I just can't compile the python file > existing in a directo

Re: What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Kay Schluehr
On 9 Mrz., 04:51, Lie <[EMAIL PROTECTED]> wrote: > A more through implementation would start from the raiser inspecting > the execution stack and finding whether there are any try block above > it, if no try block exist it pass silently and if one exist it will > check whether it have a matching e

Re: Regarding coding style

2008-03-08 Thread [EMAIL PROTECTED]
On Mar 8, 7:34 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 08 Mar 2008 19:31:47 +, Grant Edwards wrote: > > I'm also a bit baffled by people who put a comment at the top of every > > file that tells you what the filename is. > > [snip rant] > > You've never print

Python installation problem

2008-03-08 Thread cosmo_general
Hi Folks, I downloaded a pre-compiled version 2.5, and intalled it without any error message; and I can command line playing on Python through firing up IDLE or command-line. However, I just can't compile the python file existing in a directory. Today, I tried to fire Python in a DOS window, then

Re: Parse specific text in email body to CSV file

2008-03-08 Thread Paul McGuire
On Mar 8, 4:20 pm, [EMAIL PROTECTED] wrote: > I have been searching all over for a solution to this. I am new to > Python, so I'm a little lost. Any pointers would be a great help. I > have a couple hundred emails that contain data I would like to > incorporate into a database or CSV file. I want t

Re: securely getting the user's password

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 18:50:30 -0800, Chick wrote: > Hello, > > I'm writing a security tool Oh good, just what we need, beginners writing security tools. > which requies wiping off the memory of > certain string after being used, which I've done by implementing it as a > mutable list as follow:

What c.l.py's opinions about Soft Exception?

2008-03-08 Thread Lie
I'm asking about people in c.l.py's opinion about a _probably_ very Pythonic way of doing something if such features is implemented. It is to be known that I'm not a Python expert and actually relatively new to Python programming, so probably I'm just not thinking pythonic enough yet or this featur

Re: Green's Function

2008-03-08 Thread olusina eric
I did search for "Python Green's function" and no reasonable hit. I also searched on scipy with no result. Thanks EOF olusina eric <[EMAIL PROTECTED]> wrote: Hi All, I am new to Python and trying to solve the Hamiltonian of a linear chain of atoms using green’s function. Does anyone

securely getting the user's password

2008-03-08 Thread Chick
Hello, I'm writing a security tool which requies wiping off the memory of certain string after being used, which I've done by implementing it as a mutable list as follow: class secureStr: def __init__(self, str): self.__s = [] for i in range(len(str)): self.s += st

SV: Regarding coding style

2008-03-08 Thread K Viltersten
>> /** Projects an object from 3D to 2D using >> the method of Alexander The Great. >> \param 3D structure to be projected >> \returns 2D projection >> */ >> public Proj2D get2Dfrom3D(Proj3D param); >> >> The above is, to me, very clear and >> consistent. Not to mention, easily >> handl

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Steven D'Aprano
On Sun, 09 Mar 2008 02:16:39 +, Steven D'Aprano wrote: > On Sat, 08 Mar 2008 15:26:35 -0800, Paul Rubin wrote: > >> Alasdair <[EMAIL PROTECTED]> writes: >>> What is the best way of finding a ceiling of a quotient of arbitrary >>> sized integers? >> >> ceiling(a/b) = (a+b-1)//b > > > Unfort

Re: Green's Function

2008-03-08 Thread Daniel Fetchinson
> I am new to Python and trying to solve the Hamiltonian of a linear chair > of atoms using green's function. > Does anyone know any pre-existing library functions and literature that > could be helpful? You might find this helpful: http://scipy.org/ HTH, Daniel -- http://mail.python.org/mailman

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Steven D'Aprano
On Sun, 09 Mar 2008 10:11:53 +1100, Alasdair wrote: > I need to apply the ceiling function to arbitrary sized (long) integers. > However, division automatically returns the type of its operands, so > that, for example: math.ceil(7/4) returns 1. I can use float, as in: > math.ceil(7/float(4)), exc

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Steven D'Aprano
On Sun, 09 Mar 2008 01:48:21 +, Steven D'Aprano wrote: > (And the ease that these mistakes can happen is why such fundamental > functions should be in the standard library, no matter how easy they are > to implement.) Which, of course, they are. math.ceil() and math.floor() I knew that. *co

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Mark Dickinson
On Mar 8, 9:19 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > Obvious typo: -(-a)//b == a//b > > This should be -(-a//b) == -((-a)//b) Yes: thanks for the correction! A lesson to me to include parentheses even when redundant... This reminds me of the following parenthesization gem (see next to

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Terry Reedy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On Sat, 08 Mar 2008 17:09:11 -0800, Mark Dickinson wrote: | | > On Mar 8, 6:26 pm, Paul Rubin wrote: | >> Alasdair <[EMAIL PROTECTED]> writes: | >> > What is the best way of finding a ceilin

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 15:26:35 -0800, Paul Rubin wrote: > Alasdair <[EMAIL PROTECTED]> writes: >> What is the best way of finding a ceiling of a quotient of arbitrary >> sized integers? > > ceiling(a/b) = (a+b-1)//b Unfortunately that doesn't work reliably. >>> a, b = 9007199254741000.0, -3.0 >>

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Mark Dickinson
On Mar 8, 8:48 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 08 Mar 2008 17:09:11 -0800, Mark Dickinson wrote: > > I prefer: > > > ceiling(a/b) = -(-a)//b > > Unfortunately it doesn't give the right answer. > > >>> a, b = 101.0, 10.0 > >>> -(-a)//b  # should be 11.0 >

Re: Regarding coding style

2008-03-08 Thread dave_mikesell
On Mar 8, 5:14 pm, "K Viltersten" <[EMAIL PROTECTED]> wrote: > /** Projects an object from 3D to 2D using > the method of Alexander The Great. > \param 3D structure to be projected > \returns 2D projection > */ > public Proj2D get2Dfrom3D(Proj3D param); > > The above is, to me, very cl

SV: SV: SV: Regarding coding style

2008-03-08 Thread K Viltersten
>>> If you can't/don't look at the source file, >>> then comments aren't going to help (except >>> in the case of something like docstrings in >>> Python). >> >> I strongly disagree. Now, perhaps we're >> talking about different things, here? >> Usually, in the header file (C++), there >> won't

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 17:09:11 -0800, Mark Dickinson wrote: > On Mar 8, 6:26 pm, Paul Rubin wrote: >> Alasdair <[EMAIL PROTECTED]> writes: >> > What is the best way of finding a ceiling of a quotient of arbitrary >> > sized integers? >> >> ceiling(a/b) = (a+b-1)//b > > I

Re: Green's Function

2008-03-08 Thread Terry Reedy
"olusina eric" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | I am new to Python and trying to solve the Hamiltonian of a linear chair of atoms using green's function. | Does anyone know any pre-existing library functions and literature that could be helpful? Did you try searc

Re: Image Libraries

2008-03-08 Thread PB
Maybe I am unaware of the right way to do it, but the only way I can think to draw several shapes of different transparencies is to create an image for each layer and then combine them which seems overly complex. It would be nice to simply be able to specify colors with an alpha value combined (ie

Re: Image Libraries

2008-03-08 Thread Ken
PB wrote: > I have been using PIL for generating images, however it does not > easily support operations with transparency etc. > > I tried to install aggdraw but it wouldn't compile. > > Ideally I'd like something open source so I can adapt it, hopefully > mostly written in python rather than C. >

Re: Regarding coding style

2008-03-08 Thread Micah Cowan
[EMAIL PROTECTED] writes: > On Mar 8, 2:38 am, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Fri, 07 Mar 2008 20:57:32 -0800, dave_mikesell wrote: >> >> x = get_stuff(store) # Get the stuff what was brought at the store. >> >> > Perfect example of an unnecessary comment.

Re: Regarding coding style

2008-03-08 Thread Dan Bishop
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: ... > > What I really can't stand are the pointy-haired comment blocks > at the beginnings of C/C++ functions that do things like tell > you the name and return type of the function and list the names > and types of the parameters. Gee, t

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Mark Dickinson
On Mar 8, 6:26 pm, Paul Rubin wrote: > Alasdair <[EMAIL PROTECTED]> writes: > > What is the best way of finding a ceiling of a quotient of arbitrary sized > > integers? > > ceiling(a/b) = (a+b-1)//b I prefer: ceiling(a/b) = -(-a)//b which also works if a and b are some

Re: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 13:40:56 -0800, dave_mikesell wrote: > On Mar 8, 2:27 pm, [EMAIL PROTECTED] wrote: > >> Good comments are better than bad names. Good names are better than bad >> comments. > > If you're taking the time to write good comments, why not just fix the > bad names? The compiler/i

SV: SV: Quit-command not quiting

2008-03-08 Thread K Viltersten
"Gabriel Genellina" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] > En Fri, 07 Mar 2008 13:56:45 -0200, K Viltersten <[EMAIL PROTECTED]> > escribi�: > The window itself vanishes if i click the cross in the upper-right corner but pressing the quit-button only makes

Re: SV: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 21:21:48 +0100, K Viltersten wrote: > Coming from C++/Java camp i can't help noticing that in most cases, when > i'm using a class written by somebody else, i don't want to see his/her > code. I only want to know WHAT the function does (is intended to be > doing, at least). >

Re: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 19:31:47 +, Grant Edwards wrote: > I'm also a bit baffled by people who put a comment at the top of every > file that tells you what the filename is. [snip rant] You've never printed out a source file on pieces of dead tree to read on the train on the way home, or in bed

Re: What is a class?

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 09:52:41 -0800, castironpi wrote: > On Mar 7, 6:16 am, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Thu, 06 Mar 2008 08:40:47 -0800, castironpi wrote: >> > you >> > could say exec( open( 'modA.py' ).read() ) ==> import modA >> >> Yes, you could say that

Re: List as FIFO in for loop

2008-03-08 Thread Paul Hankin
On Mar 8, 10:42 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Mar 8, 9:43 am, malkarouri <[EMAIL PROTECTED]> wrote: > > > Hi everyone, > > > I have an algorithm in which I need to use a loop over a queue on > > which I push values within the loop, sort of: > > > while not(q.empty()): > >     x = q

Green's Function

2008-03-08 Thread olusina eric
Hi All, I am new to Python and trying to solve the Hamiltonian of a linear chair of atoms using green’s function. Does anyone know any pre-existing library functions and literature that could be helpful? Thanks EOF - Looking for last minute shopp

Re: float / rounding question

2008-03-08 Thread Roel Schroeven
Mark Dickinson schreef: > On Mar 7, 11:23 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum wrote: >>> Sorry to come in so late in this discussion. Although it is correct to >>> say that many real numbers that have an exact d

Re: SV: SV: Regarding coding style

2008-03-08 Thread Ben C
On 2008-03-08, K Viltersten <[EMAIL PROTECTED]> wrote: >> If you can't/don't look at the source file, >> then comments aren't going to help (except >> in the case of something like docstrings in >> Python). > > I strongly disagree. Now, perhaps we're > talking about different things, here? > Us

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Robert Kern
Alasdair wrote: > I need to apply the ceiling function to arbitrary sized (long) integers. > However, division automatically returns the type of its operands, so that, > for example: math.ceil(7/4) returns 1. I can use float, as in: > math.ceil(7/float(4)), except that for very large integers flo

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Paul Rubin
Alasdair <[EMAIL PROTECTED]> writes: > What is the best way of finding a ceiling of a quotient of arbitrary sized > integers? ceiling(a/b) = (a+b-1)//b -- http://mail.python.org/mailman/listinfo/python-list

Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Alasdair
I need to apply the ceiling function to arbitrary sized (long) integers. However, division automatically returns the type of its operands, so that, for example: math.ceil(7/4) returns 1. I can use float, as in: math.ceil(7/float(4)), except that for very large integers float causes an unacceptabl

Re: SV: Quit-command not quiting

2008-03-08 Thread Gabriel Genellina
En Fri, 07 Mar 2008 13:56:45 -0200, K Viltersten <[EMAIL PROTECTED]> escribi�: >>> The window itself vanishes if i click the >>> cross in the upper-right corner but pressing >>> the quit-button only makes it "pressed". >>> Then, the program freezes. >> >> How did you run it? From inside IDLE? ID

SV: SV: Regarding coding style

2008-03-08 Thread K Viltersten
> If you can't/don't look at the source file, > then comments aren't going to help (except > in the case of something like docstrings in > Python). I strongly disagree. Now, perhaps we're talking about different things, here? Usually, in the header file (C++), there won't be any source code, e

Re: List as FIFO in for loop

2008-03-08 Thread Carl Banks
On Mar 8, 9:43 am, malkarouri <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I have an algorithm in which I need to use a loop over a queue on > which I push values within the loop, sort of: > > while not(q.empty()): > x = q.get() > #process x to get zero or more y's > #for each y: >

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 6:24 pm, rockingred <[EMAIL PROTECTED]> wrote: > I think it's a bad practice to get into.  Did you intend to do the > "process" step again over the added variables?  If not I would set a > new variable, based on your awful naming convention, let's call it z. > Then use z.append(y) within

Fwd: [PyQt] Popen + poll & pid

2008-03-08 Thread Kevin
Hi, I sent the question below to the wrong list. I was wondering if someone here could help? Kevin Sent from my iPhone Begin forwarded message: From: Kevin <[EMAIL PROTECTED]> Date: March 8, 2008 11:53:39 AM PST To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> Subject: [PyQt] Popen + poll & pid

Re: extract multiple ranges from a list

2008-03-08 Thread pi . arctan
On 8 Mar, 17:32, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > One of my many project involves working with YUV-files, where I need > > to reduce > > the vertical resolution with a factor of two, i.e. remove every other > > scan line. > > Today I'm using two for-loops in the

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 4:44 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: ... > Notice that the language specification *deliberately* does not > distinguish between deletion of earlier and later items, but > makes modification of the sequence undefined behavior to allow > alternative implementations. E.g. an

Parse specific text in email body to CSV file

2008-03-08 Thread dpw . asdf
I have been searching all over for a solution to this. I am new to Python, so I'm a little lost. Any pointers would be a great help. I have a couple hundred emails that contain data I would like to incorporate into a database or CSV file. I want to search the email for specific text. The emails ba

off topic: 2 videos on source control and open source development

2008-03-08 Thread Aaron Watters
I just wanted to send out links to 2 informative videos regarding open source and change control systems. The first is Linus Torvalds on git and how it contrasts with subversion and other approaches (where he says some nice things about Mercurial, btw). http://www.youtube.com/watch?v=4XpnKHJAok8

Re: identifying and parsing string in text file

2008-03-08 Thread Paul McGuire
On Mar 8, 2:02 pm, Nemesis <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I have a large file that has many lines like this, > > > > name="DoseReferenceStructureType">SITE > > > I would like to identify the line by the tag (300a,0014) and then grab > > the name (DoseReferenceStructureTy

Re: SV: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-08, K Viltersten <[EMAIL PROTECTED]> wrote: >> What I really can't stand are the pointy-haired comment blocks >> at the beginnings of C/C++ functions that do things like tell >> you the name and return type of the function and list the >> names and types of the parameters. Gee, thanks.

Re: Regarding coding style

2008-03-08 Thread dave_mikesell
On Mar 8, 2:27 pm, [EMAIL PROTECTED] wrote: > Good comments are better than bad names. > Good names are better than bad comments. If you're taking the time to write good comments, why not just fix the bad names? The compiler/interpreter can never, ever catch bad comments. -- http://mail.python

Re: Regarding coding style

2008-03-08 Thread dave_mikesell
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: LOL. Thanks for the laughs. I share your frustration. -- http://mail.python.org/mailman/listinfo/python-list

Re: for-else

2008-03-08 Thread Terry Reedy
"egbert" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | However the loop-else really works more like this: | . try to do the loop; | . if it starts but is interrupted by a break, | . then do something else as well. This is NOT how loop-else works for Python. If you want to do s

Re: distutils - Is is possible to install without the .py extensions

2008-03-08 Thread Robert Kern
Jari Aalto wrote: > * Fri 2008-03-07 Robert Kern <[EMAIL PROTECTED]> gmane.comp.python.general > * Message-Id: [EMAIL PROTECTED] > > setup(name='program', >>> ... > scripts = ['program,py'], > ) > that the the result is: > > /usr/bin/program > >>

Re: List as FIFO in for loop

2008-03-08 Thread castironpi
> Notice that the language specification *deliberately* does not > distinguish between deletion of earlier and later items, but > makes modification of the sequence undefined behavior to allow > alternative implementations. E.g. an implementation that would > crash, erase your hard disk, or set you

Re: Can't get items out of a set?

2008-03-08 Thread castironpi
> something something equivalence class. > The intern() builtin uses this approach: > >    interned = {} >    def intern(s): >         if s in interned: >             return interned[s] >         interned[s] = s >         return s If you've seen it before, and have the old one, return the old one

Re: for-else

2008-03-08 Thread castironpi
> The idea of the if-else is: > .  depending on some condition either do this or do something else, > .  don't do them both. yes = the loop completed. 'else' isn't rechecking a piece of the loop, it's checking the loop. Does it test successfully--- not the loop condition, the loop? What is 'if a

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Does one side of this hold that there are no -good- comments? > > I wouldn't say there are _no_ good comments, but I would say > that 90+% of the comments I've seen in my

Adjust a canvas as the window is resized

2008-03-08 Thread K Viltersten
Do i need to set a callback to a canvas in order to "listen" to the root window being resized in order to make it adjust its contents? If so, how? If not, how do i make the canvas draw a line from one corner to an other? from Tkinter import * class Demo(Frame): def __init__(self, master =

SV: Regarding coding style

2008-03-08 Thread K Viltersten
> What I really can't stand are the > pointy-haired comment blocks at the > beginnings of C/C++ functions that do > things like tell you the name and return > type of the function and list the names > and types of the parameters. Gee, thanks. > I never could have figured that out from > looki

Re: identifying and parsing string in text file

2008-03-08 Thread Nemesis
[EMAIL PROTECTED] wrote: > I have a large file that has many lines like this, > > name="DoseReferenceStructureType">SITE > > I would like to identify the line by the tag (300a,0014) and then grab > the name (DoseReferenceStructureType) and value (SITE). > > I would like to create a file that woul

Re: identifying and parsing string in text file

2008-03-08 Thread Bernard
Hey Brian, It seems the text you are trying to parse is similar to XML/HTML. So I'd use BeautifulSoup[1] if I were you :) here's a sample code for your scraping case: from BeautifulSoup import BeautifulSoup # assume the s variable has your text s = "whatever xml or html here" # turn it into a

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Does one side of this hold that there are no -good- comments? > > I wouldn't say there are _no_ good comments, but I would say > that 90+% of the comments I've seen in my

identifying and parsing string in text file

2008-03-08 Thread [EMAIL PROTECTED]
I have a large file that has many lines like this, SITE I would like to identify the line by the tag (300a,0014) and then grab the name (DoseReferenceStructureType) and value (SITE). I would like to create a file that would have the structure, DoseReferenceStructureType = Site ...

Re: Python CGI & Webpage with an Image

2008-03-08 Thread rodmc
> Is the cgi script in the same directory? The user's browser looks > for the jpg relative to the URL it used to get the page, which in > the case of the CGI script is the path to the script, not the > path to the html file. No the CGI script is in a different folder, I could move everything to

Re: SQL problem in python

2008-03-08 Thread petr . jakes . tpc
Maybe you should try SQLObject :-) from sqlobject import * from sqlobject.sqlbuilder import Select #from sqlobject.sqlbuilder import * from datetime import datetime # === sqlite == #connection = connectionForURI('sqlite:///dev/shm/ourdata.db') connection = conne

Intra-Package References

2008-03-08 Thread xkenneth
Does your python module have to exist in the path in order for intra- package references to work? Regards, Kenneth Miller -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a string to the most probable type

2008-03-08 Thread castironpi
On Mar 8, 12:05 pm, Pierre Quentel <[EMAIL PROTECTED]> wrote: > > >>> def convert(x): > > >         if '.' in x: > >                 try: return float(x) > >                 except ValueError: return x > >         else: > >                 try: return int(x) > >                 except: return x > >

Re: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Does one side of this hold that there are no -good- comments? I wouldn't say there are _no_ good comments, but I would say that 90+% of the comments I've seen in my lifetime were bad. Most of them were bad to the extent that anybody ne

Image Libraries

2008-03-08 Thread PB
I have been using PIL for generating images, however it does not easily support operations with transparency etc. I tried to install aggdraw but it wouldn't compile. Ideally I'd like something open source so I can adapt it, hopefully mostly written in python rather than C. Is there any other dec

Re: Can't get items out of a set?

2008-03-08 Thread Raymond Hettinger
> > > Is it possible to get an object out of a set() given another object > > > that has the same hash code and equality (__hash__() and __eq__() > > > return the same)? > > > Yes, but it requires an indirect > > approach.http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499299 > > > Raymond

Re: del class with recursive list

2008-03-08 Thread Peter Otten
duccio wrote: > Will someone have time to tell me why this code don't work as I expect? > And what should I do to make the "del n" delete all the lower nodes? > Thanks! > > class Node: > def __init__(self): > self.childs=[] > def appendNode(self, n): > self.childs.appe

Re: SQL problem in python

2008-03-08 Thread Carsten Haese
On Sat, 2008-03-08 at 10:11 -0800, Dennis Lee Bieber wrote: > On Sat, 8 Mar 2008 09:28:23 -0800 (PST), aiwarrior > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > Thanks a lot. > > In the Python documentation, the sqlite module documentation doesn't > > mention that special

del class with recursive list

2008-03-08 Thread duccio
Hello! Will someone have time to tell me why this code don't work as I expect? And what should I do to make the "del n" delete all the lower nodes? Thanks! class Node: def __init__(self): self.childs=[] def appendNode(self, n): self.childs.append(n) def __del__(s

Re: List as FIFO in for loop

2008-03-08 Thread rockingred
On Mar 8, 9:43 am, malkarouri <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I have an algorithm in which I need to use a loop over a queue on > which I push values within the loop, sort of: > > while not(q.empty()): >     x = q.get() >     #process x to get zero or more y's >     #for each y: >    

Re: multiplication of lists of strings

2008-03-08 Thread castironpi
On Mar 8, 12:04 pm, [EMAIL PROTECTED] wrote: > On Mar 5, 2:16 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] a écrit : > > (snip) > > > > That reminds me:  Is there a generic 'relation' pattern/recipie, such > > > as finding a computer that's "paired" with multiple users

Re: Converting a string to the most probable type

2008-03-08 Thread Pierre Quentel
> >>> def convert(x): > >         if '.' in x: >                 try: return float(x) >                 except ValueError: return x >         else: >                 try: return int(x) >                 except: return x > > >>> convert('123') > 123 > >>> convert('123.99') > 123.98 > >>>

Re: multiplication of lists of strings

2008-03-08 Thread castironpi
On Mar 5, 2:16 am, Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > (snip) > > > That reminds me:  Is there a generic 'relation' pattern/recipie, such > > as finding a computer that's "paired" with multiple users, each of who > > are "paired" with multiple computers, without maintaining

Re: Difference between 'function' and 'method'

2008-03-08 Thread castironpi
On Mar 7, 1:34 pm, [EMAIL PROTECTED] wrote: > On Mar 7, 6:44 am, Sion Arrowsmith <[EMAIL PROTECTED]> > wrote: > > > Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > >En Thu, 06 Mar 2008 23:46:43 -0200, <[EMAIL PROTECTED]> escribi�: > > >> [ ... ] > > >You may look at the SimpleXMLRPCServer class

Re: Intelligent Date & Time parsing

2008-03-08 Thread Tim Chase
> I am a GNU newbie. (I know C &o.) Can you point me to a > place to find the source for 'date'? It's part of the GNU Coreutils: http://ftp.gnu.org/gnu/coreutils/ Within the file, you're likely interested in lib/getdate.* It helps if you have a working knowledge of Yacc. -tkc -- http://ma

Re: What is a class?

2008-03-08 Thread castironpi
On Mar 7, 6:16 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 06 Mar 2008 08:40:47 -0800, castironpi wrote: > > you > > could say exec( open( 'modA.py' ).read() ) ==> import modA > > Yes, you could say that, but you'd be wrong. Please test your code before > making such

Help xxx.py Program Recognition problem

2008-03-08 Thread crashbangboom
Hi... I was using Python 2.4 and installed 2.5...I copied all my .py files from the Python24\ root directory to the Python25\ root directory...when I try to run them by double clicking I get: "X.py is not a valid Win32 application"... Also, the files do not appear to be associated with python

  1   2   >