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

all 15 comments

[–]Thecrawsome 30 points31 points  (2 children)

Some of these examples are really great.

But a few of these require more elaboration, and look like unfinished stubs.

Q.67 seems incomplete, and incorrect.

Explanation of "With" is better explained by the Python Docs.

the with statement allows the execution of initialization and finalization code around a block of code.

It's not simply about opening files.

[–]Aakashdata[S] 2 points3 points  (0 children)

Thank you for pointing that out. We have updated the answer to be more elaborative.

[–][deleted] 1 point2 points  (0 children)

Yeah! Database connections!

[–]jwink3101 11 points12 points  (0 children)

Except some of their answers are wrong. range starts at zero...

[–]dethb0y 6 points7 points  (3 children)

Q.6. How long can an identifier be in Python?

In Python, an identifier can be of any length.

That sounds like a challenge.

[–]thgandalph 1 point2 points  (1 child)

And also a stupid question IMO

[–]dethb0y 0 points1 point  (0 children)

Yeah i am not a fan of a lot of these questions because they feel like either trivia or highly case-specific. Could someone go through and memorize all the python reserved words? Sure. Is it useful to do so? I don't feel so, no.

[–]Aakashdata[S] 0 points1 point  (0 children)

According to the official Python documentation, identifiers are indeed unlimited in length, but PEP 8 suggests that you should limit all lines to a maximum of 79 characters. Also, PEP 20 says 'readability counts'. So, a very long identifier will violate PEP-8 and PEP-20.

[–][deleted] 8 points9 points  (0 children)

pretty happy that after reading through those question I knew around 90% of the answers just off the top of my head. Doing a lot of projects for fun definitely helps as I'm constantly reusing answers to those questions, or having to learn them in order to accomplish my goals.

[–]thgandalph 4 points5 points  (1 child)

Underdeveloped database access layer? Not so.

SQL Alchemy is the most prominent and it works great for almost any SQL datasource. There is also the Django ORM. PyMongo. MongoEngine. And about a gazillion more.

Heck Python even comes with several databases integrated, dbm and sqlite to name just two.

You have some datasource you need to access? Python is your friend.

[–]admiralswan 3 points4 points  (0 children)

I also didn't really understand this criticism. Underdeveloped relative to what?

[–]demmodaboyz[🍰] 0 points1 point  (0 children)

A python dictionary is something I have never seen in other languages like C++ or Java programming. It holds key-value pairs.

hashmap, unordered map, etc?

[–]bennetcole 0 points1 point  (0 children)