Saturday, April 3, 2010

comp.lang.python - 25 new messages in 9 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* passing command line arguments to executable - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/4f15edabd97830c8?hl=en
* off topic but please forgive me me and answer - 8 messages, 7 authors
http://groups.google.com/group/comp.lang.python/t/0d4f564a49022b74?hl=en
* (a==b) ? 'Yes' : 'No' - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/b985d5727945d2b4?hl=en
* "JOBS IN CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS
JOBS IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA" "ENGINEERING
JOBS IN CANADA" "SPORTS JOBS IN CANADA" http://jobsincanada-net.blogspot.com/ -
1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e554d6b4ab6f7ab9?hl=en
* C-style static variables in Python? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/ce1a7abe2f3816b9?hl=en
* WinXP, Python3.1.2, dir-listing to XML - problem with unicode file names - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/b298b2ed517db778?hl=en
* Get a method instance through 'getattr' but not superclass's method - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/17fe44173a924c48?hl=en
* How to access args as a list? - 7 messages, 5 authors
http://groups.google.com/group/comp.lang.python/t/4265701a4b0f611a?hl=en
* Question on templates and python logging - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0bf72baa090986f3?hl=en

==============================================================================
TOPIC: passing command line arguments to executable
http://groups.google.com/group/comp.lang.python/t/4f15edabd97830c8?hl=en
==============================================================================

== 1 of 3 ==
Date: Sat, Apr 3 2010 9:22 am
From: Simon Brunning


