Re: [OT]Royal pardon for codebreaker Turing

2013-12-28 Thread Mark Lawrence

On 28/12/2013 04:16, Steven D'Aprano wrote:

On Sat, 28 Dec 2013 07:30:34 +1100, Tim Delaney wrote:


On 28 December 2013 04:34, Mark Lawrence 
wrote:



Personally, I think that people ought to throw a party celebrating
Turing's rehabilitation, and do it right outside the Russian Embassy.



Any particular reason for the restriction to Russian Embassy?



I suspect it's in reference to the difficulties homosexuals are likely
to face when attending or competing in the 2014 Winter Olympic and
Paralympic Games at Sochi.


I don't care about the Olympians. Their presence in Russia is voluntary,
and so long as they keep it in their pants for a few weeks (or at least
don't get caught) they get to go home again a few weeks later. Have a
thought for those who don't get to go home again. I'm talking about the
situation in Russia, where the government is engaging in 1930s-style
scape-goating and oppression of homosexuals. They haven't quite reached
the level of Kristallnacht or concentration camps, but the rhetoric and
laws coming out of the Kremlin are just like that coming out of the
Reichstag in the thirties.



The moral of the story is clear.  Stay well clear of Russia if you're 
gay.  Head to some gay friendly nation, such as Uganda or for that 
matter the vast majority of African states.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: cascading python executions only if return code is 0

2013-12-28 Thread Gene Heskett
On Friday 27 December 2013 19:07:08 pec...@pascolo.net did opine:

> Roy Smith  writes:
> > Or how to deal with languages where 26 letters isn't enough.
> 
> English! that is, imvho
> English is in sore need
> of some more letters[*]
> and of diacriticals too
>   g
> [*] unable to quantify!

You know, this gentleman is indeed correct.  But since that is all I have 
ever been speaking/reading/writing for almost 80 years, please have the 
courtesy of waiting to extend the character set and grammatical rules until 
after I've passed.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 

If one studies too zealously, one easily loses his pants.
-- A. Einstein.
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: String Template

2013-12-28 Thread Giuseppe Tripoli
The problem is that I have a huge amount of log apache, log Akami, log cotendo, 
log iis ... messily all together.

And the program does is that, according to the file name, use the configuration 
file to read.
Certainly the quickest and easiest method is to use the regex, but I did not 
really intend to change the configuration file.

I think I will change technique.

Thank you very much for your answer
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: String Template

2013-12-28 Thread Chris Angelico
On Sat, Dec 28, 2013 at 11:33 PM, Giuseppe Tripoli  wrote:
> Certainly the quickest and easiest method is to use the regex, but I did not 
> really intend to change the configuration file.

Then all you need is a way to convert your config file string into a
regex, which shouldn't be too difficult. Try the translation I
described in the earlier post; it might be all you need.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: String Template

2013-12-28 Thread Cristiano Araujo
On Friday, December 27, 2013 9:55:00 AM UTC-3, Giuseppe Tripoli wrote:
> Hello
> 
> 
> 
> I'm rewriting a program previously written in C #, and trying to keep the 
> same configuration file, I have a problem with untapped strings.
> 
> 
> 
> The previous configuration files provide an input template string of this 
> type:
> 
> 
> 
>  
> 
> 
> 
> 
> 
> This string is parsed and the values are replaced with the actual values 
> written to a log file (apache), then he is given the variable name.
> 
> 
> 
> Taking for example a classic line of apache log:
> 
> 
> 
> 0.0.0.0 - [27/Dec/2013: 00:56:51 +0100] "GET / webdav / HTTP/1.1" 404 524 "-" 
> "Mozilla/5.0 (Windows, U, Windows NT 5.1, en-US , rv: 1.9.2.12) 
> Gecko/20101026 Firefox/3.6.12 "
> 
> 
> 
> Is there any way to pull out the values so arranged as follows:
> 
> 
> 
> ip = 0.0.0.0
> 
> date = 27/Dec/2013: 00:56:51 +0100
> 
> url = / webdav /
> 
> 
> 
> Tnx

maybe it can be helpful: 
http://stackoverflow.com/questions/12544510/parsing-apache-log-files
-- 
https://mail.python.org/mailman/listinfo/python-list


NOW Watch Hot Sexy Star Aishwarya rai Bathing Videos In All Angles

2013-12-28 Thread vbfvf6
Sexys
-- 
https://mail.python.org/mailman/listinfo/python-list


outsmarting context managers with coroutines

2013-12-28 Thread Burak Arslan
Hi,

Have a look at the following code snippets:
https://gist.github.com/plq/8164035

Observations:

output2: I can break out of outer context without closing the inner one
in Python 2
output3: Breaking out of outer context closes the inner one, but the
closing order is wrong.
output3-yf: With yield from, the closing order is fine but yield returns
None before throwing.

All of the above seem buggy in their own way. And actually, Python 2
seems to leak memory when generators and context managers are used this way.

Are these behaviours intentional? How much of it is
implementation-dependent? Are they documented somewhere? Neither PEP-342
nor PEP-380 talk about context managers and PEP-343 talks about
generators but not coroutines.

My humble opinion:

1) All three should behave in the exact same way.
2) Throwing into a generator should not yield None before throwing.

