Writing a chess-playing AI like Alphago in Python
How many lines of code in Python would it take to create a Go-playing AI like AlphaGo ? Estimates ? -- https://mail.python.org/mailman/listinfo/python-list
Re: While, If, Count Statements
On Tuesday, November 28, 2017 at 8:12:09 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:a8335d2c-1fb9-4ba9-b752-418d19e57...@googlegroups.com... > > > > On Tuesday, November 28, 2017 at 4:18:04 PM UTC+8, Frank Millman wrote: > > > "Cai Gengyang" wrote in message > > > news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... > > > > > > > Sure, so how would the code look like if I want the "if" statement to > > > > be > > > > nested inside the "while" loop > > > > > > Have you tried putting the 'if' statement inside the 'while' loop? > > > > > > If not, give it a shot and see what happens. > > > > > > Frank Millman > > > > I tried this : > > > > count = 0 > > > > while count < 10: > > if count < 5: > > print "Hello, I am an if statement and count is", count > > print "Hello, I am a while and count is", count > > count += 1 > > > > but it gives an "indentation error: expected an indented block" with an > > arrow pointing at the count after the 3rd statement. Indentation error is > > supposed to be an error about tabs and spaces right ? But I can't find any > > mistakes with it ... > > You are almost there. > > An 'if' statement always requires that the following statements are > indented. This applies even if you are already at one level of indentation. > > You could have, for example - > > if a == 'something': > if b == 'something else': > if c == 'and another one': > do_something_if_a_and_b_and_c_are_true() > > Or in your case - > > while condition: > if a == 'something': > do_something_if_a_is_true() > continue with while clause > > Indentation is fundamental to the way Python works, so if anything above is > not clear, query it now. It is essential that you have a firm grasp of this. > > HTH > > Frank It works now ! All I had to shift the 2nd "print" statement up a few spaces and it worked --- This is my code: count = 0 while count < 10: if count < 5: print "Hello, I am an if statement and count is", count print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am an if statement and count is 1 Hello, I am a while and count is 1 Hello, I am an if statement and count is 2 Hello, I am a while and count is 2 Hello, I am an if statement and count is 3 Hello, I am a while and count is 3 Hello, I am an if statement and count is 4 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 -- https://mail.python.org/mailman/listinfo/python-list
Re: While, If, Count Statements
On Tuesday, November 28, 2017 at 4:18:04 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... > > > Sure, so how would the code look like if I want the "if" statement to be > > nested inside the "while" loop > > Have you tried putting the 'if' statement inside the 'while' loop? > > If not, give it a shot and see what happens. > > Frank Millman I tried this : count = 0 while count < 10: if count < 5: print "Hello, I am an if statement and count is", count print "Hello, I am a while and count is", count count += 1 but it gives an "indentation error: expected an indented block" with an arrow pointing at the count after the 3rd statement. Indentation error is supposed to be an error about tabs and spaces right ? But I can't find any mistakes with it ... -- https://mail.python.org/mailman/listinfo/python-list
Re: While, If, Count Statements
On Tuesday, November 28, 2017 at 6:09:17 AM UTC+8, Ned Batchelder wrote: > On 11/27/17 7:54 AM, Cai Gengyang wrote: > > Input : > > > > count = 0 > > > > if count < 5: > >print "Hello, I am an if statement and count is", count > > > > while count < 10: > >print "Hello, I am a while and count is", count > >count += 1 > > > > Output : > > > > Hello, I am an if statement and count is 0 > > Hello, I am a while and count is 0 > > Hello, I am a while and count is 1 > > Hello, I am a while and count is 2 > > Hello, I am a while and count is 3 > > Hello, I am a while and count is 4 > > Hello, I am a while and count is 5 > > Hello, I am a while and count is 6 > > Hello, I am a while and count is 7 > > Hello, I am a while and count is 8 > > Hello, I am a while and count is 9 > > > > The above input gives the output below. Why isn't the output instead : > > > > Hello, I am an if statement and count is 0 > > Hello, I am a while and count is 0 > > Hello, I am an if statement and count is 1 > > Hello, I am a while and count is 1 > > Hello, I am an if statement and count is 2 > > Hello, I am a while and count is 2 > > Hello, I am an if statement and count is 3 > > Hello, I am a while and count is 3 > > Hello, I am an if statement and count is 4 > > Hello, I am a while and count is 4 > > Hello, I am a while and count is 5 > > Hello, I am a while and count is 6 > > Hello, I am a while and count is 7 > > Hello, I am a while and count is 8 > > Hello, I am a while and count is 9 > > It's easy to imagine that this sets up a rule that remains in effect for the > rest of the program: > > â â â if count < 5: > â â â â â â â print "Hello, I am an if statement and count is", count > > But that's not how Python (and most other programming languages) works.â > Python > reads statements one after another, and executes them as it encounters > them.â > When it finds the if-statement, it evaluates the condition, and if it is true > *at that moment*, it executes the contained statements.â Then it forgets all > about that if-statement, and moves on to the next statement. > > --Ned. Sure, so how would the code look like if I want the "if" statement to be nested inside the "while" loop and give me the result : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am an if statement and count is 1 Hello, I am a while and count is 1 Hello, I am an if statement and count is 2 Hello, I am a while and count is 2 Hello, I am an if statement and count is 3 Hello, I am a while and count is 3 Hello, I am an if statement and count is 4 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 -- https://mail.python.org/mailman/listinfo/python-list
While, If, Count Statements
Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am a while and count is 1 Hello, I am a while and count is 2 Hello, I am a while and count is 3 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 The above input gives the output below. Why isn't the output instead : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am an if statement and count is 1 Hello, I am a while and count is 1 Hello, I am an if statement and count is 2 Hello, I am a while and count is 2 Hello, I am an if statement and count is 3 Hello, I am a while and count is 3 Hello, I am an if statement and count is 4 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 -- https://mail.python.org/mailman/listinfo/python-list
While, If, Count Statements
Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am a while and count is 1 Hello, I am a while and count is 2 Hello, I am a while and count is 3 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 The above input gives the output below. Why isn't the output instead : Hello, I am an if statement and count is 0 Hello, I am a while and count is 0 Hello, I am an if statement and count is 1 Hello, I am a while and count is 1 Hello, I am an if statement and count is 2 Hello, I am a while and count is 2 Hello, I am an if statement and count is 3 Hello, I am a while and count is 3 Hello, I am an if statement and count is 4 Hello, I am a while and count is 4 Hello, I am a while and count is 5 Hello, I am a while and count is 6 Hello, I am a while and count is 7 Hello, I am a while and count is 8 Hello, I am a while and count is 9 -- https://mail.python.org/mailman/listinfo/python-list
Re: Searching For Old Posts On Python
Right ... I am going to continue learning Python then ... On Thursday, October 19, 2017 at 3:39:44 AM UTC+8, Ian wrote: > On Mon, Oct 16, 2017 at 10:42 PM, Cai Gengyang <gengyang...@gmail.com> wrote: > > https://duckduckgo.com/html/?q=%22Cai%20Gengyang%22%20python This > > seems to be the only method that works, using DuckDuckGo > > Or any search engine, really. > https://www.google.com/search?q=site%3Apython.org+cai+gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Searching For Old Posts On Python
https://duckduckgo.com/html/?q=%22Cai%20Gengyang%22%20python This seems to be the only method that works, using DuckDuckGo On Tue, Oct 17, 2017 at 4:54 AM, Thomas Jollans <t...@tjol.eu> wrote: > On 16/10/17 22:04, Cai Gengyang wrote: > > I cannot remember where I posted the question it was a while ago .. > > > > On Mon, Oct 16, 2017 at 5:12 PM, Thomas Jollans <t...@tjol.eu > > <mailto:t...@tjol.eu>> wrote: > > > > On 2017-10-16 11:01, Cai Gengyang wrote: > > > Does anyone here know a way I can search for and display all my > > old posts on Python ? Thanks a lot. > > > > > > Gengyang > > > > > > > You already asked this recently. You received good answers. > > > It was just over one week ago. On this very list. > > Here is the original thread in the archive: > https://mail.python.org/pipermail/python-list/2017-October/727139.html > > And here is this one: > https://mail.python.org/pipermail/python-list/2017-October/727567.html > > > -- > Thomas Jollans > -- https://mail.python.org/mailman/listinfo/python-list
Re: Searching For Old Posts On Python
On Tuesday, October 17, 2017 at 4:05:16 AM UTC+8, Cai Gengyang wrote: > I cannot remember where I posted the question it was a while ago .. > > On Mon, Oct 16, 2017 at 5:12 PM, Thomas Jollans <t...@tjol.eu> wrote: > > > On 2017-10-16 11:01, Cai Gengyang wrote: > > > Does anyone here know a way I can search for and display all my old > > posts on Python ? Thanks a lot. > > > > > > Gengyang > > > > > > > You already asked this recently. You received good answers. > > > > > > Oh Ok. The DuckDuckGo thing works ... I can find my old posts now. Cool ... -- https://mail.python.org/mailman/listinfo/python-list
Re: Searching For Old Posts On Python
I cannot remember where I posted the question it was a while ago .. On Mon, Oct 16, 2017 at 5:12 PM, Thomas Jollans <t...@tjol.eu> wrote: > On 2017-10-16 11:01, Cai Gengyang wrote: > > Does anyone here know a way I can search for and display all my old > posts on Python ? Thanks a lot. > > > > Gengyang > > > > You already asked this recently. You received good answers. > > > -- https://mail.python.org/mailman/listinfo/python-list
Searching For Old Posts On Python
Does anyone here know a way I can search for and display all my old posts on Python ? Thanks a lot. Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Finding Old Posts on Python
Hello, Does anyone know of a way to find all my old posts about Python ? Thanks a lot! GengYang -- https://mail.python.org/mailman/listinfo/python-list
Re: Boolean Expressions
On Wednesday, September 27, 2017 at 1:01:50 PM UTC+8, Cameron Simpson wrote: > On 26Sep2017 20:55, Cai Gengyang <gengyang...@gmail.com> wrote: > >On Wednesday, September 27, 2017 at 6:45:00 AM UTC+8, Cameron Simpson wrote: > >> On 26Sep2017 14:43, Cai Gengyang <gengyang...@gmail.com> wrote: > >> >C) Set bool_three equal to the result of > >> >19 % 4 != 300 / 10 / 10 and False > >> > > >> 19 % 4 = 3 which is equal to 300 / 10 / 10 = 3, hence the first term is > >> False. Entire expression is then equal to True, because False and False = > >> True > >> > >> Entire expression is False because the left hand side is False. > > > >Am I missing something here ? 19 % 4 = 19 modulo 4 equals to 3 right ? which > >equals the right hand side , hence first term is True > > But the test is for "!=", not "==". So False. > > Cheers, > Cameron Simpson <c...@cskk.id.au> (formerly c...@zip.com.au) Right ... I didn't see the ' =! ' -- https://mail.python.org/mailman/listinfo/python-list
Re: Boolean Expressions
On Wednesday, September 27, 2017 at 6:45:00 AM UTC+8, Cameron Simpson wrote: > On 26Sep2017 14:43, Cai Gengyang <gengyang...@gmail.com> wrote: > >Help check if my logic is correct in all 5 expressions > > Why not just run some code interactively? Unless this is entirely a thought > exercise to verify that you have a solid mental understanding of Python > semantics, all your reasoning is easy to test. > > In order to be honest to yourself, you could write does all your answers > (exactly as you have just done), _then_ go and run the expressions by hand in > python to see which are correct. You can also run the subparts of the > expressions, so that you can see which you have misevaluated versus which you > have made correct/incorrect logic reasoning about. > > >A) Set bool_one equal to the result of > >False and False > > > >Entire Expression : False and False gives True because both are False > > No. False and anything gives False. An "and" only gives True if both sides > are > true. > > >B) Set bool_two equal to the result of > >-(-(-(-2))) == -2 and 4 >= 16 ** 0.5 > > > >-(-(-(-2))) is equal to 2, and 2 is not equal to -2, hence the first term > > -(-(-(-2))) == -2 is False. 4 >= 16 ** 0.5 is True because 16 ** 0.5 is > >equal to 4, and 4 is greater then or equal to 4, hence the 2nd term 4 >= 16 > >** 0.5 is True. > > > >Entire expression : False because False and True gives False > > In python, "and" and "or" short circuit. So if you know enough to evaluate > the > condition from the left hand side, the right hand side is not evaluated at > all. > > So since 2 == -2 gives False, the expresion is False and the right hand is > not > evaluated. > > Note, BTW, that 16 ** 0.5 returns a floating point value. While that > particular > example works nicely, probably because it is all powers of 2 and doesn't hit > rounding issues, testing equality with floating point is a dangerous area. > > >C) Set bool_three equal to the result of > >19 % 4 != 300 / 10 / 10 and False > > > >19 % 4 = 3 which is equal to 300 / 10 / 10 = 3, hence the first term is > >False. Entire expression is then equal to True, because False and False = > >True > > Entire expression is False because the left hand side is False. > > >D) Set bool_four equal to the result of > >-(1 ** 2) < 2 ** 0 and 10 % 10 <= 20 - 10 * 2 > > > >-(1 ** 2) is equal to -1 , which is less than 2 ** 0 = 1, hence the first > >term is True. 2nd term 10 % 10 is equal to 0 , which is less than or equal > >to 20 - 10 * 2 , hence 2nd term is True. > > > >Entire expression : True and True = True > > Correct. (In my head; haven't run the code.) > > >E) Set bool_five equal to the result of > >True and True > > > >Entire Expression : True and True = True > > Correct. > > Cheers, > Cameron Simpson <c...@cskk.id.au> > > ERROR 155 - You can't do that. - Data General S200 Fortran error code list > 19 % 4 = 3 which is equal to 300 / 10 / 10 = 3, hence the first term is > False. Entire expression is then equal to True, because False and False = True > > Entire expression is False because the left hand side is False. Am I missing something here ? 19 % 4 = 19 modulo 4 equals to 3 right ? which equals the right hand side , hence first term is True -- https://mail.python.org/mailman/listinfo/python-list
Re: Boolean Expressions
I'm trying to understand the logic behind AND. I looked up Python logic tables False and False gives False False and True gives False True and False gives False True and True gives True. So does that mean that the way 'and' works in Python is that both terms must be True (1) for the entire expression to be True ? Why is it defined that way, weird ? I was always under the impression that 'and' means that when you have both terms the same, ie either True and True or False and False , then it gives True On Wednesday, September 27, 2017 at 5:54:32 AM UTC+8, Chris Angelico wrote: > On Wed, Sep 27, 2017 at 7:43 AM, Cai Gengyang <gengyang...@gmail.com> wrote: > > Help check if my logic is correct in all 5 expressions > > > > > > A) Set bool_one equal to the result of > > False and False > > > > Entire Expression : False and False gives True because both are False > > This is not correct, and comes from a confusion in the English > language. In boolean logic, "and" means "both". For instance: > > *IF* we have eggs, *AND* we have bacon, *THEN* bake a pie. > > Can you bake an egg-and-bacon pie? You need *both* ingredients. The > assertion "we have eggs" is True if we do and False if we do not; and > the overall condition cannot be True unless *both* assertions are > True. > > In Python, the second half won't even be looked at if the first half > is false. That is to say, Python looks beside the stove to see if > there's a carton of eggs, and if it can't see one, it won't bother > looking in the freezer for bacon - it already knows we can't bake that > pie. > > Your other questions are derived from this one, so you should be fine > once you grok this one concept. > > ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Boolean Expressions
Help check if my logic is correct in all 5 expressions A) Set bool_one equal to the result of False and False Entire Expression : False and False gives True because both are False B) Set bool_two equal to the result of -(-(-(-2))) == -2 and 4 >= 16 ** 0.5 -(-(-(-2))) is equal to 2, and 2 is not equal to -2, hence the first term -(-(-(-2))) == -2 is False. 4 >= 16 ** 0.5 is True because 16 ** 0.5 is equal to 4, and 4 is greater then or equal to 4, hence the 2nd term 4 >= 16 ** 0.5 is True. Entire expression : False because False and True gives False C) Set bool_three equal to the result of 19 % 4 != 300 / 10 / 10 and False 19 % 4 = 3 which is equal to 300 / 10 / 10 = 3, hence the first term is False. Entire expression is then equal to True, because False and False = True D) Set bool_four equal to the result of -(1 ** 2) < 2 ** 0 and 10 % 10 <= 20 - 10 * 2 -(1 ** 2) is equal to -1 , which is less than 2 ** 0 = 1, hence the first term is True. 2nd term 10 % 10 is equal to 0 , which is less than or equal to 20 - 10 * 2 , hence 2nd term is True. Entire expression : True and True = True E) Set bool_five equal to the result of True and True Entire Expression : True and True = True -- https://mail.python.org/mailman/listinfo/python-list
Printing a Chunk Of Words
""" Boolean Operators True and True is True True and False is False False and True is False False and False is False True or True is True True or False is True False or True is True False or False is False Not True is False Not False is True """ If I simply want to print a chunk of words and a paragraph like the above, what command should I use ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Boolean Logic
Input : # Assign True or False as appropriate on the lines below! # (20 - 10) > 15 bool_one = False# We did this one for you! # (10 + 17) == 3**16 # Remember that ** can be read as 'to the power of'. 3**16 is about 43 million. bool_two = False # 1**2 <= -1 bool_three = False # 40 * 4 >= -4 bool_four = True # 100 != 10**2 bool_five = False print ("bool_one = ", bool_one) print ("bool_two = ", bool_two) print ("bool_three = ", bool_three) print ("bool_four = ", bool_four) print ("bool_five = ", bool_five) Output : ('bool_one = ', False) ('bool_two = ', False) ('bool_three = ', False) ('bool_four = ', True) ('bool_five = ', False) Is my logic / input / output correct ? Thanks a lot ... On Saturday, September 23, 2017 at 12:40:10 PM UTC+8, steve.ferg...@gmail.com wrote: > You have a lot of assignment statements, but nothing that produces output. > Try adding statements like this at appropriate places... > > print ("bool_one = ", bool_one) -- https://mail.python.org/mailman/listinfo/python-list
Python Boolean Logic
Hey guys, I'm testing this on CodeAcademy, but I cant get the program to output a result even after pressing the run button. Just wanted to check if my logic is correct. Thanks alot # Assign True or False as appropriate on the lines below! # (20 - 10) > 15 bool_one = False# We did this one for you! # (10 + 17) == 3**16 # Remember that ** can be read as 'to the power of'. 3**16 is about 43 million. bool_two = False # 1**2 <= -1 bool_three = False # 40 * 4 >= -4 bool_four = True # 100 != 10**2 bool_five = False -- https://mail.python.org/mailman/listinfo/python-list
Re: NameError
I can't import it --- keep getting an importerror message. Can you try, let me know if it works and show me the code ? Thanks alot , appreciate it ... On Thu, Nov 24, 2016 at 1:22 PM, Nathan Ernst <nathan.er...@gmail.com> wrote: > I don't see anything in that output resembling an error, just a few > warnings that some features may no be available. > > Have you tried importing pygame after you did that? That's what'll prove > one way or another that it worked. > > Regards, > Nate > > On Wed, Nov 23, 2016 at 10:48 PM, Cai Gengyang <gengyang...@gmail.com> > wrote: > >> Yea, using Mac >> >> Following the instructions here for Mac ---https://bitbucket.org/pygam >> e/pygame/issues/82/homebrew-on-leopard-fails-to-install#comment-627494 >> >> GengYang Cai CaiGengYangs-MacBook-Pro:~ CaiGengYang$ brew install python >> ==> Installing dependencies for python: xz, pkg-config, readline, sqlite, >> ==> Installing python dependency: xz >> ==> Downloading https://homebrew.bintray.com/. >> ../xz-5.2.2.yosemite.bottle.ta >> >> 100.0% >> ==> Pouring xz-5.2.2.yosemite.bottle.tar.gz >> /usr/local/Cellar/xz/5.2.2: 91 files, 1.4M >> ==> Installing python dependency: pkg-config >> ==> Downloading https://homebrew.bintray.com/. >> ../pkg-config-0.29.1_1.yosemit >> >> 100.0% >> ==> Pouring pkg-config-0.29.1_1.yosemite.bottle.tar.gz >> /usr/local/Cellar/pkg-config/0.29.1_1: 10 files, 627.3K >> ==> Installing python dependency: readline >> ==> Downloading https://homebrew.bintray.com/. >> ../readline-6.3.8.yosemite.bot >> >> 100.0% >> ==> Pouring readline-6.3.8.yosemite.bottle.tar.gz >> ==> Caveats >> This formula is keg-only, which means it was not symlinked into >> /usr/local. >> >> OS X provides the BSD libedit library, which shadows libreadline. >> In order to prevent conflicts when programs look for libreadline we are >> defaulting this GNU Readline installation to keg-only. >> >> Generally there are no consequences of this for you. If you build your >> own software and it requires this formula, you'll need to add to your >> build variables: >> >> LDFLAGS: -L/usr/local/opt/readline/lib >> CPPFLAGS: -I/usr/local/opt/readline/include >> >> ==> Summary >> /usr/local/Cellar/readline/6.3.8: 46 files, 2M >> ==> Installing python dependency: sqlite >> ==> Downloading https://homebrew.bintray.com/. >> ../sqlite-3.13.0.yosemite.bott >> >> 100.0% >> ==> Pouring sqlite-3.13.0.yosemite.bottle.tar.gz >> ==> Caveats >> This formula is keg-only, which means it was not symlinked into >> /usr/local. >> >> OS X provides an older sqlite3. >> >> Generally there are no consequences of this for you. If you build your >> own software and it requires this formula, you'll need to add to your >> build variables: >> >> LDFLAGS: -L/usr/local/opt/sqlite/lib >> CPPFLAGS: -I/usr/local/opt/sqlite/include >> >> ==> Summary >> /usr/local/Cellar/sqlite/3.13.0: 10 files, 2.9M >> ==> Installing python dependency: gdbm >> ==> Downloading https://homebrew.bintray.com/. >> ../gdbm-1.12.yosemite.bottle.t >> >> 100.0% >> ==> Pouring gdbm-1.12.yosemite.bottle.tar.gz >> /usr/local/Cellar/gdbm/1.12: 18 files, 490.8K >> ==> Installing python dependency: openssl >> ==> Downloading https://homebrew.bintray.com/. >> ../openssl-1.0.2h_1.yosemite.b >> >> 100.0% >> ==> Pouring openssl-1.0.2h_1.yosemite.bottle.tar.gz >> ==> Caveats >> A CA file has been bootstrapped using certificates from the system >> keychain. To add additional certificates, place .pem files in >> /usr/local/etc/openssl/certs >> >> and run >> /usr/local/opt/openssl/bin/c_rehash >> >> This formula is keg-only, which means it was not symlinked into >> /usr/local. >> >> Apple has deprecated use of OpenSSL in favor of its own TLS and crypto >> libraries >> >> Generally there are no consequences of this for you. If you build your >> own software and it
Re: NameError
This is what I got : CaiGengYangs-MacBook-Pro:~ CaiGengYang$ /usr/local/bin/python3 Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pygame Traceback (most recent call last): File "", line 1, in ImportError: No module named 'pygame' >>> On Friday, November 25, 2016 at 1:46:10 AM UTC+8, Michael Torrie wrote: > As alister said, please do not just hit reply and type your message at > the top. Instead, place your reply below the quoted text you are > replying too. This is not hard. I realize there's a language barrier, > but please patiently read what alister said and understand what he's > saying. I know you're impatient to get Python working, but take a few > minutes to understand what we're saying. See below for my reply to your > message (and an example of posting below quoted text). > > On 11/24/2016 08:05 AM, Cai Gengyang wrote: > > CaiGengYangs-MacBook-Pro:~ CaiGengYang$ python > > Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) > > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > > Type "help", "copyright", "credits" or "license" for more information. > >>>> import pygame > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: No module named pygame > >>>> "import pygame" > > 'import pygame' > >>>> > > Quite likely you are not running the version of Python that was > installed with brew. Instead you are running the system version of > python that came with OS X, which is likely at /usr/bin/python. The > Brew-installed python is, if I recall correctly, installed to > /usr/local/bin, and is Python 3. So the correct command-line input > would be: > > /usr/local/bin/python3 > > That should bring up the python prompt and if you were successful with > brew installing pygame, you should be able to import pygame and not get > an ImportError. -- https://mail.python.org/mailman/listinfo/python-list
Re: NameError
CaiGengYangs-MacBook-Pro:~ CaiGengYang$ pip install pygame Collecting pygame Could not find a version that satisfies the requirement pygame (from versions: ) No matching distribution found for pygame You are using pip version 7.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. CaiGengYangs-MacBook-Pro:~ CaiGengYang$ python Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. On Thursday, November 24, 2016 at 11:26:49 PM UTC+8, DFS wrote: > On 11/24/2016 10:09 AM, Cai Gengyang wrote: > > > Hmm, so whats the solution ? > > > One solution - not the solution - is: > > $ pip install pygame > Collecting pygame >Downloading pygame-1.9.2b1-cp27-cp27m-win32.whl (4.3MB) > 100% || 4.3MB 181kB/s > Installing collected packages: pygame > Successfully installed pygame-1.9.2b1 > > $ python > Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 > 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > > >>> import pygame > >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: NameError
I mean whats the solution to import pygame ? How to import pygame ? On Thursday, November 24, 2016 at 11:22:07 PM UTC+8, alister wrote: > On Thu, 24 Nov 2016 07:09:22 -0800, Cai Gengyang wrote: > > > Hmm, so whats the solution ? > > > > > The solution is to bottom post or interleave post as previously stated > > > > > On Thursday, November 24, 2016 at 11:07:05 PM UTC+8, alister wrote: > >> On Thu, 24 Nov 2016 06:00:20 -0800, Cai Gengyang wrote: > >> > >> > CaiGengYangs-MacBook-Pro:~ CaiGengYang$ import pygame -bash: import: > >> > command not found > >> > > >> > > >> > > >> please do not top post as it makes the threads difficult to follow the > >> preferred style is interleave posing (posting a reply after the text > >> you are replying to) > >> and optionally snipping irrelevant parts of the post > >> > >> > >> -- > >> "I'm growing older, but not up." > >> -- Jimmy Buffett > > > > > > -- > There was a little girl > Who had a little curl > Right in the middle of her forehead. > When she was good, she was very, very good > And when she was bad, she was very, very popular. > -- Max Miller, "The Max Miller Blue Book" -- https://mail.python.org/mailman/listinfo/python-list
Re: NameError
CaiGengYangs-MacBook-Pro:~ CaiGengYang$ python Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pygame Traceback (most recent call last): File "", line 1, in ImportError: No module named pygame >>> "import pygame" 'import pygame' >>> On Thursday, November 24, 2016 at 10:58:41 PM UTC+8, Thomas Nyberg wrote: > On 11/24/2016 09:00 AM, Cai Gengyang wrote: > > CaiGengYangs-MacBook-Pro:~ CaiGengYang$ import pygame > > -bash: import: command not found > > That indicates you're running "import pygame" at the bash interpreter > prompt. You should first start "python" (type the word python without > quotes and press enter) which starts the python interpreter. You should > see this: ">>>". After this, then type "import pygame". See if that works. > > Cheers, > Thomas -- https://mail.python.org/mailman/listinfo/python-list
Re: NameError
Hmm, so whats the solution ? On Thursday, November 24, 2016 at 11:07:05 PM UTC+8, alister wrote: > On Thu, 24 Nov 2016 06:00:20 -0800, Cai Gengyang wrote: > > > CaiGengYangs-MacBook-Pro:~ CaiGengYang$ import pygame -bash: import: > > command not found > > > > > > > please do not top post as it makes the threads difficult to follow > the preferred style is interleave posing > (posting a reply after the text you are replying to) > and optionally snipping irrelevant parts of the post > > > -- > "I'm growing older, but not up." > -- Jimmy Buffett -- https://mail.python.org/mailman/listinfo/python-list
Re: NameError
CaiGengYangs-MacBook-Pro:~ CaiGengYang$ import pygame -bash: import: command not found On Thursday, November 24, 2016 at 1:22:56 PM UTC+8, Nathan Ernst wrote: > I don't see anything in that output resembling an error, just a few > warnings that some features may no be available. > > Have you tried importing pygame after you did that? That's what'll prove > one way or another that it worked. > > Regards, > Nate > > On Wed, Nov 23, 2016 at 10:48 PM, Cai Gengyang <gengyang...@gmail.com> > wrote: > > > Yea, using Mac > > > > Following the instructions here for Mac ---https://bitbucket.org/ > > pygame/pygame/issues/82/homebrew-on-leopard-fails-to- > > install#comment-627494 > > > > GengYang Cai CaiGengYangs-MacBook-Pro:~ CaiGengYang$ brew install python > > ==> Installing dependencies for python: xz, pkg-config, readline, sqlite, > > ==> Installing python dependency: xz > > ==> Downloading https://homebrew.bintray.com/. > > ../xz-5.2.2.yosemite.bottle.ta > > > > 100.0% > > ==> Pouring xz-5.2.2.yosemite.bottle.tar.gz > > /usr/local/Cellar/xz/5.2.2: 91 files, 1.4M > > ==> Installing python dependency: pkg-config > > ==> Downloading https://homebrew.bintray.com/. > > ../pkg-config-0.29.1_1.yosemit > > > > 100.0% > > ==> Pouring pkg-config-0.29.1_1.yosemite.bottle.tar.gz > > /usr/local/Cellar/pkg-config/0.29.1_1: 10 files, 627.3K > > ==> Installing python dependency: readline > > ==> Downloading https://homebrew.bintray.com/. > > ../readline-6.3.8.yosemite.bot > > > > 100.0% > > ==> Pouring readline-6.3.8.yosemite.bottle.tar.gz > > ==> Caveats > > This formula is keg-only, which means it was not symlinked into /usr/local. > > > > OS X provides the BSD libedit library, which shadows libreadline. > > In order to prevent conflicts when programs look for libreadline we are > > defaulting this GNU Readline installation to keg-only. > > > > Generally there are no consequences of this for you. If you build your > > own software and it requires this formula, you'll need to add to your > > build variables: > > > > LDFLAGS: -L/usr/local/opt/readline/lib > > CPPFLAGS: -I/usr/local/opt/readline/include > > > > ==> Summary > > /usr/local/Cellar/readline/6.3.8: 46 files, 2M > > ==> Installing python dependency: sqlite > > ==> Downloading https://homebrew.bintray.com/. > > ../sqlite-3.13.0.yosemite.bott > > > > 100.0% > > ==> Pouring sqlite-3.13.0.yosemite.bottle.tar.gz > > ==> Caveats > > This formula is keg-only, which means it was not symlinked into /usr/local. > > > > OS X provides an older sqlite3. > > > > Generally there are no consequences of this for you. If you build your > > own software and it requires this formula, you'll need to add to your > > build variables: > > > > LDFLAGS: -L/usr/local/opt/sqlite/lib > > CPPFLAGS: -I/usr/local/opt/sqlite/include > > > > ==> Summary > > /usr/local/Cellar/sqlite/3.13.0: 10 files, 2.9M > > ==> Installing python dependency: gdbm > > ==> Downloading https://homebrew.bintray.com/. > > ../gdbm-1.12.yosemite.bottle.t > > > > 100.0% > > ==> Pouring gdbm-1.12.yosemite.bottle.tar.gz > > /usr/local/Cellar/gdbm/1.12: 18 files, 490.8K > > ==> Installing python dependency: openssl > > ==> Downloading https://homebrew.bintray.com/. > > ../openssl-1.0.2h_1.yosemite.b > > > > 100.0% > > ==> Pouring openssl-1.0.2h_1.yosemite.bottle.tar.gz > > ==> Caveats > > A CA file has been bootstrapped using certificates from the system > > keychain. To add additional certificates, place .pem files in > > /usr/local/etc/openssl/certs > > > > and run > > /usr/local/opt/openssl/bin/c_rehash > > > > This formula is keg-only, which means it was not symlinked into /usr/local. > > > > Apple has deprecated use of OpenSSL in favor of its own TLS and crypto > > libraries > > > > Generally there are no consequences of this for you. If you build your > > own software and it requires this formula, you'll need t
Re: NameError
Yea, using Mac Following the instructions here for Mac ---https://bitbucket.org/pygame/pygame/issues/82/homebrew-on-leopard-fails-to-install#comment-627494 GengYang Cai CaiGengYangs-MacBook-Pro:~ CaiGengYang$ brew install python ==> Installing dependencies for python: xz, pkg-config, readline, sqlite, ==> Installing python dependency: xz ==> Downloading https://homebrew.bintray.com/.../xz-5.2.2.yosemite.bottle.ta 100.0% ==> Pouring xz-5.2.2.yosemite.bottle.tar.gz /usr/local/Cellar/xz/5.2.2: 91 files, 1.4M ==> Installing python dependency: pkg-config ==> Downloading https://homebrew.bintray.com/.../pkg-config-0.29.1_1.yosemit 100.0% ==> Pouring pkg-config-0.29.1_1.yosemite.bottle.tar.gz /usr/local/Cellar/pkg-config/0.29.1_1: 10 files, 627.3K ==> Installing python dependency: readline ==> Downloading https://homebrew.bintray.com/.../readline-6.3.8.yosemite.bot 100.0% ==> Pouring readline-6.3.8.yosemite.bottle.tar.gz ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. OS X provides the BSD libedit library, which shadows libreadline. In order to prevent conflicts when programs look for libreadline we are defaulting this GNU Readline installation to keg-only. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/readline/lib CPPFLAGS: -I/usr/local/opt/readline/include ==> Summary /usr/local/Cellar/readline/6.3.8: 46 files, 2M ==> Installing python dependency: sqlite ==> Downloading https://homebrew.bintray.com/.../sqlite-3.13.0.yosemite.bott 100.0% ==> Pouring sqlite-3.13.0.yosemite.bottle.tar.gz ==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local. OS X provides an older sqlite3. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/sqlite/lib CPPFLAGS: -I/usr/local/opt/sqlite/include ==> Summary /usr/local/Cellar/sqlite/3.13.0: 10 files, 2.9M ==> Installing python dependency: gdbm ==> Downloading https://homebrew.bintray.com/.../gdbm-1.12.yosemite.bottle.t 100.0% ==> Pouring gdbm-1.12.yosemite.bottle.tar.gz /usr/local/Cellar/gdbm/1.12: 18 files, 490.8K ==> Installing python dependency: openssl ==> Downloading https://homebrew.bintray.com/.../openssl-1.0.2h_1.yosemite.b 100.0% ==> Pouring openssl-1.0.2h_1.yosemite.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash This formula is keg-only, which means it was not symlinked into /usr/local. Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include ==> Summary /usr/local/Cellar/openssl/1.0.2h_1: 1,691 files, 12.0M ==> Installing python Warning: Building python from source: The bottle needs the Apple Command Line Tools to be installed. You can install them, if desired, with: xcode-select --install ==> Downloading https://www.python.org/.../2.7.12/Python-2.7.12.tar.xz 100.0% ==> Downloading https://bugs.python.org/file30805/issue10910-workaround.txt 100.0% ==> Patching ==> Applying issue10910-workaround.txt patching file Include/pyport.h Hunk #1 succeeded at 713 (offset 14 lines). Hunk #2 succeeded at 736 (offset 14 lines). ==> ./configure --prefix=/usr/local/Cellar/python/2.7.12 --enable-ipv6 --dataroo ==> make /usr/local/share/python/easy_install mecurial brew install sdl brew install sdl_mixer brew install sdl_ttf brew install sdl_image hg clone https://bitbucket.org/pygame/pygame cd pygame /usr/local/bin/python setup.py install Does this work ? On Thursday, November 24, 2016 at 12:00:18 PM UTC+8, Thomas Nyberg wrote: > On 11/23/2016 10:02 PM, Cai Gengyang wrote: > > I tried to import pygame by using these commands > > https://w
Re: NameError
I tried to import pygame by using these commands https://www.google.com.sg/#q=how+to+import+pygame but this is the error I got : CaiGengYangs-MacBook-Pro:~ CaiGengYang$ sudo apt-get install python-pygame sudo: apt-get: command not found On Thursday, November 24, 2016 at 10:54:20 AM UTC+8, Joel Goldstick wrote: > On Wed, Nov 23, 2016 at 9:44 PM, Cai Gengyang <gengyang...@gmail.com> wrote: > >>>> pygame.draw.rect(screen, BROWN, [60, 400, 30, 45]) > > Traceback (most recent call last): > > File "<pyshell#3>", line 1, in > > pygame.draw.rect(screen, BROWN, [60, 400, 30, 45]) > > NameError: name 'pygame' is not defined > > > > How to solve this error ? > > -- > > https://mail.python.org/mailman/listinfo/python-list > > have you imported pygame? > > -- > Joel Goldstick > http://joelgoldstick.com/blog > http://cc-baseballstats.info/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list
NameError
>>> pygame.draw.rect(screen, BROWN, [60, 400, 30, 45]) Traceback (most recent call last): File "", line 1, in pygame.draw.rect(screen, BROWN, [60, 400, 30, 45]) NameError: name 'pygame' is not defined How to solve this error ? -- https://mail.python.org/mailman/listinfo/python-list
Function to take the minimum of 3 numbers
I'm moving on to chapter 9 (http://programarcadegames.com/index.php?lang=en=lab_functions) of programarcadegames for the time being and going back to chapter 8 later (its just fucking frustrating and doesn't seem to work for the time being and I have a very bad temper). At least for chapter 9, I got the first part correct at first try --- define a function that takes and prints the smallest of 3 numbers. I pasted it here for reference and discussion. The code can also be further modified to include a clause that says that if two numbers tie for smallest, choose any of the two numbers. (I will attempt to do it and then post it here again for future discussion with users here >>> def min3(a, b, c): min3 = a if b < min3: min3 = b if c < min3: min3 = c if b < c: min3 = b return min3 >>> print(min3(4, 7, 5)) 4 -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: multiple statements found while compiling a single statement
I defined both done and pygame in this piece of code, but now i get a new error that i have never seen before, an AttributeError >>> rect_x = 50 >>> rect_y = 50 >>> done = False >>> pygame = True >>> while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True Traceback (most recent call last): File "<pyshell#48>", line 2, in for event in pygame.event.get(): AttributeError: 'bool' object has no attribute 'event' On Sunday, October 9, 2016 at 11:42:33 AM UTC+8, Steve D'Aprano wrote: > On Sun, 9 Oct 2016 01:51 pm, Cai Gengyang wrote: > > > This is my latest result : I copy and pasted one line at a time into the > > IDLE and used ONLY the "enter-return" button to move on to the next line > > and this time I didnt get an indentation error but instead a traceback > > error: > > > Traceback (most recent call last): > > File "<pyshell#12>", line 1, in > > while not done: > > NameError: name 'done' is not defined > > Right. > > That's because 'done' is not defined. > > Why don't you try my suggestion of saving the code into a .py file, then > using the File > Open command to open it? > > > > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: multiple statements found while compiling a single statement
This is my latest result : I copy and pasted one line at a time into the IDLE and used ONLY the "enter-return" button to move on to the next line and this time I didnt get an indentation error but instead a traceback error >>> rect_x = 50 >>> rect_y = 50 >>> while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True Traceback (most recent call last): File "<pyshell#12>", line 1, in while not done: NameError: name 'done' is not defined On Sunday, October 9, 2016 at 8:15:07 AM UTC+8, Gregory Ewing wrote: > Cai Gengyang wrote: > > Somehow it still doesnt work --- it keeps giving the syntaxerror, > > inconsistent use of tabs and indentation message EVEN though i use only the > > enter and space buttons and never touched the tab button a single time. > > There was another thread about this a short time ago. > It turns out that when you press enter in the IDLE REPL, > it auto-indents the next line -- but it does it using > *tabs*, not spaces. So if you do your manual indentation > with spaces, or paste something in that uses spaces, you > can easily end up with invalid tab/space mixtures. > > The solution is to always use the tab key for indentation > when working interactively in IDLE. > > I think this should be reported as a bug in IDLE, because > it's very unintuitive behaviour, and a beginner has little > chance of figuring out what's going on by themselves. > > -- > Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: multiple statements found while compiling a single statement
Somehow it still doesnt work --- it keeps giving the syntaxerror, inconsistent use of tabs and indentation message EVEN though i use only the enter and space buttons and never touched the tab button a single time. Im pretty sure there is something wrong with the program itself. Gonna download pycharm and start testing the programs in it --- heard that it gives a better user experience with indentations On Saturday, October 8, 2016 at 7:46:57 PM UTC+8, bream...@gmail.com wrote: > On Saturday, October 8, 2016 at 12:07:47 PM UTC+1, Rustom Mody wrote: > > On Saturday, October 8, 2016 at 1:21:50 PM UTC+5:30, Cai Gengyang wrote: > > > This is the result when I copy and paste it one line at a time : > > > > > > >>> rect_x = 50 > > > >>> rect_y = 50 > > > >>> while not done: > > > >>> > > > for event in ... > > > > > > There's sure something strange about your formatting > > > > you want something like this I think: > > > > rect_x = 50 > > rect_y = 50 > > while not done: > > for event in pygame.event.get(): > > if event.type == pygame.QUIT: > > done = True > > > > On a related note in addition to Steven's 2 suggestions > > - paste 1 line at a time > > - Write the code in a py file > > > > you could also try it out without Idle > > ie start python at your shell (or terminal or cmd.exe or whatever) > > And try it there > > The easiest way is to use the ipython %paste magic command. > > Kindest regards. > > Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: multiple statements found while compiling a single statement
This is the result when I copy and paste it one line at a time : >>> rect_x = 50 >>> rect_y = 50 >>> while not done: >>> for event in pygame.event.get(): if event.type == pygame.QUIT: done = True SyntaxError: invalid syntax On Saturday, October 8, 2016 at 3:02:09 PM UTC+8, Steve D'Aprano wrote: > On Sat, 8 Oct 2016 05:29 pm, Cai Gengyang wrote: > > > Unfortunately, in this case, it is 100% of the information I am giving > > you. > > Exactly. That's the problem. You need to give us more information, like how > you are trying to run this code. Are you using an IDE? Which IDE? > > > > You can try it yourself. The code is in the first section (8.1) of > > > > > http://programarcadegames.com/index.php?chapter=introduction_to_animation=en#section_8 > > > > Just copy and paste it into your Python IDLE and let me know what you get > > > I don't normally use IDLE, and you shouldn't assume that everyone does. > *That* is the extra information we need to solve the problem: > > The IDLE interactive interpreter in Python 3 does not seem to allow you to > paste multiple lines at once. If you do, it highlights the first line of > code with a red background and prints the error: > > SyntaxError: multiple statements found while compiling a single statement > > > > For example: > > > Python 3.3.0rc3 (default, Sep 27 2012, 18:44:58) > [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux > Type "copyright", "credits" or "license()" for more information. > >>> # Define some colors > BLACK = (0, 0, 0) > WHITE = (255, 255, 255) > GREEN = (0, 255, 0) > RED = (255, 0, 0) > SyntaxError: multiple statements found while compiling a single statement > >>> > > > > I can't show the colour highlighting, but the line BLACK = ... is > highlighted in red. > > > You can either copy and paste one line at a time, or you can use the File > > Open menu command to open a complete script. > > > > > > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: SyntaxError: multiple statements found while compiling a single statement
Unfortunately, in this case, it is 100% of the information I am giving you. You can try it yourself. The code is in the first section (8.1) of http://programarcadegames.com/index.php?chapter=introduction_to_animation=en#section_8 Just copy and paste it into your Python IDLE and let me know what you get ... On Saturday, October 8, 2016 at 2:19:26 PM UTC+8, Steve D'Aprano wrote: > On Sat, 8 Oct 2016 05:02 pm, Cai Gengyang wrote: > > > Any idea how to correct this error ? Looks fine to me > > As usual, the first and most important rule of debugging is to use ALL the > information the compiler gives you. Where is the rest of the traceback? At > the very least, even if nothing else, the compiler will print its best > guess at the failed line with a caret ^ pointing at the place it realised > there was an error. > > Asking us to debug your problem without giving us ALL the information is > like that old joke: > > > A man makes an appointment at the doctor because he isn't feeling > well. He goes in to see the doctor, who says "So, Mr Smith, what > seems to be the problem?" > > The man says "You're the medical expert, you tell me." > > > I do not think it is possible to get the error message you claim from > running the code you show. I think there is more code that you haven't > shown us, and that the error is there. > > The only way I can reproduce the error message you give is by using the > compile() function: > > py> compile("a=1\nb=2", "", "single") > Traceback (most recent call last): > File "", line 1, in > File "", line 1 > a=1 > ^ > SyntaxError: multiple statements found while compiling a single statement > > > Notice how the compiler shows the offending line and puts a caret ^ at the > end? > > Unless you show us what code actually causes this error message, I don't > think it is possible to help you. We're not mind-readers. > > > > > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
SyntaxError: multiple statements found while compiling a single statement
Any idea how to correct this error ? Looks fine to me >>> rect_x = 50 # Main Program Loop --- while not done: for event in pygame.event.get(): # User did something if event.type == pygame.QUIT: # If user clicked close done = True # Flag that we are done so we exit this loop SyntaxError: multiple statements found while compiling a single statement Thanks ... -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
On Tuesday, September 27, 2016 at 2:14:05 PM UTC+8, Cai Gengyang wrote: > We're trying to help, but we need to know more about the > environment you're using to enter your code. > > What operating system are you using? --- OSX Yosemite Version 10.10.2 > > How are you running the interactive interpreter? Are you > using IDLE, or are you running Python in a command window? --- IDLE > > Are you typing code directly into the interactive interpreter, Typing it > directly into IDLE > or are you typing it into a text editor and then copying > and pasting it into the interpreter? > > If you're using a text editor, which one are you using? --- Not using a text > editor > > What *exactly* are you typing on the keyboard to produce > your indentation? Are you pressing the space bar, the > tab key, or some combination of them? Just the space bar, not the tab > key because it gives jumps in spaces that are too large for my liking. > > > > > > > > > On Tuesday, September 27, 2016 at 1:20:17 PM UTC+8, Gregory Ewing wrote: > > Cai Gengyang wrote: > > > I'll still be asking for help here. Please help out a newbie. > > > > We're trying to help, but we need to know more about the > > environment you're using to enter your code. > > > > What operating system are you using? > > > > How are you running the interactive interpreter? Are you > > using IDLE, or are you running Python in a command window? > > > > Are you typing code directly into the interactive interpreter, > > or are you typing it into a text editor and then copying > > and pasting it into the interpreter? > > > > If you're using a text editor, which one are you using? > > > > What *exactly* are you typing on the keyboard to produce > > your indentation? Are you pressing the space bar, the > > tab key, or some combination of them? > > > > -- > > Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
We're trying to help, but we need to know more about the environment you're using to enter your code. What operating system are you using? --- OSX Yosemite Version 10.10.2 How are you running the interactive interpreter? Are you using IDLE, or are you running Python in a command window? --- IDLE Are you typing code directly into the interactive interpreter, Typing it directly into IDLE or are you typing it into a text editor and then copying and pasting it into the interpreter? If you're using a text editor, which one are you using? --- Not using a text editor What *exactly* are you typing on the keyboard to produce your indentation? Are you pressing the space bar, the tab key, or some combination of them? Just the space bar, not the tab key gives too jumps in spaces that are too large for my liking. On Tuesday, September 27, 2016 at 1:20:17 PM UTC+8, Gregory Ewing wrote: > Cai Gengyang wrote: > > I'll still be asking for help here. Please help out a newbie. > > We're trying to help, but we need to know more about the > environment you're using to enter your code. > > What operating system are you using? > > How are you running the interactive interpreter? Are you > using IDLE, or are you running Python in a command window? > > Are you typing code directly into the interactive interpreter, > or are you typing it into a text editor and then copying > and pasting it into the interpreter? > > If you're using a text editor, which one are you using? > > What *exactly* are you typing on the keyboard to produce > your indentation? Are you pressing the space bar, the > tab key, or some combination of them? > > -- > Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Sure, I just sent in a subscription request to it ... but I'll still be asking for help here. Please help out a newbie. When I master this language I can help other new users too (This is good for the world and for everyone involved). Ideally, Information and education should be free and not locked up by a few academics and institutions. On Tuesday, September 27, 2016 at 6:00:40 AM UTC+8, bream...@gmail.com wrote: > On Monday, September 26, 2016 at 9:57:52 PM UTC+1, Cai Gengyang wrote: > > Ok it works now: > > > > >>>for row in range(10): > > for column in range(10): > >print("*",end="") > > > > > > > > > > but how is it different from --- > > > > >>> for row in range(10): > >for column in range(10): > > print("*",end="") > > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > > > Why does the example on top work and the example below doesn't work ? The > > only difference is that the "print" statement is one space different from > > each other. Forgive me if i can't explain things clearly over the forum > > > > Perhaps you'd be more comfortable on the tutor mailing list > https://mail.python.org/mailman/listinfo/tutor > > Kindest regards. > > Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
Ok it works now: >>>for row in range(10): for column in range(10): print("*",end="") but how is it different from --- >>> for row in range(10): for column in range(10): print("*",end="") SyntaxError: inconsistent use of tabs and spaces in indentation Why does the example on top work and the example below doesn't work ? The only difference is that the "print" statement is one space different from each other. Forgive me if i can't explain things clearly over the forum On Tuesday, September 27, 2016 at 3:57:18 AM UTC+8, Larry Hudson wrote: > On 09/26/2016 08:25 AM, Cai Gengyang wrote: > > I just wanted to note that sometimes the code works, sometimes it doesn't. > > (even though both are exactly the same code) ... Weird , dum dum dum > > > > It is NOT weird. Python is being consistent, YOU are not. > > These examples are NOT "exactly the same code"! The indenting is different. > Python (correctly) > treats them as being different. > > YOU MUST USE CONSISTENT INDENTING. You MUST always use spaces (the > recommended) or always use > tabs. Never, ever, not at any time, can you mix them. > > (Now, does that emphasize the point enough?) Go back and REWRITE your code > with CONSISTENT > indenting. > > -- > -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
What is a tab and what is a space in python and what's the difference ? Which piece of code is indented with tabs and which one is indented with spaces ? On Tuesday, September 27, 2016 at 12:40:16 AM UTC+8, MRAB wrote: > On 2016-09-26 16:25, Cai Gengyang wrote: > > I just wanted to note that sometimes the code works, sometimes it doesn't. > > (even though both are exactly the same code) ... Weird , dum dum dum > > > >>>> for row in range(10): > >for column in range(10): > > print("*",end="") > > > > SyntaxError: inconsistent use of tabs and spaces in indentation > >>>> for row in range(10): > > for column in range(10): > >print("*",end="") > > > [snip] > > They are not exactly the same code. They are indented differently (tabs > vs spaces), and that matters in Python. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum >>> for row in range(10): for column in range(10): print("*",end="") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end="") On Monday, September 26, 2016 at 5:36:26 PM UTC+8, Steven D'Aprano wrote: > On Monday 26 September 2016 18:32, Cai Gengyang wrote: > > > These are my attempts --- > > That's nice. Do you have a question? > > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > When you indent, press TAB or SPACE but not both. > > This error can only happen if you are use spaces for some lines and tabs for > other lines. Do not do that. Use spaces only or tabs only, never both. > > > > SyntaxError: expected an indented block > > You forgot to indent at all. You must indent with at least one space or one > tab. > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > Use only spaces, or only tabs, never both. If you use spaces for one line, > then > always use spaces. If you use tabs for one line, then always use tabs. > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > Same as above. > > > > > > -- > Steven > git gets easier once you get the basic idea that branches are homeomorphic > endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
These are my attempts --- >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: expected an indented block >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: inconsistent use of tabs and spaces in indentation >>> for row in range(10): for column in range(10): print("*",end=" ") * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * On Monday, September 26, 2016 at 4:16:37 PM UTC+8, Steven D'Aprano wrote: > On Monday 26 September 2016 17:21, Jussi Piitulainen wrote: > > > Cai Gengyang <gengyang...@gmail.com> writes: > [snip 80 or so lines] > > Reindent your lines. > > In case Cai doesn't know what "reindent" means: > > > It depends on your text editor. At worst, you have to delete all the indents, > and re-enter them, using ONLY spaces, or ONLY tabs, but never mixing them. > > Some text editors may have a command to reindent, or clean indentation, or > fix > indentation, or something similar. > > Or you can use the tabnanny.py program: > > > python -m tabnanny path/to/file.py > > > > P.S. Hey Jussi, is the backspace key on your keyboard broken? Every time > somebody bottom-posts without trimming, a pixie dies... > > > > -- > Steven > git gets easier once you get the basic idea that branches are homeomorphic > endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list
Re: Nested for loops and print statements
So what do i need to do to correct the error ? Regards On Monday, September 26, 2016 at 2:48:16 PM UTC+8, Terry Reedy wrote: > On 9/26/2016 1:59 AM, Cai Gengyang wrote: > > Why is it that you need a print() at the end to create the table for > > example 1: > > > > Example 1 --- > > > >>>> for row in range(10): > > for column in range(10): > > print("*",end=" ") > > # Print a blank line for next row > > print() > > These indents are either 4 or 8 spaces. > > The print provides a carriage return. > Each line ends with a space. > > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > * * * * * * * * * * > > One can avoid both extra print and spaces with > > for row in range(10): > for column in range(10): > print("*", end=" " if column<9 else '\n') > > # or > for row in range(10): > print(' '.join(['*']*10)) > # or > print((' '.join(['*']*10)+'\n')*10) > > # or > for row in range(10): > print('* '*9 + '*') > # or > print(('* '*9 + '*\n')*10) > > > > but not for Example 2 --- > > > > for row in range(10): > > print("*",end=" ") > > > > * * * * * * * * * * > > > > When I try to do example 1 without the print() statement at the end, I get > > this error : > > > > for row in range(10): > > for column in range(10): > > print("*",end=" ") > > These indents are 4 spaces and 1 tabs. > > > SyntaxError: inconsistent use of tabs and spaces in indentation > > Because you mixed tabs and spaces. Has nothing to do with print statement. > > > -- > Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Nested for loops and print statements
Why is it that you need a print() at the end to create the table for example 1: Example 1 --- >>> for row in range(10): for column in range(10): print("*",end=" ") # Print a blank line for next row print() * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * but not for Example 2 --- for row in range(10): print("*",end=" ") * * * * * * * * * * When I try to do example 1 without the print() statement at the end, I get this error : for row in range(10): for column in range(10): print("*",end=" ") SyntaxError: inconsistent use of tabs and spaces in indentation -- https://mail.python.org/mailman/listinfo/python-list
Re: Data Types
On Wednesday, September 21, 2016 at 11:22:42 AM UTC+8, Steve D'Aprano wrote: > On Wed, 21 Sep 2016 01:00 pm, Cai Gengyang wrote: > > > So I am going through chapter 7.1 (Data Types) of > > http://programarcadegames.com/index.php… What do these terms (input and > > output) mean --- Can someone explain in plain English and layman's terms ? > > http://www.dictionary.com/browse/input > > http://www.dictionary.com/browse/output > > > Does that answer your question about "input and output"? > > > > Thanks a lot ... > > > >>>> type(3) > > > >>>> type(3.145) > > > >>>> type("Hi there") > > > >>>> type(True) > > > > I don't understand why you are showing this. What part don't you understand? > > The number 3 is an int (short for integer); that is the type of value it is. > 5 is also an int, and 0, and 9253, and -73. They are all integers. > > 3.145 is a float (short for "floating point number"). "Hi there" is a str > (short for string). True is a bool (short for Boolean value, which is a > technical term for special True/False values). > > Perhaps if you can ask a more clear question, I can give a more clear > answer. > > > > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. Right, So for example for "bool" , it only applies to True/False and nothing else? (2 data types), i.e. : >>> type(True) >>> type(False) Are there any other data types that will give you type(A) or type(B) = besides True and False? Regards, GY -- https://mail.python.org/mailman/listinfo/python-list
Data Types
So I am going through chapter 7.1 (Data Types) of http://programarcadegames.com/index.php… What do these terms (input and output) mean --- Can someone explain in plain English and layman's terms ? Thanks a lot ... >>> type(3) >>> type(3.145) >>> type("Hi there") >>> type(True) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Indentation
Yay ! On Sunday, August 14, 2016 at 1:40:09 AM UTC+8, Chris Angelico wrote: > On Sun, Aug 14, 2016 at 3:06 AM, Cai Gengyang <gengyang...@gmail.com> wrote: > > Oh ok, so for the first block , it works because the indentation is the > > same for all 3 "print" statements , i.e. the indentation is 4 spaces for > > each of the 3 print statements. > > > > if a == 1: > > print("If a is one, this will print.") > > print("So will this.") > > print("And this.") > > > > print("This will always print because it is not indented.") > > > > For the 2nd block of code, it doesn't work because the indentation is > > different, 2 spaces for the first statement, 5 for the 2nd statement and 4 > > for the 3rd statement. > > > > if a == 1: > > print("Indented two spaces.") > > print("Indented four. This will generate an error.") > > print("The computer will want you to make up your mind.") > > > > Am i correct ? > > Yep! That's correct. > > ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Indentation
Oh ok, so for the first block , it works because the indentation is the same for all 3 "print" statements , i.e. the indentation is 4 spaces for each of the 3 print statements. if a == 1: print("If a is one, this will print.") print("So will this.") print("And this.") print("This will always print because it is not indented.") For the 2nd block of code, it doesn't work because the indentation is different, 2 spaces for the first statement, 5 for the 2nd statement and 4 for the 3rd statement. if a == 1: print("Indented two spaces.") print("Indented four. This will generate an error.") print("The computer will want you to make up your mind.") Am i correct ? On Saturday, August 13, 2016 at 7:12:19 PM UTC+8, Marko Rauhamaa wrote: > Cai Gengyang <gengyang...@gmail.com>: > > > Can someone explain in layman's terms what indentation is > > Indentation means the number space (" ") characters in the beginning of a > line. > > A sequence of lines that have the same indentation belong to the same > block of statements. > > > Marko -- https://mail.python.org/mailman/listinfo/python-list
Python Indentation
Indentation matters. Each line under the if statement that is indented will only be executed if the statement is true: if a == 1: print("If a is one, this will print.") print("So will this.") print("And this.") print("This will always print because it is not indented.") Indentation must be the same. This code doesn't work. if a == 1: print("Indented two spaces.") print("Indented four. This will generate an error.") print("The computer will want you to make up your mind.") Why does the first example work and the 2nd example doesn't work ? Can someone explain in layman's terms what indentation is and why the first one works and the 2nd one doesn't ? Thanks alot Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?
Yea, using IDLE on OSX, Python 3.4.3. Yeah it works now ... I had to increase the font size and the indentation width. When that happened , it could define miles_driven On Thursday, August 11, 2016 at 2:09:11 AM UTC+8, Zachary Ware wrote: > On Wed, Aug 10, 2016 at 12:39 PM, Cai Gengyang <gengyang...@gmail.com> wrote: > > I managed to get this piece of code to work : > > > >>>> print("This program calculates mpg.") > > This program calculates mpg. > >>>> milesdriven = input("Enter miles driven:") > > Enter miles driven: 50 > >>>> milesdriven = float(milesdriven) > >>>> gallonsused = input("Enter gallons used:") > > Enter gallons used: 100 > >>>> gallonsused = float(gallonsused) > >>>> gallonsused = float(gallonsused) > >>>> mpg = milesdriven / gallonsused > >>>> print("Miles per gallon:", mpg) > > Miles per gallon: 0.5 > >>>> print("This program calculates mpg.") > > This program calculates mpg. > >>>> milesdriven = input("Enter miles driven:") > > Enter miles driven: 100 > >>>> milesdriven = float(milesdriven) > >>>> gallonsused = input("Enter gallons used:") > > Enter gallons used: 500 > >>>> gallonsused = float(gallonsused) > >>>> mpg = milesdriven / gallonsused > >>>> print("Miles per gallon:", mpg) > > Miles per gallon: 0.2 > > > > But, why can't i define a variable like "miles_driven" with an underscore > > in my Python Shell ? When I try to define it , the underscore doesn't > > appear at all and instead I get this result : > > "miles driven" , with no underscore appearing even though I have already > > typed "_" between "miles" and "driven" ? > > Are you using IDLE on OSX? Try changing your font or bumping up the > size (or switch to 3.5.2, which has better defaults). > > -- > Zach -- https://mail.python.org/mailman/listinfo/python-list
Why can't I define a variable like "miles_driven" with an underscore in Python 3.4.3 ?
I managed to get this piece of code to work : >>> print("This program calculates mpg.") This program calculates mpg. >>> milesdriven = input("Enter miles driven:") Enter miles driven: 50 >>> milesdriven = float(milesdriven) >>> gallonsused = input("Enter gallons used:") Enter gallons used: 100 >>> gallonsused = float(gallonsused) >>> gallonsused = float(gallonsused) >>> mpg = milesdriven / gallonsused >>> print("Miles per gallon:", mpg) Miles per gallon: 0.5 >>> print("This program calculates mpg.") This program calculates mpg. >>> milesdriven = input("Enter miles driven:") Enter miles driven: 100 >>> milesdriven = float(milesdriven) >>> gallonsused = input("Enter gallons used:") Enter gallons used: 500 >>> gallonsused = float(gallonsused) >>> mpg = milesdriven / gallonsused >>> print("Miles per gallon:", mpg) Miles per gallon: 0.2 But, why can't i define a variable like "miles_driven" with an underscore in my Python Shell ? When I try to define it , the underscore doesn't appear at all and instead I get this result : "miles driven" , with no underscore appearing even though I have already typed "_" between "miles" and "driven" ? -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I make a game in Python ?
Games are great. I guess I would like to invent animated games that can teach students how to solve mathematical, physics, engineering , Go and programming puzzles, basic financial literacy and investing techniques through interesting and enriching games and puzzles and university admissions interviews ... Create a piece of software like this, get users to test it ... then when the feedback streams in, iterate the product accordingly based on user feedback ... On Sunday, August 7, 2016 at 12:02:56 PM UTC+8, Chris Angelico wrote: > On Sun, Aug 7, 2016 at 1:14 PM, Michael Torrie <torr...@gmail.com> wrote: > > On 08/06/2016 03:51 PM, Cai Gengyang wrote: > >> As in, any recommended websites that helps users create complex games in > >> Python ? > > > > I imagine you create a complex game in Python the same way you'd do it > > in just about any other language. Thus any website on game design would > > be broadly applicable. And I'm sure there are a wide variety of topics > > that are relevant. Logic, game play, artificial intelligence, user > > interface, physics engines, and so forth. > > > > What you need to learn depends on what you already know and have > > experience in. The programming language is really only a part of > > developing "complex games." You'd probably want to start with simple, > > even child-like games first. Asking how to program complex games is a > > bit like asking how to build a car. > > Three of my students just recently put together a game (as their > first-ever collaborative project, working on different parts of the > project simultaneously), so I can tell you broadly how you would go > about it: > > 1) SCOPE. This is incredibly important. With the student project, they > had to have something demonstrable by Friday 5PM, so they had just > five days to get something working. But even when you don't have a > hard cut-off like that, you should scope back hard - brutally, even - > so you can get something workable as early as possible. > > 2) Pin down exactly what the *point* of your game is. What is the > fundamental thing you're trying to do? In their case, it was: Click on > the red squares before they turn back to white, then watch for another > square to turn red. As you develop, you'll mess around with everything > else, but don't mess with that. > > 3) Build a very basic project, managed in source control (git/hg/bzr > etc), and get it to the point of being testable. I don't mean unit > tests (although if you're a fan of TDD, you might well go that route), > but be able to fire up your game and actually run it. Commit that. > > 4) Progressively add features, constantly committing to source > control. Whenever your game isn't runnable, STOP and debug it until it > is. It's just way too hard to debug something that you can't even run. > > 5) Eventually, you'll get bored of the project or be forced to move on > to something else. At that point, the game is done. :) > > ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I make a game in Python ?
As in, any recommended websites that helps users create complex games in Python ? On Sunday, August 7, 2016 at 5:41:25 AM UTC+8, Ian wrote: > On Aug 6, 2016 11:57 AM, "Cai Gengyang" <gengyang...@gmail.com> wrote: > > How do I make a game in Python ? > > > import random > > answer = random.randint(0, 100) > while True: > guess = input("What number am I thinking of? ") > if int(guess) == answer: > print("Correct!") > break > print("Wrong!") > > And now you've made a game in Python. > > > On Aug 6, 2016 11:57 AM, "Cai Gengyang" <gengyang...@gmail.com> wrote: > > > How do I make a game in Python ? > > -- > > https://mail.python.org/mailman/listinfo/python-list > > -- https://mail.python.org/mailman/listinfo/python-list
How do I make a game in Python ?
How do I make a game in Python ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Float
You mentioned that : A floating point number[2] is number that is not an integer (and not a complex number) Hence , 10 is not a floating point number because it is an integer 25 is not a floating point number because it is an integer 7 + 3i is not a floating number because it is a complex number 8 + 5i is not a floating number because it is a complex number. Is 3.0 a floating number ? It is a rational number, not an integer right ? On Saturday, July 30, 2016 at 6:34:25 PM UTC+8, Steven D'Aprano wrote: > On Sat, 30 Jul 2016 08:21 pm, Cai Gengyang wrote: > > > Cool ... can you give a concrete example ? > > A concrete example of a float? > > I already gave two: > > > >> Python floats use 64 bits (approximately 18 decimal digits). Because the > >> decimal point can "float" from place to place, they can represent very > >> small numbers: > >> > >> 1.2345678901234567e-100 > >> > >> and very big numbers: > >> > >> 1.2345678901234567e100 > > > Here are some more: > > 0.5 # one half > 0.25 # one quarter > 7.5 # seven and a quarter > 0.001 # one thousandth > > 12345.6789 > # twelve thousand, three hundred and forty-five, point six seven eight nine > > -1.75 # minus one point seven five > 0.0 # zero > 3.0 # three > > 1.23e45 # one point two three times ten to the power of forty-five > > > > > -- > Steven > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: Float
Cool ... can you give a concrete example ? On Friday, July 29, 2016 at 10:27:08 PM UTC+8, Steven D'Aprano wrote: > On Fri, 29 Jul 2016 07:44 pm, Cai Gengyang wrote: > > > Can someone explain in layman's terms what "float" means ? > > Floating point number: > > https://en.wikipedia.org/wiki/Floating_point > > As opposed to fixed point numbers: > > https://en.wikipedia.org/wiki/Fixed-point_arithmetic > > Python floats use 64 bits (approximately 18 decimal digits). Because the > decimal point can "float" from place to place, they can represent very > small numbers: > > 1.2345678901234567e-100 > > and very big numbers: > > 1.2345678901234567e100 > > using just 64 bits. If it were *fixed* decimal place, the range would be a > lot smaller: for example, suppose the decimal place was fixed after three > digits. The largest number would be 999.999 and the smallest > would be 0.001. > > > > > -- > Steven > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Float
Can someone explain in layman's terms what "float" means ? >>> x = float(input("Write a number")) Write a number 16 -- https://mail.python.org/mailman/listinfo/python-list
Python Print Error
How to debug this ? >>> print "This line will be printed." SyntaxError: Missing parentheses in call to 'print' -- https://mail.python.org/mailman/listinfo/python-list
Python Print Error
How to debug this error message ? print('You will be ' + str(int(myAge) + 1) + ' in a year.') Traceback (most recent call last): File "", line 1, in print('You will be ' + str(int(myAge) + 1) + ' in a year.') ValueError: invalid literal for int() with base 10: '' -- https://mail.python.org/mailman/listinfo/python-list
Re: An educational site written in Python (from YCombinator's RFS)
Ned, At the risk of sounding like a naggy grandmother, I am not trying to argue with you (since it is pointless arguing over the internet with a stranger whom i don't know and I hate arguing) but It is important to note that whether there is a need/demand for a competitor or clone is not up to you or me to decide, it is up to the market and users to decide. If following your logic that there is no need for competition, then we would only have 1 search engine in the world. It is competition that creates real wealth in the world and improvement in people's lives. Before Google, there were already tons of search engines in existence like Yahoo and Altavista that had hundreds of millions if not billions of users. I am not sure exactly what special "sauce" that Google had that made it scale so fast so successfully and become the dominant search engine over others , but the point I was simply trying to make is that competition is a great thing in the free market, and that users are always willi ng to switch or use a new alternative if it is significantly better / different or novel (different design). Very few things are totally novel ... most technologies are copycats of one another. Even Steve Jobs, whom many would describe as the most creative tech innovator for the past 20 or 30 years probably stole / copied / cloned his ideas for his many inventions from various other sources (while constantly whining and accusing Microsoft and Bill Gates of ripping off his ideas lol). Amongst the "educational startup" sector, there are also several up and coming sites : http://www.inc.com/ilan-mochari/16-startups-that-will-disrupt-the-education-market.html and I predict that there will be demand for more similar sites in the future by users As Paul Graham mentioned : "Startups are often ruthless competitors, but they're competing in a game won by making what people want." On Saturday, May 14, 2016 at 12:52:58 AM UTC+8, Ned Batchelder wrote: > On Friday, May 13, 2016 at 12:05:33 PM UTC-4, Cai Gengyang wrote: > > edx.org is a great example , perhaps a competitor / clone with different > > functionalities and better design , more videos, graphics , more > > interactive > > As I mentioned in a previous reply, edx.org runs on Open edX, which is > open source, written in Python. There's no need for a competitor/clone, > you can use it as a starting point, and improve it how you like. > > The content is completely up to the course designer, you can include > whatever videos or graphics you like. For interactives, we have have > the XBlock API which lets you create new courseware components that > work however you like. > > --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: An educational site written in Python (from YCombinator's RFS)
My "vision" if you will for this site is one which should have these basic functionalities : 1) A forum for students , educators, parents and lawyers to post and discuss issues about education, fees, admissions process , visa issues. 2) A search engine for users to well (search for stuff lol) 2) Puzzles , Quizzes, Games and Tests in various topics. (Make it dynamic, animated and really interesting , I mean, I really love math, physics and engineering but a lot of lecturers are just fucking boring to listen to if you know what I mean. (makes you feel like you want to punch something. It would be great if every lecturer and professor in the world was as eloquent as Christopher Hitchens or as funny as Bill Maher, but especially in the hard sciences and math, alot of the lecturers are extremely smart but also very boring to listen to. 3) A live online discussion forum where users can discuss and chat see each other in real-time with a live video thingy (i don't know what its called) with some translator to help translate foreign accents and help users from different countries communicate properly. Imagine you are a poor genius amateur mathematician from Sudan who has just found a partial proof to the Riemann Hypothesis and you want to discuss it live in person over the internet with other math enthusiasts but can't speak English. A live translator that translates what you are speaking in real-time (if such a thing were possible, I have no idea) would be a good idea to create 4) A system to help parents connect with tutors whom they want to hire for their kids. I have no idea what the tutoring industry is like in other countries , but its a huge industry in Singapore with its super "kiasu" parents). There are already several such sites available, but I guess I could clone them and build them with different design (there can be infinite types of design, so its not like a zero-sum game). Especially as the population grows , there's likely to be more demand for these kind of sites and services. Alot of websites have very poor generic design and are unappealing to look at. edx.org is a great example , perhaps a competitor / clone with different functionalities and better design , more videos, graphics , more interactive On Wednesday, May 11, 2016 at 3:07:17 AM UTC+8, DFS wrote: > On 5/10/2016 2:13 AM, Cai Gengyang wrote: > > Ok, so after reading YCombinator's RFS, I have decided that I want to > > work on this : > > > > > > --- > > > > EDUCATION > > > > If we can fix education, we can eventually do everything else on this > > list. The first attempts to use technology to fix education have > > focused on using the Internet to distribute traditional content to a > > wider audience. This is good, but the Internet is a fundamentally > > different medium and capable of much more. > > > > Solutions that combine the mass scale of technology with one-on-one > > in-person interaction are particularly interesting to us. > > one room, one teacher, one student, and one web browser? > > > > > This may not require a "breakthrough" technology in the classical > > sense, but at a minimum it will require very new ways of doing > > things. > > > > --- > > > > I want to create such a site using Python. What are the various > > steps I need to take to create such a site ? This is a big project, > > but one that is worth doing ... Any suggestions / help appreciated ? > > Thanks alot > > > When you say 'such a site' what do you envision? -- https://mail.python.org/mailman/listinfo/python-list
An educational site written in Python (from YCombinator's RFS)
Ok, so after reading YCombinator's RFS, I have decided that I want to work on this : --- EDUCATION If we can fix education, we can eventually do everything else on this list. The first attempts to use technology to fix education have focused on using the Internet to distribute traditional content to a wider audience. This is good, but the Internet is a fundamentally different medium and capable of much more. Solutions that combine the mass scale of technology with one-on-one in-person interaction are particularly interesting to us. This may not require a "breakthrough" technology in the classical sense, but at a minimum it will require very new ways of doing things. --- I want to create such a site using Python. What are the various steps I need to take to create such a site ? This is a big project, but one that is worth doing ... Any suggestions / help appreciated ? Thanks alot Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Python PygLatin
I am guessing that the 2 you mentioned are Bill Gates and Larry Ellison ? I heard that they have tons of lawsuits against them in their career (anti-monopoly, anti-competitive laws filed against them both from the government and from individuals) ? Paul Graham has this very interesting related essay on meanness and success --http://paulgraham.com/mean.html On Monday, May 9, 2016 at 1:53:31 AM UTC+8, alister wrote: > On Mon, 09 May 2016 03:12:14 +1000, Steven D'Aprano wrote: > > > On Sun, 8 May 2016 08:21 pm, Cai Gengyang wrote: > > > >> If one looks at the Forbes List, you will see that there are 4 > >> programmers amongst the top ten richest people in the world (Bill > >> Gates, Mark Zuckerberg, Larry Ellison and Jeff Bezos) , a very large > >> percentage. Science and Technology is in a sense the most egalitarian > >> field in the world, because it involves using your brains and > >> creativity. You don't need to have a father who is a director at > >> Goldman Sachs or a mother who is the admissions officer at Harvard to > >> succeed in this line. > > > > Bill Gates III's father was a prominent lawyer, his mother was on the > > board of directors for First Interstate BancSystem and United Way, and > > one of his grandfathers was a national bank president. Gates himself > > went to Harvard. > > > > Zuckerberg's paternal grandparents were successful middle class, > > described as being the first on the block to own a colour TV. (This was > > back in the days when colour TVs were an expensive toy that few could > > afford.) His parents were also very successful professionals: a dentist > > and a psychiatrist. And he too went to Harvard. Despite the jeans and > > tee-shirts Zuckerberg is known for wearing, he's firmly from the > > professional/upper class. > > > > Bezos comes from a family of land-holders from Texas. His grandfather > > was regional director of the U.S. Atomic Energy Commission, and was > > financially successful enough to retire at an early age. He didn't go to > > Harvard, but he did go to Princeton. > > > > Ellison is the son of an unwed mother who gave him up for adoption by > > her aunt and uncle, comfortably middle-class. That makes him the closest > > out of the group as a "regular guy". > > And at least 2 of the above reached their position using business > practices that could be described as less than 100% honorable & above > board. > > > > > -- > Wait ... is this a FUN THING or the END of LIFE in Petticoat Junction?? -- https://mail.python.org/mailman/listinfo/python-list
Python PygLatin
I just "clicked" through the lesson on Conditionals and Control Flows and am on the lesson "PygLatin" . This will hopefully be a more interesting and interactive lesson because I will be building a PygLatin Translator ... It seems to me like it will take a long time before I can reach the point where I can become a master of programming languages and even create new programming languages and technologies. This is a long road ahead, but I believe it is worth it because the power of a new technology does eventually translate into money. If one looks at the Forbes List, you will see that there are 4 programmers amongst the top ten richest people in the world (Bill Gates, Mark Zuckerberg, Larry Ellison and Jeff Bezos) , a very large percentage. Science and Technology is in a sense the most egalitarian field in the world, because it involves using your brains and creativity. You don't need to have a father who is a director at Goldman Sachs or a mother who is the admissions officer at Harvard to succeed in this line. All you need is have the ability to create something that many users love to use. -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
Sorry I mistyped , this should be correct : bool_one = False and False --- This should give False because none of the statements are True bool_two = True and False --- This should give False because only 1 statement is True bool_three = False and True --- This should give False because only 1 statement is True bool_five = True and True --- This should give True because both statements are True On Wednesday, May 4, 2016 at 11:10:28 PM UTC+8, Jussi Piitulainen wrote: > Cai Gengyang writes: > > > I am trying to understand the boolean operator "and" in Python. It is > > supposed to return "True" when the expression on both sides of "and" > > are true > > > > For instance, > > > > 1 < 3 and 10 < 20 is True --- (because both statements are true) > > Yes. > > > 1 < 5 and 5 > 12 is False --- (because both statements are false) > > No :) > > > bool_one = False and False --- This should give False because none of the > > statements are False > > bool_two = True and False --- This should give False because only 1 > > statement is True > > bool_three = False and True --- This should give False because only 1 > > statement is True > > Yes. > > > bool_five = True and True --- This should give True because only 1 > > statement is True > > No :) > > > Am I correct ? > > Somewhat. > > In a technical programming-language sense, these are "expressions", not > "statements". Technically, if the first expression evaluates to a value > that counts as true in Python, the compound expression "E and F" > evaluates to the value of the second expression. > > Apart from False, "empty" values like 0, "", [] count as false in > Python, and all the others count as true. > > But it's true that "E and F" only evaluates to a true value when both E > and F evaluate to a true value. > > Your subject line is good: Python's "and" is indeed a conditional, > control-flow operator. -- https://mail.python.org/mailman/listinfo/python-list
Conditionals And Control Flows
I am trying to understand the boolean operator "and" in Python. It is supposed to return "True" when the expression on both sides of "and" are true For instance, 1 < 3 and 10 < 20 is True --- (because both statements are true) 1 < 5 and 5 > 12 is False --- (because both statements are false) bool_one = False and False --- This should give False because none of the statements are False bool_two = True and False --- This should give False because only 1 statement is True bool_three = False and True --- This should give False because only 1 statement is True bool_five = True and True --- This should give True because only 1 statement is True Am I correct ? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to become more motivated to learn Python
Cool, I have finally summoned up enough activation energy to start on Unit 3, now going through the topic on Conditionals and Control Flows (stuff like this) >>> boolthree = 200 == (50 * 5) >>> boolthree False Guess it would be really cool to work on AI and games. ( I have been addicted to computer games for a long time lol --- To be able to design a blockbuster like Starcraft 2, Diablo 3 or Final Fantasy 7 would be an incredible feat !) Didn't know that chess programming goes back 50+ years --- I always thought that computer programs were a recent invention. As it turns out , Ada Lovelace wrote the world's first computer program in 1842 (http://www.todayifoundout.com/index.php/2011/02/in-1842-ada-lovelace-wrote-the-worlds-first-computer-program/) if this piece is true On Wednesday, May 4, 2016 at 10:13:13 AM UTC+8, Christopher Reimer wrote: > On 5/3/2016 4:20 AM, Cai Gengyang wrote: > > So I have completed up to CodeAcademy's Python Unit 2 , now moving on to > > Unit3 : Conditionals and Control Flow. > > > > But I feel my motivation wavering , at times I get stuck and frustrated > > when trying to learn a new programming language ? > > > > This might not be a technical question per say, but it is a Python > > programming related one. How do you motivate a person (either yourself or > > your child) to become more interested in programming and stick with it ? Is > > determination in learning (especially in a tough field like software) > > partly genetic ? > > > > Related , This is a very well written essay on determination by Paul Graham > > http://www.paulgraham.com/determination.html > > > > Gengyang > > I started out translating old BASIC games into Python. These are the > same BASIC games that I tried to program into my Commodore 64 without > much success when I was much younger. Many of these BASIC games are a > good introduction to classical programming problems like rolling dice > and playing cards. > > http://www.atariarchives.org/basicgames/ > > When I realized that I wasn't learning enough about the Python language > from translating BASIC games, I started coding a chess engine. If you > ever look at the academic literature for chess programming from the last > 50+ years, you can spend a lifetime solving the programming challenges > from implementing the game of kings. > > Thank you, > > Chris R. -- https://mail.python.org/mailman/listinfo/python-list
How to become more motivated to learn Python
So I have completed up to CodeAcademy's Python Unit 2 , now moving on to Unit3 : Conditionals and Control Flow. But I feel my motivation wavering , at times I get stuck and frustrated when trying to learn a new programming language ? This might not be a technical question per say, but it is a Python programming related one. How do you motivate a person (either yourself or your child) to become more interested in programming and stick with it ? Is determination in learning (especially in a tough field like software) partly genetic ? Related , This is a very well written essay on determination by Paul Graham http://www.paulgraham.com/determination.html Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Madlibs.py code and error message
Ok, I got it to work with no error message finally ... Enter a name: cai gengyang Enter an adjective: beautiful Enter a second adjective: honest Enter a third adjective: pretty Enter a verb: hit Enter a second verb: run Enter a third verb: jump Enter a noun: honesty Enter a noun: patience Enter a noun: happiness Enter a noun: danger Enter an animal: elephant Enter a food: burger Enter a fruit: watermelon Enter a number: 1985 Enter a superhero_name: batman Enter a country: america Enter a dessert: icekachang Enter a year: 1984 This morning I woke up and felt because _ was going to finally h e big _ honest. On the other sid onesty were many patiences prote eep elephant in stores. The crow _ to the rythym of the burger, all of the runs very _. happine o _ into the sewers and found wa ats. Needing help, pretty quickl ump. 1985 appeared and saved cai by flying to batman and dropping puddle of america. icekachang th leep and woke up in the year 198 rld where dangers ruled the worl $ On Thursday, April 28, 2016 at 3:25:46 PM UTC+8, Steven D'Aprano wrote: > On Thursday 28 April 2016 17:08, Stephen Hansen wrote: > > > On Wed, Apr 27, 2016, at 11:55 PM, Ben Finney wrote: > >> Stephen Hansen <m...@ixokai.io> writes: > >> > >> > On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote: > >> > > Better: when you have many semantically-different values, use named > >> > > (not positional) parameters in the format string. [...] > >> > > > >> > > <URL:https://docs.python.org/3/library/string.html#formatstrings> > >> > > >> > Except the poster is not using Python 3, so all of this is for naught. > >> > >> Everything I described above works fine in Python 2. Any still-supported > >> version has 'str.format'. > > > > This response is completely unhelpful. The OP is using Python 2, and > > using %-formatting, and so you give a series of examples of using > > str.format, to, what? Confuse matters? > > How about we assume good faith and give Ben the benefit of the doubt that he > simply made a minor and trivial misjudgement rather than accusing him of > intentionally trying to confuse matters? > > You are correct that the OP can use % formatting with named arguments. Ben > is correct that the OP can also change his code to use str.format. Some > people hate %-formatting and cannot wait to migrate to {}-formatting, and > some people don't. > > (For the record, Internet rumours that %-formatting is deprecated are simply > not correct.) > > > > -- > Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Madlibs.py code and error message
I changed it to all lowercase, this time I get a different error message though (a TypeError message) # This program does the following ... writes a Mad Libs story # Author: Cai Gengyang print "Mad Libs is starting!" name = raw_input("Enter a name: ") adjective1 = raw_input("Enter an adjective: ") adjective2 = raw_input("Enter a second adjective: ") adjective3 = raw_input("Enter a third adjective: ") verb1 = raw_input("Enter a verb: ") verb2 = raw_input("Enter a second verb: ") verb3 = raw_input("Enter a third verb: ") noun1 = raw_input("Enter a noun: ") noun2 = raw_input("Enter a noun: ") noun3 = raw_input("Enter a noun: ") noun4 = raw_input("Enter a noun: ") animal = raw_input("Enter an animal: ") food = raw_input("Enter a food: ") fruit = raw_input("Enter a fruit: ") number = raw_input("Enter a number: ") superhero_name = raw_input("Enter a superhero_name: ") country = raw_input("Enter a country: ") dessert = raw_input("Enter a dessert: ") year = raw_input("Enter a year: ") #The template for the story STORY = "This morning I woke up and felt %s because _ was going to finally %s over the big _ %s. On the other side of the %s were many %ss protesting to keep %s in stores. The crowd began to _ to the rythym of the %s, which made all of the %ss very _. %s tried to _ into the sewers and found %s rats. Needing help, %s quickly called %s. %s appeared and saved %s by flying to %s and dropping _ into a puddle of %s. %s then fell asleep and woke up in the year _, in a world where %ss ruled the world." print STORY % (adjective1, name, verb1, adjective2, noun1, noun2, animal, food, verb2, noun3, fruit, adjective3, name, verb3, number, name , superhero_name, superhero_name, name, country, name, dessert, name, year, noun4) Terminal Output : $ python Madlibs.py Mad Libs is starting! Enter a name: andrew Enter an adjective: beautiful Enter a second adjective: honest Enter a third adjective: pretty Enter a verb: hit Enter a second verb: run Enter a third verb: fire Enter a noun: honesty Enter a noun: love Enter a noun: peace Enter a noun: wisdom Enter an animal: elephant Enter a food: burger Enter a fruit: watermelon Enter a number: 1985 Enter a superhero_name: batman Enter a country: america Enter a dessert: icekachang Enter a year: 1982 Traceback (most recent call last): File "Madlibs.py", line 34, in print STORY % (adjective1, name, verb1, adjective2, noun1, noun2, an imal, food, verb2, noun3, fruit, adj ective3, name, verb3, number, name , superhero_name, superhero_name, nam e, country, name, dessert, name, yea r, noun4) TypeError: not all arguments converted during string formatting On Thursday, April 28, 2016 at 12:50:28 PM UTC+8, Gregory Ewing wrote: > Cai Gengyang wrote: > > > adjective1 = raw_input("Enter an adjective: ") > > > > NameError: name 'Adjective1' is not defined > > Python is case-sensitive. You've spelled it "adjective1" in one > place and "Adjective1" in another. You need to be consistent. > > -- > Greg -- https://mail.python.org/mailman/listinfo/python-list
Python Madlibs.py code and error message
Python Madlibs.py code and error message --- Anyone can help? I keep getting stuck here ... # This program does the following ... writes a Mad Libs story # Author: Cai Gengyang print "Mad Libs is starting!" name = raw_input("Enter a name: ") adjective1 = raw_input("Enter an adjective: ") adjective2 = raw_input("Enter a second adjective: ") adjective3 = raw_input("Enter a third adjective: ") verb1 = raw_input("Enter a verb: ") verb2 = raw_input("Enter a second verb: ") verb3 = raw_input("Enter a third verb: ") noun1 = raw_input("Enter a noun: ") noun2 = raw_input("Enter a noun: ") noun3 = raw_input("Enter a noun: ") noun4 = raw_input("Enter a noun: ") animal = raw_input("Enter an animal: ") food = raw_input("Enter a food: ") fruit = raw_input("Enter a fruit: ") number = raw_input("Enter a number: ") superhero_name = raw_input("Enter a superhero_name: ") country = raw_input("Enter a country: ") dessert = raw_input("Enter a dessert: ") year = raw_input("Enter a year: ") #The template for the story STORY = "This morning I woke up and felt %s because _ was going to finally %s over the big _ %s. On the other side of the %s were many %ss protesting to keep %s in stores. The crowd began to _ to the rythym of the %s, which made all of the %ss very _. %s tried to _ into the sewers and found %s rats. Needing help, %s quickly called %s. %s appeared and saved %s by flying to %s and dropping _ into a puddle of %s. %s then fell asleep and woke up in the year _, in a world where %ss ruled the world." print STORY % (Adjective1, name, Verb1, Adjective2, Noun1, Noun2, animal, food, Verb2, Noun3, fruit, Adjective3, name, Verb3, number, name , superhero_name, superhero_name, name, country, name, dessert, name, year, Noun4) Terminal Output : $ python Madlibs.py Mad Libs is starting! Enter a name: Cai Gengyang Enter an adjective: beautiful Enter a second adjective: honest Enter a third adjective: huge Enter a verb: hit Enter a second verb: run Enter a third verb: jump Enter a noun: anger Enter a noun: belief Enter a noun: wealth Enter a noun: regret Enter an animal: elephant Enter a food: burger Enter a fruit: watermelon Enter a number: 6 Enter a superhero_name: batman Enter a country: America Enter a dessert: icekachang Enter a year: 1984 Traceback (most recent call last): File "Madlibs.py", line 34, in print STORY % (Adjective1, name, Verb1, Adjective2, Noun1, Noun2, an imal, food, Verb2, Noun3, fruit, Adj ective3, name, Verb3, number, name , superhero_name, superhero_name, nam e, country, name, dessert, name, yea r, Noun4) NameError: name 'Adjective1' is not defined -- https://mail.python.org/mailman/listinfo/python-list
An Educational Software Platform written in Python
So after reading YCombinator's new RFS, I have decided I want to build an educational software platform written in Python (mostly, if not entirely). Here is the description from YCombinator's RFS : If we can fix education, we can eventually do everything else on this list. The first attempts to use technology to fix education have focused on using the Internet to distribute traditional content to a wider audience. This is good, but the Internet is a fundamentally different medium and capable of much more. Solutions that combine the mass scale of technology with one-on-one in-person interaction are particularly interesting to us. This may not require a "breakthrough" technology in the classical sense, but at a minimum it will require very new ways of doing things. What resources would I need to obtain, learn and utilise on order to create this platform? Can I create something like this entirely in Python, or would I need to learn other technologies? Anyone can give some directions, thanks alot ! Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Returning a result from 3 items in a list
Programming is indeed tough ... I wish I had picked up this skill much earlier in life. But true, I will try to research my questions more in depth before posting here. My goal eventually is to build a successful YCombinator based web-based startup. On Wednesday, November 25, 2015 at 12:59:36 AM UTC+8, Ned Batchelder wrote: > On Tuesday, November 24, 2015 at 9:29:30 AM UTC-5, Mark Lawrence wrote: > > On 24/11/2015 14:07, Denis McMahon wrote: > > > On Tue, 24 Nov 2015 02:04:56 -0800, Cai Gengyang wrote: > > > > > >> Here's a dictionary with 3 values : > > >> > > >> results = { > > >>"gengyang": 14, > > >>"ensheng": 13, "jordan": 12 > > >> } > > >> > > >> How do I define a function that takes the last of the 3 items in that > > >> list and returns Jordan's results i.e. (12) ? > > > > > > You open a web browser and google for "python dictionary" > > > > > > > Ooh steady on old chap, surely you should have fitted the bib, done the > > spoon feeding and then changed the nappy? That appears to me the > > preferred way of doing things nowadays on c.l.py, rather than bluntly > > telling people not to be so bloody lazy. > > Mark and Denis, if you are having a hard time with newcomers to this list, > perhaps you need to find another list to read? > > Yes, Cai Gengyang could do more research before asking questions. But > your response does nothing to improve the situation. It's just snark > and bile, and does not exemplify the Python community's culture. > > > My fellow Pythonistas, ask not what our language can do for you, ask > > what you can do for our language. > > What you can do for our language is put a better foot forward. > > --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Returning a result from 3 items in a list
Here's a dictionary with 3 values : results = { "gengyang": 14, "ensheng": 13, "jordan": 12 } How do I define a function that takes the last of the 3 items in that list and returns Jordan's results i.e. (12) ? Thanks a lot ! Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Returning a result from 3 items in a list
Yup, thanks a lot ... it works now ! >>> results = { "gengyang": 14, "ensheng": 13, "jordan": 12 } >>> results["jordan"] 12 On Tuesday, November 24, 2015 at 6:40:26 PM UTC+8, Peter Otten wrote: > Cai Gengyang wrote: > > > Strange, it gives me an error message when i type result["jordan"] or > > result[max(result)] though : > > > >>>> results = { > > "gengyang": 14, > > "ensheng": 13, > > "jordan": 12 > > } > > > >>>> result["jordan"] > > Traceback (most recent call last): > > File "<pyshell#27>", line 1, in > > result["jordan"] > > NameError: name 'result' is not defined > > Yeah, the error message really should be > > "NameError: name 'result' is not defined; did you mean 'results'?" > > ;) -- https://mail.python.org/mailman/listinfo/python-list
Re: Returning a result from 3 items in a list
Strange, it gives me an error message when i type result["jordan"] or result[max(result)] though : >>> results = { "gengyang": 14, "ensheng": 13, "jordan": 12 } >>> result["jordan"] Traceback (most recent call last): File "<pyshell#27>", line 1, in result["jordan"] NameError: name 'result' is not defined >>> result[max(result)] Traceback (most recent call last): File "<pyshell#28>", line 1, in result[max(result)] NameError: name 'result' is not defined >>> On Tuesday, November 24, 2015 at 6:14:43 PM UTC+8, Chris Angelico wrote: > On Tue, Nov 24, 2015 at 9:04 PM, Cai Gengyang <gengyang...@gmail.com> wrote: > > Here's a dictionary with 3 values : > > > > results = { > > "gengyang": 14, > > "ensheng": 13, > > "jordan": 12 > > } > > > > How do I define a function that takes the last of the 3 items in that list > > and returns Jordan's results i.e. (12) ? > > > > Thanks a lot ! > > If you want Jordan's result, that's easy: > > result["jordan"] > > But there's no concept of "the last" entry in a dict. They don't have > an order. Do you mean "the entry with the greatest key"? That could be > written thus: > > result[max(result)] > > because max(result) is the string "jordan". > > Does either of those make sense for what you're doing? > > ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Getting math scores (Dictionary inside dictionary)
results = { "gengyang": { "maths": 10, "english": 15}, "ensheng": {"maths": 12, "english": 10}, "jordan": {"maths": 9, "english": 13} } How do you get gengyang's maths scores ? Thank you ... -- https://mail.python.org/mailman/listinfo/python-list
Re: Returning a result from 3 items in a list
Its cool ... No problem On Tuesday, November 24, 2015 at 7:05:25 PM UTC+8, Chris Angelico wrote: > On Tue, Nov 24, 2015 at 9:35 PM, Peter Otten <__pete...@web.de> wrote: > > Yeah, the error message really should be > > > > "NameError: name 'result' is not defined; did you mean 'results'?" > > > > ;) > > Heh. Yes, that was my fault. Sorry Cai! it should have been > results["jordan"], as you figured out. > > ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Getting math scores (Dictionary inside dictionary)
Great, it works! Thanks a lot .. >>> results = { "gengyang": { "maths": 10, "english": 15}, "ensheng": {"maths": 12, "english": 10}, "jordan": {"maths": 9, "english": 13} } >>> print((results["gengyang"])["maths"]) 10 On Tue, Nov 24, 2015 at 7:10 PM, Arie van Wingerden <xapw...@gmail.com> wrote: > print((results["gengyang"])["maths"]) > > 2015-11-24 12:04 GMT+01:00 Cai Gengyang <gengyang...@gmail.com>: > >> results = { >> "gengyang": { "maths": 10, "english": 15}, >> "ensheng": {"maths": 12, "english": 10}, >> "jordan": {"maths": 9, "english": 13} >> } >> >> How do you get gengyang's maths scores ? >> >> Thank you ... >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > -- https://mail.python.org/mailman/listinfo/python-list
Finding scores from a list
results = [ {"id": 1, "name": "ensheng", "score": 10}, {"id": 2, "name": "gengyang", "score": 12}, {"id": 3, "name": "jordan", "score": 5}, ] I want to find gengyang's score. This is what I tried : >>> print((results["gengyang"])["score"]) but I got an error message instead : Traceback (most recent call last): File "", line 1, in print((results["gengyang"])["score"]) TypeError: list indices must be integers, not str Any ideas how to solve this? Thank you .. -- https://mail.python.org/mailman/listinfo/python-list
Creating a Dynamic Website Using Python
Ok, So I have gone through the CodeAcademy Python modules and decided to jump straight into a project. I want to create a dynamic web-based site like this --- https://www.wedpics.com using Python How / where do I start ? Thanks a lot ! Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a Dynamic Website Using Python
Ok, I will look through the Flask tutorials then ... On Monday, November 23, 2015 at 8:21:28 PM UTC+8, Chris Angelico wrote: > On Mon, Nov 23, 2015 at 8:55 PM, Cai Gengyang <gengyang...@gmail.com> wrote: > > So I have gone through the CodeAcademy Python modules and decided to jump > > straight into a project. > > > > I want to create a dynamic web-based site like this --- > > https://www.wedpics.com using Python > > > > How / where do I start ? > > While it's *possible* to create a web site using just a base Python > install, it's a lot more work than you need. What you should instead > do is pick up one of the popular web frameworks like Django, Flask, > Bottle, etc, and use that. Pick a framework (personally, I use Flask, > but you can use any of them), and work through its tutorial. Then, > depending on how fancy you want your site to be, you'll need anywhere > from basic to advanced knowledge of the web's client-side technologies > - HTML, CSS, JavaScript, and possibly some libraries like Bootstrap, > jQuery, etc. Again, pick up any that you want to use, and work through > their tutorials. > > This is a massively open-ended goal. You can make this as big or small > as you want. > > ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: *= operator
>>> bill = 100 >>> bill *= 1.08 >>> bill 108.0 >>> On Saturday, November 21, 2015 at 9:47:29 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:a76b1b5b-4321-41bb-aeca-0dac78775...@googlegroups.com... > > > This is a piece of code that calculates tax and tip : > > > > def tax(bill): > > """Adds 8% tax to a restaurant bill.""" > > bill *= 1.08 > > print "With tax: %f" % bill > > return bill > > > > def tip(bill): > > """Adds 15% tip to a restaurant bill.""" > > bill *= 1.15 > > print "With tip: %f" % bill > > return bill > > > > meal_cost = 100 > > meal_with_tax = tax(meal_cost) > > meal_with_tip = tip(meal_with_tax) > > > > Does bill *= 1.08 mean bill = bill * 1.15 ? > > Firstly, I assume that you actually meant 'bill = bill * 1.08' at the end of > the last line. > > Secondly, how can I help you to answer this kind of question yourself. > > Here are two ways. > > 1. Try it out at the interpreter - > > c:\> > Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit > (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> bill = 100 > >>> bill *= 1.08 > >>> bill > > I deliberately omitted the last line. Try it yourself and see what you get. > > 2. Read the fine manual. > > The Index has a section headed 'Symbols'. From there you will find '*=', > with a link to 'augmented assignment'. > > If you follow the link, you will find a detailed explanation. Here is an > excerpt - > > "An augmented assignment expression like x += 1 can be rewritten as x = x + > 1 to achieve a similar, but not exactly equal effect. In the augmented > version, x is only evaluated once. Also, when possible, the actual operation > is performed in-place, meaning that rather than creating a new object and > assigning that to the target, the old object is modified instead." > > Frank Millman -- https://mail.python.org/mailman/listinfo/python-list
*= operator
This is a piece of code that calculates tax and tip : def tax(bill): """Adds 8% tax to a restaurant bill.""" bill *= 1.08 print "With tax: %f" % bill return bill def tip(bill): """Adds 15% tip to a restaurant bill.""" bill *= 1.15 print "With tip: %f" % bill return bill meal_cost = 100 meal_with_tax = tax(meal_cost) meal_with_tip = tip(meal_with_tax) Does bill *= 1.08 mean bill = bill * 1.15 ? -- https://mail.python.org/mailman/listinfo/python-list
print("%.2f" % total)
meal = 44.50 tax = 0.0675 tip = 0.15 meal = meal + meal * tax total = meal + meal * tip print("%.2f" % total) What do the lines inside the parentheses in this statement print("%.2f" % total) mean ? What does "%.2f" % total represent ? Thanks alot ... Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Comparators
Comparators, interesting ... >>> booltwo = (10 + 18) == 3**17 >>> booltwo False >>> boolone = (50 - 35) > 35 >>> boolone False >>> booltwo = (65 - 35) > 15 >>> booltwo True >>> boolalpha = 3 < 6 >>> boolalpha True >>> boolbeta = 100 == 10*30 >>> boolbeta False >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: Comparators
Hmm .. I am a slow learner and have poor memory. Sometimes when I see a new programming operator, I have to type it out so that I can remember it and let it sink into my brain On Sunday, November 22, 2015 at 6:24:28 AM UTC+8, Jon Ribbens wrote: > On 2015-11-21, Cai Gengyang <gengyang...@gmail.com> wrote: > > Comparators, interesting ... > > > >>>> booltwo = (10 + 18) == 3**17 > >>>> booltwo > > False > > What's interesting about that? -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback error
Right ... I removed the 'j' and the code works now. I must have accidentally put it in , forgot about it and thought that it was part of the original code when it shouldn't have been there in the first place. Thanks ! On Saturday, November 21, 2015 at 3:27:02 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:e5d80196-61c5-44d9-bec8-dc563d58f...@googlegroups.com... > > > This is a piece of code about comparators : > > > > j# Assign True or False as appropriate on the lines below! > > [snip rest of code] > > > When I tried to run it, this is the error I got : > > > Traceback (most recent call last): > > File "python", line 1, in > > NameError: name 'j' is not defined > > > > Any ideas how to debug this ? > > > It looks to me as if the error is right there on the first line. What is > that 'j' doing there? It looks like a typo. > > HTH > > Frank Millman -- https://mail.python.org/mailman/listinfo/python-list
Traceback error
This is a piece of code about comparators : j# Assign True or False as appropriate on the lines below! # Set this to True if 17 < 328 or to False if it is not. bool_one = 17 < 328 # We did this one for you! # Set this to True if 100 == (2 * 50) or to False otherwise. bool_two = 100 == (2 * 50) # Set this to True if 19 <= 19 or to False if it is not. bool_three = 19 <= 19 # Set this to True if -22 >= -18 or to False if it is not. bool_four = -22 >= -18 # Set this to True if 99 != (98 + 1) or to False otherwise. bool_five = 99 != (98 + 1) When I tried to run it, this is the error I got : Traceback (most recent call last): File "python", line 1, in NameError: name 'j' is not defined Any ideas how to debug this ? Thanks a lot! Appreciate it Cai Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Writing a Financial Services App in Python
>From YCombinator's new RFS, This is the problem I want to solve as it is a >severe problem I face myself and something I need. I want to write this app in >Python as I heard that Python is a great language that many programmers use >... How / where do I start ? The problem is detailed below : FINANCIAL SERVICES Saving money is hard and Americans are particularly bad at it. Because the personal savings rate has largely been falling since the early 80s, we don't have sufficient cushions to face economic shocks, weather unexpected unemployment, or even enjoy our retirements. Its simply too hard to find good ways to save or to invest. Savings accounts only pay a fraction of what's needed to keep up with inflation. Picking individual stocks and bonds exposes investors to huge volatility and does nothing to guarantee a return. While investors can dampen their volatility through various exchanges or closed ended funds, the reality is that few have the expertise needed to properly mix those funds, rebalance them, and optimize them for taxes to capture the best possible return (no matter how you define that) given each dollar of invested capital. Even if investors were able to pick optimal investment strategies, they'd find that that fees are a huge drag on performance. This seems to us like something software should help solve. We'd like to see teams tackling each of the component issues around saving and investing, along with ones tackling the entire package. Thanks alot ! Cai Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Re: Writing a Financial Services App in Python
Sure ... is this : https://www.codecademy.com/learn/python a good place to learn Python ? Are you wanting to contract with some programmers to create this application for you? Eventually I will have to find programming co-founders and employees to create and iterate the product as user feedback streams in. But I will write the initial prototype myself because I plan to be the main programmer / founder , but yes ... eventually I will need 1 or even 2 co-founders and when the platform gains enough users, we will have to hire programmers and sales/ business people. But this will be a tech-heavy company and all the main founders and employees should be excellent programmers. But for the moment, I plan to write the initial prototype myself ... On Friday, November 20, 2015 at 12:00:34 AM UTC+8, Michael Torrie wrote: > On 11/19/2015 04:59 AM, Cai Gengyang wrote: > > > > From YCombinator's new RFS, This is the problem I want to solve as it > > is a severe problem I face myself and something I need. I want to > > write this app in Python as I heard that Python is a great language > > that many programmers use ... How / where do I start ? The problem is > > detailed below : > > I'm afraid you're going to be discouraged. > > Well the first step is you have to learn programming. And you don't > start with such a large problem, I assure you. You start by learning > the language by following the tutorials, writing small programs to > become familiar with programming and the language itself. Then you > become familiar with related things like algorithms and data structures, > and how to use them with and from Python (or any language). Eventually > you add to that graphical user interface development. > > After that then you might be in a position to start thinking about how > to design and build a program that does what you were talking about. > > There honestly are no shortcuts. Python is a great language, and is > easy to learn, but it's not like you can start cranking out full-blown > applications magically. In the hands of experienced programmers, yes > Python is incredibly fast and flexible for cranking out working apps. > > You might try checking out a Python application development framework > that can produce apps that will run on Android and iOS (and Windows and > Linux) called Kivy. I would think mobile should be your target platform > for such an app. > > > > > > This seems to us like something software should help solve. We'd like > > to see teams tackling each of the component issues around saving and > > investing, along with ones tackling the entire package. > > Are you wanting to contract with some programmers to create this > application for you? -- https://mail.python.org/mailman/listinfo/python-list
Re: Writing a Financial Services App in Python
It will be a web-based application. Something like this : https://www.slicedinvesting.com/, but with different, better, more features and also graphics , forums, a system to track your daily, monthly expenses and earnings, a graphical tutorial system to teach users financial literacy , learn and utilise ways to invest and trade their money properly and create computerised trend following systems to trade stocks in the stock market. The truth is, very few individual investors really know how to properly trade stocks , and hedge funds are open to mainly very wealthy clients. Computerised and automated trend following systems can legally create huge profits for investors if a disciplined automated systems are utilised. I for example, am a terrible trader because of having almost zero discipline and thus keep losing money. My plan is to create such an all-in-one platform to help individual users like myself who might not have millions of dollars to invest in professional hedge funds properly invest , trade , keep track of their money and also network with our individual investors. On Thursday, November 19, 2015 at 11:03:50 PM UTC+8, Jeremy Leonard wrote: > On Thursday, November 19, 2015 at 7:00:05 AM UTC-5, Cai Gengyang wrote: > > From YCombinator's new RFS, This is the problem I want to solve as it is a > > severe problem I face myself and something I need. I want to write this app > > in Python as I heard that Python is a great language that many programmers > > use ... How / where do I start ? The problem is detailed below : > > > > FINANCIAL SERVICES > > > > Saving money is hard and Americans are particularly bad at it. Because the > > personal savings rate has largely been falling since the early 80s, we > > don't have sufficient cushions to face economic shocks, weather unexpected > > unemployment, or even enjoy our retirements. > > Its simply too hard to find good ways to save or to invest. Savings > > accounts only pay a fraction of what's needed to keep up with inflation. > > Picking individual stocks and bonds exposes investors to huge volatility > > and does nothing to guarantee a return. > > > > While investors can dampen their volatility through various exchanges or > > closed ended funds, the reality is that few have the expertise needed to > > properly mix those funds, rebalance them, and optimize them for taxes to > > capture the best possible return (no matter how you define that) given each > > dollar of invested capital. Even if investors were able to pick optimal > > investment strategies, they'd find that that fees are a huge drag on > > performance. > > > > This seems to us like something software should help solve. We'd like to > > see teams tackling each of the component issues around saving and > > investing, along with ones tackling the entire package. > > > > > > Thanks alot ! > > > > Cai Gengyang > > What platform do you want the app to target (web/desktop/etc...)? > > Jeremy -- https://mail.python.org/mailman/listinfo/python-list
A Program that prints the numbers from 1 to 100
I want to write a program in Python that does this "Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz"." How do I go about doing it ? -- https://mail.python.org/mailman/listinfo/python-list
Execute Python Scripts
So I am going through this article on Python for newbies ---http://askpython.com/execute-python-scripts/ Managed to create a file with these contents : 1 #!/usr/bin/env python3 2 3 print('hello world') and saved it as hello.py Next step, I wanted to open the 'command line' so I can type 'python hello.py' to execute the scripts. Where do I find the "command line" ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Execute Python Scripts
Ok thanks ... this --- https://docs.python.org/3/tutorial/index.html looks like a way more comprehensive resource. Paul Graham has written an excellent essay called "The Python Paradox" : http://www.paulgraham.com/pypar.html. Putting it here for sharing and discussion ... On Thursday, October 15, 2015 at 1:47:50 AM UTC+8, Ian wrote: > On Wed, Oct 14, 2015 at 11:04 AM, Cai Gengyang <gengyang...@gmail.com> wrote: > > So I am going through this article on Python for newbies > > ---http://askpython.com/execute-python-scripts/ > > That looks like a terrible resource. There are plenty of tutorials and > books out there that are actually good. I suggest starting with the > tutorial from the Python docs: > > https://docs.python.org/3/tutorial/index.html > > > Pleasure to meet you ... I am using a Mac OS X Yosemite Version 10.10.2 > > Operating System. > > > > Is the command line on this operating system the "Terminal" (black screen) ? > > Yes. You will also need to "cd" to the same directory where you saved > the script. For example, if you saved it to your Documents directory, > then type "cd Documents" at the command line. > > You might also want to read a tutorial on the Mac OS X command line, > e.g.: http://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line -- https://mail.python.org/mailman/listinfo/python-list
Re: Execute Python Scripts
On Thursday, October 15, 2015 at 1:18:27 AM UTC+8, paul.her...@gmail.com wrote: > > Where do I find the "command line" ? > > Welcome to Python. > > Starting a command shell depends on which operating system you are running. > > If you are on Microsoft Windows, choose the Start button, then type "cmd" > into the edit control, then press Enter. Pleasure to meet you ... I am using a Mac OS X Yosemite Version 10.10.2 Operating System. Is the command line on this operating system the "Terminal" (black screen) ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with Debugging
I am glad to announce that it works now ! The error was an addition random 'qq' that somehow appeared in my settings.py file on line 44. Once I spotted and removed it , the code works. I have pasted the entire successful piece of code here for viewing and discussion ... CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls manage.py mysite CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate Operations to perform: Synchronize unmigrated apps: staticfiles, messages Apply all migrations: admin, contenttypes, auth, sessions Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying sessions.0001_initial... OK CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ On Monday, September 28, 2015 at 2:20:39 PM UTC+8, Andrea D'Amore wrote: > On 2015-09-28 05:26:35 +0000, Cai Gengyang said: > > > File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45 > > > > 'django.middleware.csrf.CsrfViewMiddleware', > > > > ^ > > > > SyntaxError: invalid syntax > > The syntax looks fine in the pastebin, did you possibly copy text from > web thus pasting smartquotes or unprintables in your source file? > > > -- > Andrea -- https://mail.python.org/mailman/listinfo/python-list
Re: Django Tutorial (Database setup) Question
I believe I am already in the same directory that contains manage.py , but I still get an error (a syntax error). Checked the lines in settings.py and can't find anything wrong with them either. Posted my entire code below : CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls manage.py mysite CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute settings.INSTALLED_APPS File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__ self._setup(name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup self._wrapped = Settings(settings_module) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45 'django.middleware.csrf.CsrfViewMiddleware', ^ SyntaxError: invalid syntax CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ On Mon, Sep 28, 2015 at 12:08 AM, Joel Goldstick <joel.goldst...@gmail.com> wrote: > > > On Sun, Sep 27, 2015 at 3:32 AM, Cai Gengyang <gengyang...@gmail.com> > wrote: > >> Hello all ! >> >> So I am going through the (Database setup) chapter of this tutorial ( >> https://docs.djangoproject.com/en/1.8/intro/tutorial01/) --- Its the >> section right after the first chapter on "Creating a project" >> >> I opened up mysite/settings.py as per the instructions on the Django >> tutorial. >> >> However, when I try to run the following command : $ python manage.py >> migrate to create the tables in the database, >> >> CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate >> input >> >> I get the following error message : >> >> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: >> can't open file 'manage.py': [Errno 2] No such file or directory output >> >> Any idea how to solve this issue? >> >> Thanks a lot ! >> >> You need to be in the directory that contains manage.py > >> Gengyang >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Joel Goldstick > http://joelgoldstick.com > -- https://mail.python.org/mailman/listinfo/python-list
Help with Debugging
http://pastebin.com/RWt1mp7F --- If anybody can find any errors with this settings.py file, let me know ! Can't seem to find anything wrong with it ... -- https://mail.python.org/mailman/listinfo/python-list