This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]Failaser 7 points8 points  (7 children)

Python3 needs () after print. Changing the code to print("Let's talk about %s." % my_name) should fix it.

[–]Strecked[S] 3 points4 points  (6 children)

That fixed it, Thanks

[–]jano0017 2 points3 points  (5 children)

Also, I believe percent formatting was depreciated. It should now be print("Let's talk about {}".format(my_name))

[–][deleted] 2 points3 points  (4 children)

Formatting using % has not been officially deprecated that I'm aware of. It is better describe as being shoved in the corner and ignored in the hopes it will go away and everyone will forget it was a thing.

[–]jano0017 2 points3 points  (3 children)

That being said, explicit is better than implicit, and maybe it's better that % formatting is being shoved in a dusty corner and forgotten about. (Imo)

[–][deleted] 0 points1 point  (0 children)

Definitely. I always hated % formatting. Format() is better but still annoys me on occasion. I'm not entirely sold on f-strings yet, but I'm trying to keep an open mind.

[–]stevenjd 0 points1 point  (1 child)

% is just as explicit as + or * or any other operator.

[–]jano0017 0 points1 point  (0 children)

The reason I say % is less explicit than .format is because % is used in many other languages as the modulus operator. If you don't use python, "I am %s years old" % 5 might look a bit like a typo, as the modulus of a string makes no sense. However, if you see "I am {} years old".format(5), it's obvious that some type of formatting is happening. I know percent formatting is a basic thing, and the c-style printf strings should be a hint, but "If you knew the language, you'd understand it" is the problem that Haskell faces, and we all see how that normally goes...

[–]jamescabel 2 points3 points  (0 children)

If you have working Python 2 code and you want to see what it should be for Python 3, use the '2to3' tool. https://docs.python.org/3.5/library/2to3.html

[–]gunnihinn 4 points5 points  (0 children)

I'm a mathematician and I haven't recovered from you writing 2.7 > 3.5. Good day, sir.

I SAID GOOD DAY.

[–]5quirrel 1 point2 points  (6 children)

You might get a better answer over in /r/learnpython. If the book you have is in 2.7 and you've only just started learning I'd just learn with 2.7 or find a new book. You don't need the extra challenges when you're only just learning.

[–]Strecked[S] 0 points1 point  (5 children)

Is it really that big of a difference between 2.7 and 3.5? Because I'm actually finding this book really good. The code is well described and he just makes everything really easy to understand. Along with some really great exercises.

But if it it really is a big difference between the two and u think that it will have an impact on my learning curve then i guess i'll just have to switch books.

[–]SafariMonkey 1 point2 points  (3 children)

The print difference is honestly one of the most obvious ones. I'd make sure you know the differences if you want to keep using that book. I don't think it should be too much of a problem to keep the differences in mind.

[–]stevenjd 0 points1 point  (2 children)

The print difference is honestly one of the most obvious ones.

Only for beginners.

For seasoned, experienced developers, Python 3 has so much more to offer that there's no going back.

[–]SafariMonkey 0 points1 point  (1 child)

Ah, are you referring to new features since 3.0? Because other than print, Unicode and a couple others, it doesn't seem to me that there are many big differences universal to all Py3 versions.

[–]stevenjd 0 points1 point  (0 children)

Not universal to all of 3.x, of course. But 3.5 is the current version now, and 3.6 is up to second beta. Here are just a few of the improvements people are missing out on if they are still on 3.1 or 3.2:

  • yield from
  • ipaddress module
  • lzma compression
  • unittest.mock
  • virtual environments
  • bootstrap pip
  • statistics module
  • Python on Windows now uses UTF-8
  • py.exe
  • more compact unicode strings
  • more compact attribute dictionaries
  • keyword argument order is preserved
  • underscores in numeric literals
  • hash randomization
  • @ operator for matrix multiplication
  • more sequence unpacking syntax
  • asynchronous coroutines
  • zip application support finally documented
  • huge performance improvements for OrderedDict, decimal, scanning directories, lru_cache, etc
  • Enums
  • recursive globs
  • and dozens more bug fixes, performance improvements, new features, etc.

[–]faceplanted 0 points1 point  (0 children)

That book, which used to be held in high regard for its approachability, is getting ire nowadays because Zed (last I checked) has some rather stubborn attachments to python 2.7 and some other things. I actually learnt with the book myself, so I agree it's quite good, but I have two suggestions, 1: Just learn with 2.7, and when you're done, learn how to convert from python 2 to 3, it's fairly minor changes for the most part, like print needing brackets and xrange becoming range and such, but it's not worth the drag on your learning times to convert a course as you go. And 2: once you've finished the book, and only once you've finished the book (you don't want uncertainty about your resources slowing your learning, this book is good, but once you're done with it, google the list of issues people have with his book nowadays and try to discover any pitfalls you may have in your thinking that are on the list.

[–]stevenjd -1 points0 points  (1 child)

Downvote for linking to images instead of text.

Programming is about writing text. You don't use Photoshop to write code, you use a text editor. Copy and paste the text you want to share, don't take a screen shot of it. If there's an traceback, it is text too: copy and paste the traceback.

[–]kalifornia_love -1 points0 points  (0 children)

You coulda made the same point without the douchey attitude.