Re: What version of glibc is Python using?

2013-10-13 Thread John Nagle
On 10/12/2013 4:43 AM, Ian Kelly wrote:
> On Sat, Oct 12, 2013 at 2:46 AM, Terry Reedy  wrote:
>> On 10/12/2013 3:53 AM, Christian Gollwitzer wrote:
>>>
>>> That function is really bogus. It states itself, that it has "intimate
>>> knowledge of how different libc versions add symbols to the executable
>>> and thus is probably only useable for executables compiled using gcc"
>>> which is just another way of saying "it'll become outdated and broken
>>> soon". It's not even done by reading the symbol table, it opens the
>>> binary and matches a RE *shocked* I would have expected such hacks in a
>>> shell script.
>>>
>>> glibc has a function for this:
>>>
>>>  gnu_get_libc_version ()
>>>
>>> which should be used.
>>
>>
>> So *please* submit a patch with explanation.
> 
> Easier said than done.  The module is currently written in pure
> Python, and the comment "Note: Please keep this module compatible to
> Python 1.5.2" would appear to rule out the use of ctypes to call the
> glibc function.  I wonder though whether that comment is really still
> appropriate.

   What a mess.  It only "works" on Linux,
it only works with GCC, and there it returns bogus results.

   Amusingly, there was a fix in 2011 to speed up
platform.libc_ver () by having it read bigger blocks:

http://code.activestate.com/lists/python-checkins/100109/

It still got the wrong answer, but it's faster.

There's a bug report that it doesn't work right on Solaris:

http://comments.gmane.org/gmane.comp.python.gis/870

It fails on Cygwin ("wontfix")
http://bugs.python.org/issue928297

The result under GenToo is bogus:

http://archives.gentoo.org/gentoo-user/msg_b676eccb5fc00cb051b7423db1b5a9f7.xml

There are several programs which fetch this info and
display it, or send it in with crash reports, but
I haven't found any that actually use the result
for anything.  I'd suggest deprecating it and
documenting that.

John Nagle



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


Doubt on generators behavior

2013-10-13 Thread Krishnan Shankar
Hi Friends,

I am new to Generators and was learning the same by experimenting. I wrote
a small code which is as below.

>>> def test_gen(var):
... print "The number is", var
... if var % 2 == 0:
... yield var
... else:
... print "Number is odd"
...
>>>

But when i was executing i saw a behavior i could not understand. When i
gave an even number,
1. The generator object was created
2. When i gave next the argument was yielded.
3. In the subsequent next the Stop Iteration was raised.

>>> res = test_gen(78)
>>> res.next()
The number is 78
78
>>> res.next()
Traceback (most recent call last):
  File "", line 1, in 
StopIteration

But When i ran with an odd number the result of "Number is odd" is printed.
But it seems the generator runs again by itself to Stop Iteration.

>>> res2 = test_gen(77)
>>> res2.next()
The number is 77
Number is odd
Traceback (most recent call last):
  File "", line 1, in 
StopIteration
>>>

How did this happen automatically? I am not able to get the execution of a
generator. Can someone please help me in understanding?
Regards,
Krishnan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Doubt on generators behavior

2013-10-13 Thread Jussi Piitulainen
Krishnan Shankar writes:

> Hi Friends,
> 
> I am new to Generators and was learning the same by experimenting. I
> wrote a small code which is as below.
> 
> >>> def test_gen(var):
> ... print "The number is", var
> ... if var % 2 == 0:
> ... yield var
> ... else:
> ... print "Number is odd"
> ...
> >>>
> 
> But when i was executing i saw a behavior i could not
> understand. When i gave an even number,
> 1. The generator object was created
> 2. When i gave next the argument was yielded.
> 3. In the subsequent next the Stop Iteration was raised.
> 
> >>> res = test_gen(78)
> >>> res.next()
> The number is 78
> 78
> >>> res.next()
> Traceback (most recent call last):
>   File "", line 1, in 
> StopIteration

