Search python

142840 results
2

votes
1

answer

Python Repl in Python

Am I right in assuming that the Python shell is coded in Python? If so, where, might one find the source code? If I wanted to write a shell program that did things differently, could I just copy the code to new_shell.py, make a few changes, and then set up a bash alias 'python'='python3 new_shell'...
skwarerüt
12

votes
6

answer

Python generating Python

I have a group of objects which I am creating a class for that I want to store each object as its own text file. I would really like to store it as a Python class definition which subclasses the main class I am creating. So, I did some poking around and found a Python Code Generator on effbot.org. I...
Jonathanb
1

votes
3

answer

Regex Python [python-2.7]

I'm working on a Python program that sifts through a .txt file to find the genus and species name. The lines are formatted like this (yes, the equals signs are consistently around the common name): 1. =Common Name= Genus Species some other words that I don't want. 2. =Common Name= Genus Species some...
Nick Vitha
3

votes
1

answer

Python path define / Python 2.7.3

I am trying to define a simple python path, but I always get an error. Can someone please tell me how to set the correct path. I am working on a Raspberry Pi. Here is the code that doesn't work: import re, os, rrdtool, time, sys # define pathes to 1-wire sensor data pathes = "/sys/bus/w1/devices/10-...
User01
13

votes
2

answer

python 2.7 vs python 3.1

Some python 3 features and modules having been backported to python 2.7 what are the notable differences between python 3.1 and python 2.7?
simha
3

votes
3

answer

Python path: Reusing Python module

I have written a small DB access module that is extensively reused in many programs. My code is stored in a single directory tree /projects for backup and versioning reasons, and so the module should be placed within this directory tree, say at /projects/my_py_lib/dbconn.py. I want to easily config...
Adam Matan
1

votes
3

answer

Checking Python Syntax, in Python

I would like to know if it's possible to check if a Python code has a correct syntax, without running it, and from a Python program. The source code could be in a file or better in a variable. The application is the following: I have a simple text editor, embedded in my application, used for editing...
Maxime Chéramy
1

votes
3

answer

Python Apps and Python Interpreter?

I'm wondering how many python interpreter would be executed for distinct python apps? Say I have 6 different python apps up and running, so does that mean there are 6 different python interpreters are running for each of them?
sepisoad
3

votes
2

answer

running python script inside python

I know this question have been asked multiple times, I read multiple questions trying to solve this issue. However, none of those actually worked. I have a python script I downloaded from: https://github.com/endrebak/kg I'm trying to run the following command from inside python. It works when I run...
ifreak
3

votes
1

answer

Running Python apps without python

Hi Are there any other ways to run python application without python installed exept installing py2exe. I se that the latest update was for Python 2.7, but I need something similiar for python 3.1/3.2
Andy.l
0

votes
0

answer

Specify python-mode.el's python executable

I recently installed anaconda, which installed its own python 2.7 into ~/anaconda2/bin/python. I wish for my IPy mode to point to the anaconda python so that I can use them together. However, IPy instead uses /usr/bin/python for its executable. This in spite of my using customize-variable to set py-...
fpt
3

votes
1

answer

Python 2 + Python 3 + library

I have both Python 2 and 3 in the same machine and installed a library (requests) through my package manager. I am only able to import it in Python 2, is it meant to be like that? If not how can I import it in Python 3?
xyz
1

votes
2

answer

Python syntax highlighter for Python

Is there a simple (possibly with no dependencies) syntax highlighter witch tokenizes Python source code? I need it to return the token type, the offset from the beginning of the code and token length. I wanted to use Python build-in tokenize but it does not return the offsets. I also looked to a few...
Ecir Hana
21

votes
5

answer

Efficient Python to Python IPC

What would be an inter-process communication (IPC) framework\technique with the following requirements: Transfer native Python objects between two Python processes Efficient in time and CPU (RAM efficiency irrelevant) Cross-platform Win\Linux Nice to have: works with PyPy UPDATE 1: the processes are...
Jonathan
2

votes
1

answer

Python duplicate a python-igraph

I have a python-igraph and need to make two copies of it and change each of the copies without changing the other one. Right now I am doing it like this: copy1 = fullGraph copy2 = fullGraph But it seems that this is not the correct way of doing it since whatever I change in copy1, the same thing hap...
ahajib
4