On 3 April 2010 17:09, mcanjo <mcanjo@gmail.com> wrote:
> I have an executable (I don't have access to the source code) that
> processes some data. I double click on the icon and a Command prompt
> window pops up. The program asks me for the input file, I hit enter,
> and then it asks me for and output filename, I hit enter a second time
> and it goes off and does its thing and when it is finished running the
> Command Prompt goes away and I have my new output file in the same
> directory as my executable and input file. I would like to be able to
> batch process a group of files. I thought about using "os.spawnv()" in
> a loop and at each iteration of the loop passing in the file in and
> out names but that didn't work. Does anyone have any ideas?

Have a look at the subprocess module.

--
Cheers,
Simon B.


== 2 of 3 ==
Date: Sat, Apr 3 2010 10:20 am
From: mcanjo


On Apr 3, 11:15 am, Patrick Maupin <pmau...@gmail.com> wrote:
> On Apr 3, 11:09 am, mcanjo <mca...@gmail.com> wrote:
>
> > I have an executable (I don't have access to the source code) that
> > processes some data. I double click on the icon and a Command prompt
> > window pops up. The program asks me for the input file, I hit enter,
> > and then it asks me for and output filename, I hit enter a second time
> > and it goes off and does its thing and when it is finished running the
> > Command Prompt goes away and I have my new output file in the same
> > directory as my executable and input file. I would like to be able to
> > batch process a group of files. I thought about using "os.spawnv()" in
> > a loop and at each iteration of the loop passing in the file in and
> > out names but that didn't work. Does anyone have any ideas?
>
> You need to look at the subprocess module, and use pipes.
>
> Regards,
> Pat


I tried doing the following code:

from subprocess import Popen
from subprocess import PIPE, STDOUT
exefile = Popen('pmm.exe', stdout = PIPE, stdin = PIPE, stderr =
STDOUT)
exefile.communicate('MarchScreen.pmm\nMarchScreen.out')[0]

and the Command Prompt opened and closed, no exceptions were generated
but the program didn't run. Am I doing something wrong?


== 3 of 3 ==
Date: Sat, Apr 3 2010 10:29 am
From: Patrick Maupin


On Apr 3, 12:20 pm, mcanjo <mca...@gmail.com> wrote:
> On Apr 3, 11:15 am, Patrick Maupin <pmau...@gmail.com> wrote:
>
>
>
> > On Apr 3, 11:09 am, mcanjo <mca...@gmail.com> wrote:
>
> > > I have an executable (I don't have access to the source code) that
> > > processes some data. I double click on the icon and a Command prompt
> > > window pops up. The program asks me for the input file, I hit enter,
> > > and then it asks me for and output filename, I hit enter a second time
> > > and it goes off and does its thing and when it is finished running the
> > > Command Prompt goes away and I have my new output file in the same
> > > directory as my executable and input file. I would like to be able to
> > > batch process a group of files. I thought about using "os.spawnv()" in
> > > a loop and at each iteration of the loop passing in the file in and
> > > out names but that didn't work. Does anyone have any ideas?
>
> > You need to look at the subprocess module, and use pipes.
>
> > Regards,
> > Pat
>
> I tried doing the following code:
>
> from subprocess import Popen
> from subprocess import PIPE, STDOUT
> exefile = Popen('pmm.exe', stdout = PIPE, stdin = PIPE, stderr =
> STDOUT)
> exefile.communicate('MarchScreen.pmm\nMarchScreen.out')[0]
>
> and the Command Prompt opened and closed, no exceptions were generated
> but the program didn't run. Am I doing something wrong?

I don't use communicate because I've never gotten it to do what I
want. I also don't use Windows. I have a linux solution that allows
me to feed stuf into a pipe, but I don't think it will work under
Windows because it uses os functions to block on empty pipes that
Windows doesn't support.

You might read PEP 3145 -- it addresses some of the issues, and there
is some code to help, I think:

http://www.python.org/dev/peps/pep-3145/

Regards,
Pat


==============================================================================
TOPIC: off topic but please forgive me me and answer
http://groups.google.com/group/comp.lang.python/t/0d4f564a49022b74?hl=en
==============================================================================

== 1 of 8 ==
Date: Sat, Apr 3 2010 9:35 am
From: Mensanator


On Apr 3, 10:17 am, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.au> wrote:
> On Sat, 03 Apr 2010 15:43:41 +0100, Martin P. Hellwig wrote:
> > I am replying to this post not because I disagree but because it
> > postalogically  fits the best (I am by no means an expert either).
>
> > IMHO, the crackpot in this regard is actually partially right,
> > multiplication does mean that the number must get bigger, however for
> > fractions you multiply four numbers, two numerators and two
> > denominators. The resulting numerator and denominator by this
> > multiplication get indeed bigger.
>
> But you're not multiplying four numbers,

You are if you're using Rationals.

> you're multiplying two numbers.

Because they're expressed as Decimals.

> One-half is not "two numbers",

Sometimes it is.

> that would be a tuple

Like this?

>>> gmpy.mpq('0.5')
mpq(1,2)


> or a list or
> possibly a coordinate pair. One-half is a single number,

When dealing with crackpots, it does not help to use the
wrong arguments. When multiplying gmpy.mpq(2,3) by gmpy.mpq(2,3),
the numerator and denominator have both indeed gotten bigger.
The trick is that when combined, the overall result is smaller.

> the number which
> if you double it gives one.
>
> Fortunately multiplication is consistent. Multiplying the two numbers 0.5
> and 0.5 is exactly the same as multiplying 1*1 and 2*2 then dividing to
> get a single number. It's not the same as multiplying 1*1 and 2*2 to get
> two numbers, 1 and 4.
>
> You say that multiplication means that the number "must get bigger".

Yes, not in every case, but in many cases it does. You need to point
out that it is wrong EVEN IN THE CASES WHERE IT'S TRUE. It is a
Non Sequitur - it does not follow that a number must be bigger if
the numerator and denominator have each gotten larger.

>
> 5*1 = 5
> 5*0 = 0
> 5*-2 = -10
>
> I hope you won't try to argue that 5, 0 and -10 are all bigger than 5.

Yes, but these special cases don't help. It needs to be pointed out
that the argument is wrong even in cases like 2/3 * 2/3.

>
> There really is no point trying to dignify superpollo's friend's
> assertion on the basis of some technicality. His argument is no different
> from the argument that says that pythons are snakes, and therefore python
> can't be a programming language and this newsgroup can't possibly exist.
> Words can have multiple meanings, and meanings can shift. Multiply may be
> derived from a word which, once upon a time, meant to get bigger, but
> that's not what multiply means. I don't like to dismiss somebody I've
> never met, but on the basis of what superpollo says, yes, he's a crackpot.
>
> Either that or about age four. When I was four I strongly believed that
> "one hundred" and "a hundred" were different numbers. I argued (not very
> convincingly, but with great vehemence) to my teacher and my parents that
> you counted up to ninety-nine, then a hundred, a hundred and one, a
> hundred and two, ... a hundred and ninety-nine, *one* hundred.
>
> --
> Steven

== 2 of 8 ==
Date: Sat, Apr 3 2010 9:59 am
From: Emile van Sebille


On 4/3/2010 8:46 AM Patrick Maupin said...
> On Apr 3, 9:43 am, "Martin P. Hellwig"> IMHO, the crackpot in this
> regard is actually partially right,
>> multiplication does mean that the number must get bigger, however for
>> fractions you multiply four numbers, two numerators and two
>> denominators. The resulting numerator and denominator by this
>> multiplication get indeed bigger.
>
> That argument is great! Just make sure that you've managed to leave
> before the class has to learn about irrational numbers that don't
> *have* numerators and denominators ;-)

Ahh, but no ones arguing that irrational numbers don't get bigger --
even before you multiply them!

Emile

== 3 of 8 ==
Date: Sat, Apr 3 2010 10:13 am
From: Steve Holden


Mensanator wrote:
[...]
> When dealing with crackpots, it does not help to use the
> wrong arguments. [...]

Correct. Unfortunately, it doesn't help to use the right ones either.
In fact, that could almost be a definition of "crackpot" (and alas now
we approach territory where we risk offending the religious, so I will
cease and desist).

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/

== 4 of 8 ==
Date: Sat, Apr 3 2010 10:15 am
From: Patrick Maupin


On Apr 3, 11:59 am, Emile van Sebille <em...@fenx.com> wrote:
> On 4/3/2010 8:46 AM Patrick Maupin said...
>
> > On Apr 3, 9:43 am, "Martin P. Hellwig">  IMHO, the crackpot in this
> > regard is actually partially right,
> >> multiplication does mean that the number must get bigger, however for
> >> fractions you multiply four numbers, two numerators and two
> >> denominators. The resulting numerator and denominator by this
> >> multiplication get indeed bigger.
>
> > That argument is great!  Just make sure that you've managed to leave
> > before the class has to learn about irrational numbers that don't
> > *have* numerators and denominators ;-)
>
> Ahh, but no ones arguing that irrational numbers don't get bigger --
> even before you multiply them!

True, but being an optimist, just as (-1 * -1 == +1) (which
admittedly, I had a hard time trying to explain to my father years
ago), and just as (not not True == True) and just as multiplying two
imaginary numbers can have a real result, I was hoping that it would
also be the case that having a discussion with an irrational person
about irrational numbers could have a rational result. Of course,
that hope was incredibly naive of me, since most operations with
irrational numbers which do not involve either closely related
irrational numbers or zero will also result in irrational numbers. I
think induction will show that this property (that an irrational
number can make any result that it is involved in irrational) can also
be applied to irrational people and discussions. ;-)