Yes. The yield suspended the computation at a point where all that
remains is to fall through. That happens at next, and the exception is
raised then.

> But When i ran with an odd number the result of "Number is odd" is
> printed.  But it seems the generator runs again by itself to Stop
> Iteration.

It doesn't run again. It just does what remains after the print
statement: it falls through, and the exception is raised.

> >>> res2 = test_gen(77)
> >>> res2.next()
> The number is 77
> Number is odd
> Traceback (most recent call last):
>   File "", line 1, in 
> StopIteration
> >>>
> 
> How did this happen automatically? I am not able to get the
> execution of a generator. Can someone please help me in
> understanding?

I think you might benefit from the following experiments (untested):

def gen3(seed):
   yield(seed)
   yield(seed + 1)
   yield(seed + 2)

def genby2(seed):
   while True:
 yield seed
 seed += 2

def geneven(seed):
   if seed % 2 == 1:
  raise Exception('odd seed')
   while True:
  yield seed
  seed += 2

def genrange(begin, end):
   for k in range(begin, end):
  yield k

...

Insert print statements at will, watch the behaviour, and I think
you'll get it quickly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Doubt on generators behavior

2013-10-13 Thread Steven D'Aprano
On Sun, 13 Oct 2013 13:49:53 +0530, Krishnan Shankar wrote:

> Hi Friends,
> 
> I am new to Generators and was learning the same by experimenting. I
> wrote a small code which is as below.
> 
 def test_gen(var):
> ... print "The number is", var
> ... if var % 2 == 0:
> ... yield var
> ... else:
> ... print "Number is odd"
> ...
> But when i was executing i saw a behavior i could not understand. When i
> gave an even number,
> 1. The generator object was created
> 2. When i gave next the argument was yielded. 3. In the subsequent next
> the Stop Iteration was raised.

Correct. Follow the program logic. The first time you call next, 
execution of the generator begins:

- the generator first prints "The number is 78";

- the "if" block is then checked, since 78 is an even number the
  line "yield var" is executed and 78 is yielded;

- after "yield", execution halts until you call next again;

- when you call next the second time, execution continues following 
  the if...else block, which reaches the end of the function and
  StopIteration is raised.


> But When i ran with an odd number the result of "Number is odd" is
> printed. But it seems the generator runs again by itself to Stop
> Iteration.

Again, follow the program logic. The first time you call next, execution 
of the generator begins:

- the generator first prints "The number is 77";

- the "if" block is then checked, since 77 is an odd number the
  "else" clause is executed, and "The number is off" is printed;

- execution continues following the if...else block, which reaches
  the end of the function and StopIteration is raised.


Execution only halts at a yield statement. Try experimenting with this 
one:

def example():
var = 3
print "Starting with", var
yield var  # pauses after this
print "execution continues..."
var -= 1
print "var now has result", var
yield var   # pauses after this
var -= 1
print "var now has result", var
yield 1000 + var  # pauses after this
yield "nearly done"  # pauses after this
print "Finished now."



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


Re: Doubt on generators behavior

2013-10-13 Thread Terry Reedy

On 10/13/2013 4:19 AM, Krishnan Shankar wrote:

Hi Friends,

I am new to Generators and was learning the same by experimenting. I
wrote a small code which is as below.

 >>> def test_gen(var):
... print "The number is", var
... if var % 2 == 0:
... yield var
... else:
... print "Number is odd"
...
 >>>

But when i was executing i saw a behavior i could not understand. When i
gave an even number,
1. The generator object was created
2. When i gave next the argument was yielded.
3. In the subsequent next the Stop Iteration was raised.

 >>> res = test_gen(78)
 >>> res.next()
The number is 78
78
 >>> res.next()
Traceback (most recent call last):
   File "", line 1, in 
StopIteration

But When i ran with an odd number the result of "Number is odd" is
printed. But it seems the generator runs again by itself to Stop Iteration.