votes
2

answer

Python 2.6 -> Python 3 (ProxyHandler)

I wrote a script that works with a proxy (py2.6x): proxy_support = urllib2.ProxyHandler({'http' : 'http://127.0.0.1:80'}) But in py3.11x there is no urllib2 just a urllib... and that doesn't support the ProxyHandler How can I use a proxy with urllib? Isn't Python 3 newer then Python 2? Why did they...
blah
11

votes
5

answer

Python vs Iron Python [closed]

I have to make a GUI for some testing teams. I have been asked to do it in Python, but when I Google, all I see is about Iron Python. I also was asked not to use Visual Studio because it is too expensive for the company. So if you have any idea to avoid that I would be very happy. I am still new to...
Benjamin Karlog
1

votes
1

answer

Python install python-ntlm-1.0

I downloaded the python-ntlm-1.0.tar.gz and am trying to install. I extracted the .tar file to its own directory (C:\python-ntlm-1.0) and executed the following command in the command prompt from that directory: C:\python27\python.exe C:\Python27\Tools\Scripts\setup.py install I get the following o...
Drew
6

votes
7

answer

python 2.6 or python 3.1?

I am about to learn Python and was wondering what is recommended, learning python 2.6 or 3.1? (any tips on learning python is welcomed as well =) edit: Is the difference really big between the two? If I learn python 2 will i have trouble learning python 3?
user176121
1

votes
2

answer

Python pydoc for python packages

I'm trying to document a python package in init.py and it's unclear to me how pydoc parses a """triple bracketed""" comment to display to the user via: >>> help(package) or $ pydoc package How is the comment parsed to provide content in the NAME and DESCRIPTION sections of the pydoc output? Are...
sdruser
1

votes
1

answer

Python-pptx for Python 3.5.1

Is it possible to use the pptx (Python-pptx) module for Python 3.5.1? Like for example: from pptx import Presentation from pptx.util import Pt If not then what is the easyest way to replace this module? I think it shouldn't matter for the result but I am using PyCharm as IDE. I have tried to install...
Morganis
5

votes
2

answer

Python* to boost::python::object