Best,
Burak

ps: I have:

$ python -V; python3 -V
Python 2.7.5
Python 3.3.2
-- 
https://mail.python.org/mailman/listinfo/python-list


Python mange with liste

2013-12-28 Thread Bala Ji
Hello guys,
i need some help with is program

I have a txt file "test.txt" where there is Name;Sexe;Answer(Y or N)
example of txt file:
--
nam1;F;Y
nam2;M;N
nam3;F;Y
nam4;M;N
halo;M;Y
rock;M;N
nam1;F;N
_

so my program will ask the name, sexe, and answer and it will tell me if the 
name exist or not

example i will enter
nam1;F;O

The program must tell me that nam1 with sexe F existe. (it must take in count 
the answer)


name = raw_input('name: ')
sexe = raw_input('sexe: ')
r1 = raw_input('r1 Y or N: ')
infos = name+";"+sexe+";"+r1

f=open("test.txt","r")
conten = f.read()
print conten
f.close()

#f=open("test.txt","a")
#f.write(infos)
#f.write('\n')
#f.close()


thank you =)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: outsmarting context managers with coroutines

2013-12-28 Thread Burak Arslan
On 12/29/13 00:13, Burak Arslan wrote:
> Hi,
>
> Have a look at the following code snippets:
> https://gist.github.com/plq/8164035
>
> Observations:
>
> output2: I can break out of outer context without closing the inner one
> in Python 2
> output3: Breaking out of outer context closes the inner one, but the
> closing order is wrong.
> output3-yf: With yield from, the closing order is fine but yield returns
> None before throwing.

It doesn't, my mistake. Python 3 yield from case does the right thing, I
updated the gist. The other two cases still seem weird to me though. I
also added a possible fix for python 2 behaviour in a separate script,
though I'm not sure that the best way of implementing poor man's yield from.

Sorry for the noise.

Best,
Burak

> All of the above seem buggy in their own way. And actually, Python 2
> seems to leak memory when generators and context managers are used this way.
>
> Are these behaviours intentional? How much of it is
> implementation-dependent? Are they documented somewhere? Neither PEP-342
> nor PEP-380 talk about context managers and PEP-343 talks about
> generators but not coroutines.
>
> My humble opinion:
>
> 1) All three should behave in the exact same way.
> 2) Throwing into a generator should not yield None before throwing.
>
> Best,
> Burak
>
> ps: I have:
>
> $ python -V; python3 -V
> Python 2.7.5
> Python 3.3.2

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python mange with liste

2013-12-28 Thread Rustom Mody
On Sun, Dec 29, 2013 at 5:00 AM, Bala Ji wrote:
> Hello guys,
> i need some help with is program
>
> I have a txt file "test.txt" where there is Name;Sexe;Answer(Y or N)
> example of txt file:
> --
> nam1;F;Y
> nam2;M;N
> nam3;F;Y
> nam4;M;N
> halo;M;Y
> rock;M;N
> nam1;F;N
> _
>
> so my program will ask the name, sexe, and answer and it will tell me if the 
> name exist or not
>
> example i will enter
> nam1;F;O
>
> The program must tell me that nam1 with sexe F existe. (it must take in count 
> the answer)
>
> 
> name = raw_input('name: ')
> sexe = raw_input('sexe: ')
> r1 = raw_input('r1 Y or N: ')
> infos = name+";"+sexe+";"+r1
>
> f=open("test.txt","r")
> conten = f.read()
> print conten
> f.close()
>
> #f=open("test.txt","a")
> #f.write(infos)
> #f.write('\n')
> #f.close()
> 

One general rule of programming is:
If you dont know how to solve a problem:
- solve a related simpler problem
- figure out how to convert your original problem into the simpler one


So heres a simpler problem to try:

Give up on file-IO, ie dont use the EXTERNAL file

nam1;F;Y
nam2;M;N
nam3;F;Y
nam4;M;N
halo;M;Y
rock;M;N
nam1;F;N

But ASSUME you have the internal python data structure
names = [("nam1", "F", "Y"), ("nam2", "M", "N")] # complete the list

Likewise if you wish, get rid of the raw_inputs and just ASSUME you
somehow have a tuple: a variable info of the form
(name, sex, r1) # whatever r1 is

