Re: import question

2021-11-19 Thread dn via Python-list
On 20/11/2021 03.38, lucas wrote: > ok. all good advice. thank you for that. and with all that I've decided > what to do. > > I'm going to close off any server-side python access so that I don't expose > my server or the file system to vulnerabilities and/or wonton attacks. I am > building

Re: import question

2021-11-19 Thread lucas
ok. all good advice. thank you for that. and with all that I've decided what to do. I'm going to close off any server-side python access so that I don't expose my server or the file system to vulnerabilities and/or wonton attacks. I am building a site for education and what I will configure

Re: import question

2021-11-19 Thread Mats Wichmann
On 11/18/21 21:00, Dan Stromberg wrote: On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: If you're trying to make a Python-in-Python sandbox, I recommend not. Instead, use

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 3:00 PM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: >> >> On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: >> > >> > >> > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: >> >> >> >> If you're trying to make a Python-in-Pyt

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: > On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg > wrote: > > > > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico > wrote: > >> > >> If you're trying to make a Python-in-Python sandbox, I recommend not. > >> Instead, use an OS-level sand

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: >> >> If you're trying to make a Python-in-Python sandbox, I recommend not. >> Instead, use an OS-level sandbox (a chroot, probably some sort of CPU >> usage limiting, etc), and use

Re: import question

2021-11-18 Thread Grant Edwards
On 2021-11-17, lucas wrote: > are there any other ways to import a module or package other then > the "import" or "from...import..." statements? i ask because i'm > allowing programming on my web2py website and i don't want any > accessing packages like os or sys. Safely allowing people to ente

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: > If you're trying to make a Python-in-Python sandbox, I recommend not. > Instead, use an OS-level sandbox (a chroot, probably some sort of CPU > usage limiting, etc), and use that to guard the entire Python process. > Python-in-Python will b

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 7:09 AM lucas wrote: > > hello one and all, > > are there any other ways to import a module or package other then the > "import" or "from...import..." statements? i ask because i'm allowing > programming on my web2py website and i don't want any accessing packages like

Re: Import module from a different subdirectory

2019-05-19 Thread Peter J. Holzer
On 2019-05-18 16:15:34 -0700, Rich Shepard wrote: > My apologies to all who patiently tried to get me to see what I kept > missing. I've certainly made similar mistakes in the past (and probably will in the future). And I didn't see it when I read your mail the first time. But then I read Piet's

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sun, 19 May 2019, Peter J. Holzer wrote: This won't help much if your directory named "business-tracker" (see above). Peter, et al.: Yep. User error. The directory is actually 'business_tracker' and I used the application name, 'bustrac', instead when I set PYTHONPATH. Discovered this a bi

Re: Import module from a different subdirectory

2019-05-18 Thread Peter J. Holzer
On 2019-05-18 09:43:34 -0700, Rich Shepard wrote: > The project layout, briefly, is: > > ~/development/business-tracker/ > classes/ > gui/ > > All subdirectories contain a __init__.py file to identify them as packages. > 'classes/' contains model.py; '

Re: Import module from a different subdirectory

2019-05-18 Thread Piet van Oostrum
Rich Shepard writes: > > $ python3 > Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. import sys sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sat, 18 May 2019, Peter J. Holzer wrote: "" is in sys.path, so "classes" and classes.model are found. Now lets go to a different subdirectory: This doesn't work, since there is no classes/model.py in "", only in "..". But if I add a PYTHONPATH, it works again: Peter, The project layout,

Re: Import module from a different subdirectory

2019-05-18 Thread Peter J. Holzer
On 2019-05-18 05:45:23 -0700, Rich Shepard wrote: > On Sat, 18 May 2019, dieter wrote: > > > > sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', > '/usr/lib/python3.7/site-packages'] > > All directories are pres

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sat, 18 May 2019, dieter wrote: Test this by looking at "sys.path" instead: import sys sys.path It is "sys.path" which actually controls the import machinery. Dieter, Thank you. I missed this when researching PYTHONPATH. Here's what I get: sys.path ['', '/home/rshepard/development/bus

Re: Import module from a different subdirectory