I am trying to build a Python module in C++ that transforms a 2D vector into a Numpy 2D array. What is incorrect here - presumably there is some transformation needed to a boost python object from PyObject*? boost::python::object build_day(int year, int day) { PyObject* arr; const int HEIGHT = 5; co...
timbo
14

votes
4

answer

Python IDLE: Change Python Version

I have Python 2.x and 3.x on my machine (Mac OS X 10.6). For some things I want to use ver 2, but for others I want ver 3. I like the IDLE software for editing/running, but it always uses version 3. Is there any way to change the version of the interpreter that IDLE uses? Thanks!
Nathan
20

votes
3

answer

Can't find Python executable “python”

When i install iconv with npm got the following error: [email protected] install /root/Dropbox/nodeApps/nodeApp/node_modules/iconv node-gyp rebuild gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. gyp ERR! stack at failNoPython...
Maxim Yefremov
2

votes
1

answer

Run python script from python using different python

I have a software that has python 2.5.5. I want to send a command that would start a script in python 2.7.5 and then proceed with the script. I tried using #!python2.7.5 and http://redsymbol.net/articles/env-and-python-scripts-version/ But I cant get it to work... In my python 2.5.5 I can execute s...
Dariusz
2

votes
5

answer

“Python Implementation” vs. “Python distribution” vs. Python itself?

New to Python world. What is the difference between "Python Implementation" vs. "Python distribution" vs. Python itself? for example: I can download Python itself (Python 3.4.2) from python.org/downloads/release/python-342/ OR there is an "implementation" "nicknamed CPython" I can get from python....
Kardo Paska
75

votes
5

answer

Python extending with - using super() Python 3 vs Python 2

Originally I wanted to ask this question, but then I found it was already thought of before... Googling around I found this example of extending configparser. The following works with Python 3: $ python3 Python 3.2.3rc2 (default, Mar 21 2012, 06:59:51) [GCC 4.6.3] on linux2 >>> from configparser i...
Oz123
2

votes
2

answer

python - Change python to /usr/local/bin/python?

I'm trying to install opencv using python2.7. When I use brew install python. I got Warning: python-2.7.11 already installed, it's just not linked And then I run brew link python and brew install python again got 1 export PATH="/usr/local/mysql/bin:$PATH" Warning: python-2.7.11 already installed Bu...
Jinglei.Y
2

votes
1

answer

Python virtualenv -> New python executable in venv/bin/python

I'm currently trying to install Sevabot with this tutorial: https://sevabot-skype-bot.readthedocs.org/en/latest/ubuntu.html Everything is going fine until I need to install Sevabot. I can download the virtualenv.py file just fine but when I want to execute python virtualenv.py it returns a error. ~/...
xolympus
2

votes
1

answer

Setting up a python pipeline - python subprocess

What is the best way to accomplish the following pipeline in python using subprocess: run three script files python1_a.py, python1_b.py, python1_c.py in parallel If no errors have been raised, run python2.py If no errors have been raised, run python3.py Also I'd want to pass arguments through argpra...
marosh maroshka
3

votes
2

answer

Piping 2 python scripts using python

I have 3 python files : 1 for accepting string, one for reversing it and one for piping them . I new to this concept , so please help me on how to achieve this. 1.py def main(): print 'Input Your String : ' stri = raw_input() return stri main() 2.py import sys if __name__=='__main__': for line in s...
2

votes
2

answer

Accessing python objects within objects in Python

I have a Python object called "form" looking like this: > dir(form) ['Meta', 'SECRET_KEY', 'TIME_LIMIT', '__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__...
Rodolphe
1

votes
1

answer

Automatically Generate Python Egg from Python PasteScript

So I'm using PasteScript's paster, and I'm trying to automate egg creation. My first step is to get a template of a Python egg. I noticed that PasteScript's paster has one built in, so I've been creating my template from the command line: $paster create -t basic_package However, this asks me the que...
DrakeAnderson
15

votes
4

answer

Python & Windows: Where is the python launcher?

I'm trying to use different versions of python on win7, and I was told that I can use the python laucher. I find the docs for it: https://docs.python.org/3/using/windows.html#launcher But I don't know where is it. Someone say its called py.exe, but there is no file with this name on my computer. I...
cqcn1991
4

votes
1

answer

Bash alias --> Python 2.7 to Python 3.3

I am trying to make Python 3.4.2 the default in Linux (currently it is 2.7.6). I am not very knowledgeable on this stuff, but I have read in several places online that you can simply put an alias in the ~/.bashrc or ~/.bash_aliases file like this: alias python='python3' I don't have either the ~/.ba...
laurenll
2

votes
0

answer

homebrew python upgrade breaks installed python tools

I use Homebrew and pip to manage my Python installation. A recent brew upgrade seems to have broken the Python shell commands such as pip, ipython and jupyter. ! ~/ jupyter...
clstaudt
1

votes
2

answer

Python 2 dict_items.sort() in Python 3

I'm porting some code from Python 2 to 3. This is valid code in Python 2 syntax: def print_sorted_dictionary(dictionary): items=dictionary.items() items.sort() In Python 3, the dict_items have no method 'sort' - how can I make a workaround for this in Python 3?
DaveWeber
2

votes
1

answer

Python 3 pickle load from Python 2

I have a pickle file that was created (I don't know how exactly) in python 2. It is intended to be loaded by the following python 2 lines, which when used in python 3 (unsurprisingly) do not work: with open('filename','r') as f: foo, bar = pickle.load(f) Result: 'ascii' codec can't decode byte 0x...
Novak
26

votes
5

answer

python: run interactive python shell from program

I often have the case that I'll be writing a script, and I'm up to a part of the script where I want to play around with some of the variables interactively. Getting to that part requires running a large part of the script I've already written. In this case it isn't trivial to run this program from...
Claudiu
3

votes
4

answer

Python MD5 Hash comparison in Python 3.2

I am trying to validate two files downloaded from a server. The first contains data and the second file contains the MD5 hash checksum. I created a function that returns a hexdigest from the data file like so: def md5(fileName): """Compute md5 hash of the specified file""" try: fileHandle = open(f...
David