Re: How to Add ANSI Color to User Response

2024-04-12 Thread Gisle Vanem via Python-list

Pierre Fortin wrote:


Over the years, I've tried different mechanisms for applying colors until
I got my hands on f-stings; then I created a tiny module with all the
colors (cR, cG, etc) which made my life so much simpler (attached).


Attachments are stripped off in this list.
It would be nice to see this tiny module of yours.
An URL or attach as inline text please.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation

2023-06-09 Thread Gisle Vanem via Python-list

Dennis Lee Bieber wrote:


Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Owner> Get-ChildItem -Path C:\Python310\ -Recurse -Name -Filter
"pip.*"


Tried it. Oh man what a slow process:
  sync & timer &
  pwsh -Command Get-ChildItem -Path F:\gv\Python310\ -Recurse -Name -Filter "pip.*" 
&
  timer

  (15 results stripped). Completed in 12.44 sec!

As opposed to my own Envtool:
  sync & timer &
  envtool.exe --evry pip.* | grep "Python310" &
  timer

  (15 results stripped) Completed in 0.57 sec!

But I have 5 GByte of stuff under 'f:\gv\Python310\'

Envtool is at https://github.com/gvanem/Envtool
Works best together with the amazing EveryThing search engine
by David Carpenter at https://www.voidtools.com

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list

Thomas Passin wrote:

So please, try to think out how your questions will seem to the reader, and be clear about what you are asking.  You may 
not know the terminology that some other people use, but don't let that stop you from being clear about what you really 
need to find out.  Including more context is likely to be helpful, too.  Don't leave it to the readers to infer what you 
were thinking of.


I'll do that. My post was written in a bit of a hurry
and frustration after struggling with my 'typo' for
30 minutes.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list

Thomas Passin wrote:

Are you trying to troll here?  


You just showed how you got an error with this construction, so why are you 
asking how to

get an error with this construction?


I meant (obviously), another error-message besides:
  error: unrecognized arguments: -cn

Perhaps from 'parser.add_argument ("-c, --clean", dest="clean", 
action="store_true")'
  error: "-c, --clean", 2 options are unsupported.

BTW, accusing someone of 'trolling' is rather rude IMHO.
And thanks to ChrisA for a nice and normal answer.

--
--gv

--
https://mail.python.org/mailman/listinfo/python-list


Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list

I accidentally used 'argparse' like this in my Python 3.9 program:
  parser.add_argument ("-c, --clean",  dest="clean", action="store_true")
  parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")

instead of:
  parser.add_argument ("-c", "--clean",  dest="clean", action="store_true")
  parser.add_argument ("-n", "--dryrun", dest="dryrun", action="store_true")

So any use of 'my-prog.py -cn' threw an error:
  error: unrecognized arguments: -cn

So is there something that throws an error on this wrong use of
"-c, --clean" instead? Could be useful. Or is "-c, --clean" legit somehow?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: pip issue

2022-11-30 Thread Gisle Vanem via Python-list

Dieter Maurer wrote:


Otherwise no issues. But where is this text "-arkupsafe" stored
and how to get rid it it? I've searched through all of my .pth
files and found no such string.


Have you looked at the content of the folder mentioned
in the warnings (e.g. `...\site-packages`).


I had 2 folders named:
  site-packages\~arkupsafe\
  site-packages\~arkupsafe-2.1.1.dist-info\

Removing those, the problem was gone.

So perhaps this tilde '~' means something special
for pip?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


pip issue

2022-11-30 Thread Gisle Vanem via Python-list

Hello list.

I have an issue with 'pip v. 22.3.1'. On any
'pip install' command I get warning like this:
  c:\> pip3 install asciinema
  WARNING: Ignoring invalid distribution -arkupsafe 
(f:\gv\python310\lib\site-packages)
  WARNING: Ignoring invalid distribution -arkupsafe 
(f:\gv\python310\lib\site-packages)
  Collecting asciinema
Downloading asciinema-2.2.0-py3-none-any.whl (92 kB)
  ...

Otherwise no issues. But where is this text "-arkupsafe" stored
and how to get rid it it? I've searched through all of my .pth
files and found no such string.

I assume this is an entry for an orphaned package "MarkupSafe"
since a 'pip list | grep markup' will list 'MarkupSafe 2.1.1'.


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Changing 'Scripts/*.exe'

2022-10-03 Thread Gisle Vanem via Python-list

dn wrote:


E.g. 'Scripts/pip2.exe' has the path
"f:\programfiler\python27\python.exe" hard-coded
inside it.

Is there a easy way to fix this w/o re-installing this
old Python?


Yes, by putting a symbolic-link at the old 'programfiler' location which
points to the new 'gv' installation.


I'm suspicious about sym-links.

Instead for 'pip' I just did a 'py -2 get-ip.py' which seems
to have fixed it. The newly generated 'f:\gv\Python27\Scripts\pip2.exe'
seems to work fine; the list from 'pip2.7.exe list' is correct.

--
--gv

--
https://mail.python.org/mailman/listinfo/python-list


Changing 'Scripts/*.exe'

2022-10-01 Thread Gisle Vanem via Python-list

Hello list.

I'm moved my old Python27 installation from
  f:\ProgramFiler\Python27  ( == 'ProgramFiles')
to
  f:\gv\Python27

and now many 'scripts/*.exe' program fails
to start since the old path to 'Python.exe'
is wrong.

E.g. 'Scripts/pip2.exe' has the path
"f:\programfiler\python27\python.exe" hard-coded
inside it.

Is there a easy way to fix this w/o re-installing this
old Python?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Persistent Error: Python was not found

2022-08-15 Thread Gisle Vanem via Python-list

Eryk Sun wrote:


If the redirector app
is run without arguments, it will open the Microsoft Store to install
the latest version of the Python store app distribution. Currently
that means Python 3.10.


That is true with cmd. But with a shell like 4NT, I get:
  c:\> "%LocalAppData%\Microsoft\WindowsApps\python.exe"
  4NT: (Sys) No access to the file.
   "C:\Users\gvane\AppData\Local\Microsoft\WindowsApps\python.exe"

No matter what I do with this "App Alias" setting.
What a broken and confusing design this AppX design is.


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to have python 2 and 3 both on windows?

2022-04-22 Thread Gisle Vanem

Barry wrote:


Tip “py.exe -0” will list the state of installed pythons.

Not here; 'py.exe -0' gives:
  Requested Python version (0) not installed

Which PyInstaller version support this '-0' option?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: URLError:

2022-02-12 Thread Gisle Vanem

Shaozhong SHI wrote:


The following is used in a loop to get response code for each url.

print (urllib.request.urlopen(url).getcode())

However, error message says: URLError: 

11001 == WSAHOST_NOT_FOUND.

Look in any 'winsock.h' header:
  #define WSAHOST_NOT_FOUND (WSABASEERR+1001)

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Best way to check if there is internet?

2022-02-09 Thread Gisle Vanem

Abdur-Rahmaan Janhangeer wrote:


It's a demo to get the idea behind, uses requests and the rich library.


I'd never heard of 'Rich'. But d/l it and playing
with it, I came up with this version with fat green
spinner-bar:

import requests
from rich.console import Console

def ensure_internet():
console = Console()
domains = [ "https://google.com";,
"https://yahoo.com";,
"https://bing.com";,
"https://www.ecosia.org";,
"https://www.wikipedia.org"; ]
results = []
with console.status ("Checking internet ...", spinner="material") as c:
for domain in domains:
c._spinner.text = "Checking %-40s" % domain
try:
requests.get(domain)
results.append(1)
except Exception as e:
results.append(0)

if not any(results):
   print("No internet connection")

ensure_internet()

---

Rich' is IMO a pretty amazing package.

--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Best way to check if there is internet?

2022-02-09 Thread Gisle Vanem

Abdur-Rahmaan Janhangeer wrote:


Thanks everybody for the answers. It was very enlightening. Here's my
solution:

# using rich console
def ensure_internet():
console = Console()
domains = [
'https://google.com',
'https://yahoo.com',
'https://bing.com',
'https://www.ecosia.org',
'https://www.wikipedia.org'
]
results = []
with console.status("Checking internet ...", spinner="dots"):
for domain in domains:
try:
requests.get(domain)
results.append(1)
except Exception as e:
results.append(0)
if not any(results):
print('No internet connection')
sys.exit()


Was this supposed to be a self-contained working
program? It doesn't work here.

Were/what is 'Console()' for example?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to compile my C Extension on Windows: unresolved external link errors

2021-11-12 Thread Gisle Vanem

Marco Sulla wrote:


Error LNK2001: unresolved external symbol PyErr_SetObject

and so on.

I post the part of my setup.py about the C Extension:

extra_compile_args = ["-DPY_SSIZE_T_CLEAN", "-DPy_BUILD_CORE"]


Shouldn't this be "-DPy_BUILD_CORE_MODULE"?


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Create a real-time interactive TUI using Python.

2021-09-01 Thread Gisle Vanem

hongy...@gmail.com wrote:


The following are some python TUI framework libraries/projects I have 
discovered so far:

https://github.com/pfalcon/picotui
https://github.com/peterbrittain/asciimatics
https://github.com/bczsalba/pytermgui
https://github.com/GeorgeFilipkin/pulsemixer
https://github.com/jwlodek/py_cui
https://github.com/saulpw/visidata
https://github.com/willmcgugan/textual
https://github.com/urwid/urwid


Tried some of these. But only Asciimatics and
Py_CUI works on Windows.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: "py.ini" question

2021-04-26 Thread Gisle Vanem

Ralf M. wrote:


I think the problem / misunderstanding is that Gisle put in py.ini only
  [defaults]
  python=3.6