2019-05-17 Thread dieter
Rich Shepard writes: >> The project directory contains subdirectories, including gui/ (with the >> tkinter views) and classes/ with the SQLAlchemy model.py. > ... > Second, in ~/.bash_profile I added two lines, the first is the project's > root directory: > > PYTHONPATH=$HOME/development/bustrac >

Re: Import module from a different subdirectory

2019-05-17 Thread Rich Shepard
On Thu, 16 May 2019, Rich Shepard wrote: The project directory contains subdirectories, including gui/ (with the tkinter views) and classes/ with the SQLAlchemy model.py. Getting closer, but still missing a piece of the solution. First, I added __init__.py to each module subdirectory to speci

Re: Import module from a different subdirectory

2019-05-17 Thread Rich Shepard
On Fri, 17 May 2019, Inada Naoki wrote: This is slightly off topic (not relating to your problem), but please don't think "Python 3 doesn't require __init__.py for packages". It is common misunderstanding. Inada, Actually, your response is on topic and probably the reason I have the import pr

Re: Import module from a different subdirectory

2019-05-16 Thread Inada Naoki
2019年5月17日(金) 9:25 Rich Shepard : > > My understanding is that Python3 does not require subdirectories to have an > __init__.py file, only Python2 does. If that's not correct I'll add the > blank file. > This is slightly off topic (not relating to your problem), but please don't think "Python 3 do

Re: Import module from a different subdirectory

2019-05-16 Thread dieter
Rich Shepard writes: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within the gui/ directory as

Re: Import module from a different subdirectory

2019-05-16 Thread Rich Shepard
On Fri, 17 May 2019, duncan smith wrote: You could make the subdirectories Python packages. Google (or better DuckDuckGo) is your friend. Duncan, My understanding is that Python3 does not require subdirectories to have an __init__.py file, only Python2 does. If that's not correct I'll add the

Re: Import module from a different subdirectory

2019-05-16 Thread duncan smith
On 16/05/2019 22:50, Rich Shepard wrote: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within

Re: Import module from file path

2018-12-05 Thread Thomas Jollans
On 05/12/2018 02:30, Oscar Benjamin wrote: > Hi all, > > I'm looking to import a module given a string representing the path to > the .py file defining the module. For example given this setup > > mkdir -p a/b/c > touch a/__init__.py > touch a/b/__init__.py > touch a/b/c/__init__.py > touch a/b/c

Re: Import module from file path

2018-12-05 Thread Oscar Benjamin
On Wed, 5 Dec 2018 at 07:57, Peter Otten <[email protected]> wrote: > > Oscar Benjamin wrote: > > > > I'm looking to import a module given a string representing the path to > > the .py file defining the module. > > I am not aware of a clean way. I have used > > def guess_modulename(filename): >

Re: Import module from file path

2018-12-04 Thread Peter Otten
Oscar Benjamin wrote: > Hi all, > > I'm looking to import a module given a string representing the path to > the .py file defining the module. For example given this setup > > mkdir -p a/b/c > touch a/__init__.py > touch a/b/__init__.py > touch a/b/c/__init__.py > touch a/b/c/stuff.py > > I hav

Re: import inspect error

2018-09-17 Thread Gary Herron
You appear to have a local file named keyword.py which is hiding a python installation file of the same name. Gary Herron On 09/17/2018 01:06 AM, [email protected] wrote: I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. Python 2.7.15rc1 (default, A

Re: import inspect error

2018-09-17 Thread Chris Angelico
On Mon, Sep 17, 2018 at 6:06 PM, nobody wrote: > I have following errors running on Ubuntu 18, any insight how to fix it? > Thank you. > > Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) > [GCC 7.3.0] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import

Re: Import issue in python packages

2018-08-11 Thread Peter Otten
Venkatesh Adiga wrote: > Thanks Peter... What are the ways to update outside of the python program > without defining environment variable for source code path Otherwise > can I do it once in during initialization of sys.path update? I don't understand the question. Your options are - instal

Re: Import issue in python packages