When number is odd, there is nothing to yield, so it raises 
StopIteration on the first next call.



 >>> res2 = test_gen(77)
 >>> res2.next()
The number is 77
Number is odd
Traceback (most recent call last):
   File "", line 1, in 
StopIteration
 >>>

How did this happen automatically? I am not able to get the execution of
a generator. Can someone please help me in understanding?
Regards,
Krishnan





--
Terry Jan Reedy

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


Re: Inter-process locking

2013-10-13 Thread Piet van Oostrum
Jason Friedman  writes:

> The lockfile solution seems to be working, thank you.

There is one caveat, however. If a process that has the lock crashes without 
releasing the lock, the lock file will stay around and prevent other processes 
to acquire it. Then you will have to manually remove it. I generally prefer a 
solution where the pid of the locking process is written to the lock file, so 
that other processes trying to acquire the lock can find out if the process is 
still around and remove the lock file if not. I have seen such solutions on 
Unix systems. But I am not sure if this can be done in a platform independent 
way without the risk of race conditions. Maybe I have to find out.
-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Would you l like to take over lockfile?

2013-10-13 Thread Skip Montanaro
I don't have the time or inclination to continue supporting lockfile (
https://pypi.python.org/pypi/lockfile/). If you'd like to take it over, let
me know.

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


Re: Python was designed (was Re: Multi-threading in Python vs Java)

2013-10-13 Thread Roy Smith
In article <525a15ad$0$29984$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> While I agree with your general thrust, I don't think it's quite so 
> simple. Perl has a king, Larry Wall, but his design is more or less 
> "throw everything into the pot, it'll be fine" and consequently Perl is, 
> well, *weird*, with some pretty poor^W strange design decisions.

To be fair to Larry, there were different design drivers working there.

Pre-perl, people built humungous shell scripts, duct-taping together 
little bits of sed, grep, awk, and other command-line tools.  What perl 
did, was make it easier to use the functionality of those disparate 
tools together in a single language.  By holding on to the little bits 
of syntax from the precursor languages, he kept the result familiar 
feeling, so Unix sysadmins (who were the main audience for perl) were 
willing to adopt it.

It was wildly successful, not because it was perfect, but because it 
beat the pants off what came before it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Would you l like to take over lockfile?

2013-10-13 Thread Piet van Oostrum
Skip Montanaro  writes:

> I don't have the time or inclination to continue supporting lockfile ( 
> https://pypi.python.org/
> pypi/lockfile/). If you'd like to take it over, let me know.
>
> Skip

Hi Skip,

I am interested.
-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What version of glibc is Python using?

2013-10-13 Thread John Nagle
On 10/12/2013 1:28 PM, Ian Kelly wrote:
> Reading the docs more closely, I think that the function is actually
> working as intended.  It says that it determines "the libc version
> against which the file executable (defaults to the Python interpreter)
> is linked" -- or in other words, the minimum compatible libc version,
> NOT the libc version that is currently loaded.

   A strange interpretation.

> So I think that a patch to replace this with gnu_get_libc_version()
> should be rejected, since it would change the documented behavior of
> the function.  It may be worth considering adding an additional
> function that matches the OP's expectations, but since it would just
> be a simple ctypes wrapper it is probably best done by the user.

   Ah, the apologist approach.

   The documentation is badly written.  The next line,
"Note that this function has intimate knowledge of how different libc
versions add symbols to the executable is probably only usable for
executables compiled using gcc" isn't even a sentence.

   The documentation needs to be updated.  Please submit a patch.

John Nagle


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


Re: web scraping

