programming-languages

understanding the cyclic rotation codility challenge?

understanding the cyclic rotation codility challenge? Question: I want to start by saying thank you for the help first. I am tackling the cyclic rotation problem where you have to shift the contents of an list/array to the right and effectively wrapping the elements around so for example: For example, given A = [3, 8, …

Total answers: 6

Shorter alternative for 'lambda' keyword?

Shorter alternative for 'lambda' keyword? Question: Background: Python is about simplicity and readable code. It has gotten better over the versions and I am a huge fan! However, typing l a m b d a every time I have to define a lambda is not fun (you may disagree). The problem is, these 6 characters …

Total answers: 3

How Does Calling Work In Python?

How Does Calling Work In Python? Question: For a project I’m working on, I’m implementing a linked-list data-structure, which is based on the idea of a pair, which I define as: class Pair: def __init__(self, name, prefs, score): self.name = name self.score = score self.preferences = prefs self.next_pair = 0 self.prev_pair = 0 where self.next_pair …

Total answers: 4

What are Python namespaces all about

What are Python namespaces all about Question: I have just started learning Python & have come across “namespaces” concept in Python. While I got the jist of what it is, but am unable to appreciate the gravity of this concept. Some browsing on the net revealed that one of the reasons going against PHP is …

Total answers: 6

Compiled vs. Interpreted Languages

Compiled vs. Interpreted Languages Question: I’m trying to get a better understanding of the difference. I’ve found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are …

Total answers: 13

Why are Python Programs often slower than the Equivalent Program Written in C or C++?

Why are Python Programs often slower than the Equivalent Program Written in C or C++? Question: Why does Python seem slower, on average, than C/C++? I learned Python as my first programming language, but I’ve only just started with C and already I feel I can see a clear difference. Asked By: Riemannliness || Source …

Total answers: 11

Why are dates calculated from January 1st, 1970?

Why are dates calculated from January 1st, 1970? Question: Is there any reason behind using date(January 1st, 1970) as default standard for time manipulation? I have seen this standard in Java as well as in Python. These two languages I am aware of. Are there other popular languages which follows the same standard? Please describe. …

Total answers: 7

What statically typed languages are similar to Python?

What statically typed languages are similar to Python? Question: Python is the nicest language I currently know of, but static typing is a big advantage due to auto-completion (although there is limited support for dynamic languages, it is nothing compared to that supported in static). I’m curious if there are any languages which try to …

Total answers: 12

Can you monkey patch methods on core types in Python?

Can you monkey patch methods on core types in Python? Question: Ruby can add methods to the Number class and other core types to get effects like this: 1.should_equal(1) But it seems like Python cannot do this. Is this true? And if so, why? Does it have something to do with the fact that type …

Total answers: 15