2018-08-11 Thread Venkatesh Adiga
Thanks Peter... What are the ways to update outside of the python program without defining environment variable for source code path Otherwise can I do it once in during initialization of sys.path update? On Fri, 10 Aug 2018, 10:56 pm Peter Otten, <[email protected]> wrote: > Venkatesh Adiga

Re: Import issue in python packages

2018-08-10 Thread Peter Otten
Venkatesh Adiga wrote: > Hi All, > > I am facing issue with python package import. > In my project, I have many directories with different python classes > defined within them. I am trying to import those classes in another python > program, but not able to import them. > Here are my directories

Re: `import somemodule` does not check all paths in `sys.path`

2018-07-30 Thread stefand986
Note that in the `sys.path`variable the path is given as absolute path (I only wrote it relative to `~` in the in my post, but in the script the absolute path is used everywhere). See line 2: ``` ['/home/pyuser/.homeassistant', '/home/pyuser/.homeassistant/deps/lib/python3.7/site-packag

Re: `import somemodule` does not check all paths in `sys.path`

2018-07-29 Thread Chris Angelico
On Mon, Jul 30, 2018 at 3:15 PM, dieter wrote: > [email protected] writes: >> ... >> The "story" is: In homeassistant (short HA) some modules are installed at >> runtime during first start ("bootstrapping"), and for some reason loading >> the modules fails directly after installing the module

Re: `import somemodule` does not check all paths in `sys.path`

2018-07-29 Thread dieter
[email protected] writes: > ... > The "story" is: In homeassistant (short HA) some modules are installed at > runtime during first start ("bootstrapping"), and for some reason loading the > modules fails directly after installing the modules. Subsequent starts work > fine. > > The modules tha

Re: `import somemodule` does not check all paths in `sys.path`

2018-07-29 Thread stefand986
Am Sonntag, 29. Juli 2018 01:32:07 UTC+2 schrieb MRAB: That was also my first suspicion, but I checked that the path exists by printing the directory contents out, right before the ìmport ` statement. The "please check your config" message are a result of another package (aiohttp_cors) that is a

Re: `import somemodule` does not check all paths in `sys.path`

2018-07-28 Thread MRAB
On 2018-07-28 22:16, [email protected] wrote: Hi everyone, I am currently investigating an interesting bug in homeassistant which is a bit hard to reproduce. I already dug so deep that I ask here, because I think the root cause has to do with how Python locates and loads modules/packages. T

Re: import in code

2018-07-23 Thread Cameron Simpson
On 22Jul2018 15:38, Mark Lawrence wrote: On 22/07/18 05:45, Cameron Simpson wrote: Circular imports: 2 codependent modules. If you have:  module A:    import B  module B:    import B That won't work: the second import (whichever it turns out to be) will fail. One workaround is to make one of

Re: import in code

2018-07-22 Thread Mark Lawrence
On 22/07/18 05:45, Cameron Simpson wrote: On 22Jul2018 06:43, Abdur-Rahmaan Janhangeer wrote: i have found some reputable books that include import within code with ...    import x if ...    import y def ...     import z according to me they should be placed at the top. but an advantage of

Re: import in code

2018-07-21 Thread dieter
Abdur-Rahmaan Janhangeer writes: > i have found some reputable books that include import within code > > with ... > import x > > if ... > import y > > def ... > import z > > according to me they should be placed at the top. but an advantage of it is > optimisation where you only load

Re: import in code

2018-07-21 Thread Abdur-Rahmaan Janhangeer
> > > apart from circular imports? > sorry your last mail was sent to spam by gmail. now seeing it . thank you ! -- Abdur-Rahmaan Janhangeer https://github.com/abdur-rahmaanj Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: import in code

2018-07-21 Thread Abdur-Rahmaan Janhangeer
On Sun, Jul 22, 2018 at 8:49 AM Cameron Simpson wrote: > On 22Jul2018 14:45, Cameron Simpson wrote: > >Circular imports: 2 codependent modules. apart from circular imports? -- Abdur-Rahmaan Janhangeer https://github.com/abdur-rahmaanj Mauritius -- https://mail.python.org/mailman/listinfo/pyt

Re: import in code

