Search python

197506 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
1

votes
0

answer

Python CoreProperties python-docx

I need to know the core properties of a docx as author, language, created (date), identifier, last_printed, modified (date), version, title, subject. I wrote this code: import docx import os os.chdir('C:\\abc\\Documents') doc = docx.Document('ATD.docx') docx.opc.coreprops.CoreProperties.author(doc)...
anitasp
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
1

votes
2

answer

Python - Include another Python script

I have a question. When you are programming in PHP you can use this to include external php script to current script. include('test_page.php'); So you don't have to repeat a code in every script. Is there a way in Python to include another Python script, just like the php page?
Vreesie
1

votes
2

answer

Python and MySQL-Connector-Python

note I am using the following version of Python on a Windows OS: (venv) C:\>python Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type 'help', 'copyright', 'credits' or 'license' for more information. *The following Python script below is run and the out...
Nate Benton
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
1

votes
1

answer

Python repl in python application

Hello i am learning python(so i can use qt with python not only c++) and i'm curios if it would be possible to embed a python interpreter in my application as a repl. I would like to give users to possibility to script the app using python either loading a file (and that file to act as a plugin for...
Olorin
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
1

votes
2

answer

system python versus user python

I've installed Python 2.7 using macports and because of my $PATH variable, that's the one I get when I type $ python. However, virtualenv defaults to using Python 2.6 unless I remember to force it to do otherwise with the -p flag. On a related note, globally running yolk -l shows the following: Pyt...
wmfox3
1

votes
1

answer

Mockito-python with python 2.7

I wanted to use mockito with python version 2.6 & 2.7. I have downloaded the latest version of mockito package and tried to use it. But I am unable to use it. The package is imported successfully but when I am using any function it is failing. Do you have any idea about the compatibility of mockito...
Bhupesh Pant
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
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
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
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: calling another python script

Is it possible to call another python script to access just the definitions inside the script and nothing else? In the script I want to import, there are plots that I want to suppress since there an not needed for this other program. That is, I only want to access the definitions of the Stumpff fun...
dustin
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
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
1

votes
1

answer

Python: disabling $HOME/.python-eggs?

Is there an easy way to disable Python egg caching? We have the situation where a system account needs to run a python program which imports a module. Since this is a non-login robot account, it does not have a home directory, and dies trying to create the directory /.python-eggs. What's the best w...
Mark Harrison
1

votes
1

answer

Installed Python to portable python

I have installed python from .msi installer in windows and installed a lot of other modules. i would like to have all these available on a portable thumbdrive, but i don't want to redownload all the extramodules. Is there a way i can convert my C:\python26* to a portable python installation?
Tutul
1

votes
1

answer

Tick Python instances from Python

I am interrested in doing a programming game using python, and I would like to do it in the style of GunTactyx (http://apocalyx.sourceforge.net/guntactyx/index.php). Only much simpler, as I am primarily interrested in the parallel execution of python scripts from python. Gun Tactyx challenges the pl...
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

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
1

votes
3

answer

Python: is a Python function equivalent to a Python object?

I was experimenting with Python, and tried out an example and it worked. def foo(): print 'hello world' foo.a = True So it looks to me foo is an object though it looks like a function. What is the technical term for it, and what are the use-cases of it?
nik_kgp
1

votes
1

answer

Python C-API equivalent of “python -m module_name” (python 2.7)

Having looked the Python C-API documentation, I cannot figure out a way to execute a python script given just the name of the module (from c or c++ code). Is there an equivalent C-API function for python -m module_name? I am using Python 2.7 embedded in a C++ executable.
Eddy