Date: 17/03/2014 14:05:16
From: poikilotherm
ID: 504551
Subject: Python
Reply Quote

Date: 17/03/2014 14:06:05
From: Dropbear
ID: 504552
Subject: re: Python

poikilotherm said:

yes indeed

Reply Quote

Date: 17/03/2014 14:07:14
From: CrazyNeutrino
ID: 504553
Subject: re: Python

Dropbear said:


poikilotherm said:

yes indeed

The one that ate the dog?

Reply Quote

Date: 17/03/2014 14:10:31
From: bob(from black rock)
ID: 504554
Subject: re: Python

Perhaps he went to siphon the python?

Reply Quote

Date: 17/03/2014 14:21:39
From: party_pants
ID: 504556
Subject: re: Python

Cast our your pythons today, in the name of The Lord.

Reply Quote

Date: 17/03/2014 16:39:23
From: ms spock
ID: 504609
Subject: re: Python
Reply Quote

Date: 17/03/2014 16:46:36
From: PM 2Ring
ID: 504613
Subject: re: Python

Reply Quote

Date: 17/03/2014 16:47:20
From: ms spock
ID: 504614
Subject: re: Python

PM 2Ring said:


Nice!

A handsome photo indeed.

Reply Quote

Date: 17/03/2014 16:48:02
From: bob(from black rock)
ID: 504615
Subject: re: Python

PM 2Ring said:


.

Is his name “Monty”?

Reply Quote

Date: 17/03/2014 16:49:43
From: Carmen_Sandiego
ID: 504616
Subject: re: Python

ms spock said:


PM 2Ring said:

img src=“http://i2.photobucket.com/albums/y43/PM2Ring/Snake029.jpg

Nice!

A handsome photo indeed.

Reply Quote

Date: 17/03/2014 16:50:05
From: ms spock
ID: 504617
Subject: re: Python

bob(from black rock) said:


PM 2Ring said:

.

Is his name “Monty”?

Of course!

continues Irish Dancing with a flourish

Reply Quote

Date: 17/03/2014 16:50:49
From: ms spock
ID: 504619
Subject: re: Python

Carmen_Sandiego said:


ms spock said:

PM 2Ring said:

img src=“http://i2.photobucket.com/albums/y43/PM2Ring/Snake029.jpg

Nice!

A handsome photo indeed.

Awesome!

At your place?

Reply Quote

Date: 17/03/2014 16:51:05
From: PM 2Ring
ID: 504620
Subject: re: Python

bob(from black rock) said:


PM 2Ring said:

.

Is his name “Monty”?

No, Mum named him Cedric. He stayed in that rock wall over winter a couple of years ago, but left in the spring.

OTOH, the Python programming language is named after Monty Python.

Reply Quote

Date: 17/03/2014 16:55:47
From: bob(from black rock)
ID: 504621
Subject: re: Python

PM 2Ring said:


bob(from black rock) said:

PM 2Ring said:

.

Is his name “Monty”?

No, Mum named him Cedric. He stayed in that rock wall over winter a couple of years ago, but left in the spring.

OTOH, the Python programming language is named after Monty Python.

.
You can’t call a python Cedric he will get a complex and need to see a snake shrink.

Reply Quote

Date: 17/03/2014 17:01:10
From: Carmen_Sandiego
ID: 504623
Subject: re: Python

ms spock said:


Carmen_Sandiego said:

ms spock said:

Nice!

A handsome photo indeed.

!https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-ash3/t31.0-8/q83/s720×720/964120_10200395570872010_2112334682_o.jpg

Awesome!

At your place?

Yeah, our kitchen. (That’s the edge of its head just poking over the edge of the cupboard – 2.7m, average adult size is 4m)

Reply Quote

Date: 17/03/2014 17:08:11
From: ms spock
ID: 504624
Subject: re: Python

PM 2Ring said:


bob(from black rock) said:

PM 2Ring said:

.

Is his name “Monty”?

No, Mum named him Cedric. He stayed in that rock wall over winter a couple of years ago, but left in the spring.

OTOH, the Python programming language is named after Monty Python.

I didn’t know that. That is so cool.

*files away information for next time she is with the true nerds.

Reply Quote

Date: 17/03/2014 17:08:25
From: ms spock
ID: 504625
Subject: re: Python

PM 2Ring said:


bob(from black rock) said:

PM 2Ring said:

