Skip to main content

All Questions

Filter by
Sorted by
Tagged with
3 votes
3 answers
16k views

Why don't empty iterables in python raise Exceptions when you try to iterate over them [duplicate]

I find this behaviour in Python quite peculiar and I believe it can lead to many bugs especially if you have a function/method that takes in a list and returns another list after carrying out some ...
danidee's user avatar
  • 149
21 votes
3 answers
24k views

Why do you need "self." in Python to refer to instance variables?

I have been programming into a number of languages like Java, Ruby, Haskell and Python. I have to switch between many languages per day due to different projects I work on. Now, the issue is I often ...
vivek's user avatar
  • 473
10 votes
5 answers
1k views

Are there technical limitations or language features that prevent my Python script from being as fast as an equivalent C++ program?

I'm a long-time Python user. A few years ago, I started learning C++ to see what it could offer in terms of speed. During this time, I would continue to use Python as a tool for prototyping. This, it ...
KidElephant's user avatar
8 votes
4 answers
4k views

When to import names into the global namespace? (using x::y, from x import y etc.)

I've been programming in various languages for about 10 years now. And I still haven't figured out when it is a good idea to import something into the global namespace (using x::y in C++, from x ...
futlib's user avatar
  • 2,205
2 votes
4 answers
2k views

Multiple attribution in Python, JS, ...?

I accidentally discovered this a=b=c=d=e=f=2 in python(2.7)(and JavaScript a few minutes later) interpreter . Is this a feature or just the way the interpreter works, if is a feature how it is ...
Eduard Florinescu's user avatar
5 votes
8 answers
1k views

Confusion regarding def function within Python

I've been learning Python for about 2 months now (Started with Learn Python The Hard Way, now reading Dive Into Python), and within both books, I still seem to be confused over this one bit of code. ...
Kevin's user avatar
  • 127
16 votes
11 answers
17k views

Why is Python recommended as an entry level programming language? [closed]

I've read here on P.SE more questions in which beginner programmers are advised to pick Python as their first programming language. Don't get me wrong, I like Python. I like it a lot! But its ...
JohnDoDo's user avatar
  • 2,319
38 votes
5 answers
5k views

Java dev learning Python: what concepts do I need to wrap my head around?

Background: I've run through a few tutorials and written some small projects. All is going well enough using Google and StackOverflow. Several times in the last few days I've found myself wondering "...
LRE's user avatar
  • 728