and expected this to make py -3 start 3.6. However py -3 looks for a key named 'python3' and, not finding it, uses 
default behaviour (ignoring the 'python' key), i.e. starts the most modern stable 3.x.


The py.ini documentation is a bit hard to find in the help file and hard to understand 


I totally agree with that.


I tried the (rather insane) py.ini
  [defaults]
  python=3.7
  python2=3.8
  python4=2.7
and it works as documented (py -3 shows default behaviour as there is no 
'python3' in py.ini):

C:\>py
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 
bit(AMD64)] on win32
C:\>py -2
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit 
(AMD64)] on win32
C:\>py -3
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit 
(AMD64)] on win32
C:\>py -4
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:19:08) [MSC v.1500 32 bit 
(Intel)] on win32


Thank for confirming what I suspected. And as I wrote earlier:
  Since I'm on a 64-bit Python, a 'py -3' totally seems to ignore
  'py.ini', unless it says:
[defaults]
python3=3.6
python3=3.6-32
---

Except, I meant "Since I'm on a 64-bit Windows" and
 not "Since I'm on a 64-bit Python".
--
https://mail.python.org/mailman/listinfo/python-list


Re: "py.ini" question

2021-04-24 Thread Gisle Vanem

Barry Scott wrote:


A copy of this is also in 'c:\Windows\py.ini'.
So when I do a:
  py -3 -c "import sys; print(sys.version)"

I would assume a "3.6..." would be printed.
But no, py.exe chooses to run my newest Python 3.8:
  3.8.9 (default, Apr 13 2021, 15:54:59)  [GCC 10.2.0 64 bit (AMD64)]

Only when I do 'py -3.6 -c ...', I get what I'd expect.

So is a 'py.ini' and the '[defaults]' simply ignored
or is my syntax wrong?



On windows 10 your personal py.ini is in %localappdata%\py.ini
do you have one?


Yes, that's my 'c:\Users\Gisle\AppData\Local\py.ini'
in my case.


C:\Users\barry>py -0
Installed Pythons found by py Launcher for Windows
  -3.10-64
  -3.10-32
  -3.9-64 *
  -3.9-32
  -3.8-64
  -3.8-32
  -3.7-64
  -3.7-32
  -3.6-64
  -3.6-32
  -3.5-64
  -3.5-32
  -3.4-64
  -3.4-32
  -2.7-64
  -2.7-32


On that, I'm getting:
  Requested Python version (0) not installed

Is that '-0' some 3.9+ feature?


C:\Users\barry>py
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr  6 2021, 13:40:21) [MSC v.1928 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

With a 'py', I get:
  Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit 
(Intel)] on win32

With 'py -3.6' or 'py 3.8' I get the expected.
But with 'py -3':
  Python 3.8.9 (default, Apr 13 2021, 15:54:59)  [GCC 10.2.0 64 bit (AMD64)] on 
win32

Since I'm on a 64-bit Python, a 'py -3' totally seems to ignore
'py.ini', unless it says:
  [defaults]
  python3=3.6
  python3=3.6-32

Strange as always.

And yes, Mats Wichmann, I've tried a 'set PYLAUNCH_DEBUG=1'.
No help.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


"py.ini" question

2021-04-24 Thread Gisle Vanem

I have a question about the Python launcher;
  c:\Windows\py.exe and the py.ini file.

I have both Python 3.6 (32-bit) and Python 3.8 (64-bit)
installed. And I have a 'c:\Users\Gisle\AppData\Local\py.ini'
with this only:
  [defaults]
  python=3.6

A copy of this is also in 'c:\Windows\py.ini'.
So when I do a:
  py -3 -c "import sys; print(sys.version)"

I would assume a "3.6..." would be printed.
But no, py.exe chooses to run my newest Python 3.8:
  3.8.9 (default, Apr 13 2021, 15:54:59)  [GCC 10.2.0 64 bit (AMD64)]

Only when I do 'py -3.6 -c ...', I get what I'd expect.

So is a 'py.ini' and the '[defaults]' simply ignored
or is my syntax wrong?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Current thinking on required options

2021-04-19 Thread Gisle Vanem

Loris Bennett wrote:


   usage: grocli [-h] [-o {check,add,delete}] [-u USERS [USERS ...]] [-g GROUP]

   Command line grouper tool

   optional arguments:
 -h, --helpshow this help message and exit
 -o {check,add,delete}, --operation {check,add,delete}
   operation to apply
 -u USERS [USERS ...], --users USERS [USERS ...]
   users to apply operation to
 -g GROUP, --group GROUP
   group to apply operation to

However, the options -o, -u, and -g are required, not optional.


Just a nitpick.

To quote from https://en.wikipedia.org/wiki/Usage_message
"To indicate required arguments, Angled brackets are
  commonly used, ..."

So then it should better be written as:
  grocli [-h] <-o {check,add,delete}> <-u USERS [USERS ...]> <-g GROUP>

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: port to PDOS (especially mainframe)

2021-03-23 Thread Gisle Vanem

Edwards wrote:


I don't wish to run configure, I want to hand-construct
the makefile. PDOS is a very simple system, so I only
want to produce a single executable, no DLLs etc. I
don't need extensions to work or anything, all I need
to be able to do is run asma.


Why not try to port MicroPython instead? Much lighter.
I've ported it to MSDOS/djgpp with some success.


However I'm currently stuck on this unresolved
external:

