Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.

learn more… | top users | synonyms

-3
votes
0answers
38 views

Python: How to translate code from 1.5.2 [on hold]

So today I went to my local library because I decided to take my journey with python a step further. Naturally, I logged on to the library's intranet and searched for "Python programming language", ...
-2
votes
0answers
21 views

Rpy2 - install and configure it [closed]

I dowloaded the zip file rpy2. I'd like to use some function of R statistic in python. How can we install and configure it, in order to import it in a file or module of python please? Thank you for ...
0
votes
0answers
51 views

Can I listen on a port without interrupting traffic?

I have developed the bare bones on a socket server in Python. I'm trying to capture the HTTP packets going to a web server without blocking them. try: self.socket = ...
-2
votes
0answers
8 views

IPython notebook connection failed issue [migrated]

This is probably very simple; and I am embarrassed to ask; but I spent a long time trying to solve it already. I am trying to use an IPython notebook and on the click to get a Python 3 notebook, I ...
4
votes
2answers
937 views

Does this code follow duck typing?

The principle of duck typing says that you shouldn't care what type of object you have - just whether or not you can do the required action with your object. For this reason the isinstance keyword ...
0
votes
0answers
23 views

Ipython3 development cycle

I am new to python (python3) and am using Ipython3 while writing the code just in my preferred text editor. I am not yet sure what is a good development cycle as I keep getting problems with reloading ...
2
votes
1answer
35 views

log method calls per object

How to log method calls on a per object basis for a particular class? I.e. after instanciating a = myClass() I somehow want to keep a log for what methods have been called on a like a.reverse() ...
-1
votes
1answer
114 views

Dictionary representation of an object

As python memory model is dictionaries of dictionaries, looks like any object in JavaScript has similar representation. Below code, > foo = {} makes foo as an empty dictionary {}. fine. If ...
2
votes
1answer
86 views

Break big method into 2 methods, first containing a “for” loop and second a “break”

A method grew too big for its own good, and I need to break it up into two separate methods. def big_method(dct): # Initial code # ... for i in dct: # More code # ... ...
4
votes
3answers
101 views

Parent class using methods defined in child

I am working on a large program (more than 10k lines of code). Below is a (hopefully not over-simplified) example of a problem I sometimes face: class MyClass1(object): def func_1(self): ...
0
votes
0answers
121 views

“Python interpreter vs Javascript engine” memory model

I learnt that memory model of python interpreter is dictionaries of dictionaries, where each module is a dictionary. Let me elaborate more on this with an example, After i run >>> python ...
-1
votes
2answers
161 views

'Tuple' vs 'List' operations in python

Only two operations are allowed on tuple, as shown below. Operations like insert / delete at an index is not allowed. I learnt that tuple is an immutable data model. list allows insert and delete ...
1
vote
1answer
100 views

More efficient alternative that checks if a list can be made a palindrome

I asked this question on Stackoverflow, but they told me this is the best place to ask. For my algorithms and data structures class, I have to write an algorithm that is more efficient in the worst ...
3
votes
3answers
193 views

closure property of datatype “tuple” in python

From this link, below is the slide that I would like to understand: The Closure Property of Data Types A method for combining data values satisfies the closure property if: The result of ...
1
vote
1answer
245 views

Building Data abstraction for rational numbers using “objects”

I follow this definition of "object":An object is a value exporting a procedural interface to data or behavior. Objects use procedural abstraction for information hiding, not type abstraction. Object ...
-3
votes
1answer
205 views

Why every value is an object in python?

I know about writing programs (using C) that have: Data values, that are manipulated. For example: integer, float values etc.. functions (rules), by which data values are manipulated. object is a ...
-1
votes
1answer
91 views

Significance of '__name__ ' attribute in python

1) Below python code, >>> def f(): return creates a function type object which has __name__ attribute with value 'f' which looks fine. But, 2) Below line of code, >>> x = ...
-4
votes
4answers
140 views

