Python is a dynamic, high-level language. Its design focuses on clear syntax, an intuitive approach to object-oriented programming, and making the right way to do things obvious. Python supports modules, exceptions, had an extensive standard module library. Python can also be embedded in other ...
0
votes
0answers
6 views
I am getting this : TypeError: can only concatenate tuple (not “int”) to tuple, even though it is an int [migrated]
num_1 = 3
num_2 = 5
num_3 = 15
div_1 = 1000/3
div_2 = 1000/5
div_3 = 1000/15
sum_1 = 0
sum_2 = 0
...
3
votes
2answers
116 views
Do I need to learn python first to understand the part 2 of the book Test Driven development?
It seems like Python is used as a coding language for part 2 of Kent Beck's book Test Driven Development. I have read the first part of that book and started appreciating the value of TDD . First part ...
-2
votes
1answer
36 views
Interesting Projects Involving Strings and WordLists for Python? [closed]
I'm currently trying to teach my friend a bit about Python. He likes iterating over wordLists and using various String methods in order to answer interesting questions like, "Which word has the most ...
-1
votes
0answers
11 views
Fastest way to search for keywords in a array in Python? [migrated]
In Python, I have read in a file and am searching through it for a set of words.
I have the below test code which shows the fastest (so far) is set.intersection().
The question is, Are there other ...
3
votes
5answers
150 views
python random with a skew
I am trying to create a very simple evolution algorithm for a creature simulator, what I would like to have is, both creatures have a trait and a dominance level, both noted by ints. their child's ...
-1
votes
0answers
13 views
Combine each element in a list of strings with another string [migrated]
my input is:
list1=['car','bike','mango']
and I want to append "JNU" to every item. Desired output:
list1=[('car', 'JNU'), ('bike', 'JNU'), ('mango', 'JNU')]
I'm unable to get that result.
0
votes
1answer
70 views
Developing for the RenRen social network [closed]
I have a Django-based API to interact with social networks, and I would like to integrate with RenRen.
My main problem is not a programming one, but how to create an application for RenRen. I try to ...
4
votes
2answers
145 views
Designing a function with many optional components
I'm trying to figure out a good practice for designing a function with (many) optional components.
For a specific example, say I am interested in designing a feature extractor function that takes as ...
4
votes
3answers
313 views
Space between negative sign and variable name
I tried doing a Google search, as well as searching this Stack Exchange site but could not find a question relating directly to this.
The PEP 8 -- Style Guide for Python Code has lots of good style ...
-3
votes
1answer
65 views
more concise than get then check then either return or progress further [closed]
I have a function that checks if user is allowed to post a comment of an image. With one database read, the code results in 1 of 3 outcomes:
Image exists and user has not commented on it before. ...
4
votes
2answers
226 views
What is the preferred way of communicating between applications on the same system?
I'm designing a system that is built on several small applications written in python, some of these will be services and others will be programs that only run during special situations. What I need to ...
1
vote
0answers
50 views
Would porting JPype to Python 3 be useful?
I have an open source project my company would like me to do with a small team, creating an adapter for the Oracle NoSQL database to be used in Python, but to do that we would need to be able to make ...
0
votes
1answer
107 views
Programming in a competitive environment as a motivator [closed]
I figured that a big motivator for me has always been competition. That's why I am looking for a platform where I can spend my free time coding on a project which will be compared with other projects ...
5
votes
2answers
126 views
How does a symbol table relate to a namespace?
The official tutorial uses the term symbol table in a few places where I would expect the term namespace.
1. Defining functions
The execution of a function introduces a new symbol table used for ...
-1
votes
1answer
115 views
How do I get an open source project off the ground? [closed]
I just finished laying down the groundwork for an opensource project that I hope to carry out, and then I realized I don't really have a way of reaching my intended audience (new Python programmers), ...
3
votes
4answers
342 views
Why isn't the ‘format’ method more widely used in Python?
I'm probably missing something here, after searching I couldn't find an answer.
I've explored quite a few Python projects and one thing I keep noticing is the fact that the majority of them continue ...
6
votes
4answers
327 views
'import module' vs. 'from module import function'
I have always been using this method:
from sys import argv
and use argv with just argv. But there is a convention of using this:
import sys
and using the argv by sys.argv
The second method ...
4
votes
0answers
205 views
How has having multiple implementations affected Python [closed]
Python has 5 implementations listed on their homepage:
Python / CPython
IronPython
PyPy
Jython
Stackless Python*
When considered against languages such as PHP or even Java that seems like a lot of ...
12
votes
3answers
801 views
Why Was Python Written with the GIL?
The global interpreter lock (GIL) seems to be often cited as a major reason why threading and the like is a touch tricky in Python - which raises the question "Why was that done in the first place?"
...
5
votes
1answer
301 views
Is using '{}' within format strings considered Pythonic?
I just learned you can write
'{}{}'.format(string_a, string_b)
instead of
'{0}{1}'.format(string_a, string_b)
in Python, i.e. you can omit the numerals for the string format parameters when you ...
0
votes
0answers
101 views
STAF/STAX and python alternative
We are looking into replacing some homegrown pieces and the candidates are:
STAF (http://staf.sourceforge.net/)
anything mature in python
My colleague Kevin has looked into STAF so I am ...
4
votes
4answers
200 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 ...
-1
votes
3answers
127 views
Brief python overview / introduction for programmers [closed]
I'm amazed that I can't find a brief and very concise python introduction, similar to the very excellent one for perl, in spite of hours of googling.
That is, something like this:
Single page (no ...
8
votes
4answers
291 views
Strategy for keeping up with (Python) language changes
Writing code that will still run years from now
Programming languages change.
Libraries change.
Some code from 5, 10, or even 20 years ago might still run and produce expected results, whereas some ...
0
votes
1answer
89 views
Why does flask use Jinja2 and not xpath?
I'm just starting out with python and since I'm coming from a PHP background (thus have to adjust my mind to wrap around new concepts) one major question still stands without answer - why does Flask ...
2
votes
1answer
95 views
Good serialization solution for communication between Python AND Haskell programs? [closed]
I found this:
http://msgpack.org/
But.. I've never used it, so I don't know what whether it is much good. Anybody has proposals?
Basic requirements:
serialize as many data structures used ...
0
votes
0answers
62 views
Portability: Python's C/C++ libraries/extensions vs JRuby's Java libraries
I've had some discussion with colleagues who chose to go with JRuby along the following line of argumentation:
JRuby can make use of anything that is available in Java, ergo such programs are more ...
0
votes
1answer
252 views
Is python lambda “really formal” λ-calculus or just share the name?
Now and then I use the Python lambda. Is it so formal that it is safe to say that you can do formal lambda calculus with it? I just used it but I didn't fully understand whether the python lambda and ...
0
votes
0answers
59 views
Resources for Python Developers [closed]
I'm developing an online course for beginning python programmers starting from basic syntax through object oriented design and GUI. I'd like to include some helpful community resources like Code ...
1
vote
1answer
132 views
Python for first programming / web development job [closed]
I've been teaching myself python and django for a couple of years, but I don't seem to find many entry-level python jobs in the UK. If I'm looking to begin a career in programmming / web development, ...
1
vote
2answers
160 views
What is the best way to plot 3D/2D plots with real time data? [closed]
First of all, I like to use Python, because it is easy to work with. I am not a programmer, so I prefer anything that is easy to use and understand. I understand that it might be faster to program 3D ...
2
votes
2answers
111 views
Changing __class__ in a factory?
I'm parsing a set of XML files of different kinds (these kinds are known in advance).
These are my requirements:
I want an object to represent each XML document (object-xml mapping)
I'd rather ...
2
votes
2answers
237 views
How to fix bad fundamentals? [closed]
I am a native PHP developer, and have been for about a year or so. I love PHP and it was very easy for me to learn, but I have developed some bad habits along the way due to never having a formal ...
1
vote
3answers
166 views
Hacking Python “Requests” library.. How to start as an intermediate pythonista?
My question is conceptual, yet extremely vital for me.
I'm an intermediate Python developer. I know fair enough about it, and actually use it on a daily basis. Now, I would like to transform my ...
8
votes
2answers
262 views
In python, is it considered better to define a module with functions or a module with a class that contains functions? [closed]
In my code either of the above two options would work equally well but I am interested in finding out the pros and cons of both approaches.
4
votes
2answers
163 views
Ensuring conceptual integrity in Python project with multiple programmers
One objection that I have often heard raised against Python that it is difficult to synchronize a team of many programmers on large Python project. Note: that synchronization is possible in such a ...
1
vote
1answer
71 views
Splitting documentation between docstrings and sphinx
I'm using a combination of docstrings and Sphinx to document my Python programs. With Sphinx's autodoc, I can write a lot of documentation into the source as docstrings. Is there any standard for ...
1
vote
4answers
384 views
NodeJS as an avenue towards learning JavaScript [closed]
I'm a backend programmer who works mainly in Python. I'll probably never want to be a full time front end developer, but with the goal of growing my skill set, I would like to become at least passably ...
-2
votes
1answer
141 views
Sending binary data from a computer to a server using HTTP or sockets [closed]
I am working on a script which can send data to a remote server computer and I am wondering which is better to achieve this functionality, the high level functionality provided by HTTP or just raw ...
2
votes
1answer
168 views
Loop Invariants in Python
I have a bit of experience with loop invariants but I'm not really clear on them. I'm trying to learn them through an example in Python. Can someone point one out or help me understand?
I've ...
3
votes
2answers
70 views
Machine Learning With Categorical and Continuous Data
This question could go here or on S.O. perhaps...
Suppose that your training dataset contains both categorical and continuous data such as this setup:
Animal, breed, sex, age, weight, ...
2
votes
1answer
116 views
call sub function based on variable value
I have a function containing other functions. These function are called based on value of variable action.
These sub functions are logically grouped - i.e., they all deal with file manipulation.
...
2
votes
1answer
98 views
How should I distinguish between built-in types in Python?
I have a function that accepts either a string or a dictionary as an argument. That is, it can be called as either:
lookup_person({name: "John Smith", age: 57})
or
lookup_person("John Smith")
My ...
1
vote
2answers
111 views
Simplest token-system for authenticating and authorizating
I want to make Python script that will accept input from Vim and send it to my web-site. So basically I want to make Vim my text-editor for blog articles.
Of course, I need to authenticate and ...
11
votes
4answers
417 views
Why store a function inside a python dictionary?
I'm a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me ...
3
votes
2answers
299 views
Is it possible to use python as a shell replacement?
Recently I was looking at python's shutil and subprocess etc... And I started wondering: wouldn't it be ok to use python instead of e.g. bash?
What am I missing?
5
votes
3answers
184 views
What are the challenges related to typing in writing a compiler for a dynamically typed language?
In this talk, Guido van Rossum is talking (27:30) about attempts to write a compiler for Python code, commenting on it saying:
turns out it's not so easy to write a compiler that maintains all the
...
2
votes
1answer
183 views
What are your techniques for storing numpy structures in django database fields and how do you serialize them for http?
I want to publish a small web project that is supposed to contain some of my research results to present it to the scientific community. All my analysis I ran so far have been written in python ...
4
votes
1answer
167 views
Behavior Driven Development and Unit Testing in Python
We might be interested in starting to incorporate a unit test suite to our project, which is coded in Python (and it uses Redis, PostgreSQL and some third-party libraries, if that bears into the ...
6
votes
3answers
408 views
Python in Big Data?
Can python be efficiently implemented in big data field? To be precise I am building an web app that analyses really big data in medical health care field consisting of medical history and huge ...