python.a(abstract.o)(.text+0x668c):abstract.c: undefined reference to 
`PyExc_StopIteration'


It's in 'Objects/exceptions.c'. When in doubt, look at the
'python*.map' files. I assume you have managed to build
Python 3 on Windows (?).

And BTW, it's also forwarded from 'python3.dll' via some
hacks in 'python3dll.c' to the real Python in 'Python310.dll'
(in my case):
  pedump python3.dll | grep PyExc_StopIteration
853A   227  PyExc_StopIteration (forwarder -> 
python310.dll.PyExc_StopIteration)

  plus a lot more; it's quite ugly.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error

2020-11-23 Thread Gisle Vanem

Barry Scott wrote:


If you have python from python.org installed you should be able to list all the 
version you have installed
with the command:

   py -0

When was that '-0' feature added?
I have Python 3.6 from Python.org and here a
'py.exe -0' gives:
  Requested Python version (0) not installed

But using 'py.exe -0' from Python 3.9 correctly
gives:
  -3.6-32 *
  -2.7-32

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: The speed of glob()

2020-07-29 Thread Gisle Vanem

Chris Angelico wrote:


BTW, I just noticed something. The path you're using for testing
purposes is "e:/net". Is that network-attached or local? If it's a
remote mount of some sort, then that will make a HUGE difference


No. Did the word 'net' make you think that :-) It's a local
FAT32 partition where I keep old 'net' related projects.
Whether it's NTFS or FAT32 should hopefully not matter for
relative speed-compares.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: The speed of glob()

2020-07-29 Thread Gisle Vanem

Chris Angelico wrote:


Has anybody noticed the speed of 'glob()' has
decreased somewhere between v3.6 and v3.10.

I got these results:
Python 3.6.5:
  1st run: 0.14694
  2nd run: 0.09506   <- *always* the fastest
Python 3.7.7:<- from Nuget
  1st run: 0.12440
  2nd run: 0.09602
Python 3.10.0:   <- from Git repo
  1st run: 0.15922
  2nd run: 0.12424

'glob()' in Python 3.6.5 is consistently 30% faster on
the 2nd run compared to 3.10.0.



Unfortunately that's very hard to compare. If you're building Python
from source, the parameters may be VERY different from a prepackaged
binary.


I guess so w/o knowing why. I just tried this from MS' AppStore:
Python 3.8.5:
  1st run: 0.12121
  2nd run: 0.07674

Fastest I've tried so far.


Are you able to redo this test with more consistent Python builds? For
instance, you can go as far as 3.8 using python.org binaries, or
alternatively, build all your tests from git (by checking out
different branches).


I do not want to put to much stress on this. Maybe I'm just 'ass-u-me'ing
too much?

The important thing is that any Python3.x is much faster on both
the 1st and 2nd run compared to my Python 2.7.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


The speed of glob()

2020-07-29 Thread Gisle Vanem

Has anybody noticed the speed of 'glob()' has
decreased somewhere between v3.6 and v3.10.
With this little test:


import os, sys, timeit, glob

# change to suite
globPath = u'e:/net/*/*/*/*'

def _glob():
  glob.glob (globPath)

# I used this 'https://docs.microsoft.com/en-gb/sysinternals/downloads/sync'
def flush_disks():
  sync = r"f:\ProgramFiler\Sysinternals\sync.exe -nobanner"
  print ("Exec sync: %s" % sync)
  os.system (sync)

flush_disks()
print ("Python %d.%d.%d:" % sys.version_info[:3])
print ("  1st run: %.5f" % timeit.timeit (_glob, number=1))
print ("  2nd run: %.5f" % timeit.timeit (_glob, number=1))



I got these results:
  Python 3.6.5:
1st run: 0.14694
2nd run: 0.09506   <- *always* the fastest
  Python 3.7.7:<- from Nuget
1st run: 0.12440
2nd run: 0.09602
  Python 3.10.0:   <- from Git repo
1st run: 0.15922
2nd run: 0.12424

'glob()' in Python 3.6.5 is consistently 30% faster on
the 2nd run compared to 3.10.0.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to create an Excel app that runs Python?

2020-03-25 Thread Gisle Vanem

Grant Edwards wrote:


On 2020-03-24, oliver  wrote:


Use the win32com library to interact with Excel via COM.


Huh?  I thought that the users have no way of running a local Python
app.


Maybe creating a self-contained .exe using PyInstaller?
For me, this:
  pyinstaller.exe --noconfirm --console --onefile file.py

creates a 'dist/file.exe' that depend on nothing but
system libraries. But it's 5 MByte though.


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.6 on Windows - does a python3 alias get created by installation?

2019-10-11 Thread Gisle Vanem

Eryk Sun wrote:


The simplest way to create a shell link is via the Windows GUI shell,
Explorer. To inherit the working directory of the parent process,
leave the link's "start in" field empty. Also, add ".LNK" to the
system PATHEXT environment variable to allow finding link files
without having to include the ".lnk" file extension, i.e. to be able
to run "python3.lnk <...>" as just "python3 <...>".


An "alias" could also simply be created using:
  doskey python3=f:\ProgramFiles\Python36\python.exe

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Announcing colour-text and colour-print

2019-10-01 Thread Gisle Vanem

Barry Scott wrote:


Here is an example:

from colour_text import ColourText
ct = ColourText()
ct.initTerminal()

print( ct( "The next section is in green: <>green example<>." ) )


Looking at the sources, it seems 'win32' should be
supported. But no; with the above example:
  c:\>py -3 example.py
  The next section is in green: ←[32mexample←[m.

No colours, just the pesky SGI-codes.

BTW. it fails completely in Python 2.7.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: PIP question

2019-09-27 Thread Gisle Vanem

dieter wrote:


directory with some possible leftovers. It there a connection
between this mysterious '-ip' package and this directory?


This is possible. A so called "distribution" can install
packages of a different name (for example, the distribution "Zope"
installs (among others) a package "ZPublisher"). In addition, the
actual installation typically has lost metadata information (e.g.
the version number). Therefore, "pip" may use "*.dist-info" or
"*.egg-info" directories to provide this metadata. Look into those
directories to find out which packages are installed for the
corresponding distribution. You can then check whether those packages
are truely available (and if not delete the *-info* directory).


Thanks for this info.

After deleting the
 f:\programfiler\python36\lib\site-packages\~ip-19.1.1.dist-info
directory and running my script again, the "-ip" is gone.

All this *.dist-info stuff is alien stuff to me, but I guess
'pip install --upgrade' uses these?

BTW, there is no command 'pip uninstall --orphans'. Any
other tool that does the same?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


PIP question

2019-09-26 Thread Gisle Vanem

Hello list.

This little program should print the location of all
my installed Python packages:

-- 8< -- 8< ---
import pip

try:
  packages = pip.get_installed_distributions (local_only=False, skip=())
except AttributeError:
  import pkg_resources   # Python3
  packages = pkg_resources.working_set

package_list = []
for p in sorted (packages):
  print ("%-20s -> %s" % (p.key, p.location))

-- 8< -- 8< ---

But for my Python 3.6 installation, it claims I have
an '-ip' package:
-ip-> f:\programfiler\python36\lib\site-packages

I fail to find one, but I do have a:
  f:\programfiler\python36\lib\site-packages\~ip-19.1.1.dist-info

directory with some possible leftovers. It there a connection
between this mysterious '-ip' package and this directory?


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Passing back the ERRORLEVEL

2018-12-28 Thread Gisle Vanem

I have trouble understanding why a 'sys.exit(2)' is
*not* passed back to the CMD shell in this little example:

- c:\py_cmd_test.cmd --
@%WinDir%\py.exe -2 -x %~dp0py_cmd_test.cmd & exit /b %ERRORLEVEL%

# The '-x' is for Python to skip the 1st line of this file.
import sys
print ("Hello, I am %s; %s" % (sys.argv[0], sys.version_info))
sys.exit (2)



Executing this in a 4NT shell (from JPsoft), correctly reports:
c:\> py_cmd_test.cmd & echo %errorlevel
Hello, I am C:\py_cmd_test.cmd; sys.version_info(major=2, minor=7, micro=15, 
releaselevel='final', serial=0)
2

But the junk-ware cmd.exe does not:
C:\>py_cmd_test.cmd & echo %ERRORLEVEL%
Hello, I am C:\py_cmd_test.cmd; sys.version_info(major=2, minor=7, micro=15, 
releaselevel='final', serial=0)
0

Anybody here who can spot the problem?

Same issue with 'py -3'. I'm on Windows-10.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread nospam . nospam . Gisle Vanem
Greg Tibbet wrote:

> ellipse() uses the method  self.draw.draw_ellipse()   Okay, fine...
> but WHERE is draw_ellipse defined??  What magic is happening there?
> I've searched the entire PIL directory tree, and the ONLY two places
> draw_ellipse is mentioned are right there in the ellipse() function...
> WHAT am I missing??

The C sources. Not all of PIL is ritten in Python.

draw_ellipse() is a thin wrapper for ImagingDrawEllips(). See PIL/_imaging.c:
   https://github.com/python-pillow/Pillow/_imaging.c

Which again is in libimage/Draw.c:
   https://github.com/python-pillow/Pillow/blob/13d84993717cffd64a2e1d7e3e6edb1
85973d559/libImaging/Draw.c

calling ellipse().

--
--gv

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread nospam . Gisle Vanem
Greg Tibbet wrote:

> ellipse() uses the method  self.draw.draw_ellipse()   Okay, fine...
> but WHERE is draw_ellipse defined??  What magic is happening there?
> I've searched the entire PIL directory tree, and the ONLY two places
> draw_ellipse is mentioned are right there in the ellipse() function...
> WHAT am I missing??

The C sources. Not all of PIL is ritten in Python.

draw_ellipse() is a thin wrapper for ImagingDrawEllips(). See PIL/_imaging.c:
   https://github.com/python-pillow/Pillow/_imaging.c

Which again is in libimage/Draw.c:
   https://github.com/python-pillow/Pillow/blob/13d84993717cffd64a2e1d7e3e6edb1
85973d559/libImaging/Draw.c

calling ellipse().

--
--gv

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread Gisle Vanem

Greg Tibbet wrote:


ellipse() uses the method  self.draw.draw_ellipse()   Okay, fine...
but WHERE is draw_ellipse defined??  What magic is happening there?
I've searched the entire PIL directory tree, and the ONLY two places
draw_ellipse is mentioned are right there in the ellipse() function...
WHAT am I missing??


The C sources. Not all of PIL is ritten in Python.

draw_ellipse() is a thin wrapper for ImagingDrawEllips().
See PIL/_imaging.c:
  https://github.com/python-pillow/Pillow/_imaging.c

Which again is in libimage/Draw.c:
  
https://github.com/python-pillow/Pillow/blob/13d84993717cffd64a2e1d7e3e6edb185973d559/libImaging/Draw.c

calling ellipse().

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Easiest way to access C module in Python

2017-11-07 Thread Gisle Vanem

bartc wrote:


 From inside python 2.7:
   Python 2.7.13rc1 (v2.7.13rc1:4d6fd49eeb14, Dec  3 2016, 21:49:42) [MSC 
v.1500 32 bit (Intel)] on win32
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import life
   >>> dir(life)
   ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 
'__test__']
   >>>

works fine.


Not really, as it's missing the attribute 'life' which is needed for the second 
part of 'life.life':


Not sure what happend there. All is working now. But as
you stated, Cython is truly a "beast".

But as I wrote to Lele privately, the main reason for the failure,
was Cygwin's Python2.7 messing up. I invoked the build from a GNU-Makefile.
Thus Cygwin's Python was picked up from /bin/bash instead of my regular
Python on PATH. A real PITA.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Easiest way to access C module in Python

2017-11-07 Thread Gisle Vanem

Lele Gaifax wrote:


On my PC, I get the following, using the "-v" option to verbosely see the
imported modules:

$ $ python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
...

import life

dlopen("./life.so", 2);
import life # dynamically loaded from life.so

dir(life)

['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__test__', 
'life']

Can you try to import the "life" module and print its "dir()" to see the
symbols it exposes?


From inside python 2.7:
  Python 2.7.13rc1 (v2.7.13rc1:4d6fd49eeb14, Dec  3 2016, 21:49:42) [MSC v.1500 
32 bit (Intel)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import life
  >>> dir(life)
  ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__test__']
  >>>

works fine. But as I wrote, doing a:
  python -vc "import life; print(life.life())"

from the cmd-line doesn't work:
  ...
  import life # dynamically loaded from life.pyd
  Traceback (most recent call last):
File "", line 1, in 
  AttributeError: 'module' object has no attribute 'life'
  ...

Inspection life.pyd shows no problems. It do export a "initlife"
function.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Easiest way to access C module in Python

2017-11-07 Thread Gisle Vanem

Lele Gaifax wrote:


$ python setup.py build_ext --inplace
Compiling life.pyx because it changed.
[1/1] Cythonizing life.pyx
running build_ext
building 'life' extension
creating build
creating build/temp.linux-x86_64-3.6
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fdebug-prefix-map=/build/python3.6-5reRaQ/python3.6-3.6.3=. 
-specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat 
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/tmp/ct/include 
-I/usr/include/python3.6m -c life.c -o build/temp.linux-x86_64-3.6/life.o
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes 
-g -fdebug-prefix-map=/build/python3.6-5reRaQ/python3.6-3.6.3=. 
-specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat 
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/tmp/ct/include 
-I/usr/include/python3.6m -c fred.c -o build/temp.linux-x86_64-3.6/fred.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions 
-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro 
-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -g 
-fdebug-prefix-map=/build/python3.6-5reRaQ/python3.6-3.6.3=. 
-specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat 
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 
build/temp.linux-x86_64-3.6/life.o build/temp.linux-x86_64-3.6/fred.o -o 
/tmp/ct/life.cpython-36m-x86_64-linux-gnu.so
$ python -c "import life; print(life.life())"
42


I tried your example on Python 2.7 (Win-10 / MSVC), but failed:

python.exe setup.py build_ext --inplace
running build_ext
building 'life' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
f:\gv\VC_2017\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\cl.exe /c /nologo /Ox 
/MD /W3 /GS- /DNDEBUG
-If:\ProgramFiler\Python27\include -If:\ProgramFiler\Python27\PC /Tclife.c 
/Fobuild\temp.win32-2.7\Release\life.obj
life.c
f:\gv\VC_2017\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\cl.exe /c /nologo /Ox 
/MD /W3 /GS- /DNDEBUG
-If:\ProgramFiler\Python27\include -If:\ProgramFiler\Python27\PC /Tcfred.c 
/Fobuild\temp.win32-2.7\Release\fred.obj
fred.c
f:\gv\VC_2017\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\link.exe /DLL /nologo 
/INCREMENTAL:NO
/LIBPATH:f:\ProgramFiler\Python27\libs /LIBPATH:f:\ProgramFiler\Python27\PCbuild
/EXPORT:initlife build\temp.win32-2.7\Release\life.obj 
build\temp.win32-2.7\Release\fred.obj
/OUT:F:\ProgramFiler\Python27\test\Cython-test2\life.pyd 
/IMPLIB:build\temp.win32-2.7\Release\life.lib
/MANIFESTFILE:build\temp.win32-2.7\Release\life.pyd.manifest
   Creating library build\temp.win32-2.7\Release\life.lib and object 
build\temp.win32-2.7\Release\life.exp

python.exe -c "import life; print(life.life())"
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'life'


Can you give a hint?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Windows: subprocess won't run different Python interpreter

2016-11-11 Thread Gisle Vanem via Python-list
Thorsten Kampe wrote:

> My goal is to verify that other shells/interpreters on Windows work 
> the same way as Python when running an application or creating a sub-
> process. Cmd does not. What's else there? I have Bash here but that's 
> a Cygwin executable. And Cygwin Python does not work like Windows 
> Python.
> 
> Any ideas?

Is there a Python.exe in the Registry "App Paths". Either of these:
 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
or
 HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

-- 
--gv
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The next major Python version will be Python 8

2016-04-01 Thread Gisle Vanem via Python-list
Michael Selik wrote:

> It suddenly occurred to me that if Microsoft announced it's
> Ubuntu-in-Windows feature today, no one would believe it.

My feeling too, but this was announced 30 March.
In the video in this link:
  
http://www.cnx-software.com/2016/03/31/microsoft-brings-bash-on-ubuntu-on-windows-10/

they say Python inside Ubuntu-in-Windows works! Ref. time 03:03.

-- 
--gv
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Testing whether the VPN is running?

2016-02-23 Thread Gisle Vanem
Cameron Simpson:

> You might also want to check that the interface is up.
> 
> My personal hack (not for a VPN, but for "being online", which turns my ssh 
> tunnels on and off) is to look in the output
> of "netstat -rn" for a default route. This may imply that an alternative test 
> for you is to test for a route to your
> VPN's address range?  Just an idea.

And for VPN in Windows *and* using WinPcap, one can check if this device
exist:
  \Device\NPF_GenericDialupAdapter

(controllable using 'sq query rasdial'). This works if you use
PPTP or L2TP but not OpenVPN.

BTW, a VPN on Windows doesn't come back up automatically after
a sleep/hibernation. The WOSB tool at http://www.dennisbabkin.com/wosb/
could be handy. What happens with your VPN on Linux (?) after coming
back from sleep/hibernation? Automatic or you need to script that too?

-- 
--gv
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: extending PATH on Windows?

2016-02-19 Thread Gisle Vanem
Dennis Lee Bieber wrote:

>>> How can one search for files with DOS?
>>
>> dir /s /b \*add2path.*
>>
>> ChrisA
>
>   Or move to PowerShell...
>
> Windows PowerShell
> Copyright (C) 2009 Microsoft Corporation. All rights reserved.
>
> PS C:\Users\Wulfraed\Documents> Get-ChildItem -Path c:\ -Filter *add2path*
> -Name -Recurse

Clumsy IMHO. Try:
c:\> envtool --path *ipython*

Matches in %PATH:
  12 Feb 2015 - 17:16:12: f:\ProgramFiler\Python27\Scripts\ipython-script.py
  12 Feb 2015 - 17:16:12: f:\ProgramFiler\Python27\Scripts\ipython.exe
  12 Feb 2015 - 17:16:12: 
f:\ProgramFiler\Python27\Scripts\ipython.exe.manifest
  12 Feb 2015 - 17:16:12: 
f:\ProgramFiler\Python27\Scripts\ipython2-script.py
  12 Feb 2015 - 17:16:12: f:\ProgramFiler\Python27\Scripts\ipython2.exe
  12 Feb 2015 - 17:16:12: 
f:\ProgramFiler\Python27\Scripts\ipython2.exe.manifest
  08 Feb 2015 - 12:48:56: 
f:\ProgramFiler\Python27\Scripts\ipython_win_post_install.py
7 matches found for "*ipython*".

---

Or find a spec on *all partitions* using Everything Search engine:
c:\> envtool --evry *ipython*
Matches from EveryThing:
...
133 matches found for "*ipython*".

---

Or for Python-path searches:
c:\> envtool --python *ipython*
Matches in "f:\ProgramFiler\Python27\python.exe" sys.path[]:
  23 Jan 2016 - 13:50:30: 
f:\ProgramFiler\Python27\lib\site-packages\ipython-2.1.0-py2.7.egg\IPython\
  23 Jan 2016 - 13:50:26: 
f:\ProgramFiler\Python27\lib\site-packages\IPython\
  23 Jan 2016 - 13:50:30: 
f:\ProgramFiler\Python27\lib\site-packages\ipython-2.1.0-py2.7.egg\
3 matches found for "*ipython*".

-

My envtool is at https://github.com/gvanem/EnvTool
EveryThing is at http://voidtools.com/

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python.exe is not a valid win32 executable

2015-10-29 Thread Gisle Vanem

Mark Lawrence wrote:


CPython's Windows support now follows this lifecycle. A new feature
release X.Y.0 will support all Windows releases whose extended support
phase is not yet expired. Subsequent bug fix releases will support the
same Windows releases as the original feature release (even if the
extended support phase has ended).


The reason for error message the OP reported is what
the MSVC 2015 (?) linker puts in the PE optional header.
From 'pedump python3.exe':

Optional Header
  Magic 010B
  linker version14.00
  ...
  file align200
  required OS version   6.00   << !!

Hence the error on Win-XP (i.e. 5.x).

Wouldn't it be more elegant of Python (and it's installer)
to put a '-subsystem:console,5.02' in the link flags?
And then detect Win-XP later on and refuse a further install?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: A high-level cross-platform API for terminal/console access

2015-10-22 Thread Gisle Vanem

"Chris Angelico"  wrote:


Ah, that might well be it. Does it work if you run:

python -S -m pip install --upgrade win32api


Hm. 
 c:\>python2 -S -m pip install --upgrade win32api

 Collecting win32api
   Could not find any downloads that satisfy the requirement win32api
   No distributions at all found for win32api

I think you mean 'pypiwin32'. Since:
 c:\>python2 -S -m pip install --upgrade pypiwin32
 Requirement already up-to-date: pypiwin32 in 
g:\programfiler\python27\lib\site-packages

So now, running 'setup.py install' in AsciiMatics' directory, all seems 
to install okay. 


But the samples have problems if launched from the sample directory!
It seems to be related to my Windows associations for .png files; 
'python2 win_demo.py' launches this:
 g:\util\Graphics\IrfanView\i_view32.exe 
 G:\Programfiler\Python27\Lib\site-packages\AsciiMatics\samples\python.png 
 G:\Programfiler\Python27\Lib\site-packages\AsciiMatics\samples\win_demo.py


Yes, all on 1 line. Notice the 'win_demo.py' is last!!?? But 
'python2 samples\win_demo.py' works fine (see attached screen-shot).

Allthough it messes up the screen's scrollback buffer. Similar to how
most PDcurses do on Windows :-(


--gv-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A high-level cross-platform API for terminal/console access

2015-10-22 Thread Gisle Vanem

"Chris Angelico"  wrote:


On Thu, Oct 22, 2015 at 10:22 PM, Gisle Vanem  wrote:

 IOError: [Errno 13] Permission denied:
'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd'

-

BTW, this is on Python 2.7.9 on Win-XP SP3.


Does that file exist? A .pyd file is a DLL, so if it already exists
and is in use, it's entirely possible it can't be overwritten (eg to
upgrade it).


It exists all right and I do have full access to that folder.

I think the Errno 13 (=EACCESS) is due to another module (WConio.pyd) 
that seems gets loaded via my site-customize.py is using this
win32api.pyd. Hence it's is in use and shutil fails in updating it. 


--gv

--
https://mail.python.org/mailman/listinfo/python-list


Re: A high-level cross-platform API for terminal/console access

2015-10-22 Thread Gisle Vanem

"Peter Brittain"  wrote:


I have recently been working on a terminal/console animation package
(https://github.com/peterbrittain/asciimatics). 


I tried installing your package with "pip.exe -v install asciimatics".
Some problem with pypiwin32 it seems:

Installing collected packages: pypiwin32, future, Pillow, pyfiglet, asciimatics

 Cleaning up...
 Exception:
 Traceback (most recent call last):
   File 
"g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\basecommand.py",
 line 232, in main
 status = self.run(options, args)
   File 
"g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\commands\install.py",
 line 347, in run
 root=options.root_path,
   File 
"g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_set.py",
 line 549, in install
 **kwargs
   File 
"g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_install.py",
 line 751, in install
 self.move_wheel_files(self.source_dir, root=root)
   File 
"g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_install.py",
 line 960, in move_wheel_files
 isolated=self.isolated,
   File 
"g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\wheel.py", 
line 234, in move_wheel_files
 clobber(source, lib_dir, True)
   File 
"g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\wheel.py", 
line 212, in clobber
 shutil.copyfile(srcfile, destfile)
   File "g:\Programfiler\Python27\lib\shutil.py", line 83, in copyfile
 with open(dst, 'wb') as fdst:
 IOError: [Errno 13] Permission denied: 
'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd'

-

BTW, this is on Python 2.7.9 on Win-XP SP3.

--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc?

2015-10-15 Thread Gisle Vanem

eryksun wrote:


The version of py.exe distributed with Python 3 is a 32-bit
application, so when the debug output says it's looking in the
"native" registry, it's referring to the WOW64 redirected registry
path, i.e. "HKLM\Software\Wow6432Node\Python". If py.exe can't find
your installation of Python 3 in the registry, then the installation
is broken or non-standard. Try to repair or reinstall.


Thanks for the detailed info. I fixed some paths under:
  HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.5-32

Now my Python3.5 almost works. But something is wrong with the
Python3 sys.prefix:
  c:> py -2 -c "import os, sys; print(sys.prefix)"
  F:\ProgramFiler\Python27

  c:> py -3 -c "import os, sys; print(sys.prefix)"
  F:\ProgramFiler

Where should I look for the reason for this?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc?

2015-10-15 Thread Gisle Vanem

eryksun wrote:


Here's a slightly simpler way to open the folder:

 py -3.5 -c "import os, sys; os.startfile(sys.prefix)"


And what to do if the Pylauncher itself seems confused or the
Registry settings for PythonCore is messed up? The WOW64 mess
MS has have seems to have caused some problems here. With:
 c:\> set PYLAUNCH_DEBUG=1 & py -3 -c "import os, sys; print(sys.prefix)"

I get:
  ...

  locating Pythons in 64bit registry
  locate_pythons_for_key: unable to open PythonCore key in HKCU
  locate_pythons_for_key: unable to open PythonCore key in HKLM
  locating Pythons in native registry
  locate_pythons_for_key: unable to open PythonCore key in HKCU
  locate_pythons_for_key: F:\ProgramFiler\Python27\python.exe is a 32bit 
executable
  ...

  locate_pythons_for_key: F:\ProgramFiler-x86\Python35\python.exe: Systemet 
finner ikke angitt bane.
  locate_pythons_for_key: 
F:\ProgramFiler-x86\Python35\PCBuild\win32\python.exe: Systemet finner ikke 
angitt bane.
  locate_pythons_for_key: 
F:\ProgramFiler-x86\Python35\PCBuild\amd64\python.exe: Systemet finner ikke 
angitt bane.
  found no configured value for 'python3'
  search for Python version '3' found no interpreter
  Requested Python version (3) not installed

  ("Systemet finner ikke angitt bane." == "File not found").

This is non-sense. I do have Python2 + 3 both on PATH (but both 32-bits).
Not sure if PyLauncher looks for 64-bit registry entries only.

But is there a way for py.exe to use '%USERPROFILE%\Local\py.ini' only?
I failed to find any good documentation on it's format.


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Issue: cannot successfully install Python 3 on Windows 7

2015-09-29 Thread Gisle Vanem

Gilad Mayani wrote:


I always get this message:

the program can't start because api-ms-win-crt-runtime-I1-1-0.dll is 
missing from your computer.


Is that really an 'I' in there? The .dll should really
be named:
  %SystemRoot%\system32\api-ms-win-crt-runtime-l1-1-0.dll

with an lower-case 'l'. (This .dll is itself a forwarder .dll to
ucrtbase.dll).

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Py_InitializeEx() in CygWin64's Python2.7

2015-07-01 Thread Gisle Vanem

I've written a C-program that embeds Python 2.7.
It has worked fine for several years using MingW or MSVC. Now I'd like
to support the python2.7.exe that comes with CygWin64.

But it seems to fail inside 'Py_InitializeEx(0)' where it just prints:
  ImportError: No module named site

What? Does really all Pythons needs a 'PYTHONPATH' set to point to the
site.py? Or is it only CygWin that is special here? Since if I do a
"set PYTHONPATH=/usr/lib/python2.7" in my shell, my program works.

These are some of the func-ptr and arguments I use during init:

 Py_SetProgramName ("/cygdrive/f/gv/VC_project/EnvTool/src/envtool.exe")
 Py_SetPythonHome ("/usr/lib/python2.7")
 Py_InitializeEx(0)   << libpython2.7.dll chokes inside here for a mysterious 
reason.

I maybe naively assumes calling 'Py_SetPythonHome' is doing part of
what parsing the PYTHONPATH should do. But it doesn't seems so.

If I from my cmd-line do a:

c:\> f:\CygWin64\bin\python2.7.exe -c "import sys; print (sys.modules)"

I can see:
  

So what could be the reason it's not able to load and parse it
without a 'PYTHONPATH' set explicit?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5 crashes on wrong %PYTHONHOME

2015-05-27 Thread Gisle Vanem

Zachary Ware wrote:


Is there any particular reason you're setting PYTHONHOME in the first
place?


I have several GNU Makefiles that picks up this variable
(to find Python.h, python*.lib etc.). But using Python 27
and 35 w/o having a %PYTHONHOME set, seems to work fine.
I have to revise those Makefiles.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Python 3.5 crashes on wrong %PYTHONHOME

2015-05-27 Thread Gisle Vanem

I just installed the 32-bit Python 3.5b4 via the Web-installer.
First, I was a bit annoyed by the fact it installed under
  'f:\ProgramFiler-x86\Python35' instead of
  'f:\ProgramFiler\Python35' as I customided for. But I guess
this is a WOW64 thing. I'm on Win-8.1 (64-bit).

But then I noticed the whole thing crashes when calling
python35!Py_FatalError. On a simple 'python -v' command.

Presumably because my env-var:
 PYTHONHOME=f:\Programfiler\Python27

(and not 'PYTHONHOME=f:\Programfiler\Python35').

Reading the message on this list, gave me the impression
Python 2.7 and Python 3.5 can co-exist with no problem.
Doesn't look the case so far. Is there another 'PYTHONxx'
env-var to override 'PYTHONHOME' in this case? Or what should
I do to keep on using both 27 and 35?

For reference, the call-stack:

  ucrtbase!abort+0x4b
  python35!Py_FatalError+0xbc
  python35!Py_InitializeEx_Private+0x45b
  python35!Py_Main+0x72c
  python+0x11df
  KERNEL32!BaseThreadInitThunk+0x24
  ntdll!__RtlUserThreadStart+0x2f
  ntdll!_RtlUserThreadStart+0x1b

And some of the modules shown in WinDbg:

  ModLoad: 1c47 1c47c000   F:\ProgramFiler\Python35\python.exe
  ModLoad: 7772 7788e000   C:\Windows\SYSTEM32\ntdll.dll
  ModLoad: 7750 7764   C:\Windows\SYSTEM32\KERNEL32.DLL
  ModLoad: 76e2 76ef7000   C:\Windows\SYSTEM32\KERNELBASE.dll
  ModLoad: 6cd5 6d057000   F:\ProgramFiler\Python35\python35.dll
  ModLoad: 6e7e 6e7f5000   C:\Windows\SYSTEM32\VCRUNTIME140.dll

(the new universal CRT from MS)


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-07 Thread Gisle Vanem

Chris Angelico wrote:


There's a specific search order. Back in the days of DOS, it was
simply "com, then exe, then bat", but on modern Windowses, I think
it's governed by an environment variable.


You probably mean '%PATHEXT'. Mine is:
 .COM;.EXE;.BAT;.BTM;.CMD;.JS;.JSE;.WSF;.WSH;.MSC;.tcl;.py;.pyw;.pl;.htm;.html

In my favourite shell 4NT, I simply can have:
  set .py=python

Instead of the Explorer associations that the Python-installer puts
in my registry. Revealed from my shell:
  c:\> assoc .py
   .py=py_auto_file
  c:\> ftype py_auto_file
   py_auto_file="F:\ProgramFiler\Python27\python.exe" "%1"

In ShellExecuteEx(), what program gets launched for "py_auto_file" in this
case, seems to be determined by the 'SHELLEXECUTEINFO:lpClass' member.
I fail to see that Python uses this structure anywhere.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: l = range(int(1E9))

2015-04-30 Thread Gisle Vanem

Cecil Westerhof wrote:


If I execute:
 l = range(int(1E9)

The python process gobbles up all the memory and is killed. The
problem is that after this my swap is completely used, because other
processes have swapped to it. This make those programs more slowly. Is
there a way to circumvent Python claiming all the memory?

By the way: this is CPython 2.7.8.


On what OS? If I try something similar on Win-8.1
and CPython 2.7.5 (32-bit):

 python -c "for i in range(int(1E9)): pass"
  Traceback (most recent call last):
File "", line 1, in 
  MemoryError


--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python27.dll could not be found

2015-03-02 Thread Gisle Vanem

Dave Angel wrote:


When I ran Windows, I had written a simple utility that searched the PATH for a 
specified file.
I called it which.bat to match the Linux equivalent.


I've written a similar tool; envtool --path --python python27.dll

Matches in %PATH:
  15 May 2013 - 21:43:38: f:\ProgramFiler\Python27\python27.dll
Matches in Python's sys.path[]:
  15 May 2013 - 21:43:38: f:\programfiler\Python27\python27.dll

(available at http://watt-32.net/misc/#envtool )


You can look to see where the system thinks the Python executable is located by 
doing

 ftype .py
and seeing what it shows.  Mine shows Python.File

   Then do
 assoc  Python.File

to see an actual path.


That will give you the path of python.exe. Not pythonXX.dll (as the
OP had problems with).

But by Windows DLL loading rules, it's IMHO safer to have pythonXX.dll
in the directory of python[w].exe. On Windows, ACAICR the Python MSI
installer puts pythonXX.dll in %Windir\system32. So it depends on how
the OP installed his Python.


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python path on windows

2015-02-21 Thread Gisle Vanem

Dave Angel wrote:


Finally, when py.exe starts, it reads that first (shebang) line, and decides 
which python interpreter to actually use.


py.exe? Do you mean python.exe?

Is there a way to make python.exe ignore all Shebang lines
in all scripts? I had many generated .py-files with:
  #!g:\ProgramFiler\Python27\python.EXE

After transferring my Python tree to a new Win-8.1 PC, my Python
tree was installed under "f:\ProgramFiler\" and my CD-ROM on "g:\"

This caused those scripts to access my CD-ROM or pop-up a Win-GUI
error dialogue if no CD-ROM was in the drive. Irritating.


--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Odd version scheme

2015-02-12 Thread Gisle Vanem

Tim Chase wrote:> So the test should actually be something like


   if LooseVersion(QtCore.PYQT_VERSION_STR) < LooseVersion("4.10"):
 balk()


That's exactly what they do now in IPython/utils/version.py with
the comment:
  Utilities for version comparison
  It is a bit ridiculous that we need these.

Not sure why this is "ridiculous".

I had an "old" version of IPython v0.13 installed! I've upgraded
to v2.10 and all is good.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Odd version scheme

2015-02-12 Thread Gisle Vanem

I tried using Interactive Python with a PyQt4 console:
  "IPython.exe qtconsole"

But got a
  "ImportError: IPython requires PyQT4 >= 4.7, found 4.10.4"

Looking at Ipython's check (in site-packages\IPython\external\qt.py):
  if QtCore.PYQT_VERSION_STR < '4.7':
  raise ImportError("IPython requires PyQt4 >= 4.7, found 
%s"%QtCore.PYQT_VERSION_STR)

So even if '4.10' < '4.7', my '4.10' is newer. What odd version scheme is
this really? I just edited that line to read:
 if QtCore.PYQT_VERSION_STR < '4.10':

Seems to be working fine now.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Non-unique dirs in sys.path

2015-01-09 Thread Gisle Vanem

Ian Kelly wrote:


I checked my own Python 2.7 installation and discovered that I have
the same problem, although without the different casing. Perusing the
.pth files in site-packages turns up setuptools.pth, which just
contains the site-packages path. Removing that file solves the issue
for me.


That was the case here too! Deleted my setuptools.pth and the "problem"
was gone. It would be nice to know how these .pth files are involved in
extending the 'sys.path[]'. Who does that and how? Any good reference on
that?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Non-unique dirs in sys.path

2015-01-09 Thread Gisle Vanem

I'm having some trouble understanding why my Python 2.7.9
has the '%PYTHONHOME%\lib\site-packages' listed multiple
times.

I cooked up this .bat file to demonstrate the issue:
  @echo off
  setlocal
  set PYTHONPATH=
  python -c "import sys; [sys.stdout.write('%%s\n' %% p) for (i,p) in 
enumerate(sys.path)]" | sort --ignore-case

which produces:

  f:\Documents and Settings\Gisle 
Vanem\Programdata\Python\Python27\site-packages
  f:\windows\system32\python27.zip<< !! doesn't exist, but okay.
  G:\Programfiler\Python27
  g:\Programfiler\Python27\DLLs
  g:\Programfiler\Python27\lib
  g:\Programfiler\Python27\lib\lib-tk
  g:\Programfiler\Python27\lib\plat-win
  g:\Programfiler\Python27\lib\site-packages   << !!
  g:\programfiler\python27\lib\site-packages   << !!
  ...

Why are these listed twice with different casing? One
would assume that Python on Win32 would be case-insensitive.
Some .pth-file to blame here?

I've checked that PYTHONPATH is not defined elsewhere. Like in:
  HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
or
  HKCU\Environment

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Command Line Inputs from Windows

2015-01-03 Thread Gisle Vanem

Ken Stewart wrote:


Here is a sample key:
S1-5-21-1560217580-722697556-320042093-1000-Classes
py_auto_file
shell
open
command

The corrected data for the key looks like this:

"C:\Python34\python.exe" %1 %*



Yikes! You use the awful cmd.exe as the shell don't you?
An advice is to use something like TakeCommand or 4NT (from jpsoft.com)
and create an "executable extension" for .py/.pyw files. Like I've
done:
 set .py=C:\Python34\python.exe
 set .pyw=C:\Python34\pythonw.exe

No need to fiddle with registry settings.

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: set environmental variable from python

2014-10-31 Thread Gisle Vanem

"Artur Bercik"  wrote:


I have to set several variables so it would be easier if I could set them
from Python.


You can write a Python-script that generates a .bat file (in your %TEMP-dir?).
And run this .bat file when Python ends. Put it all in an alias or another .bat
file. E.g. untested:
alias set_env=python  -o %TEMP%\set_env.bat & %TEMP%\set_env.bat

--gv

--
https://mail.python.org/mailman/listinfo/python-list


Re: What can Nuitka do?

2014-06-28 Thread Gisle Vanem

"Chris Angelico"  wrote:


The only other time I've been waiting for X display was when I was
mobile, on a 3G connection, and using X11 forwarding on an SSH link
back to my home LAN. 


Doing X11 calls over a network could really be a nuisance for others. And 
an archaic design IMHO.


I remember approx. 10 years ago a neighboring dept. at my work effectively 
killed our 10 MB/s Ethernet segment with such traffic (due to a misconfigured 
switch/router?). Running an ethernet analyzer showed a single X11 host-server 
session occupied ~80% bandwidth.  AFAICR, it was a Sun workstation.

A real PITA.

--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Working with the set of real numbers (was: Finding size of Variable)

2014-02-12 Thread Gisle Vanem

"Grant Edwards" wrote:


Not *any* computer? Not in *any* way? The Python built-in "float"
type "works with the set of real numbers", in a way.


The only people who think that are people who don't actualy _use_
floating point types on computers.


FPU parsing the IEEE spec, or?. I didn't quite parse what *you* wrote. 
To paraphrase:

 #include 
 "there are FP_NORMAL and FP_SUBNORMAL people in the world; 
  those who understand IEEE 754 and those who don't."  ..


--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Newcomer Help

2014-02-10 Thread Gisle Vanem

"Walter Hughey"  wrote:


Thank you for your reply. One quick question, when
I reply should it be replay to all or to the person who sent the emial?


When replying, the most important thing to remember is... order.

A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Get the picture now newcomer?

--gv

-- this crap came from you -





Apple does install a version of Python, normally a somewhat older version. My computer has 2.5 and 2.6 installed and I have opened 
it and inserted code that works. I do need a way to write the code, test it, and then save a copy to turn in for the assignment. I 
was not aware that a normal text editor would work. I shall definitely look at that later today.



Walter
- Original Message -

From: "Rustom Mody" 
To: python-list@python.org
Sent: Monday, February 10, 2014 11:07:14 AM
Subject: Re: Newcomer Help

On Monday, February 10, 2014 9:40:22 PM UTC+5:30, Walter Hughey wrote:
I am new to Python programming, actually new to any programming language. I sent the email below to the "python...@python.org a 
few days ago. So far I have not seen a reply, actually, I have not seen anything from pythonmac in any emails although I am 
supposed to be a member.



I don't know if I am sending these to the correct place or if I am not receiving emails from the pythonmac list. I would 
appreciate any assistance either in how do I get to the pythonmac list or answers to the issue below. I went to the pythonmac 
list because I am trying to run Python 3.3 on a Mac computer.



Thank you,


Walter

From: "Walter Hughey" 
To: python...@python.org
Sent: Friday, February 7, 2014 11:54:49 AM
Subject: Newcomer Help


Greetings,
I am new at Python programming, technically a newbie at writing programming code. I have been involved in the maintenance of 
computers for several years and have decided to increase my knowledge and experience. I am taking a course that - although not a 
programming course - does require writing of code. I am trying to use Python to write the code.


I use a Mac computer and the first issue is getting working with Python. The computer I currently use is running Mac OS X 10.6.8, 
Intel Core i5 Processor, with 4GB RAM. It has Python 2.3, 2.5, and 2.6 installed by Apple. I have added Python 3.3, the version 
our Professor recommended. I have checked out the Python installed by Apple and can enter in code and it works, but I need to 
create a file, run it, and then provide it for the Professor to grade and I don't know how with the Apple installed version.


While reading about Python, I saw comments about the note concerning outdated 
software: If you are using Python from a python.org
64-bit/32-bit Python installer for Mac OS X 10.6 and later,
you should only use IDLE or tkinter with an updated
third-party Tcl/Tk 8.5, like
ActiveTcl 8.5
installed.

I located, downloaded and installed the recommended version of ActiveTcl 8.5.15.0. When I open Idle, I see a warning that "The 
version of Tcl/Tk (8.5.7) in use may be unstable." I received this warning both before and after installing the software above. I 
open Idle, choose "New File" then most often the computer will freeze, Idle does nothing, cannot enter text into the text box, 
cannot close the application either with the red circle or by selecting Idle>Close Idle. As often as that, Idle freezes as soon 
as I open new file, and I cannot close without resorting to Force Quit.


I have removed and re-installed Python after downloading and installing the Tcl/Tk software and it does not help. I have seen 
this work fine on a Mac running Mac OS X 10.8.3. I really just need to get this working on the older version.


A am not only new to Python, I am new on this list and hope I have started my 
stay here in the correct manner!



Hi! You have started on a clear note and are welcome here.
I dont know anything about macs so hopefully someone else will give you
more specific answers.

However can you check that python interpreter runs in a shell, and that
after starting it if you type say:
2 + 3 RETURN
you get 5

If that is the case you can still develop the way most python programmers
develop, viz
Write your code in a normal text editor
Load it into the interpreter
Check it
Go back to the editor and continue writing/correcting the code
--
https://mail.python.org/mailman/listinfo/python-list









--
https://mail.python.org/mailman/listinfo/python-list



--
https://mail.python.org/mailman/listinfo/python-list


Vedr: What does """ means in python?

2014-02-08 Thread Gisle Vanem


 
Gisle V.


"Computers are useless. They can only give answers"  --Pablo Picasso
Chris Angelico  wrote:

> For SQL? Ignore the extra spaces, it's a free-form language. The only
> reason to consider dedent() would be if you're worried about how your
> log files will look. The actual execution of SQL won't be bothered by
> newlines and spaces/tabs.

Regrading handy uses of ''', you learned me one trick when using Python 
code in a Windows .bat file:


  rem = '''
  @echo off
  echo This is 
batch
  \python32\python %0
  echo All done
  exit /b
  rem '''
  import 
sys
  print("This is Python")
  for i,p in 
enumerate(sys.path):
     print('sys.path[%2d]: %s' % (i, p))
  print("Python 
done")

You'll have a variable in Python called 'rem' which contains all 
your
batch code :) It exploits the fact that 'rem' makes a 
one-line
comment, but the triple quotes go across multiple lines.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Odd msg received from list

2013-11-14 Thread Gisle Vanem

"Chris Angelico"  wrote:


I agree in general, but I happen to be pretty familiar with Mailman
alerts, and this one was genuine. Also, it pointed to what does appear
to be the right address (mail.python.org). There's definitely
something going around that's causing problems for gmail users;


It happended to me too. And I'm a Yahoo user. I clicked the MailMan
confirmation link and all emails seems to be received now (comparing
to what's on the NNTP group).

--gv

--
https://mail.python.org/mailman/listinfo/python-list


Re: how to find out utf or not

2013-11-05 Thread Gisle Vanem

"Steven D'Aprano"  wrote:

If myVar is a Unicode string, you don't need to care about the encoding 
(UTF-8 or otherwise) until you're ready to write it to a file. Then I 
strongly recommend you always use UTF-8, unless you have to interoperate 
with some old, legacy system:


assert isinstance(myVar, unicode)
byte_string = myVar.encode('utf-8')


An excellent summary of the mystics around text-encoding. Thank you.

--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Running code from source that includes extension modules

2013-10-02 Thread Gisle Vanem

"Michael Schwarz"  wrote:


So how do I run my code so it will find the built extension module? Do I
pass the output directory on the command line manually or is there some
other solution? I would like to still be able to run the code from the
source directory as I'm using PyCharm to edit and debug the code.


Doesn't Python on Linux (I assume that since you mentioned the module's .so)
support having current-dir '.' in $PYTHONPATH? Works fine on Windows.

Check with "python -v script.py | grep ".

--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: DNS query against a specific server.

2013-09-30 Thread Gisle Vanem

"Chris Angelico"  wrote:


There are a few Python DNS modules. It means adding another
dependency, but perhaps not as large as twisted. And of course, you
could always manually send UDP packets and listen for responses, but
that seems a little unnecessary :)


Then there is pycares; "a Python module which provides an interface to 
c-ares c-ares is a C library that performs DNS requests and name resolves 
asynchronously.". I have good experience wih C-ares and it can set

specific nameservers. Ref:
 https://pypi.python.org/pypi/pycares/0.3.0

--gv
--
https://mail.python.org/mailman/listinfo/python-list


Calling Py_Main() and parsing the output from C

2013-08-10 Thread Gisle Vanem

Hello Python & C-experts.

I'm trying to embed python27.dll in a C-program written in
MingW-gcc 4.7.2. I've successfully done these initial steps:

 typedef int (*Py_Main_t) (int argc, char **argv);
 handle = LoadLibrary ("python27.dll");
 py_main = (Py_Main_t) GetProcAddress (handle, "Py_Main");
 argv[0] = who_am_I;/* the .exe of the embedding program. python*.dll 
doesn't seems to care what this is */
 argv[1] = (char*) "-c";
 argv[2] = PYTHON_CMD;  /* see below */
 argv[3] = NULL;

 rc = (*py_main) (3, argv);

DEBUG: pyembed.c(76): Calling Py_Main():
 argv[0] = "G:\vc_2010\VC\Projects\EnvTool\src\envtool.exe"
 argv[1] = "-c"
 argv[2] = "import sys;[sys.stdout.write('%s\n' % p) for (i,p) in 
enumerate(sys.path)]"
 argv[3] = NULL.

Which produces the expected 'sys.path[]:
 g:\Programfiler\Python27\lib\site-packages\pyzmq-2.2.0.1-py2.7-win32.egg
 g:\Programfiler\Python27\lib\site-packages\nose-1.2.1-py2.7.egg
 ...

But I'd like to grab the stdout from Py_Main() into a pipe, mmap-file or similar
for the calling program to parse. Before I used the embedding solution, I simply 
spawned python.exe using my shell and popen(). Then parsed the output 
using fgets(). This work fine. But I'd like to try embedding now. Since avoiding 
the shell should be faster. No?


How can I accomplish the grabbing of Py_Main() output simplest? Is creating
a memory-mapped file in the calling program a good idea? Can Py_Main() print 
to that? If so, how? I'm on Win-XP SP3.


--gv
--
http://mail.python.org/mailman/listinfo/python-list


Modules list-tool

2013-05-21 Thread Gisle Vanem

Are anyone aware of a tool that can show me at run-time
which modules (pyd/dll) are loaded into a Python program 
at a specific time (or over time)?


To clarify, e.g. when running a sample from PyQt4
(examples\tutorials\addressbook\part1.pyw) and using Process Explorer [1],
I can launch WinDbg from it and get this list of modules:


ModLoad: 1d00 1d00a000   G:\ProgramFiler\Python27\python.EXE
ModLoad: 7c90 7c9b1000   F:\WINDOWS\system32\ntdll.dll
ModLoad: 7c80 7c8f7000   F:\WINDOWS\system32\kernel32.dll
ModLoad: 1e00 1e261000   f:\windows\system32\python27.dll
ModLoad: 7e41 7e4a1000   F:\WINDOWS\system32\USER32.dll
ModLoad: 77f1 77f59000   F:\WINDOWS\system32\GDI32.dll
ModLoad: 77dc 77e6a000   F:\WINDOWS\system32\ADVAPI32.dll
ModLoad: 77e7 77f03000   F:\WINDOWS\system32\RPCRT4.dll
ModLoad: 77fe 77ff1000   F:\WINDOWS\system32\Secur32.dll
ModLoad: 7c9c 7d1d8000   F:\WINDOWS\system32\SHELL32.dll
ModLoad: 77c0 77c58000   F:\WINDOWS\system32\msvcrt.dll
ModLoad: 77f6 77fd6000   F:\WINDOWS\system32\SHLWAPI.dll
ModLoad: 7852 785c3000   
f:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43\MSVCR90.dll
ModLoad: 7637 7638d000   f:\windows\system32\IMM32.DLL
ModLoad: 62f2 62f29000   f:\windows\system32\LPK.DLL
ModLoad: 7542 7548b000   f:\windows\system32\USP10.dll
ModLoad: 773c 774c3000 
f:\windows\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll

ModLoad: 5d5d 5d66a000   F:\WINDOWS\system32\comctl32.dll
ModLoad: 78aa 78b5f000   f:\windows\system32\MSVCR100.dll
ModLoad: 00d9 00f29000   
g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtCore.pyd
ModLoad: 6700 6726   
g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtCore4.dll
ModLoad: 774d 7760e000   F:\WINDOWS\system32\ole32.dll
ModLoad: 71aa 71ab7000   f:\windows\system32\WS2_32.dll
ModLoad: 71a9 71a98000   f:\windows\system32\WS2HELP.dll
ModLoad: 7848 7850e000   
f:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43\MSVCP90.dll
ModLoad: 00a6 00a73000   g:\ProgramFiler\Python27\lib\site-packages\sip.pyd
ModLoad: 011f 0177f000   
g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtGui.pyd
ModLoad: 6500 657c4000   
g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtGui4.dll
...

-

My example may be mooth since part1.pyw above (when I enter
the debugger) is just waiting for events. The stack of pythonw.exe 
as shown in Process Explorer:

...
ntdll.dll!ZwWaitForMultipleObjects+0xc
kernel32.dll!WaitForMultipleObjectsEx+0x12c
USER32.dll!RealMsgWaitForMultipleObjectsEx+0x13e
QtCore4.dll!QEventDispatcherWin32::processEvents+0x3c3
ntdll.dll!RtlAcquirePebLock+0x28

Is there a tool that can do something similar? (written in Python maybe?). 
But a bit simpler to use than my current method. Just launch it from the 
command-line; something like "pyXX part1.pyw "


[1] http://technet.microsoft.com/en-gb/sysinternals/bb896653

--gv 


--
http://mail.python.org/mailman/listinfo/python-list


Re: Python newbie trying to embed in C++

2013-02-28 Thread Gisle Vanem

"Marwan Badawi"  wrote:

I just noticed that my reply went to the message sender and not to the 
newsgroup, so I'm posting again: thanks, I'll look into that.


Yes, I often do that too; i.e. I'm subscribed to python-list@python.org
and get all messages from comp.lang.python mirrored to the ML a bit later.
I prefer the mailing-list over comp.lang.python since my NNTP server
(eternal-september.org) is rather slow and my ISP has deprecated NNTP 
long time ago. 


I saw you uses Thunderbird on Windows. I'm not sure how it by default handles
a reply-to when there is no "Reply-to" field in the header. To the address in 
"From" / "Sender" or what? 


I wish the NNTP-mailing list gateway could add a "Reply-to: 
".
Since I'm getting the messages via the ML, I think it would be logical that the replies 
should by default go to the ML too.


--gv



--
http://mail.python.org/mailman/listinfo/python-list


Re: FYI: AI-programmer

2013-02-22 Thread Gisle Vanem

"Chris Angelico"  wrote:


That's not artificial intelligence, though. It's artificial program
generation based on a known target output. The "Fitness" calculation
is based on a specific target string. This is fine for devising a
program that will produce the entire works of Shakespeare, since there


You mean, art generation (writing Shakespearian texts) is a process of 
generating "known target output"?. If we talk about good art (not kitch),
I disagree. For reference, "Infinite Monkey Teorem" is at 
http://en.wikipedia.org/wiki/Infinite_monkey_theorem


Disregarding the probability math in the above, the question IMHO boils 
down to whether "art can be produced by accident" (quote from above). 
I seems to recall elephant painting selling for lots of dollars some years ago. 
And long dull poems written by computers. Fooled a lot of people.



As suggested in RFC 2795 [1], the resources required to implement such
a project would also have other uses. Like the Infinite Improbability
Drive,


I did notice that RFC was written on 1 April 2000 :-)

--gv
--
http://mail.python.org/mailman/listinfo/python-list


FYI: AI-programmer

2013-02-22 Thread Gisle Vanem

Here is something interesting that you pythonistas might be
interested in:
http://www.primaryobjects.com/CMS/Article149.aspx

"""This article describes an experiment to produce an AI program, capable of 
   developing its own programs, using a genetic algorithm implementation with 
   self-modifying and self-improving code. """


The above experimental BrainF** language was written using C#. So who will 
be the first to make an AI-language in Python that generates it's own program?


--gv 


--
http://mail.python.org/mailman/listinfo/python-list


Re: pylint or similar to test version-specific language constructs?

2013-01-09 Thread Gisle Vanem

"jkn"  wrote:


   I have to write python code which must run on an old version of
python (v2.4) as well as a newer (v2.7). I am using pylint and would
like to check if is possible to check with pylint the use of operators
etc. which are not present in 2.4; the ternary operator springs to
mind.


No idea about PyLint. Why not install Python 2.4 and test
with that? Sounds safer IMHO.

-gv

--
http://mail.python.org/mailman/listinfo/python-list


Re: Calculate Big Number

2013-01-08 Thread Gisle Vanem

"Steven D'Aprano"  wrote:


py> from timeit import Timer
py> t1 = Timer("(a**b)*(c**d)", setup="a,b,c,d = 10, 25, 2, 50")
py> min(t1.repeat(repeat=5, number=10))
0.5256571769714355

So that's about 5 microseconds on my (slow) computer.


That's pretty fast. So is there still a need for a GMP python-binding like
gmpy? http://code.google.com/p/gmpy/wiki/IntroductionToGmpy

GMP can include optimized assembler for the CPU you're using. But
I guess it needs more memory. Hence disk-swapping could be an issue
on performance.

--gv
--
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-03 Thread Gisle Vanem

"Wayne Werner"  wrote:


Yep. That's how I feel. I had used ViEmu in Visual Studio for coding in .NET at
work - but I found that the buffers & macros were more powerful. So now I do
most of my programming in Vim, and only head to VS if I need autocomplete or
some of it's auto-generation tools.


Learning X different IDEs for different languages and uses can be 
confusing. So if you use Visual-Studio a lot there is Python Tools for VS [1].

A great but kinda slow extension to VS. Sticking to VS is also useful
if one does Swig and need to debug your crashing .pyd modules.

[1] http://pytools.codeplex.com/

--gv
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question about nested loop

2012-12-31 Thread Gisle Vanem

"Isaac Won"  wrote:


while c < 10:
   c = c + 1

   for  columns in ( raw.strip().split() for raw in f ):


   b.append(columns[c])

   y = np.array(b, float)
   print c, y


I thought that  can get the arrays of the columns[5] to [10],
but I only could get repetition of same arrays of columns[5].


I don't pretend to know list comprehension very well, but 
'c' isn't incremented in the inner loop ( .. for raw in f). 
Hence you only append to columns[5].


Maybe you could use another 'd' indexer inside the inner-loop?
But there must a more elegant way to solve your issue. (I'm a
PyCommer myself).

--gv
--
http://mail.python.org/mailman/listinfo/python-list


Re: Running a curl command within py script

2012-11-14 Thread Gisle Vanem

"Smaran Harihar"  wrote:


i found pycurl to execute python curl command but not sure how I can
execute the curl command using the pycurl.

curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' -d
'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp'
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/Quercus_iltisii/external.shp
?


Off-topic, but here's an idea. Use the 'curl --libcurl foo' option to see
what setopt() calls to use in PyCurl. Like:

import sys, pycurl

c = pycurl.Curl()
c.setopt (c.URL, 
'http://localhost:8080/geoserver/rest/workspaces/acme/datastores/Quercus_iltisii/external.shp')
c.setopt (c.USERPWD, 'admin:geoserver')
c.setopt (c.POSTFIELDS, 
'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp');

etc.

--gv

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python on Windows

2012-10-20 Thread Gisle Vanem

"Tim Golden"  wrote:


In general, you'll want to be using a mechanism such as pip:

 http://pypi.python.org/pypi/pip

which will look things up on PyPI so you can just do "pip install
newmodule". 


And if you have a pip.bat from some Perl installation sitting before 
python's Scripts dir in your %PATH, remember to use 
"pip.exe install newmodule" instead.


My Strawberry Perl has this "Perl Installation Package". Maybe I should
rearrange my %PATH? 


--gv
--
http://mail.python.org/mailman/listinfo/python-list


Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem

"Dave Angel"  wrote:


Why would you write some C-program just to save having two separate
files, one batch and one for the script?  For that matter, several
answers have given you approaches that didn't involve list
comprehensions, including merging the two in a single file, using an
initial variable of rem=""" 


Like I wrote; use popen() or system() from a C-program (an env-var
checker) that's not really related to Python programming. But rather to 
check various stuff needed for C-programming . Like walking the list 
of %INCLUDE / %C_INCLUDE_PATH dirs to figure out what headers are 
where. So I'd just as well add an option to check for Python paths too 
(if Python is installed that is).



What are your real constraints?  Are you just playing code-golf?


That too.

--gv
--
http://mail.python.org/mailman/listinfo/python-list


Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem

 wrote in comp.lang.python

(my ISP no longer updates this group. Last message is from 8. April.
Does the postings to the python mailing-list automatically get reposted 
to comp.lang.python?)



C:\Windows\system32\python32.zip
c:\python32\DLLs


I see a similar result:
 f:\Windows\system32\python27.zip

Where is it determined that python27.zip should be in sys.path?
I have no such file anywhere. I'm using ActivePython 2.7.2.

--gv

--
http://mail.python.org/mailman/listinfo/python-list


Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem

"Dave Angel"  wrote:


it has nothing to do with being on a command line.  You're using
semicolon to combine several statements, and there are restrictions on
what can be combined that way.  One restriction is the looping
constructs, for, if, while.


Ok, I suspected something like that.


You can do it easily enough with a list comprehension.  Let us know if
you can't work that out.


Later. I'm only scratching the surface of Python.


Any reason why you don't just make a one-file python script, and run
that instead of your one line batch file? 


I though of calling that python line from a C-program using
popen() and parsing the output. Since popen() on Win32 AFAIK doesn't accept 
multiple lines, I guess I must write a .py-file to %TEMP first.


Thank to all.

--gv
--
http://mail.python.org/mailman/listinfo/python-list


for-loop on cmd-line

2012-10-11 Thread Gisle Vanem

Hello list. I'm a newbie when it comes to Python.

I'm trying to turn this:

def print_sys_path():
   i = 0
   for p in sys.path:
 print ('sys.path[%2d]: %s' % (i, p))
 i += 1

into a one-line python command (in a .bat file):

 python -c "import sys,os; i=0; for p in sys.path: print('sys.path[%%2d]: %%s' %% 
(i, p)); i+=1"

But:
 File "", line 1
   import sys,os; i=0; for p in sys.path: print('sys.path[%2d]: %s' % (i, p)); 
i+=1
 ^
SyntaxError: invalid syntax

The caret is on the 'for'. What's the problem?

--gv
--
http://mail.python.org/mailman/listinfo/python-list


FOX Toolkit

2011-07-01 Thread Gisle Vanem

In http://docs.python.org/faq/gui.html I came across
FOX Toolkit and the binding FXPy. The latter, it seems
is no longer officially supported (hasn't for the last 7-8 
years). So my question. Has anybody to your knowledge 
tweaked FOX and FXPy to work with Python 2.7?


--gv

--
http://mail.python.org/mailman/listinfo/python-list