2013-10-13 Thread John Nagle
On 10/12/2013 1:35 PM, dvgh...@gmail.com wrote:
> On Saturday, October 12, 2013 7:12:38 AM UTC-7, Ronald Routt wrote:
>> I am new to programming and trying to figure out python.
>> 
>> 
>> 
>> I am trying to learn which tools and tutorials I need to use along
>> with some good beginner tutorials in scraping the the web.  The end
>> result I am trying to come up with is scraping auto dealership
>> sites for the following:
>> 
>> 1.Name of dealership 
>> 2.  State where dealership is located 
>> 3.  Name of Owner, President or General Manager 
>> 4.  Email address of number 3 above
>> 5.  Phone number of dealership

   If you really want that data, and aren't just hacking, buy it.
There are data brokers that will sell it to you. D&B, FindTheCompany,
Infot, etc.

   Sounds like you want to spam. Don't.

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


Re: What version of glibc is Python using?

2013-10-13 Thread Mark Lawrence

On 13/10/2013 18:43, John Nagle wrote:

The documentation is badly written.  The next line,
"Note that this function has intimate knowledge of how different libc
versions add symbols to the executable is probably only usable for
executables compiled using gcc" isn't even a sentence.

The documentation needs to be updated.  Please submit a patch.

John Nagle




If you want it done I suggest you submit the patch.

--
Roses are red,
Violets are blue,
Most poems rhyme,
But this one doesn't.

Mark Lawrence

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


Re: What version of glibc is Python using?

2013-10-13 Thread Ian Kelly
On Sun, Oct 13, 2013 at 11:43 AM, John Nagle  wrote:
>Ah, the apologist approach.

I'm not trying to defend it.  I'm saying that patching the function to
fix the issue at hand risks breaking existing code that relies upon
the function doing what the documentation says it does.

>The documentation is badly written.  The next line,
> "Note that this function has intimate knowledge of how different libc
> versions add symbols to the executable is probably only usable for
> executables compiled using gcc" isn't even a sentence.
>
>The documentation needs to be updated.  Please submit a patch.

You're the one pointing it out.  Why don't you?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: looking for best solutions for tracking projects and skills

2013-10-13 Thread Jason Friedman
I highly recommend JIRA, free for non-profit use:
https://www.atlassian.com/software/jira.

On Fri, Oct 11, 2013 at 9:09 PM, Jason Hsu  wrote:
> I realize this is off-topic, but I'm not sure what forum is best for asking 
> about this.  I figure that at least a few of you are involved in civic 
> hacking groups.
>
> I recently joined a group that does civic hacking. (Adopt-A-Hydrant is an 
> example of civic hacking.)
>
> We need a solution for tracking projects and the skills needed for the 
> projects (such as Ruby on Rails, Python, Drupal, Javascript, etc.).
>
> I'd like to hear from those of you in similar groups that have a great system 
> for tracking projects. Is there an in-house solution you use, or is there 
> something else available?
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: looking for best solutions for tracking projects and skills

2013-10-13 Thread Chris “Kwpolska” Warrick
On Sun, Oct 13, 2013 at 8:40 PM, Jason Friedman  wrote:
> I highly recommend JIRA, free for non-profit use:
> https://www.atlassian.com/software/jira.

As usual, the free version is hidden and available only on request:
https://www.atlassian.com/software/views/open-source-license-request

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


basic maze problem with turtle

2013-10-13 Thread baujacob
Hi everyone, I'm trying to create a simple maze program. When the user finishes 
the maze, I want to print in big letters "You Win!" and when the user hits a 
wall, I want the user to go back to the beginning of the maze. The problem is 
"collision detection" which is an advanced topic and I'm only in a beginning 
programming class. Is there anyway I can force the user back to the starting 
point when the turtle hits the wall? Thank you in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


basic maze problem with turtle

2013-10-13 Thread baujacob
Hi everyone, I'm trying to create a simple maze program. When the user finishes 
the maze, I want to print in big letters "You Win!" and when the user hits a 
wall, I want the user to go back to the beginning of the maze. The problem is 
"collision detection" which is an advanced topic and I'm only in a beginning 
programming class. Is there anyway I can force the user back to the starting 
point when the turtle hits the wall? Thank you in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: basic maze problem with turtle