Regards,
Pat


== 5 of 8 ==
Date: Sat, Apr 3 2010 10:39 am
From: MRAB


Patrick Maupin wrote:
> On Apr 3, 11:59 am, Emile van Sebille <em...@fenx.com> wrote:
>> On 4/3/2010 8:46 AM Patrick Maupin said...
>>
>>> On Apr 3, 9:43 am, "Martin P. Hellwig"> IMHO, the crackpot in this
>>> regard is actually partially right,
>>>> multiplication does mean that the number must get bigger, however for
>>>> fractions you multiply four numbers, two numerators and two
>>>> denominators. The resulting numerator and denominator by this
>>>> multiplication get indeed bigger.
>>> That argument is great! Just make sure that you've managed to leave
>>> before the class has to learn about irrational numbers that don't
>>> *have* numerators and denominators ;-)
>> Ahh, but no ones arguing that irrational numbers don't get bigger --
>> even before you multiply them!
>
> True, but being an optimist, just as (-1 * -1 == +1) (which
> admittedly, I had a hard time trying to explain to my father years
> ago), and just as (not not True == True) and just as multiplying two
> imaginary numbers can have a real result, I was hoping that it would
> also be the case that having a discussion with an irrational person
> about irrational numbers could have a rational result. Of course,
> that hope was incredibly naive of me, since most operations with
> irrational numbers which do not involve either closely related
> irrational numbers or zero will also result in irrational numbers. I
> think induction will show that this property (that an irrational
> number can make any result that it is involved in irrational) can also
> be applied to irrational people and discussions. ;-)
>
The square root of 2 is irrational, but if you multiply it by itself
then the result isn't irrational, so not all operations involving
irrational numbers will result in an irrational result (unless that's
what you mean by "closely related irrational numbers").


== 6 of 8 ==
Date: Sat, Apr 3 2010 10:56 am
From: Patrick Maupin