2018-07-21 Thread Cameron Simpson
On 22Jul2018 14:45, Cameron Simpson wrote: Circular imports: 2 codependent modules. If you have: module A: import B module B: import B That won't work: the second import (whichever it turns out to be) will fail. One workaround is to make one of the modules put off the import. A better

Re: import in code

2018-07-21 Thread Cameron Simpson
On 22Jul2018 06:43, Abdur-Rahmaan Janhangeer wrote: i have found some reputable books that include import within code with ... import x if ... import y def ... import z according to me they should be placed at the top. but an advantage of it is optimisation where you only load modu

Re: Import statements and multiprocessing

2018-01-31 Thread Nicholas Cole
On Tue, Jan 30, 2018 at 7:26 PM, Terry Reedy wrote: > On 1/30/2018 10:54 AM, Nicholas Cole wrote: > >> I have a strange problem on python 3.6.1 > > [involving multiprocessing] Interestingly it seems to have been a very subtle circular import problem that was showing up only in multiprocessing, an

Re: Import statements and multiprocessing

2018-01-30 Thread Terry Reedy
On 1/30/2018 10:54 AM, Nicholas Cole wrote: I have a strange problem on python 3.6.1 [involving multiprocessing] I think the first thing you should do is upgrade to 3.6.4 to get all the bugfixes since 3.6.4. I am pretty sure there have been some for multiprocessing itself. *Then* see if you

Re: Import statements and multiprocessing

2018-01-30 Thread Nicholas Cole
On Tue, Jan 30, 2018 at 4:33 PM, Nicholas Cole wrote: > On Tue, Jan 30, 2018 at 4:23 PM, Steven D'Aprano > wrote: >> On Tue, 30 Jan 2018 15:54:30 +, Nicholas Cole wrote: > >> I would say you're probably misinterpreting the nature of the problem. >> Import * isn't a directive that can be ignor

Re: Import statements and multiprocessing

2018-01-30 Thread Nicholas Cole
On Tue, Jan 30, 2018 at 4:23 PM, Steven D'Aprano wrote: > On Tue, 30 Jan 2018 15:54:30 +, Nicholas Cole wrote: > I would say you're probably misinterpreting the nature of the problem. > Import * isn't a directive that can be ignored. > > Can you show us a *simplified* demonstration? A minimal

Re: Import statements and multiprocessing

2018-01-30 Thread Steven D'Aprano
On Tue, 30 Jan 2018 15:54:30 +, Nicholas Cole wrote: [...] > The function I am passing to map calls a function in another file within > the same model. And that file has a > > from .some_file_in_the_package import * > > line at the top. > > However, in each function called in that file, I

Re: import issues python3.4

2017-11-10 Thread Matt Wheeler
On Wed, 8 Nov 2017 at 15:58 Heli wrote: > Is there anyway I can run my external script without changing the absolute > path from (1) to (2) in my code. > I would recommend using tox [0] to run your test script, and setting up an entry point in your `setup.py` [1] so that your `main` command is "

Re: import issues python3.4

2017-11-09 Thread lingmaaki
Python Tutorial http://net-informations.com/python/default.htm -- https://mail.python.org/mailman/listinfo/python-list

Re: import queue in Python 2 and Python 3

2017-06-30 Thread Thomas Jollans
On 30/06/17 06:06, Benjamin Chaney wrote: > What is the best way to import the synchronized queue class that is > compatible with both Python2 and Python3. Right now I am using the > following: > >> if sys.version_info < (3, 0): >>import Queue as queue >> else: >>import queue > > This see

Re: import queue in Python 2 and Python 3

2017-06-29 Thread Chris Angelico
On Fri, Jun 30, 2017 at 2:06 PM, Benjamin Chaney wrote: > What is the best way to import the synchronized queue class that is > compatible with both Python2 and Python3. Right now I am using the > following: > >>if sys.version_info < (3, 0): >>import Queue as queue >>else: >>import queue >

Re: import docx error

2017-05-12 Thread johnshivjo
On Wednesday, May 10, 2017 at 12:48:36 PM UTC-4, RRS1 wrote: > Hi, > > > I am very new to Python, have only done simple things >>>print("hello > world") type things. I've really been looking forward to using Python. I > bought Two books, downloaded Python 3.6.1 (32 & 64) and each time I t