2013-10-13 Thread Denis McMahon
On Sun, 13 Oct 2013 14:53:36 -0700, baujacob wrote:

> Is there anyway I can force the user back to the starting point
> when the turtle hits the wall?

Yes, however, do not expect us to code it for you.

Rather, discuss your method, and how you think it should be coded, or 
even better your solution, and why it doesn't do what you expect, and we 
will attempt to lead you to solving your problem.

At present, with no idea of how your maze is represented in terms of data 
structure, it would be near on impossible for anyone here, no matter how 
expert they are in coding python, to write code that interacts with it.

Except perhaps Nikos. Nikos can probably write you extremely elegant one 
line python solutions to any coding problem you describe to him. His 
solutions might suffer the very minor flaw of not working, but they're 
guaranteed to be Nikos certified aesthetically pure, and hence far 
superior to any solution more mundane coders might produce.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: basic maze problem with turtle

2013-10-13 Thread baujacob
On Sunday, October 13, 2013 2:52:50 PM UTC-7, bauj...@gmail.com wrote:
> Hi everyone, I'm trying to create a simple maze program. When the user 
> finishes the maze, I want to print in big letters "You Win!" and when the 
> user hits a wall, I want the user to go back to the beginning of the maze. 
> The problem is "collision detection" which is an advanced topic and I'm only 
> in a beginning programming class. Is there anyway I can force the user back 
> to the starting point when the turtle hits the wall? Thank you in advance.


Sorry about that, I realized I forgot to include the code.
So basically I have one turtle that draws the maze at the beginning and then 
another turtle(userTurtle) that completes the maze. When the userTurtle hits 
any point on the wall, I want to force userTurtle back to the start of the maze.
 Here it is:

import turtle
userTurtle = turtle.Turtle()
draw = turtle.Turtle()
scr = turtle.Screen()

def drawMaze():
draw.pencolor("gold")
draw.pensize(3)
draw.penup()
draw.goto(0,-180)
draw.pendown()
draw.speed(10)
draw.setheading(180)
draw.fd(180)
draw.setheading(90)
draw.fd(60)
draw.setheading(0)
draw.fd(120)
draw.backward(120)
draw.setheading(90)
draw.fd(300)
draw.setheading(0)
draw.fd(120)
draw.setheading(-90)
draw.fd(120)
draw.setheading(180)
draw.fd(60)
draw.setheading(90)
draw.fd(60)
draw.setheading(-90)
draw.fd(120)
draw.setheading(90)
draw.fd(60)
draw.setheading(0)
draw.fd(120)
draw.setheading(-90)
draw.fd(60)
draw.setheading(0)
draw.fd(60)
draw.setheading(-90)
draw.fd(60)
draw.backward(60)
draw.setheading(0)
draw.fd(60)
draw.setheading(90)
draw.fd(60)
draw.penup()
draw.setheading(180)
draw.fd(60)
draw.pendown()
draw.setheading(90)
draw.fd(60)
draw.setheading(180)
draw.fd(60)
draw.setheading(90)
draw.fd(60)
draw.setheading(0)
draw.fd(120)
draw.setheading(-90)
draw.fd(60)
draw.backward(60)
draw.setheading(0)
draw.fd(60)
draw.setheading(-90)
draw.fd(240)
draw.setheading(180)
draw.fd(60)
draw.setheading(-90)
draw.fd(60)
draw.setheading(180)
draw.fd(120)
draw.setheading(90)
draw.fd(60)
draw.setheading(180)
draw.fd(60)
draw.setheading(90)
draw.fd(60)
draw.backward(60)
draw.setheading(180)
draw.fd(60)
draw.penup()
draw.setheading(0)
draw.fd(300)
draw.pendown()
draw.setheading(-90)
draw.fd(120)
draw.setheading(180)
draw.fd(120)
draw.ht()

userTurtle.penup()
userTurtle.goto(-30,180)
userTurtle.setheading(-90)

def mazeGame():
scr.bgcolor("#0070ff")