On Apr 3, 12:39 pm, MRAB <pyt...@mrabarnett.plus.com> wrote:
> Patrick Maupin wrote:
> > On Apr 3, 11:59 am, Emile van Sebille <em...@fenx.com> wrote:
> >> On 4/3/2010 8:46 AM Patrick Maupin said...
>
> >>> On Apr 3, 9:43 am, "Martin P. Hellwig">  IMHO, the crackpot in this
> >>> regard is actually partially right,
> >>>> multiplication does mean that the number must get bigger, however for
> >>>> fractions you multiply four numbers, two numerators and two
> >>>> denominators. The resulting numerator and denominator by this
> >>>> multiplication get indeed bigger.
> >>> That argument is great!  Just make sure that you've managed to leave
> >>> before the class has to learn about irrational numbers that don't
> >>> *have* numerators and denominators ;-)
> >> Ahh, but no ones arguing that irrational numbers don't get bigger --
> >> even before you multiply them!
>
> > True, but being an optimist, just as (-1 * -1 == +1) (which
> > admittedly, I had a hard time trying to explain to my father years
> > ago), and just as (not not True == True) and just as multiplying two
> > imaginary numbers can have a real result, I was hoping that it would
> > also be the case that having a discussion with an irrational person
> > about irrational numbers could have a rational result.  Of course,
> > that hope was incredibly naive of me, since most operations with
> > irrational numbers which do not involve either closely related
> > irrational numbers or zero will also result in irrational numbers.  I
> > think induction will show that this property (that an irrational
> > number can make any result that it is involved in irrational) can also
> > be applied to irrational people and discussions.  ;-)
>
> The square root of 2 is irrational, but if you multiply it by itself
> then the result isn't irrational, so not all operations involving
> irrational numbers will result in an irrational result (unless that's
> what you mean by "closely related irrational numbers").

Yes, I think I am closely related to myself. But in addition to that
particular disclaimer, I qualified the statement with "most" and I
also mentioned that zero is special. I stand by the assertion that if
you take a random assortment of non-zero numbers, some irrational,
some rational, and a random assortment of numeric operators, that most
operations involving an irrational number will have an irrational
result.

Regards,
Pat


== 7 of 8 ==
Date: Sat, Apr 3 2010 12:21 pm
From: Andreas Waldenburger


On Sat, 03 Apr 2010 13:13:38 -0400 Steve Holden <steve@holdenweb.com>
wrote:

> Correct. Unfortunately, it doesn't help to use the right ones either.
> In fact, that could almost be a definition of "crackpot" (and alas now
> we approach territory where we risk offending the religious, so I will
> cease and desist).

Except that you didn't. ;)

/W

--
INVALID? DE!

== 8 of 8 ==
Date: Sat, Apr 3 2010 1:17 pm
From: "Martin P. Hellwig"


On 04/03/10 16:46, Patrick Maupin wrote:
> On Apr 3, 9:43 am, "Martin P. Hellwig"> IMHO, the crackpot in this
> regard is actually partially right,
>> multiplication does mean that the number must get bigger, however for
>> fractions you multiply four numbers, two numerators and two
>> denominators. The resulting numerator and denominator by this
>> multiplication get indeed bigger.
>
> That argument is great! Just make sure that you've managed to leave
> before the class has to learn about irrational numbers that don't
> *have* numerators and denominators ;-)

Yeah but those numbers have their own problems anyway, one of them being
that you are never sure how big/small they actually are, so by that
logic you could argue that if you can not give an exact measure for a
given number, bickering over it size after an operation is pretty
pointless (pun intended) :-)

Beside the only number that really matters is 42 ;-)

--
mph

==============================================================================
TOPIC: (a==b) ? 'Yes' : 'No'
http://groups.google.com/group/comp.lang.python/t/b985d5727945d2b4?hl=en
==============================================================================

== 1 of 2 ==
Date: Sat, Apr 3 2010 10:44 am
From: John Bokma


Steve Howell <showell30@yahoo.com> writes:

> In languages like Ruby/Perl the inverted if statement is also a useful
> idiom to emphasize concisely that code is exceptional in nature:
>
> def quotient(m, n)
> # guard code
> return None if n == 0
>
> # happy path
> return m / n
> end

Still, in Perl I prefer:

sub quotient {

my ( $m, $n ) = @_;
$n != 0 or return;

return $m / $n;
}