Re: import docx error

2017-05-11 Thread Pavol Lisy
On 5/11/17, Grant Edwards wrote: > On Wed, May 10, 2017 at 05:14:22PM -0700, somebody wrote: >> I have downloaded Anaconda to Cinnamon Mint 18.1 64 bit where Python >> 3.6 exists. >> >> It will not start up. > > The anaconda that I know about is the RedHat installer program (which > was original

Re: import docx error

2017-05-11 Thread Pavol Lisy
On 5/10/17, Grant Edwards wrote: > On 2017-05-10, RRS1 via Python-list wrote: > >> I am very new to Python, have only done simple things >>>print("hello >> world") type things. I've really been looking forward to using Python. I >> bought Two books, downloaded Python 3.6.1 (32 & 64) and eac

Re: import docx error

2017-05-11 Thread Grant Edwards
[Please keep this on the list so that others can benefit (and so that I can deal with it via my NNTP client). Further replies will only happen on-list.] On Wed, May 10, 2017 at 05:14:22PM -0700, somebody wrote: > I need to go back before John, I guess. Sorry, I have no idea what that means. >

Re: import docx error

2017-05-10 Thread Grant Edwards
On 2017-05-10, RRS1 via Python-list wrote: > I am very new to Python, have only done simple things >>>print("hello > world") type things. I've really been looking forward to using Python. I > bought Two books, downloaded Python 3.6.1 (32 & 64) and each time I try this: > > import doc

Re: Import name conflicts

2017-04-18 Thread Tim Johnson
* Steve D'Aprano [170418 16:08]: > On Wed, 19 Apr 2017 04:28 am, Tim Johnson wrote: > > > Using python 2.7~ > > > > For testing and edification purposes: > > > > I have a project which has a controllers package at the directory > > level just below the root. > > Do you mean the root of the fil

Re: Import name conflicts

2017-04-18 Thread Steve D'Aprano
On Wed, 19 Apr 2017 04:28 am, Tim Johnson wrote: > Using python 2.7~ > > For testing and edification purposes: > > I have a project which has a controllers package at the directory > level just below the root. Do you mean the root of the file system? >>From the top-level (root) of the project

Re: Import name conflicts

2017-04-18 Thread Tim Johnson
* Ben Finney [170418 14:58]: > Tim Johnson writes: > > > Using python 2.7~ > > In Python 2, you should turn on the “default import is absolute” by > issuing the statement:: > > from __future__ import absolute_import > > as one of the first statements in each module. > > When you migrate

Re: Import name conflicts

2017-04-18 Thread Ben Finney
Tim Johnson writes: > Using python 2.7~ In Python 2, you should turn on the “default import is absolute” by issuing the statement:: from __future__ import absolute_import as one of the first statements in each module. When you migrate your code to PYthon 3, that will be the default behavi

Re: import pybel in python error code

2016-09-09 Thread Peter Otten
[email protected] wrote: > ValueErrorTraceback (most recent call > last) in () > 1 from django.conf import settings > > 2 import pybel > 3 import random, os > > C:\Miniconda2\lib\site-packages\pybel.py in () > 67 _obconv = o

Re: Import graphics error

2016-04-05 Thread Steven D'Aprano
Since Dennis has X-No-Archive set on his posts, his very useful answer to Nicolae will be lost in a matter of days. So I'm going to repeat it. Nicolae, Dennis found the fix is to change the example code. Read the documentation here: http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf

Re: Import graphics error

2016-04-05 Thread Steven D'Aprano
On Wed, 6 Apr 2016 06:05 am, Thomas 'PointedEars' Lahn wrote: > | >>> from email import ID10T > | Traceback (most recent call last): > | File "", line 1, in > | ImportError: cannot import name 'ID10T' > > Why oh why can't somebody write "H

Re: Import graphics error

2016-04-05 Thread Ned Batchelder
On Tuesday, April 5, 2016 at 4:06:02 PM UTC-4, Thomas 'PointedEars' Lahn wrote: > | >>> from email import ID10T > | Traceback (most recent call last): > | File "", line 1, in > | ImportError: cannot import name 'ID10T' This is uncalled for. You don't have to participate in this thread if you d

Re: Import graphics error

2016-04-05 Thread Michael Selik
> On Apr 5, 2016, at 5:17 PM, Nicolae Morkov wrote: > > I copied the code from Python from everyone page 67. > Following the instructions The graphic modules by John Zelle I copied into > the python lacation ,to be easier to find the path . Please be more specific. What is the python

Re: Import graphics error

2016-04-05 Thread Thomas 'PointedEars' Lahn
Nicolae Morkov wrote: > […] > *Following the instructions I copied The graphic modules by John Zelle in > Python folder in Lib folder * > **And when I installed graphic library the error was :* * > > Traceback (most recent call last): > File > "C:/Users/Nicolae/AppData/Local/Programs/Python/Pytho

Re: Import graphics error

2016-04-05 Thread Nicolae Morkov
I copied the code from Python from everyone page 67. Following the instructions The graphic modules by John Zelle I copied into the python lacation ,to be easier to find the path . On Tue, Apr 5, 2016 at 11:19 AM, Nicolae Morkov wrote: > # This program creates a graphics window with a

Re: Import error

2016-04-05 Thread Tony van der Hoff
On 05/04/16 10:53, Nicolae Morkov wrote: What can I do I've tried everything Just hang your head and cry... -- Tony van der Hoff| mailto:[email protected] Buckinghamshire, England | -- https://mail.python.org/mailman/listinfo/python-list

Re: Import graphics error

2016-04-05 Thread Steven D'Aprano
On Tue, 5 Apr 2016 08:19 pm, Nicolae Morkov wrote: > # This program creates a graphics window with a rectangle. It provides the > 3 # template used with all of the graphical programs used in the book. What book? > *This is the error I get* > > Traceback (most recent call last): > File > "C

Re: Import error

2016-04-05 Thread Steven D'Aprano
On Tue, 5 Apr 2016 07:53 pm, Nicolae Morkov wrote: > What can I do I've tried everything You can start by telling us what you are trying to do, and what error you are getting. - What module are you trying to import? - Are you sure it is installed? How do you know? - What command do you g

Re: Import error

2016-04-05 Thread Tim Golden
On 05/04/2016 10:53, Nicolae Morkov wrote: > What can I do I've tried everything > You attached a screenshot, which won't make it through to this text-only mailing list. Can you copy the actual text of the error message from the IDLE session and paste it here, please? TJG -- https://mail.

Re: import cannot be used inside eval

2016-02-04 Thread Gary Herron
On 02/03/2016 09:03 PM, 阎兆珣 wrote: a = input("tell me which py to execute: ") print(a) print('import '+a) print(type('import'+a)) eval('print(a)') Eval is meant to evaluate Python expressions. The import is a statement, not an expression. Also, it's a bad idea to use e

Re: import cannot be used inside eval

2016-02-04 Thread Chris Angelico
On Thu, Feb 4, 2016 at 4:03 PM, 阎兆珣 wrote: >a = input("tell me which py to execute: ") > >print(a) > >print('import '+a) > >print(type('import'+a)) > >eval('print(a)') > >try: > >eval('import '+a) > >except Exception as e: > >print('Error: ', e) > >

Re: import locale and print range on same line

2016-01-24 Thread eryk sun
On Sat, Jan 23, 2016 at 8:45 PM, Terry Reedy wrote: > On 1/23/2016 8:58 AM, Chris Angelico wrote: >> On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano >> wrote: >>> [steve@ando ~]$ python -c "for i in range(5): print 'hello world' " >>> >>> hello world >>> hello world >>> hell

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 1:45 PM, Terry Reedy wrote: > C:\Users\Terry>python -c "for i in range(5):\n\tprint('hello world')" > File "", line 1 > for i in range(5):\n print('hello world') > ^ > SyntaxError: unexpected character after line continuat

Re: import locale and print range on same line

2016-01-23 Thread Terry Reedy
On 1/23/2016 8:58 AM, Chris Angelico wrote: On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano wrote: On Sun, 24 Jan 2016 12:19 am, Chris Angelico wrote: On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano wrote: On Sat, 23 Jan 2016 09:02 pm, [email protected] wrote: However I need to put the

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 1:03 AM, Ramo wrote: > The reason why I want to have it on onto one line has nothing to do with my > question, "why doesn't it work on one line" :) > > But if you want to know it, I use this python code in the commandline of a > texteditor :) Called it! :) It actually h

Re: import locale and print range on same line

2016-01-23 Thread Ramo
The reason why I want to have it on onto one line has nothing to do with my question, "why doesn't it work on one line" :) But if you want to know it, I use this python code in the commandline of a texteditor :) Btw.. thank you all for your help. Very happy with it :) -- https://mail.python.or

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano wrote: > On Sun, 24 Jan 2016 12:19 am, Chris Angelico wrote: > >> On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano >> wrote: >>> On Sat, 23 Jan 2016 09:02 pm, [email protected] wrote: >>> However I need to put the code on one single line. >>>

Re: import locale and print range on same line

2016-01-23 Thread Steven D'Aprano
On Sun, 24 Jan 2016 12:19 am, Chris Angelico wrote: > On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano > wrote: >> On Sat, 23 Jan 2016 09:02 pm, [email protected] wrote: >> >>> However I need to put the code on one single line. >> >> Why? Is the Enter key on your keyboard broken? > > Maybe it's

Re: import locale and print range on same line

2016-01-23 Thread Chris Angelico
On Sun, Jan 24, 2016 at 12:07 AM, Steven D'Aprano wrote: > On Sat, 23 Jan 2016 09:02 pm, [email protected] wrote: > >> However I need to put the code on one single line. > > Why? Is the Enter key on your keyboard broken? Maybe it's for a python -c invocation. ChrisA -- https://mail.python.org/ma

Re: import locale and print range on same line

2016-01-23 Thread Steven D'Aprano
On Sat, 23 Jan 2016 09:02 pm, [email protected] wrote: > However I need to put the code on one single line. Why? Is the Enter key on your keyboard broken? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: import locale and print range on same line

2016-01-23 Thread Ramo
This works also but I thought it was possible to do it easier: import locale; locale.setlocale(locale.LC_ALL, ""); print('\n'.join(locale.format("%2f", i, 1) for i in range(1,20,4))) -- https://mail.python.org/mailman/listinfo/python-list

Re: import locale and print range on same line

2016-01-23 Thread Vlastimil Brom
2016-01-23 11:36 GMT+01:00 Marko Rauhamaa : > [email protected]: > >> Can someone tell me why next code doesn't work? >> >> import locale; locale.setlocale(locale.LC_ALL, ""); for i in >> range(1,20,4): print(locale.format("%2f", i, 1)) >> >> It gives an error: SyntaxError: invalid syntax --> indica

Re: import locale and print range on same line

2016-01-23 Thread Marko Rauhamaa
[email protected]: > Can someone tell me why next code doesn't work? > > import locale; locale.setlocale(locale.LC_ALL, ""); for i in > range(1,20,4): print(locale.format("%2f", i, 1)) > > It gives an error: SyntaxError: invalid syntax --> indicating 'for' > > However I need to put the code on one

Re: import logging raise NotImplementedError

2015-11-25 Thread c.buhtz
On 2015-11-25 19:51 Chris Angelico wrote: > Ah! That would do it, yes. (Incidentally, 'pip install ebscopy' would > be how I'd do it.) Yes, I did first. But I had some problems with 'ebscopy' so I wanted to be sure to get the freshes version of it available. ;) -- GnuPGP-Key ID 0751A8EC -- http

Re: import logging raise NotImplementedError

2015-11-25 Thread Chris Angelico
On Wed, Nov 25, 2015 at 7:40 PM, wrote: > On 2015-11-25 09:00 Chris Angelico wrote: >> You appear to have installed it into your Python 3.4's package > > No really me. I found out who. > > I installed "ebscopy" from its GitHub repository with > "sudo pip3 ./setup.py install" > And this (tried to

Re: import logging raise NotImplementedError

2015-11-25 Thread c.buhtz
On 2015-11-25 09:00 Chris Angelico wrote: > You appear to have installed it into your Python 3.4's package No really me. I found out who. I installed "ebscopy" from its GitHub repository with "sudo pip3 ./setup.py install" And this (tried to) install(ed) "logging" from PyPi. Don't know why. I j

Re: import logging raise NotImplementedError

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 7:27 AM, wrote: > The problem happens with Python3 because "logging" is in the default > installation. In Python2 it is not installed. I installed it with >sudo python2 -m pip install logging -U > > This works without problems. Importing in Python2 works, too. You app

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
Now I get this error: Traceback (most recent call last): File "C:\raspberrypi\recipe-578839-1.py", line 1, in import pyttsx File "C:\Users\loek\AppData\Local\Programs\Python\Python35\lib\site-packages\pyttsx\__init__.py", line 18, in from engine import Engine ImportError: No module

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread Terry Reedy
On 11/16/2015 12:45 PM, input/[email protected] wrote: In reply to "MRAB" who wrote the following: Have you installed pyttsx? No, I did not. Where can I find pyttsx to install ? Let pip find it (its on pypi). On a command line, enter 'pip install pyttsx' -- Terry Jan Reedy -- https://mail

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread MRAB
On 2015-11-16 17:45, input/[email protected] wrote: In reply to "MRAB" who wrote the following: Have you installed pyttsx? No, I did not. Where can I find pyttsx to install ? The first place to look is PyPI. It's here: https://pypi.python.org/pypi/pyttsx You might want to look at the link

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
In reply to "MRAB" who wrote the following: Have you installed pyttsx? No, I did not. Where can I find pyttsx to install ? Thanks - > On 2015-11-16 17:12, input/[email protected] wrote: > > When I try to run this module in Win

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread MRAB
On 2015-11-16 17:12, input/[email protected] wrote: When I try to run this module in Windows IDLE I get this message: How can I solve this problem. Thanks Traceback (most recent call last): File "C:\raspberrypi\recipe-578839-1.py", line 1, in import pyttsx ImportError: No module nam

Re: Import a module from a specific file path

2014-11-21 Thread Ben Finney
Chris Angelico writes: > So can you simply: > > $ python -m foo.fooprog > > ? (or 'python3', either way) So, that's a pretty awful user interface. (The file is named ‘fooprog’ because it's an executable, intended to be run directly at the command line.) That solution would be rather inferior to

Re: Import a module from a specific file path

2014-11-21 Thread Marko Rauhamaa
Ben Finney : > Solutions usually seem to entail contortions of cluttering the import > block by discovering the current path, and fussing around with > ‘sys.path’, before finally doing the import:: > > #! /usr/bin/python3 > > import sys > import os.path > > program_dir = os.path.di

Re: Import a module from a specific file path (was: PyWart: "Python's import statement and the history of external dependencies")

2014-11-21 Thread Chris Angelico
On Sat, Nov 22, 2014 at 11:37 AM, Ben Finney wrote: > I don't think I'd ever want to specify an absolute file path for the > module. But it would make my Python life immeasurably better if I could > specify *relative* file paths for importing a module. > > Allowing relative paths makes this portab

Re: import graphics library; causes error

2014-11-17 Thread YBM
Le 17/11/2014 04:03, ryguy7272 a écrit : On Sunday, November 16, 2014 3:39:45 PM UTC-5, ryguy7272 wrote: These libraries drive me totally nuts. Sorry, just had to get it out there. Anyway, I open the cmd window, and typed this: 'easy_install python graphics'. So, it starts up and runs/downloa

Re: import graphics library; causes error

2014-11-17 Thread Mark Lawrence
On 17/11/2014 03:03, ryguy7272 wrote: On Sunday, November 16, 2014 3:39:45 PM UTC-5, ryguy7272 wrote: These libraries drive me totally nuts. Sorry, just had to get it out there. Anyway, I open the cmd window, and typed this: 'easy_install python graphics'. So, it starts up and runs/downloads

  1   2   3   4   5   6   7   8   9   >