def m1():
userTurtle.setheading(90)
userTurtle.fd(30)
userTurtle.pos()
print(userTurtle.pos())

def m2():
userTurtle.setheading(180)
userTurtle.fd(30)
userTurtle.pos()
print(userTurtle.pos())

def m3():
userTurtle.setheading(360)
userTurtle.fd(30)
userTurtle.pos()
print(userTurtle.pos())

def m4():
userTurtle.setheading(-90)
userTurtle.fd(30)
userTurtle.pos()
print(userTurtle.pos())

scr.onkeypress(m1, "Up")
scr.onkeypress(m2, "Left")
scr.onkeypress(m3, "Right")
scr.onkeypress(m4, "Down")

scr.listen()

drawMaze()
mazeGame()

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


Trying to force turtle back to beginning of maze after collides with wall

2013-10-13 Thread baujacob
Hi everyone, I'm trying to create a simple maze program. When the user finishes 
the maze, I want to print in big letters "You Win!" and when the user hits a 
wall, I want the user to go back to the beginning of the maze. The problem is 
"collision detection" which is an advanced topic and I'm only in a beginning 
programming class. Is there anyway I can force the user back to the starting 
point when the turtle hits the wall? Thank you in advance.

I've tried writing:
   if userTurtle.xcor(-30) and userTurtle.ycor(60):
  userTurtle.goto(-30,180)
  userTurtle.setheading(-90)

and

   if userTurtle.pos(-30,60):
  userTurtle.goto(-30,180)
  userTurtle.setheading(-90)

So basically I have one turtle that draws the maze at the beginning and then 
another turtle(userTurtle) that completes the maze. When the userTurtle hits 
any point on the wall, I want to force userTurtle back to the start of the 
maze. 
 Here it is: 

import turtle 
userTurtle = turtle.Turtle() 
draw = turtle.Turtle() 
scr = turtle.Screen() 

def drawMaze(): 
draw.pencolor("gold") 
draw.pensize(3) 
draw.penup() 
draw.goto(0,-180) 
draw.pendown() 
draw.speed(10) 
draw.setheading(180) 
draw.fd(180) 
draw.setheading(90) 
draw.fd(60) 
draw.setheading(0) 
draw.fd(120) 
draw.backward(120) 
draw.setheading(90) 
draw.fd(300) 
draw.setheading(0) 
draw.fd(120) 
draw.setheading(-90) 
draw.fd(120) 
draw.setheading(180) 
draw.fd(60) 
draw.setheading(90) 
draw.fd(60) 
draw.setheading(-90) 
draw.fd(120) 
draw.setheading(90) 
draw.fd(60) 
draw.setheading(0) 
draw.fd(120) 
draw.setheading(-90) 
draw.fd(60) 
draw.setheading(0) 
draw.fd(60) 
draw.setheading(-90) 
draw.fd(60) 
draw.backward(60) 
draw.setheading(0) 
draw.fd(60) 
draw.setheading(90) 
draw.fd(60) 
draw.penup() 
draw.setheading(180) 
draw.fd(60) 
draw.pendown() 
draw.setheading(90) 
draw.fd(60) 
draw.setheading(180) 
draw.fd(60) 
draw.setheading(90) 
draw.fd(60) 
draw.setheading(0) 
draw.fd(120) 
draw.setheading(-90) 
draw.fd(60) 
draw.backward(60) 
draw.setheading(0) 
draw.fd(60) 
draw.setheading(-90) 
draw.fd(240) 
draw.setheading(180) 
draw.fd(60) 
draw.setheading(-90) 
draw.fd(60) 
draw.setheading(180) 
draw.fd(120) 
draw.setheading(90) 
draw.fd(60) 
draw.setheading(180) 
draw.fd(60) 
draw.setheading(90) 
draw.fd(60) 
draw.backward(60) 
draw.setheading(180) 
draw.fd(60) 
draw.penup() 
draw.setheading(0) 
draw.fd(300) 
draw.pendown() 
draw.setheading(-90) 
draw.fd(120) 
draw.setheading(180) 
draw.fd(120) 
draw.ht() 

userTurtle.penup() 
userTurtle.goto(-30,180) 
userTurtle.setheading(-90) 

def mazeGame(): 
scr.bgcolor("#0070ff") 

def m1(): 
userTurtle.setheading(90) 
userTurtle.fd(30) 
userTurtle.pos() 
print(userTurtle.pos()) 

def m2(): 
userTurtle.setheading(180) 
userTurtle.fd(30) 
userTurtle.pos() 
print(userTurtle.pos()) 

def m3(): 
userTurtle.setheading(360) 
userTurtle.fd(30) 
userTurtle.pos() 
print(userTurtle.pos()) 

def m4(): 
userTurtle.setheading(-90) 
userTurtle.fd(30) 
userTurtle.pos() 
print(userTurtle.pos()) 

scr.onkeypress(m1, "Up") 
scr.onkeypress(m2, "Left") 
scr.onkeypress(m3, "Right") 
scr.onkeypress(m4, "Down") 

scr.listen() 

drawMaze() 
mazeGame()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: basic maze problem with turtle

2013-10-13 Thread Gary Herron

On 10/13/2013 03:03 PM, Denis McMahon wrote:

Except perhaps Nikos. Nikos can probably write you extremely elegant one
line python solutions to any coding problem you describe to him. His
solutions might suffer the very minor flaw of not working, but they're
guaranteed to be Nikos certified aesthetically pure, and hence far
superior to any solution more mundane coders might produce.


That was uncalled for.   There is already too much Nikos-bashing and 
Nikos-basher-bashing (and so on) in this newsgroup without dredging up 
even more in this completely unrelated request.


Gary Herron


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


Re: basic maze problem with turtle

2013-10-13 Thread Steven D'Aprano
On Sun, 13 Oct 2013 22:03:04 +, Denis McMahon wrote:

> On Sun, 13 Oct 2013 14:53:36 -0700, baujacob wrote:
> 
>> Is there anyway I can force the user back to the starting point when
>> the turtle hits the wall?

[skip useful advise to a beginner]

> Except perhaps [skip completely uncalled for baiting of somebody not 
> even remotely collected to this thread.]

Was that really necessary?



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


Re: Would you l like to take over lockfile?

2013-10-13 Thread Ben Finney
Skip Montanaro  writes:

> I don't have the time or inclination to continue supporting lockfile (
> https://pypi.python.org/pypi/lockfile/). If you'd like to take it over, let
> me know.

I have some experience working with the above project, and am willing to
assist. Please join us on the developer discussion forum for the code,
http://lists.alioth.debian.org/mailman/listinfo/python-lockfile-devel>.

In my opinion, we *really* need someone to become the domain expert for
the code on Windows.

-- 
 \  “Life does not cease to be funny when people die any more than |
  `\  it ceases to be serious when people laugh.” —George Bernard Shaw |
_o__)  |
Ben Finney

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


Re: converting letters to numbers

2013-10-13 Thread Tim Roberts
kjaku...@gmail.com wrote:
>
>Transfer it to an uppercase letter if it's a letter, if it's not then an error.
>This isn't right, I know, just testing around
>
>def add(c1, c2):
>ans = ''
>for i in c1 + c2:
>ans += chrord(i)-65))%26) + 65)
>return ans

It's close.  I think you're overthinking it.  Take it step by step. Decode,
process, encode.  That means convert the inputs to integers, add the
integers, convert the result back.

def add(c1, c2):
 % Decode
 c1 = ord(c1) - 65
 c2 = ord(c2) - 65
 % Process
 i1 = (c1 + c2) % 26
 % Encode
 return chr(i1+65)

Or, as a one-liner:

A = ord('A')
def add(c1, c2):
 return chr((ord(c1)-A + ord(c2)-A) % 26 + A)
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: converting letters to numbers

2013-10-13 Thread Steven D'Aprano
On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:

> def add(c1, c2):
>  % Decode
>  c1 = ord(c1) - 65
>  c2 = ord(c2) - 65
>  % Process
>  i1 = (c1 + c2) % 26
>  % Encode
>  return chr(i1+65)

Python uses # for comments, not %, as I'm sure you know. What language 
were you thinking off when you wrote the above?



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


Searching for a list of strings in a file with Python

2013-10-13 Thread Starriol
Hi guys,

I'm trying to search for several strings, which I have in a .txt file line by 
line, on another file.
So the idea is, take input.txt and search for each line in that file in another 
file, let's call it rules.txt.

So far, I've been able to do this, to search for individual strings:

[code]import re

shakes = open("output.csv", "r")

for line in shakes:
if re.match("STRING", line):
print line,[/code]

How can I change this to input the strings to be searched from another file?

So far I haven't been able to.

Thanks for the ideas.
-- 
https://mail.python.org/mailman/listinfo/python-list


Query on Python Compiled source--Urgent

2013-10-13 Thread chandan kumar
Hi,

I'm working on a python project for protocol testing.I need to provide only 
python compiled source to our customer.

Here are the steps followed to take python compiled from actual source.
1.There are 5 different test suites under the project
2..Run all 5  test suite with python sources.
3.After completion of test suite ,just take .pyc files and copied in to 
seperate folder.
4.Re run test suite for any issues with the .pyc code.I started seeing one 
issue when it logs the test results in to excel file.
 This issue occurs sometimes.50% of chances are there to see this issue

Below is the error
Traceback (most recent call last):
  File "D:\users\ScriptTestCode\scriptsCompiledCode\ExecuteScripts.py", line 
32, in 
    TestManager.execute_scripts(TEST_BUILD)
  File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py", line 764, 
in execute_scripts
  File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py", line 772, 
in _execute_all
  File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py", line 924, 
in _testsuite_950_band
  File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py", line 377, 
in exec_test_suite
  File "D:\users\ScriptTestCode\scripts\ResultReporter.py", line 321, in 
save_test_results
    _my_doc.save(StackTestData.TEST_REPORT_PATH)
  File "C:\Python27\lib\site-packages\pyExcelerator\Workbook.py", line 610, in 
save
    doc.save(filename, self.get_biff_data())
  File "C:\Python27\lib\site-packages\pyExcelerator\CompoundDoc.py", line 554, 
in save
    f = file(filename, 'wb')
IOError: [Errno 22] invalid mode ('wb') or filename: 
'.\\TestResults\\TestReport.xls'

Now my question is of there any issue with logging to excel it should happen 
for the first test suite itself,but it occurs in either 2,3,4 or 5 test suite. 
Some it runs without any issues.

Please let me know do i need to follow any sequence when copying  compiled 
source code and  whats exactly going wrong here.

Best Regards,
Chandan.-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Searching for a list of strings in a file with Python

2013-10-13 Thread Peter Otten
Starriol wrote:

> Hi guys,
> 
> I'm trying to search for several strings, which I have in a .txt file line
> by line, on another file. So the idea is, take input.txt and search for
> each line in that file in another file, let's call it rules.txt.
> 
> So far, I've been able to do this, to search for individual strings:
> 
> [code]import re
> 
> shakes = open("output.csv", "r")
> 
> for line in shakes:
> if re.match("STRING", line):
> print line,[/code]
> 
> How can I change this to input the strings to be searched from another
> file?

Assuming every line in input.txt contains a regular expression and you don't 
care which one matches:

shakes = open("output.csv")

# you will iterate over the regex multiple times, 
# so put them in a list
rattles = [line.strip() for line in open("input.txt")]

for line in shakes:
for expr in rattles:
if re.match(expr, line):
print line,
break # out of the for-rattles loop
  # at the first matching regex

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