but I guess it depends a lot on what you're used to read.

--
John Bokma j3b

Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


== 2 of 2 ==
Date: Sat, Apr 3 2010 5:26 pm
From: Lawrence D'Oliveiro


In message <mailman.1345.1269992641.23598.python-list@python.org>, Steve
Holden wrote:

> Lawrence D'Oliveiro wrote:
>
>> By the way, you don't need the parentheses.
>
> But at the same time, if you don't *absolutely know* you don't need the
> parentheses ...

But you can "abolutely know"—it's all spelled out here
<http://docs.python.org/reference/expressions.html>. Just keep that page
open every time you write Python code.

==============================================================================
TOPIC: "JOBS IN CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "
ACCOUNTS JOBS IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA" "
ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA" http://jobsincanada-net.
blogspot.com/
http://groups.google.com/group/comp.lang.python/t/e554d6b4ab6f7ab9?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Apr 3 2010 11:07 am
From: saima81


"JOBS IN CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS"
"ACCOUNTS JOBS IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN
CANADA" "ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/ "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/

==============================================================================
TOPIC: C-style static variables in Python?
http://groups.google.com/group/comp.lang.python/t/ce1a7abe2f3816b9?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Apr 3 2010 12:03 pm
From: Stephen Hansen


On 2010-04-02 20:24:46 -0700, Patrick Maupin said:

> On Apr 2, 10:11 pm, Stephen Hansen <apt.shan...@gmail.invalid> wrote:
>>
>> I don't know if properties are really faster or slower then a
>> __getattr__, but I find them a lot cleaner if I want to delay some
>> calculation until needed like that.
>
> Well, the relative speed of properties vs. __getattr__ can become
> irrelevant in at least two ways:
>
> 1) If the __getattr__ only calculates the value one time and then
> stuffs it into the instance dictionary, now you are really comparing
> the relative speed of properties vs. lookup of an attribute in the
> instance dict. If you're at all concerned about speed, I think there
> is a clear winner here.

I concede it would probably be notably faster, but there's a big
difference between "at all concerned about speed" and "optimizing a
profiled bottleneck".

The speed difference between direct attribute lookup and properties may
be notable, but that doesn't make a clear winner here. Now that I have
(with either method) optimized the expensive value-calculation
operation such that it only happens on-demand and once, I now have to
weigh further optimization.

Is the difference in speed between a standard attribute lookup and a
property fetch worth losing the clarity the property brings over the
__getattr__ solution, especially considering the __getattr__ creates a
fuzzy 'sometimes this code is responsible, othertimes the dict is'
situation that someone may down the road miss in maintenance?

For me, usually not-- unless profiling pushes me to reconsider. But
everyone makes these calls differently.

> 2) There is a single __getattr__ function, vs. one property for every
> attribute that needs a property. In cases where you can somehow
> easily compute the attribute names as well as the attribute values,
> __getattr__ can be a *lot* less code than defining dozens of
> properties.

I don't really mind a lot of properties, if they're simple. Then again,
I often prefer regular ol' attributes where possible :) However, if I'm
doing a dispatching sort of mechanism, or a situation where the "name"
isn't something static, set in stone or pre-defined-- then certainly,
__getattr__ is a fine solution. I don't mind it where its the clearest
way to accomplish a goal.

--
--S

... p.s: change the ".invalid" to ".com" in email address to reply privately.


==============================================================================
TOPIC: WinXP, Python3.1.2, dir-listing to XML - problem with unicode file
names
http://groups.google.com/group/comp.lang.python/t/b298b2ed517db778?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Apr 3 2010 2:24 pm
From: "Mark Tolonen"