Now:
1. solve your problem for the INTERNAL data structures:
a. names which is a list
b. info which is like an element of that list

Note: Observe how I sneakily made info look like the things in names

2. Convert your problem into the above by using suitable file-IO

3. If there is something in the above you dont understand -- whether
python or English -- write back here

Best
Rusi


-- 
http://blog.languager.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python mange with liste

2013-12-28 Thread Rustom Mody
On Sun, Dec 29, 2013 at 8:38 AM, Rustom Mody wrote:
> Give up on file-IO, ie dont use the EXTERNAL file
>
> nam1;F;Y
> nam2;M;N
> nam3;F;Y
> nam4;M;N
> halo;M;Y
> rock;M;N
> nam1;F;N
>
> But ASSUME you have the internal python data structure
> names = [("nam1", "F", "Y"), ("nam2", "M", "N")] # complete the list

Well it may be better to write that as
names = [("nam1", "F", True), ("nam2", "M", False), etc]

ie represent Y by boolean True rather than the string "Y" etc

though you could get bitten by the fact that python booleans are
strange in that True is True but all kinds of things are True-ish
-- 
https://mail.python.org/mailman/listinfo/python-list


Unit tests and coverage

2013-12-28 Thread Joseph L. Casale
I have a script that accepts cmdline arguments and receives input via stdin.
I have a unit test for it that uses Popen to setup an environment, pass the args
and provide the stdin.

Problem is obviously this does nothing for providing coverage. Given the above
specifics, anyone know of a way to work around this?

Thanks,
jlc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unit tests and coverage

2013-12-28 Thread Roy Smith
In article ,
 "Joseph L. Casale"  wrote:

> I have a script that accepts cmdline arguments and receives input via stdin.
> I have a unit test for it that uses Popen to setup an environment, pass the 
> args and provide the stdin.
> 
> Problem is obviously this does nothing for providing coverage. Given the 
> above specifics, anyone know of a way to work around this?

What do you mean by "providing coverage"?  If you mean, "automatically 
generate every possible combination of inputs", that's not, in general, 
possible.

There are lots of different meanings people give to the word "coverage" 
when talking about testing code.  One common definition is, "provide 
sufficient sets of inputs to cause every branch in the code to be taken 
at least once".  That's a pretty weak definition (since it doesn't talk 
about combinations of branches), but even that can be amazingly hard to 
satisfy.  For example, imagine the following code:

try:
   big_hairy_operation()
except MemoryError:
   print "Oh noes, out of memory!"

what combination of inputs do you have to provide to cause the except 
clause to be executed?  Or, to touch on an example I mentioned in a 
recent thread:

t0 = time.time()
while True:
   t1 = time.time()
   if t1 < t0:
print "Distortion detected in the time-space continuum"
t0 = t1

So, back to my original question; what do you mean by "providing 
coverage"?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: outsmarting context managers with coroutines

2013-12-28 Thread Ian Kelly
On Sat, Dec 28, 2013 at 5:35 PM, Burak Arslan
 wrote:
> On 12/29/13 00:13, Burak Arslan wrote:
>> Hi,
>>
>> Have a look at the following code snippets:
>> https://gist.github.com/plq/8164035
>>
>> Observations:
>>
>> output2: I can break out of outer context without closing the inner one
>> in Python 2
>> output3: Breaking out of outer context closes the inner one, but the
>> closing order is wrong.
>> output3-yf: With yield from, the closing order is fine but yield returns
>> None before throwing.
>
> It doesn't, my mistake. Python 3 yield from case does the right thing, I
> updated the gist. The other two cases still seem weird to me though. I
> also added a possible fix for python 2 behaviour in a separate script,
> though I'm not sure that the best way of implementing poor man's yield from.

I don't see any problems here.  The context managers in question are
created in separate coroutines and stored on separate stacks, so there
is no "inner" and "outer" context in the thread that you posted.  I
don't believe that they are guaranteed to be called in any particular
order in this case, nor do I think they should be.

For example, the first generator could yield the second generator back
to its caller and then exit, in which case the second generator would
still be active while the context manager in the first generator would
already have done its clean-up.  To assure that the context managers
exit in the order you suggest, the call to the first context manager's
exit would have to be deferred until the second context manager exits,
which could happen much later.  That would complicate the
implementation and does not fit very well with the cooperative
multi-tasking model.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Unit tests and coverage

2013-12-28 Thread Joseph L. Casale
> So, back to my original question; what do you mean by "providing
> coverage"?

Hi Roy,
I meant touch every line, such as what https://pypi.python.org/pypi/coverage
measures.

As the script is being invoked with Popen, I lose that luxury and only gain
the assertions tests but that of course doesn't show me untested branches.

Thanks,
jlc
-- 
https://mail.python.org/mailman/listinfo/python-list