Does this python program obey functional paradigm?

Below is the hailstone sequence program considering the rule of thumb in functional programming. The simple rule of thumb is: if you can replace any expression, sub-expression or subroutine call ...
1
vote
1answer
123 views

How do I enforce 'referential transparency' in this program?

Below is the python program written to follow the rule of thumb in functional programming. The simple rule of thumb is: if you can replace any expression, sub-expression or subroutine call with ...
1
vote
1answer
97 views

Persist data downloaded by Celery workers

I'm working in a tool that downloads tweets from Twitter to process them later. For this purpose I'm using Celery with RabbitMQ, sending task with the keywords that must be tracked by the workers. My ...
0
votes
1answer
60 views

how python updates references to variables

For this while loop below. It is clear how the v1,v2,v3 are updated to new data objects based on the equation. But I do not understand how u1,u2,u3 retains the original values of v1,v2,v3.Can someone ...
1
vote
1answer
62 views

Is this type of data insertion safe and can stop sql injection in Python?

I am learning Database connection from MySQL Connector/Python Developer Guide. This is the code I am using to insert data: conn = mysql.connector.connect(user="user", password="password", ...
40
votes
2answers
3k views

Why do some languages round to the nearest EVEN integer?

Programming languages like Scheme (R5RS) and Python (see this Question) round towards the nearest even integer when value is exactly between the surrounding integers. What is the reasoning behind ...
9
votes
2answers
6k views

Why doesn't Python have a “flatten” function for lists?

Erlang and Ruby both come with functions for flattening arrays. It seems like such a simple and useful tool to add to a language. One could do this: >>> mess = [[1, [2]], 3, [[[4, 5]], 6]] ...
2
votes
2answers
174 views

Is this looping solution possible with recursion?

Eventually, I would like to generalize this solutions to work with a Tuple of any length. I think recursion is required for that, but I haven't been able to do it. def combineRanges(maxValues) : ...
1
vote
1answer
149 views

Additional actions in setup.py for install

Background So, I'm developing a project, and I'm writing setup.py script for it, using distutils. I'm using CPython3.3. I use some libraries that have invalid distributions in PyPI, so they have to ...
1
vote
2answers
183 views

Is using os.environ to store the value of command line switches pythonic?

I write CLI-executable Python 3 scripts regularly to do data compilation and some maintenance tasks, and try to adhere to PEP 8 and the Google Python Style Guide when doing so. Google's guide says to ...
2
votes
2answers
422 views

What was the need of introducing Python 3 when we already had Python 2 [duplicate]

I am still learning python and I started with Python 3. This question not Python 2 vs 3 or difference between them like print() is a function and not language construct and 3/2 = 1.5 My question is ...
3
votes
1answer
219 views

What is the advantage of determining scopes statically and using them dynamically in case of Python?

Firstly let me clarify that I know C and am learning Python. So my OOPS is kind of bad. I was reading the official tutorial and found this Although scopes are determined statically, they are ...
0
votes
2answers
1k views

Why do people consider Python a weak language? [closed]

I've been using Python for a little while now and I am enjoying it, but a few of my friends are telling me to start using a language like C# or Java instead and give these reasons: Python is a ...
16
votes
1answer
620 views

What are the problems python 3 new features solve? [closed]

Python 3 new features say: we’re mostly fixing well-known annoyances and warts, and removing a lot of old cruft It mentions what is different (the fix) but not why (the problems). I have have ...
3
votes
1answer
1k views

understanding the encoding scheme in python 3

I got this error in my program which grab data from different website and write them to a file: 'charmap' codec can't encode characters in position 151618-151624: character maps to <undefined> ...
1
vote
1answer
302 views

What features are missing from Python IDE tools?

What are the most desired features currently lacking in any Python IDE tools? I'm also interested in what's missing in Komodo 6 but available in other tools (I currently use Komodo 6 for Python 3 ...