"kai_nerda" <ewomy@yahoo.com> wrote in message
news:hp69ri+ao5e@eGroups.com...
> Hi,
>
> OS = Windows XP (German language)
> Python = 3.1.2
>
> I need to write a directory listing into a XML file.
> And after hours of trying and searching i have no clue.
>
> My main problem is that the file and folder names can
> have characters of different languages like
> German, Turkish, Russian, maybe else.
>
> Because Python 3.1 is better with unicode, I
> decided to use that instead of 2.6
>
> For testing I have created the following files:
> http://img340.imageshack.us/img340/3461/files.png
> (google for the words
> russia, turkish, deutsch, france
> to find websites with special characters and copy & paste)
>
> And this is the code I have now:
> ############################################
> # -*- coding: iso-8859-1 -*-
> # inspired by:
> # http://www.dpawson.co.uk/java/dirlist.py
> # (for Python ~2.4)
>
> import sys
> print ('filesystemencoding: ' + sys.getfilesystemencoding())
> print ('defaultencoding: ' + sys.getdefaultencoding())
>
>
> from pprint import pprint
> import os.path
> from stat import *
> from xml.sax.saxutils import XMLGenerator
>
> def recurse_dir(path, writer):
> for cdir, subdirs, files in os.walk(path):
> pprint (cdir)
> writer.startElement('dir', { 'name': cdir })
> for f in files:
> uf = f.encode('utf-8')
> pprint (uf)
> attribs = {'name': f}
> attribs['size'] = str(os.stat(os.path.join(cdir,f))[ST_SIZE])
> pprint (attribs)
> writer.startElement('file', attribs)
> writer.endElement('file')
> for subdir in subdirs:
> recurse_dir(os.path.join(cdir, subdir), writer)
> writer.endElement('directory')

This should be:

writer.endElement('dir')

> break
>
> if __name__ == '__main__':
> directory = 'c:\\_TEST\\'
> out = open('C:\\_TEST.xml','w')

The above line opens the file in the default file system encoding 'mbcs'
(cp850 on your system). Try:

out = open('C:\\_TEST.xml','w',encoding='utf8')

Regards,
-Mark

> writer = XMLGenerator(out, 'utf-8')
> writer.startDocument()
> recurse_dir(directory, writer)
>
> out.close()
> ############################################

==============================================================================
TOPIC: Get a method instance through 'getattr' but not superclass's method
http://groups.google.com/group/comp.lang.python/t/17fe44173a924c48?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Apr 3 2010 3:58 pm
From: "Gabriel Genellina"


Please reply inline; top posting is harder to read.

> On Fri, Mar 12, 2010 at 12:15 AM, Gabriel Genellina
> <gagsl-py2@yahoo.com.ar>wrote:
>
>> En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
>> <radhakrishna12@gmail.com> escribió:
>>
>> I am using getattr to get a method instance from a class. But it also
>>> returns methods from the superclass. How to detect if an attribute is
>>> from
>>> superclass?
>>
>> You may look it up directly in the class dictionary (__dict__)

En Sat, 03 Apr 2010 13:37:45 -0300, Radhakrishna Bhat
<radhakrishna12@gmail.com> escribió:>

> thanks. It is working for simple classes. But now i am trying for complex
> objects.
>
> myclassinstance.__class__.dict__ returns <dictproxy object at %$^%>
>
> Looping through the same returned dictproxy gives attributes of
> superclass.
> What am i doing wrong?

Could you provide a failing example?
It works for me in this case:


py> class MyClass(int):
... "This is my derived class"
... foo = 1
... def bar(self): pass
...
py> MyClass
<class '__main__.MyClass'>
py> MyClass.__dict__
<dictproxy object at 0x00C158F0>
py> MyClass.__dict__.keys()
['__module__', 'bar', '__dict__', 'foo', '__weakref__', '__doc__']
py> for name in MyClass.__dict__:
... print '%s: %.30r %.30r' % (name, getattr(MyClass,name),
getattr(int,name,'*does*not*exist*'))
...
__module__: '__main__' '__builtin__'
bar: <unbound method MyClass.bar> '*does*not*exist*'
__dict__: <dictproxy object at 0x00C15E7 <dictproxy object at 0x00C158F
foo: 1 '*does*not*exist*'
__weakref__: <attribute '__weakref__' of 'M '*does*not*exist*'
__doc__: 'This is my derived class' 'int(x[, base]) -> integer\n\n

foo and bar are new attributes. __module__, __dict__, __weakref__ and
__doc__ are different from the base class.
If you want to filter out the last four:

- ignore all attribute names starting and ending with two underscores:
if name[:2] == '__' == name[-2:]: continue

- ignore all attributes already present in the base class.
if hasattr(int, name): continue

--
Gabriel Genellina


==============================================================================
TOPIC: How to access args as a list?
http://groups.google.com/group/comp.lang.python/t/4265701a4b0f611a?hl=en
==============================================================================

== 1 of 7 ==
Date: Sat, Apr 3 2010 3:58 pm
From: kj

Suppose I have a function with the following signature:

def spam(x, y, z):
# etc.

