Re: [Tutor] Why is it not working?

2015-02-04 Thread boB Stepp
On Wed, Feb 4, 2015 at 6:12 PM, Antonio Zagheni wrote: > Hi there, > > I am a begginer in python and I'm trying to learn something about Tkinter. > > I did a game (the code is below) using Tkinter were two players have to fill > a row, a column or a diagonal with either 'X' or 'O'. > When it happ

Re: [Tutor] Why is it not working?

2015-02-04 Thread Alan Gauld
On 05/02/15 00:12, Antonio Zagheni wrote: from Tkinter import * ... jogador = 1 rodada = 1 fim = False Notice that fim is declared here as a global variable def analise(): global jogador, rodada But you do not include fim here print flag_botaoA1, flag_botaoA2, flag_botaoA3

[Tutor] Why is it not working?

2015-02-04 Thread Antonio Zagheni
Hi there, I am a begginer in python and I'm trying to learn something about Tkinter. I did a game (the code is below) using Tkinter were two players have to fill a row, a column or a diagonal with either 'X' or 'O'. When it happens, the code was supposed to recognize the winner ('Jogador 1 or 2

Re: [Tutor] Need help with find error

2015-02-04 Thread Danny Yoo
As a revision of my initial question, when we look at next_block(), it's documented as follows: def next_block(the_file): """Return the next block of data from the trivia file.""" What if there

Re: [Tutor] Need help with find error

2015-02-04 Thread Danny Yoo
On Wed, Feb 4, 2015 at 1:01 AM, Андрей Пугачев wrote: > Hi > I'm learning python a few weeks and have problems with code that read text > from txt-file > Code doing all right, but in the end I have error > > Traceback (most recent call last): > File "trivia_challenge.py", line 81, in > main

Re: [Tutor] Assistance with UnicodeDecodeError

2015-02-04 Thread James Chapman
Actually, it's more likely that the char you are grabbing is UTF-16 not UTF-8 which is moving into the double byte... * An assumption based on the following output: >>> u = u'\u2014' >>> s = u.encode("utf-16") >>> print(s) ■¶ >>> s = u.encode("utf-32") >>> print(s) ■ ¶ >>> s = u.encode("utf-16L

Re: [Tutor] Assistance with UnicodeDecodeError

2015-02-04 Thread James Chapman
> > I am trying to scrap text from a website using Python 2.7 in windows 8 and > i am getting this error *"**UnicodeDecodeError: 'charmap codec can't encode > character u'\u2014 in position 11231 character maps to "* > > For starters, move away from Python 2 unless you have a good reason to use it.

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Alan Gauld
On 04/02/15 13:06, Raúl Cumplido wrote: There is a repeat argument on the product function that is used exactly for what you want to do: >>> for s in product(var, repeat=2) print ''.join(s) Good catch, I should have remembered that. -- Alan G Author of the Learn to Program web site

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Raúl Cumplido
There is a repeat argument on the product function that is used exactly for what you want to do: >>> for s in product(var, repeat=2) print ''.join(s) On Wed, Feb 4, 2015 at 1:01 PM, Raúl Cumplido wrote: > sorry, just me being stupid :P should have read closely what the problem > was

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Raúl Cumplido
sorry, just me being stupid :P should have read closely what the problem was On Wed, Feb 4, 2015 at 12:54 PM, Raúl Cumplido wrote: > I think you want to use combinations_with_replacement: > > >>> var = ['a', 'b', 'c', 'd', 'e'] > > >>> length=int(raw_input("enter the length of random letters you

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Raúl Cumplido
I think you want to use combinations_with_replacement: >>> var = ['a', 'b', 'c', 'd', 'e'] >>> length=int(raw_input("enter the length of random letters you need ")) enter the length of random letters you need 2 >>> length 2 >>> from itertools import combinations_with_replacement >>> [''.join(s

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Alan Gauld
On 04/02/15 09:46, Suresh Kumar wrote: print var ['a', 'b', 'c', 'd', 'e'] the user gave two so code should be like this for i in itertools.product(var,var): print i[0]+i[1] output of code should be like this aa ab ... ee based on the user given input of length i need t

Re: [Tutor] Need help with find error

2015-02-04 Thread Peter Otten
Андрей Пугачев wrote: > Hi > I'm learning python a few weeks and have problems with code that read text > from txt-file > Code doing all right, but in the end I have error > > Traceback (most recent call last): > File "trivia_challenge.py", line 81, in > main() > File "trivia_challenge.p

Re: [Tutor] Unable to install django in visual studio

2015-02-04 Thread Alan Gauld
On 04/02/15 08:40, Siya 360 wrote: Please assist with resolving this problem as am sitting behind a proxy, and I understand I have to use python get -pip.py --proxy="[user:passwd@]proxy.server:port" To install behind a proxy This group is for folks learning Python and its standard library.

Re: [Tutor] Need help with find error

2015-02-04 Thread Alan Gauld
On 04/02/15 09:01, Андрей Пугачев wrote: Code doing all right, but in the end I have error Traceback (most recent call last): File "trivia_challenge.py", line 81, in main() File "trivia_challenge.py", line 74, in main category, question, answers, correct, explanation, points =

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Suresh Kumar
here is the sample code >>> import itertools >>> import string >>> var=[] >>> for i in string.ascii_lowercase[0:5]: var.append(i) >>>print var ['a', 'b', 'c', 'd', 'e'] >>> length=int(raw_input("enter the length of random letters you need ")) enter the length of random letters you need

[Tutor] Unable to install django in visual studio

2015-02-04 Thread Siya 360
Hi, Please assist with resolving this problem as am sitting behind a proxy, and I understand I have to use python get -pip.py --proxy="[user:passwd@]proxy.server:port" To install behind a proxy > > > > > This electronic communication and the attached file(s) are subject to a

[Tutor] Need help with find error

2015-02-04 Thread Андрей Пугачев
Hi I'm learning python a few weeks and have problems with code that read text from txt-file Code doing all right, but in the end I have error Traceback (most recent call last): File "trivia_challenge.py", line 81, in main() File "trivia_challenge.py", line 74, in main category, questi

Re: [Tutor] How can I replicate a list in a for loop

2015-02-04 Thread Alan Gauld
On 03/02/15 22:51, Suresh Nagulavancha wrote: This is my sample piece of code (not full code of my original code just sample of it) I am using python 2.7 Import itertools var=[1,2,3,4,5] Length=int(raw_input("length of possible numbers required")) #This is for length of 3 chars for i in itertool