.

Is his name “Monty”?

No, Mum named him Cedric. He stayed in that rock wall over winter a couple of years ago, but left in the spring.

OTOH, the Python programming language is named after Monty Python.

I didn’t know that. That is so cool.

files away information for next time she is with the true nerds.

Reply Quote

Date: 17/03/2014 17:09:45
From: ms spock
ID: 504627
Subject: re: Python

Carmen_Sandiego said:


ms spock said:

Carmen_Sandiego said:

!https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-ash3/t31.0-8/q83/s720×720/964120_10200395570872010_2112334682_o.jpg

Awesome!

At your place?

Yeah, our kitchen. (That’s the edge of its head just poking over the edge of the cupboard – 2.7m, average adult size is 4m)

Wow. You are so lucky!

Tell spiderlily I walked 6 km yesterday! She can be proud of me.

Reply Quote

Date: 17/03/2014 17:12:01
From: Divine Angel
ID: 504628
Subject: re: Python

ms spock said:

I didn’t know that. That is so cool.

*files away information for next time she is with the true nerds.

I was pretty tired of coming second in every round of trivia on the ship. Grrrr!

Reply Quote

Date: 17/03/2014 17:15:10
From: poikilotherm
ID: 504630
Subject: re: Python

Divine Angel said:


ms spock said:

I didn’t know that. That is so cool.

*files away information for next time she is with the true nerds.

I was pretty tired of coming second in every round of trivia on the ship. Grrrr!

The first loser. Nice consistency though. :P

Reply Quote

Date: 20/03/2014 16:48:56
From: PM 2Ring
ID: 506209
Subject: re: Python

Hey poikilotherm,

What OS are you doing your Python stuff on?

It doesn’t really make much of a difference, but I’ve noticed that Windows users tend not to run Python stuff (or anything else) in a terminal if they can avoid it. On *nix (including OSX) it’s fairly easy to print coloured text in the terminal window, which can be fun to play with when you’re getting started in programming.

Reply Quote

Date: 20/03/2014 16:53:27
From: poikilotherm
ID: 506210
Subject: re: Python

PM 2Ring said:


Hey poikilotherm,

What OS are you doing your Python stuff on?

It doesn’t really make much of a difference, but I’ve noticed that Windows users tend not to run Python stuff (or anything else) in a terminal if they can avoid it. On *nix (including OSX) it’s fairly easy to print coloured text in the terminal window, which can be fun to play with when you’re getting started in programming.

At work I’m using an online emulator, at home I tried to use a Python terminal box in Win 7…hasn’t gone well yet.

Reply Quote

Date: 20/03/2014 17:00:28
From: PM 2Ring
ID: 506215
Subject: re: Python

poikilotherm said:


At work I’m using an online emulator, at home I tried to use a Python terminal box in Win 7…hasn’t gone well yet.

Ah, ok. It’s been a few years since I played with Python on Windows, and then I mostly ran stuff inside IDLE.
But this FAQ might be helpful.

Reply Quote

Date: 20/03/2014 17:03:01
From: poikilotherm
ID: 506218
Subject: re: Python

PM 2Ring said:


poikilotherm said:

At work I’m using an online emulator, at home I tried to use a Python terminal box in Win 7…hasn’t gone well yet.

Ah, ok. It’s been a few years since I played with Python on Windows, and then I mostly ran stuff inside IDLE.
But this FAQ might be helpful.

Thanks, I’ll have a read at home.

Reply Quote

Date: 20/03/2014 17:03:08
From: PM 2Ring
ID: 506219
Subject: re: Python

Does that online emulator give you access to the standard Python modules, or is it only capable of running self-contained code?

Reply Quote

Date: 20/03/2014 17:05:31
From: poikilotherm
ID: 506221
Subject: re: Python

PM 2Ring said:


Does that online emulator give you access to the standard Python modules, or is it only capable of running self-contained code?

It gives access to modules afaict, here is something the ‘classes’ have been leading up to, finally got it to work. Much headache.


from random import randint

board =

for x in range(5): board.append( * 5)

def print_board(board): for row in board: print “ “.join(row)

print “Let’s play Battleship!”
print_board(board)

def random_row(board): return randint(0, len(board) – 1)

def random_col(board): return randint(0, len(board) – 1)

ship_row = random_row(board)
ship_col = random_col(board)
print ship_row
print ship_col

for turn in range(4):

guess_row = int(raw_input(“Guess Row:”)) guess_col = int(raw_input(“Guess Col:”)) if guess_row ship_row and guess_col ship_col: print “Congratulations! You sunk my battleship!” else: if (guess_row < 0 or guess_row > 4) or \ (guess_col < 0 or guess_col > 4): print “Oops, that’s not even in the ocean.” elif(board == “X”): print “You guessed that one already.” else: print “You missed my battleship!” board = “X” print turn+1 print_board(board)
Reply Quote

Date: 20/03/2014 17:08:21
From: poikilotherm
ID: 506222
Subject: re: Python

just noticed the else/elif doesn’t look quite right.

Reply Quote

Date: 20/03/2014 17:21:52
From: PM 2Ring
ID: 506229
Subject: re: Python

poikilotherm said:


just noticed the else/elif doesn’t look quite right.

It looks ok to me. But you probably should break out of the for loop when the player makes a correct guess.

Reply Quote

Date: 20/03/2014 17:27:25
From: poikilotherm
ID: 506233
Subject: re: Python

PM 2Ring said:


poikilotherm said:

just noticed the else/elif doesn’t look quite right.

It looks ok to me. But you probably should break out of the for loop when the player makes a correct guess.

Ah, yea…the instructions were ‘everything in this section in the for loop’. And this next section is about ending the game etc. :)

Reply Quote

Date: 20/03/2014 17:30:52
From: Dropbear
ID: 506235
Subject: re: Python

PM 2Ring said:


poikilotherm said:

just noticed the else/elif doesn’t look quite right.

It looks ok to me. But you probably should break out of the for loop when the player makes a correct guess.

Pffft. Such a pedant

Reply Quote

Date: 20/03/2014 17:38:50
From: poikilotherm
ID: 506237
Subject: re: Python

Dropbear said:


PM 2Ring said:

poikilotherm said:

just noticed the else/elif doesn’t look quite right.

It looks ok to me. But you probably should break out of the for loop when the player makes a correct guess.

Pffft. Such a pedant

Well, that was rather simple…break, breaks the loop. Who woulda thort.

Reply Quote

Date: 20/03/2014 17:42:56
From: PM 2Ring
ID: 506238
Subject: re: Python

poikilotherm said:


PM 2Ring said:

poikilotherm said:

just noticed the else/elif doesn’t look quite right.

It looks ok to me. But you probably should break out of the for loop when the player makes a correct guess.

Ah, yea…the instructions were ‘everything in this section in the for loop’. And this next section is about ending the game etc. :)

Rightio.

Reply Quote

Date: 20/03/2014 17:43:12
From: PM 2Ring
ID: 506239
Subject: re: Python

Dropbear said:


PM 2Ring said:

poikilotherm said:

just noticed the else/elif doesn’t look quite right.

It looks ok to me. But you probably should break out of the for loop when the player makes a correct guess.

Pffft. Such a pedant

:)

Reply Quote

Date: 20/03/2014 17:45:40
From: poikilotherm
ID: 506240
Subject: re: Python

Loops…hope chrome is ready for some crashing…

Reply Quote

Date: 20/03/2014 17:46:32
From: PM 2Ring
ID: 506241
Subject: re: Python

poikilotherm said:


Well, that was rather simple…break, breaks the loop. Who woulda thort.

Note that with nested loops, break only breaks the innermost loop. Some languages provide special syntax that makes it easy, but generally, how to best break out of nested loops is a topic of programmers’ Religious Wars. :)

Reply Quote

Date: 20/03/2014 17:46:37
From: The Rev Dodgson
ID: 506242
Subject: re: Python

So when did the Python thread turn into a Python thread?

Reply Quote

Date: 20/03/2014 17:48:47
From: roughbarked
ID: 506243
Subject: re: Python

The Rev Dodgson said:


So when did the Python thread turn into a Python thread?

slithers about, does a python.

Reply Quote

Date: 20/03/2014 17:51:09
From: PM 2Ring
ID: 506244
Subject: re: Python

Here’s a little script I wrote this afternoon. Hopefully, it’ll run in your emulator.

Holiday Forum Post list

Reply Quote

Date: 20/03/2014 17:51:40
From: poikilotherm
ID: 506245
Subject: re: Python

The Rev Dodgson said:


So when did the Python thread turn into a Python thread?

PWM got it back on track, I just let it run…was amusing to watch and I had solved the problem I was going to ask.

Reply Quote

Date: 20/03/2014 17:53:21
From: PM 2Ring
ID: 506248
Subject: re: Python

The Rev Dodgson said:


So when did the Python thread turn into a Python thread?

It actually started out that way, but it might not have been obvious from the earlier posts. :)

Reply Quote

Date: 20/03/2014 17:53:36
From: poikilotherm
ID: 506249
Subject: re: Python

PM 2Ring said:


Here’s a little script I wrote this afternoon. Hopefully, it’ll run in your emulator.

Holiday Forum Post list

Didn’t go, but I’ll try another tonight. Approaching home time :).

Reply Quote

Date: 20/03/2014 17:53:55
From: OCDC
ID: 506250
Subject: re: Python

We all thought it was a post trolling elapid.

Reply Quote

Date: 20/03/2014 17:54:49
From: PM 2Ring
ID: 506251
Subject: re: Python

poikilotherm said:

I had solved the problem I was going to ask.

That happens surprisingly often. Merely thinking about how to describe your programming problem to others can be enough to get your brain on track to solve it for yourself.

Reply Quote

Date: 20/03/2014 17:56:55
From: roughbarked
ID: 506256
Subject: re: Python

OCDC said:


We all thought it was a post trolling elapid.

elapids are pythons now?

Reply Quote

Date: 20/03/2014 17:58:33
From: poikilotherm
ID: 506258
Subject: re: Python

I think OCDC thinks I am elapid.

Reply Quote

Date: 20/03/2014 17:59:40
From: roughbarked
ID: 506259
Subject: re: Python

poikilotherm said:


I think OCDC thinks I am elapid.

oooh K

Reply Quote

Date: 20/03/2014 18:03:14
From: PM 2Ring
ID: 506260
Subject: re: Python

poikilotherm said:


PM 2Ring said:

Here’s a little script I wrote this afternoon. Hopefully, it’ll run in your emulator.

Holiday Forum Post list

Didn’t go, but I’ll try another tonight. Approaching home time :).

Oh well. I’m not too surprised, though. I suppose that making urllib available in an online emulator could create security / DOS (Denial Of Service) problems.

But anyway, that script lets you quickly see who’s been posting what on this forum without having to fire up your browser, so it’s a bit redundant if you run it from inside a browser. :)

That script uses the standard Python Regular Expression module to do the work of extracting the relevant data. If you’ve never used regexes before they can be bit daunting, but they’re great once you get used to them.
xkcd #208
published 10 January 2007


Regular Expressions




Transcript
Narrator: Whenever I learn a new skill I concoct elaborate fantasy scenarios where it lets me save the day.
Woman: Oh no! The killer must have followed her on vacation!
{Woman points to computer}
Woman: But to find them we’d need to search through 200MB of emails looking for something formatted like an address!
Man: It’s hopeless!
Offpanel voice: Everybody stand back.
Offpanel voice: I know regular expressions.
{A man swings in on a rope, toward the computer}
<<tap tap>>
<<PERL!>>
{The man swings away, and the other characters cheer}

Reply Quote

Date: 20/03/2014 18:05:32
From: PM 2Ring
ID: 506262
Subject: re: Python

poikilotherm said:


I think OCDC thinks I am elapid.

Are you Croatian, do you fantasize about being blind or about being a park ranger?

If you answer “yes” to all the above, you could be elapid. :)

Reply Quote

Date: 20/03/2014 18:16:20
From: poikilotherm
ID: 506270
Subject: re: Python

Sounds useful, I could use them often.

Reply Quote

Date: 20/03/2014 18:21:13
From: OCDC
ID: 506271
Subject: re: Python

poikilotherm said:

I think OCDC thinks I am elapid.
Well you seem to have the same smrts…

;-)

Reply Quote

Date: 20/03/2014 18:23:03
From: PM 2Ring
ID: 506272
Subject: re: Python

poikilotherm said:


Sounds useful, I could use them often.

Most scripting languages let you use Regular Expressions (aka regexes). There are minor variations from language to language, but that mostly just affects the fancier stuff, so once you’ve learned how to use regexes in one language it’s pretty easy to use them in others. And because regexes have been around for decades there are lots of tutorials available, and almost any conceivable question about them has been asked on some programmers’ forum.

Reply Quote