Is there a way to refer, within the function, to all its arguments
as a single list? (I.e. I'm looking for Python's equivalent of
Perl's @_ variable.)

I'm aware of locals(), but I want to preserve the order in which
the arguments appear in the signature.

My immediate aim is to set up a simple class that will allow me to
iterate over the arguments passed to the constructor (plus let me
refer to these individual arguments by their names using an
instance.attribute syntax, as usual).

The best I have managed looks like this:

class _Spam(object):
def __init__(self, x, y, z):
self.__dict__ = OrderedDict(())
for p in inspect.getargspec(_Spam.__init__).args[1:]:
self.__dict__[p] = locals()[p]

def __iter__(self):
return iter(self.__dict__.values())


but rolling out inspect.getargspec for this sort of thing looks to
me like overkill. Is there a more basic approach?

P.S. this is just an example; the function I want to implement has
more parameters in its signature, with longer, more informative
names.

== 2 of 7 ==
Date: Sat, Apr 3 2010 5:16 pm
From: Andreas Waldenburger


On Sat, 3 Apr 2010 22:58:43 +0000 (UTC) kj <no.email@please.post> wrote:

> The best I have managed looks like this:
>
> class _Spam(object):
> def __init__(self, x, y, z):
> self.__dict__ = OrderedDict(())
> for p in inspect.getargspec(_Spam.__init__).args[1:]:
> self.__dict__[p] = locals()[p]
>
> def __iter__(self):
> return iter(self.__dict__.values())

Looks like you're trying to be lazy by doing extra hard work. Anything
wrong with this (?):

class Spam(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
self.arguments = (x, y, z)

def __iter__(self):
return iter(self.arguments) # iter(...) kinda optional

With what little I know about your use case, that's how I would do it.

/W


--
INVALID? DE!

== 3 of 7 ==
Date: Sat, Apr 3 2010 4:20 pm
From: Tim Chase


kj wrote:
>
>
> Suppose I have a function with the following signature:
>
> def spam(x, y, z):
> # etc.
>
> Is there a way to refer, within the function, to all its arguments
> as a single list? (I.e. I'm looking for Python's equivalent of
> Perl's @_ variable.)

It sounds like you want the "*" operator for arguments:

def foo(*args):
print "Args:", repr(args)
print " Type:", type(args)
for i, arg in enumerate(args):
print " Arg #%i = %s" % (i, arg)
foo(1)
foo("abc", "def", 42)
# pass a list as args
lst = [1,2,3]
foo(*lst)

There's also a keyword form using "**":

def foo(*args, **kwargs):
print "Args:", repr(args)
print " Type:", type(args)
print "Keyword Args:", repr(kwargs)
print " Type:", type(kwargs)
for i, arg in enumerate(args):
print " Arg #%i = %s" % (i+1, arg)
for i, (k, v) in enumerate(kwargs.items()):
print " kwarg #%i %r = %s" % (i+1, k, v)
foo(1, "hello", something="Whatever", baz=42)
# pass a list and a dict:
lst = [1,2,3]
dct = {100:10, 200:11}
foo(*lst, **dct)

Both prevent introspection, so if you want the auto-generated
help to populate with named arguments, you'd have to use the
inspection method you're currently using. But generally, if you
want to be able to treat the args as lists/tuples/dicts, you
don't care about the names given.

-tim


== 4 of 7 ==
Date: Sat, Apr 3 2010 4:20 pm
From: MRAB


kj wrote:
>
>
> Suppose I have a function with the following signature:
>
> def spam(x, y, z):
> # etc.
>
> Is there a way to refer, within the function, to all its arguments
> as a single list? (I.e. I'm looking for Python's equivalent of
> Perl's @_ variable.)
>
> I'm aware of locals(), but I want to preserve the order in which
> the arguments appear in the signature.
>
> My immediate aim is to set up a simple class that will allow me to
> iterate over the arguments passed to the constructor (plus let me
> refer to these individual arguments by their names using an
> instance.attribute syntax, as usual).
>
> The best I have managed looks like this:
>
> class _Spam(object):
> def __init__(self, x, y, z):
> self.__dict__ = OrderedDict(())
> for p in inspect.getargspec(_Spam.__init__).args[1:]:
> self.__dict__[p] = locals()[p]
>
> def __iter__(self):
> return iter(self.__dict__.values())
>
>
> but rolling out inspect.getargspec for this sort of thing looks to
> me like overkill. Is there a more basic approach?
>
> P.S. this is just an example; the function I want to implement has
> more parameters in its signature, with longer, more informative
> names.
>
I think the closest approach to what you're asking is to capture the
arguments as a list and then bind them to local names:

def spam(*args):
x, y, z = args
# etc.


== 5 of 7 ==
Date: Sat, Apr 3 2010 4:21 pm
From: Rolando Espinoza La Fuente


On Sat, Apr 3, 2010 at 6:28 PM, kj <no.email@please.post> wrote:
> Is there a way to refer, within the function, to all its arguments
> as a single list?  (I.e. I'm looking for Python's equivalent of
> Perl's @_ variable.)
>

def spam(*args, **kwargs):
print args
print kwargs

class Spam:
def __init__(self, *args, **kwargs):
print args
print kwargs

That's what are you looking for?

Regards,

~Rolando


== 6 of 7 ==
Date: Sat, Apr 3 2010 4:52 pm
From: kj


In <hp8h73$k17$1@reader1.panix.com> kj <no.email@please.post> writes:

>Suppose I have a function with the following signature:

>def spam(x, y, z):
> # etc.

>Is there a way to refer, within the function, to all its arguments
>as a single list? (I.e. I'm looking for Python's equivalent of
>Perl's @_ variable.)

>I'm aware of locals(), but I want to preserve the order in which
>the arguments appear in the signature.

>My immediate aim is to set up a simple class that will allow me to
>iterate over the arguments passed to the constructor (plus letS me
^^^^^^^^^^^^
>refer to these individual arguments by their names using an
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>instance.attribute syntax, as usual).
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The underlined portion explains why __init__(self, *args) fails to
fit the bill.

>P.S. this is just an example; the function I want to implement has
>more parameters in its signature, with longer, more informative
>names.

Andreas, perhaps this paragraph explains why I find your solution
unappealing: it requires typing the same thing over and over,
which increases the chances of bugs. That's the reason I avoid
such repetitiveness, not laziness, as you so were so quick to accuse
me of.

~K


== 7 of 7 ==
Date: Sat, Apr 3 2010 4:55 pm
From: kj


In <hp8kc9$dg7$1@reader1.panix.com> kj <no.email@please.post> writes:

>In <hp8h73$k17$1@reader1.panix.com> kj <no.email@please.post> writes:

>>Suppose I have a function with the following signature:

>>def spam(x, y, z):
>> # etc.

>>Is there a way to refer, within the function, to all its arguments
>>as a single list? (I.e. I'm looking for Python's equivalent of
>>Perl's @_ variable.)

>>I'm aware of locals(), but I want to preserve the order in which
>>the arguments appear in the signature.

>>My immediate aim is to set up a simple class that will allow me to
>>iterate over the arguments passed to the constructor (plus letS me
> ^^^^^^^^^^^^
>>refer to these individual arguments by their names using an
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>instance.attribute syntax, as usual).
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

>The underlined portion explains why __init__(self, *args) fails to
>fit the bill.

The minute I hit "send" I realized that this is wrong. Sorry.

Thanks.


==============================================================================
TOPIC: Question on templates and python logging
http://groups.google.com/group/comp.lang.python/t/0bf72baa090986f3?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Apr 3 2010 4:42 pm
From: David LePage


Hi -
I have been struggling with this problem for quite some time and was hoping somebody could give me some pointers.

I have a wxPython front end wizard that collects some information and outputs some HTML pages (not hosted by a web server, but viewable locally on the machine running the application).

The problem that i'm trying to solve is taking data collected along the way and outputting this into these HTML pages.

One of the pages is simply collecting debug information about the execution of the program.
All logging is currently being done using the python logging library.

Due to the fact that my HTML files need to be populated in the <body> tags, I wanted to write directly to the proper HTML page based on the logging level message (INFO, DEBUG, etc).

Something like this works nicely if you have a dictionary storing the data:

def template():
return open("html/html.tmpl", 'r').read() % vars

print template("html/Logs.html", { 'body' : "A test body field" })


But in my case, some of the data could be MB in size and I didn't want to read/write that entire load of data before displaying the pages if at all possible.
I was hoping I could tie the logging classes into something like this, where I was leveraging an HTML template, but also taking advantage of the logging library since it works nicely for me today.

Does anybody have any suggestions on how they might approach this problem?

thanks!

DLP


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en

To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate