Re: How to upload to Pythonhosted.org

2017-11-30 Thread Irmen de Jong
On 11/30/2017 03:31 AM, Ben Finney wrote:
> Irmen de Jong <irmen.nos...@xs4all.nl> writes:
> 
>> On 11/30/2017 02:06 AM, waylan wrote:
>>> So, how do I upload an update to my documentation?
>>
>> I ran into the same issue. From what I gathered, Pythonhosted.org is
>> in the process of being dismantled and it hasn't allowed new doc
>> uploads for quite some time now. I switched to using readthedocs.io
>> instead.
> 
> The issue that many are facing is how to update the pages *at the
> existing URL* to tell visitors where to go next. Cool URIs don't change
> <URL:https://www.w3.org/Provider/Style/URI.html> but, when they do, we
> are obliged to update the existing pages to point to the new ones.

Sorry, yes, that is the problem I experience as well. My library's old version
documentation is somehow frozen on Pythonhosted.org (and obviously still pops 
up as the
first few google hits).


> So, if pythonhosted.org is indeed being dismantled, there should be a
> way to update the pages there for informing visitor where they should go
> next.
> 
> If that's not possible and instead the service is just locked down,
> that's IMO a mistake.

I agree with that. I think it's an unsolved issue until now, that gets some 
discussion
in this github issue https://github.com/pypa/warehouse/issues/582


Irmen




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


Re: How to upload to Pythonhosted.org

2017-11-29 Thread Irmen de Jong
On 11/30/2017 02:06 AM, waylan wrote:
> I've been hosting documentation for many years on pythonhosted.org. However, 
> I can't seem to upload any updates recently. The homepage at 
> http://pythonhosted.org states:
> 
>> To upload documentation, go to your package edit page 
>> (http://pypi.python.org/pypi?%3Aaction=pkg_edit=yourpackage), and fill 
>> out the form at the bottom of the page.
> 
> However, there is no longer a form at the bottom of the edit page for 
> uploading documentation. Instead I only see:
> 
>> If you would like to DESTROY any existing documentation hosted at 
>> http://pythonhosted.org/ProjectName Use this button, There is no undo.
>>
>> [Destroy Documentation]
> 
> I also went to pypi.org and logged in there. But I don't see any options for 
> editing my projects or uploading documentation on that site.
> 
> So, how do I upload an update to my documentation?
> 
> Waylan
> 


I ran into the same issue. From what I gathered, Pythonhosted.org is in the 
process of
being dismantled and it hasn't allowed new doc uploads for quite some time now.
I switched to using readthedocs.io instead. That one is faster and has the 
additional
benefit that you can configure it in such a way that you don't have to upload 
docs
yourself anymore; it can rebuild them on the fly when it detects a change in 
your github
repo

Irmen

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


Re: Code Snippets

2017-11-01 Thread Irmen de Jong
On 11/01/2017 06:25 PM, Stefan Ram wrote:

> import random
> ...
> random.random()
> 
>   Now, the user has to cut the import, paste it to the top
>   of his code, then go back to the list of snippets, find
>   the same snippet again, copy the expression, go to his code,
>   then find the point where he wanted to insert the snippet again,
>   and finally insert the snippet. And still there now is a
>   risk of name collisions. So, it seems to me that __import__
>   is just so much better!

..or suggest them to use an IDE instead? For instance in PyCharm you can type:
random.random()   (squiggle appears under random)

(it suggests: Import This name)  
(it suggests: from random) 
done, an import random has been added at the top of my module.


Irmen


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


Re: How to determine lowest version of Python 3 to run?

2017-10-05 Thread Irmen de Jong
On 10/05/2017 04:23 AM, Christopher Reimer wrote:

> I'm leaning towards installing the latest minor version of each available 
> major version, running tox to run the unit tests against each one, and seeing 
> what blows up.

Perhaps you can use the service of Travis (travis-ci.org) to avoid installing 
the Python
versions yourself. They have lots of older versions available to run tests on.

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


Re: auto installing dependencies with pip to run a python zip application ?

2017-09-28 Thread Irmen de Jong
On 09/28/2017 09:40 AM, Paul Moore wrote:
> Are you aware of pipsi? If you do `pipsi install somepackage` it
> creates a new virtualenv in ~/.local/.venvs, populates it with
> somepackage and its dependencies, and then puts the entry point
> scripts for somepackage into ~/.local/bin. It may be a useful way of
> delivering your program, rather than building the virtualenv
> management in yourself.

No I wasn't aware of this tool, thanks for sharing. It's not what I am
looking for but it's always nice to know of some alternatives

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


Re: auto installing dependencies with pip to run a python zip application ?

2017-09-27 Thread Irmen de Jong
On 09/27/2017 09:50 AM, Paul Moore wrote:

>>> What you could do is pip install your binary dependencies into a
>>> directory in $TEMP using --target, then add that directory to
>>> sys.path. Probably easier than building a full virtualenv. Bundle pip
>>> with your app if you can't assume your users will have pip available.
>>
>> Interesting idea, although like this wouldn't I have to download the
>> dependencies every time I launch my game? (unless I re-use the same
>> temporary directory every time)
> 
> Ah, I'd assumed that's what you were doing with the virtualenv, I
> hadn't realised you were talking about a one-off setup step. Yeah,
> re-using a temporary directory doesn't buy you much compared to using
> a virtualenv (particularly if you can target versions of Python that
> have the built in venv module).

Well, I was planning on using a fixed name/location for the virtualenv.
That way when you request pip to install the dependencies again at next
launch, it will detect them already satisfied and not download/reinstall
everything. I could even test for their existence first myself in my
application (which is what I'm already doing now, to give the user a
clear error message) and only invoke pip when a dependency is missing.


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


Re: Boolean Expressions

2017-09-26 Thread Irmen de Jong
On 09/27/2017 12:23 AM, Cai Gengyang wrote:
> 
> I'm trying to understand the logic behind AND. I looked up Python logic tables
> 
> False and False gives False
> False and True gives False
> True and False gives False
> True and True gives True.
> 
> So does that mean that the way 'and' works in Python is that both terms must 
> be True (1) for the entire expression to be True ? Why is it defined that 
> way, weird ? I was always under the impression that 'and' means that when you 
> have both terms the same, ie either True and True or False and False , then 
> it gives True

There is nothing Python specific about this, by the way.
It is how AND - ∧ - has been defined in Boolean Algebra forever.  It's a
logical conjunction of its operands, it doesn't test for the 'equality'
of its operands.  https://en.wikipedia.org/wiki/Logical_conjunction


Irmen



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


Re: auto installing dependencies with pip to run a python zip application ?

2017-09-26 Thread Irmen de Jong
On 09/26/2017 10:49 PM, Paul Moore wrote:
> On 26 September 2017 at 19:47, Irmen de Jong <ir...@nospam.xs4all.nl> wrote:
>> Any thoughts on this? Is it a good idea or something horrible? Has
>> someone attempted something like this before perhaps?
> 
> When I've done this, I've bundled my dependencies in with my zipapp.
> Of course that's trickier if you have binary dependencies like pillow.

Yeah I've considered that for a moment but I think sometimes you've also
got to deal with licensing issues. I'd rather avoid this.

> What you could do is pip install your binary dependencies into a
> directory in $TEMP using --target, then add that directory to
> sys.path. Probably easier than building a full virtualenv. Bundle pip
> with your app if you can't assume your users will have pip available.

Interesting idea, although like this wouldn't I have to download the
dependencies every time I launch my game? (unless I re-use the same
temporary directory every time)


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


Re: auto installing dependencies with pip to run a python zip application ?

2017-09-26 Thread Irmen de Jong
On 09/26/2017 09:19 PM, Thomas Jollans wrote:
>> - use venv.EnvBuilder() to create a new virtualenv somewhere in the
>> user's home directory (~./virtualenvs/mygreatgame ?)
> 
> The appropriate place for this kind of thing, on Linux, would be
> $XDG_DATA_HOME, default "~/.local/share/", i.e.:
> 
> f"{os.getenv('XDG_DATA_HOME', os.path.expanduser(
> '~/.local/share'))}/{my_app}/{subdir}"
> 
> Other operating system have other conventions. (On Windows I think
> os.getenv('APPDATA') is a good place to start)

Ah, yes thanks for this reminder. I used the appdirs library elsewhere
to take care of this but this is not available (yet) until we are
running in the virtual env

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


auto installing dependencies with pip to run a python zip application ?

2017-09-26 Thread Irmen de Jong
Hi,
I've been using Python's executable zip application feature to neatly
package my little game into a single "executable" file.
Here "executable" means the user can simply start it by doubleclicking
it, or launching it from a shell prompt. Of course the user already has
to have a proper Python installation on their system but that's okay for me.

However, I would like to also take care of the library dependencies of
my game. Currently it requires pillow and sounddevice. If the user
doesn't have these installed, the game exits with an error message
telling the user to install these dependencies manually. I was thinking
about a way to automate this so that you don't have to install anything
manually to run the game.

I was thinking about the following solution:
- assume bare default Python (3.5+) installation
- use venv.EnvBuilder() to create a new virtualenv somewhere in the
user's home directory (~./virtualenvs/mygreatgame ?)
- use the with_pip=True argument so we also get pip installed into it
- exec() the python executable from the new virtual env and let that
"pip install -r mygamerequirements.txt"
- inject "./mygame.pyz" in sys.modules[0]
- run the game's main class and play!

Notice that I'm not looking for a fully standalone executable created by
things as cx_freeze, just something that is usable from within my zipped
application.

Any thoughts on this? Is it a good idea or something horrible? Has
someone attempted something like this before perhaps?

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


Re: Fw: Problems Installing Python36

2017-09-22 Thread Irmen de Jong
On 09/22/2017 08:34 PM, Stephan Houben wrote:

> I was vaguely tempted to offer the Mingw-w64 (GCC) Python as an
> alternative, since it doesn't rely on any optionally-installed Microsoft
> DLLs and so avoids this issue. But I suppose that is not really the
> newbie-friendly solution the OP was looking for...

Mingw? Perhaps better to choose Anaconda/Miniconda instead if you go for
an alternative implementation...

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


Re: Fw: Problems Installing Python36

2017-09-20 Thread Irmen de Jong
On 14/09/2017 05:46, Michael Torrie wrote:
> On 09/12/2017 03:05 AM, Thomas Jollans wrote:
>> Other people on this list:
>> This isn't the first time I've someone with this issue here. It's
>> probably putting off plenty of potential new users who don't make as
>> much effort to find a solution. I can't say I understand the ins and
>> outs of installing things on Windows... is there anything that can be done?
> 
> Last time I brought this up, someone mentioned that the Python installer
> is supposed to automatically install this runtime library if it's not
> installed already.  If so, why are so many people having this problem?
> 

That is what I'm wondering as well.

The only thing I can think of is that it asks windows update to install said KB 
update
but that it depends on something else that isn't installed or that the user 
running the
installation doesn't have the rights to install windows updates. (I suspect 
something
will be logged in the event viewer somewhere...?)

Or that it doesn't attempt to download it at all and that we are misinformed :P


Btw, I personally never had any issues installing Python on Windows.

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


v2.0 released of: a Boulder Dash clone with retro graphics and sound

2017-09-10 Thread Irmen de Jong
On 06/09/2017 23:17, Irmen de Jong wrote:

> 
> https://github.com/irmen/bouldercaves
> 

My Boulder Dash clone is now at version 2.0 because a few important things that 
were
lacking are now implemented:

* authentic mode:
The game is now displayed in a small screen that scrolls smoothly over the 
level, like
the original game. It also has the retro c-64 color palette enabled. You enable 
this via
a command line option.

* pre-recorded demo:
If you press F9 or wait a while at the title screen, the game plays back a 
prerecorded
demo of cave A, like the original game.

* synthesized sounds:
Instead of using sampled sounds you can now run the game with a software sound
synthesizer that creates the sounds in real time, including the title music. 
I've tried
to simulate the sounds of the original game but ended up with slightly 
different ones.
Maybe I'll tweak the synth to make them closer to the original, but there's a 
charm to
the variation as well I think.


All in all I am very pleased with the results. I didn't expect it to be possible
creating a decently performing arcade game using just the bare essentials:
- default tkinter to draw everything on the screen
- pillow to load images
- sounddevice to play sounds (optional).

I posted this update because I now consider it a full game [1] and I think it's
interesting to see that this can be realized in Python without any of the 
specialized
'game libraries' (pygame, etc) being used. While tkinter sometimes has troubles 
updating
the screen at 30 hz, the Python code itself is barely breaking a sweat, even 
the sound
synth.


Have fun
Irmen de Jong


[1] full game: errr... there's still no highscore table. Sorry :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a Boulder Dash clone with retro graphics and sound

2017-09-06 Thread Irmen de Jong
On 05/09/2017 00:02, Irmen de Jong wrote:

https://github.com/irmen/bouldercaves

> There's just two things missing I think:
> - high score table
> - being able to play multiple sounds simultaneously, as the amoeba and
> magic wall sounds are lacking at the moment.

In version 1.2 sound mixing is implemented so the game can now play multiple 
samples
simultaneously, and is able to play sounds in a loop. This means it now 
properly plays
the title screen music, and the amoeba and magic wall sounds are now also in 
the game.
(and I fixed a magic wall behavior bug as well)

Saving and displaying high scores are left as an exercise for the reader :)


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


Re: wrote a commodore-64 emulator using just Python

2017-09-04 Thread Irmen de Jong
On 08/13/2017 03:50 PM, Irmen de Jong wrote:
> Hi,
> 
> As another experiment with using just tkinter for graphics, this time I 
> created a
> Commodore-64 emulator. You can find it here https://github.com/irmen/pyc64

[...]

> There's also https://github.com/mnaberez/py65 so... possibilities?

Well, I went ahead and integrated that with my emulator. With just a
slight modification (that is now merged into the py65 library) I could
hook it up to the bytearray that my emulator uses to simulate the C64's
RAM. And letting the 'SYS' basic command kick of the 6502 simulator,
rather than doing nothing, it suddenly was able to actually run real
(although simple) Commodore-64 programs. Speed seems to be around 0.5x
real-time on my machine.

The py65 library also already provides a simple machine code monitor
(assembler/disassembler) that you can use to inspect or write the
machine code in the C64's memory. With some effort it should be possible
to run it in the emulated screen, but for now, interaction with it is
done on the console prompt.

It was a great deal of fun integrating this into my project and I found
it quite spectacular to see some existing Commodore-64 programs actually
running unaltered.  Even when they're doing nothing more than changing
the screen colors and unpacking an image. At half speed. But still :-)


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


Re: tkinter keypress events are a mess for numpad keys

2017-08-29 Thread Irmen de Jong
On 29/08/2017 06:32, Terry Reedy wrote:

> *The* documentation (for 8.6) is the tcl.tk/man doc set:
> https://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm
> For the level of detail you are looking at, they are essential.
> 
> The nmt docs for 8.5 are neither complete (intentionally not) nor always 
> correct nor
> always up to date.  The tk docs may also have errors, just as our do, but I 
> presume one
> can file a report somewhere and possibly get a fix.

Hi Terry thanks for pointing me to that resource.
I'll have a look at https://www.tcl.tk/man/tcl8.6/TkCmd/keysyms.htm
but I don't have high hopes because I already tried empirically to figure out 
the
distinguishing attributes of the keypress event object, on various platforms 
(Mac OS,
Linux, Windows)...

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


tkinter keypress events are a mess for numpad keys

2017-08-28 Thread Irmen de Jong
Hi,

Using tkinter in python3, I was trying to intercept individual keypresses (and 
releases)
of keys on the numeric keypad. I want to use this as a simple joystick 
simulation.
While you can bind the  event, actually doing something sensible with 
it in a
cross platform way seems utterly impossible.

The distinguishing attribute of the event object is different depending on what 
OS
you're using (keysym, keycode, keysym_num) and on Windows registering some keys 
doesn't
even seem to work (or they're confused with the same keys on the normal 
keyboard area).
The keysym names/values in the documentation are not correct either
(I'm mainly looking at 
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/key-names.html)


My original question with the details on stackoverflow:
https://stackoverflow.com/questions/45869902/better-way-to-deal-with-tks-keyboard-events-mess-for-numpad-keys-in-pythontkin

Unfortunately there hasn't been a useful response or answer.

A gist with a small example program is here:
https://gist.github.com/irmen/2c9d6bb0afb16b464805410c108a2885

Does anyone here have a clue perhaps?
Or have any idea why this is so messy?


Thank you!
Irmen
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wrote a commodore-64 emulator using just Python

2017-08-14 Thread Irmen de Jong
On 08/13/2017 03:50 PM, Irmen de Jong wrote:

> Now, it's not a "true" emulator: obviously it doesn't simulate the C64 on a 
> hardware
> level. It does however implement enough to load and run simple basic programs 
> that can
> show interesting PETSCII pictures by manipulating the colors and characters 
> on the screen.

As people have been asking me about this: NO - you cannot run any
existing C-64 software with my program. I should have put the word
emulator in quotes I suppose. The program is mostly an experiment with
tkinter graphics, in this case reproducing the C-64 (textmode) screen.
The 'BASIC interpreter' is just enough to be able to print stuff to the
screen and POKE the memory to change the contents of the screen and the
colors.

If you want to run your old c-64 software, use a _real_ emulator such as
Vice or ccs64 - this was never my goal :)

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


wrote a commodore-64 emulator using just Python

2017-08-13 Thread Irmen de Jong
Hi,

As another experiment with using just tkinter for graphics, this time I created 
a
Commodore-64 emulator. You can find it here https://github.com/irmen/pyc64
You only need the pillow library to be able to run this. I guess most people 
have that
one already anyway.

It works pretty well :)   (although having some slight speed/timing issues on 
windows)

Now, it's not a "true" emulator: obviously it doesn't simulate the C64 on a 
hardware
level. It does however implement enough to load and run simple basic programs 
that can
show interesting PETSCII pictures by manipulating the colors and characters on 
the screen.

And perhaps you can think of doing some other silly things because part of the 
BASIC
dialect is just executed using eval() in python. What about hooking this up as 
a ssh
client to get access to your server in a way nobody thought possible? :-P
There's also https://github.com/mnaberez/py65 so... possibilities?


Fun fact: emulator source is smaller than 64KB

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


Re: SSL/TLS support in Pyro4

2017-08-04 Thread Irmen de Jong
On 04/08/2017 15:44, Robin Becker wrote:
> ..
>>
>> Hi Robin
>>
>> I am not sure how this is any benefit over the self-signed root certs that I 
>> now use?
>>
>> Except for the fact that these are a root cert as well and don't use any CA 
>> trust chain.
>> To be able to validate this cert, I have to load it as a CA cert on the 
>> validating side.
>> Which isn't bad perse.
>>
>> I've used openssl as mentioned here to create my certs:
>> https://docs.python.org/3.7/library/ssl.html#self-signed-certificates
> .Welle I was thinking perhaps you had trouble with self signed certs 
> for some
> reason. I only used CA type setup because some recipe for mongo clusters 
> seems to want
> that. I think the mariadb clusters were fine with simple self signed certs. 
> However, if
> I control the cluster can I not just distribute the cert to all members and 
> have them
> validate it against itself or does python refuse to do that? I vaguely 
> remember some
> python apis allow the authority chain to be specified.

You can specify a CAcert using load_verify_locations on the ssl context. Is 
that what
you meant? I figured out that if you set that to the peer's certificate it will 
then be
accepted.  I understand it as much as "hey openssl here is a root cert that you 
should
trust if you encounter it".
Without doing this, the cert is denied on the SSL level (unless you set the ssl 
options
to no-cert-required but that is definitely not what I wanted)

Bottom line is I learned something new :)

And also that Python's standard ssl library isn't as bad as I remember it to be 
a few
years ago.  Is there still a reason to use, say, PyOpenSSL anymore?


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


Re: SSL/TLS support in Pyro4

2017-08-04 Thread Irmen de Jong
On 03/08/2017 20:30, Irmen de Jong wrote:

> Alternatively, is there a cheap way to get an 'official' SSL certificate for 
> testing
> purposes.  I don't think letsencrypt can help here because it is only for web 
> sites?
> (and their certs are only valid for a very short period)

With some host file trickery (had to fool my dev machine into thinking it is my 
web
server) I managed to get it all to work with a letsencrypt cert as well.

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


Re: SSL/TLS support in Pyro4

2017-08-04 Thread Irmen de Jong
On 04/08/2017 10:26, Robin Becker wrote:
> On 03/08/2017 19:30, Irmen de Jong wrote:
> .
>>
>> I wonder if any current (or new) users of Pyro4 want to check this out? The 
>> biggest
>> concern I have is that I only have dummy (self-signed) certificates so I 
>> can't test it
>> with "real" certs to see if the validation works correctly.
> ..
> 
> I've used self created authorities with mariadb and mongo to secure local 
> clusters.
> Could this provide private secure certs for pyro?

Hi Robin

I am not sure how this is any benefit over the self-signed root certs that I 
now use?

Except for the fact that these are a root cert as well and don't use any CA 
trust chain.
To be able to validate this cert, I have to load it as a CA cert on the 
validating side.
Which isn't bad perse.

I've used openssl as mentioned here to create my certs:
https://docs.python.org/3.7/library/ssl.html#self-signed-certificates


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


SSL/TLS support in Pyro4

2017-08-03 Thread Irmen de Jong
Hi,

Pyro4 (http://pyro4.readthedocs.io) allows you to call methods on Python 
objects running
on other machines, as if they were just normal local objects.

Regarding the network communication: it hasn't got any real security mechanisms 
built-in
and always explicitly depended on external tools or systems to provide this 
(such as VPN
or SSL tunneling). Until now: I've finally started adding SSL/TLS support to 
Pyro4
itself. The work-in-progress 4.62 version has it (git master branch). Docs are 
still
lacking right now but there is a working ssl example included.

I wonder if any current (or new) users of Pyro4 want to check this out? The 
biggest
concern I have is that I only have dummy (self-signed) certificates so I can't 
test it
with "real" certs to see if the validation works correctly.

Alternatively, is there a cheap way to get an 'official' SSL certificate for 
testing
purposes.  I don't think letsencrypt can help here because it is only for web 
sites?
(and their certs are only valid for a very short period)


Cheers
Irmen de Jong

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


Re: Issues with Python

2017-07-30 Thread Irmen de Jong
On 30/07/2017 23:31, Ode Idoko wrote:
> Hi, I am new to Python and though I have been able to download the 3.6 
> version on my laptop , I still have issues with the syntax. While writing a 
> program to execute, it will display syntax error with different shades of 
> color usually green or yellow. 
> What can I do about this? How do I know the error and effect it? Can't it be 
> programmed like we have in excel that will tell you error and prompt you if 
> you wish to accept the right formula format? 
> Please I need more information on this. 
> Thanks. 
> Ode 
> 
> Sent from my iPhone
> 

You'll have to learn the language if you want to do anything meaningful with it.
Python isn't anything like excel formula's, it is a full general multipurpose
programming language.  If you make a mistake, it usually is almost impossible 
to deduce
what you meant to write instead. (because otherwise we wouldn't have to program 
our
computers anymore and instead let them figure out automatically what we wanted 
to do,
right? Just joking)

Because you are comparing it to excel formulas: are you sure you've chosen the 
right
tool for whatever the task is that you wanted to solve?
If so: may I suggest first working through the Python tutorial.
https://docs.python.org/3/tutorial/index.html


Irmen

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


[issue31072] add filter to zipapp

2017-07-28 Thread Irmen de Jong

Irmen de Jong added the comment:

That sounds fine to me. I guess the paths passed to the function should be 
relative to the root folder being zipped?

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31072>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: zipapp should not include temporary files?

2017-07-28 Thread Irmen de Jong
On 28/07/2017 18:36, Irmen de Jong wrote:
> On 27/07/2017 00:03, Paul Moore wrote:
>> If you want to create a feature request for a filter function on 
>> bugs.python.org and assign it to me, I'll take a look at it. \
> 
> 
> I will do this, thanks in advance.

Should have included a link perhaps. Here it is: 
http://bugs.python.org/issue31072

Irmen

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


[issue31072] add filter to zipapp

2017-07-28 Thread Irmen de Jong

New submission from Irmen de Jong:

As briefly discussed on comp.lang.python, I propose to add an optional filter 
callback function to zipapp.create_archive.


The function could perhaps work like the os.walk generator or maybe just lets 
you to return a simple boolean for every folder/file that it wants to include 
in the zip.

My use case is that I sometimes don't want to include every file in the root 
folder into the zip file (I want to be able to skip temporary or irrelevant 
folders such as .git/.svn, .tox, .tmp and sometimes want to avoid including 
*.pyc/*.pyo files).  Right now, I first have to manually clean up the folder 
before I can use zipapp.create_archive.


(Instead of providing a filter callback fuction, another approach may be to 
provide your own dir/file generator instead, that fully replaces the internal 
file listing logic of zipapp.create_archive?)

--
assignee: paul.moore
components: Library (Lib)
keywords: easy
messages: 299409
nosy: irmen, paul.moore
priority: normal
severity: normal
status: open
title: add filter to zipapp
type: enhancement

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31072>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Installation Python 3.6.x on Windows using command line installer (without GUI)

2017-07-28 Thread Irmen de Jong
On 27/07/2017 20:55, Andreas Jung wrote:
> 
> I need to installed Python 3.6.x on Windows as part of an automated process 
> without user-interaction. Recently Python releases provided MSI files for 
> installation using the "msiexec" utility however there are no more MSI 
> release files available for Python 3.6.X. Are there any alternatives?
> 
> -aj
> 

https://docs.python.org/3/using/windows.html#installing-without-ui

Irmen

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


Re: zipapp should not include temporary files?

2017-07-28 Thread Irmen de Jong
On 27/07/2017 00:03, Paul Moore wrote:
> On Wednesday, 26 July 2017 18:37:15 UTC+1, Irmen de Jong  wrote:

>> What do you think? Should the zipapp module perhaps be improved to 
>> automatically skip
>> obvious temporary files or perhaps allow to provide a filter function?

> If you want to create a feature request for a filter function on 
> bugs.python.org and assign it to me, I'll take a look at it. \


I will do this, thanks in advance.

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


zipapp should not include temporary files?

2017-07-26 Thread Irmen de Jong
Hi,

when creating an executable zip file using the zipapp module, it's a little sad 
to see
that no effort is done to filter out obvious temporary files: the resulting 
zipfile
contains any *.pyc/pyo files and other things such as .git, .tox, .tmp folders.

The documentation says "zip is created from the contents of the directory" so 
strictly
speaking it's not wrong that it is doing this. However I think it is 
inconvenient,
because we either have to clean out the directory manually first before zipping 
it, or
afterwards, remove stuff from the resulting zipfile.

What do you think? Should the zipapp module perhaps be improved to 
automatically skip
obvious temporary files or perhaps allow to provide a filter function?


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


Re: JSON encoding PDF or Excel files in Python 2.7

2017-07-21 Thread Irmen de Jong
On 21/07/2017 20:52, Skip Montanaro wrote:
> I would like to JSON encode some PDF and Excel files. I can read the content:
> 
> pdf = open("somefile.pdf", "rb").read()
> 
> but now what?  json.dumps() insists on treating it as a string to be
> interpreted as utf-8, and bytes == str in Python 2.x. I can't
> json.dumps() a bytearray. I can pickle the raw content and json.dumps
> that, but I can't guarantee the listener at the other end will be
> written in Python. Am I going to have to do something like
> base64-encode the raw bytes to transmit them?
> 
> Thx,
> 
> Skip
> 

Yes, json is a text based format and can't contain arbitrary binary data. So 
you'll have
to encode the bytes into some textual form first.
If you think base-64 is too verbose you might try base-85 instead which is 
slightly more
efficient (available since python 3.4 in the base64 module)?

Irmen


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


Re: pythonhosted.org status?

2017-07-03 Thread Irmen de Jong
On 02/07/2017 11:27, breamore...@gmail.com wrote:
> On Sunday, July 2, 2017 at 10:03:34 AM UTC+1, Irmen de Jong wrote:
>> Hi,
>> I'm using pythonhosted.org to host the docs for various projects but it has 
>> either been
>> very slow or unavailable over the past week. Anyone else having the same 
>> problems?
>> Should I perhaps consider putting my docs on readthedocs.org instead?
>>
>> Irmen
> 
> I get:-
> 
> "Service Unavailable
> 
> The service is temporarily unavailable. Please try again later."
> 
> http://downforeveryoneorjustme.com says it's down.

Thanks, I forgot about that site. Quite handy for things like this.

I've decided to mirror my docs on readthedocs.org, an added bonus is their 
automated
documentation build system that relieves me from having to create, zip and 
upload the
docs myself.

> 
> Kindest regards.
> 
> Mark Lawrence.
> 

Cheers
Irmen

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


pythonhosted.org status?

2017-07-02 Thread Irmen de Jong
Hi,
I'm using pythonhosted.org to host the docs for various projects but it has 
either been
very slow or unavailable over the past week. Anyone else having the same 
problems?
Should I perhaps consider putting my docs on readthedocs.org instead?

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


Re: Progress on the Gilectomy

2017-06-10 Thread Irmen de Jong
On 10-6-2017 14:54, Steve D'Aprano wrote:
> Larry Hastings is working on removing the GIL from CPython:
> 
> https://lwn.net/Articles/723949/


Here is Larry's "How's it going" presentation from Pycon 2017 on this subject
https://www.youtube.com/watch?v=pLqv11ScGsQ

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


Re: Transitioning from Linux to Windows

2017-06-05 Thread Irmen de Jong
On 3-6-2017 15:44, chitt...@uah.edu wrote:
> Ideally, I would like to set up the user on their Windows 7/10 system so that 
> they can "login" to the ubuntu system (say putty) - change working directory 
> (to where desired) - run the script (on the ubuntu system) - and scp the file 
> back to the windows desktop.


You can use Pyro4 to directly call the python scripts running on your ubuntu 
system from
python code on the windows machines, thereby avoiding the hassle of having to 
deal with
a remote shell session.
It does require you to run a Pyro4 daemon on the linux box and deal with 
security in
some other way.

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


Re: Very Slow Disk Writes when Writing Large Data Blocks

2017-06-02 Thread Irmen de Jong
On 2-6-2017 20:14, remmm wrote:

> These write speeds are in the range of 18 to 25 MBytes per second for 
> spinning disks and about 50 Mbytes/sec for SSDs.  Keep in mind these numbers 
> should be more like 120 MBytes/sec for spinning disks and 300 MBytes/sec for 
> SSDs.  

You'll only reach those numbers in the ideal situation. Is there just one 
program doing
this disk i/o, sequentially, from a single thread?
If it is not, you are probably suffering disk i/o trashing once you filled up 
the
drive's cache buffers.

For example using Crystal Disk Mark on one of my HDD drives it reports max 60 
MBytes/sec
write speed sequentially in the ideal case (ok, it is not a very fast drive...) 
but only
0.7 (!) in the random 4k block case.

Apparently Linux deals with this better than Windows, for your situation.

Other than that the only other thing I can think of is interference of other 
programs on
the system, such as malware protection or anti-virus tooling that is trying to 
scan your
big files at the same time.  That should be visible in Window's resource 
monitor tool
however, I think.


> I've since written test code using just python "write" 

Post it somewhere?

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


Re: Bug or intended behavior?

2017-06-02 Thread Irmen de Jong
On 2-6-2017 19:17, sean.diza...@gmail.com wrote:
> Can someone please explain this to me?  Thanks in advance!
> 
> ~Sean
> 
> 
> Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
 print "foo %s" % 1-2
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: unsupported operand type(s) for -: 'str' and 'int'



The % operator has higher precedence than the - operator.
See https://docs.python.org/3/reference/expressions.html#operator-precedence
So what you wrote is equivalent to:

print ("foo %s" % 1) - 2

which means subtract the number 2 from the string "foo 1". Hence the error.

Solution is to use parentheses to make sure the things are evaluated in the 
order you
intended:

print "foo %s" % (1-2)


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


adding type hints to one of my projects, things learned

2017-05-24 Thread Irmen de Jong
is really used even if it is just a type 
hint comment.
  To be honest, PyCharm has a point, because it is *mypy* that uses it, not 
*python*...
  But it causes me to have to accept several warnings that aren't.

- The code becomes harder to read. In some cases, _a lot harder_ because
  some type hints can become quite elaborate (list of dicts mapping str to 
tuple... etc)
  You can ease the pain a bit by creating your own type classes but
  this clutters the module namespace.



Things learned, thoughts


After adding type hints to all of Tale's code, a lot of time
was spent fixing mistakes (in the hints I wrote) and several bugs (that mypy 
found).

After all of this, I learned that

- using type hints helps uncover bugs and improves IDE feedback and code 
understanding
- it is quite a lot of work to add it to an existing code base and "get it 
right" (= no
mypy errors)
- it has to be done in an 'unnatural' way sometimes, because of the way Python 
parses stuff
- it can clutter up code that was very concise and clean before.


But the most important thing really:

**...static typing (via type hints + mypy tooling) clashes with Python's 
dynamic duck
type nature.**
It all still feels 'off' to me, in the context of Python. It introduces new 
kinds of
problems, that we didn't have
without them, and the syntax is not as 'natural' as I hoped.

Right now, I am not really sure if I want to continue to use type hints.
In Tale I probably will because it now has them everywhere already, but
my other projects have to wait.

As this is the first and only time so far that I have used type hints,
it is very likely that I made some mistakes or missed a better solution to
some of the issues I encountered.
Please correct me on them or give me some tips on improving my application
and understanding of Python's type hints. Thank you!



Irmen de Jong
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SSL certificate of a server on Windows

2017-05-23 Thread Irmen de Jong
On 23-5-2017 10:19, COPIN Mathieu. wrote:
> Hi, 
> 
> I want to get a server certificate from the host-name.
> 
> I know I could do something like :
>> call(openssl, s_client, -showcerts, -connect, hostname:port)
> 
> 
> But the thing is to do it without openssl because I want to run the script on 
> Windows.
> 
> Any suggestions ?
> Mathieu
> 

I guess you mean: without calling "openssl.exe"


import ssl
cert = sll.get_server_certificate(("www.google.com", 443))

See
https://docs.python.org/3.6/library/ssl.html#ssl.get_server_certificate



Irmen


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


Re: How to install Python package from source on Windows

2017-05-18 Thread Irmen de Jong
On 18-5-2017 3:30, Dennis Lee Bieber wrote:
>   Late-comer... I'm pretty sure 1.4, if not 1.3 was the version
> documented in the first books I bought on the language...
> 
>   And I bought because AmigaOS was listed as a viable candidate (thanks
> Irmen) -- within a week I had written an outgoing SMTP daemon that
> correctly handled TO/CC/BCC while relaying through my ISP (Using AREXX to
> SPOOL outgoing messages from AmigaELM

(offtopic:)
Awesome. I remember it was a lot of fun and a good learning opportunity for me 
back in
the days to port Python to AmigaOS and even adding some AREXX support to it as 
well.
I think the latest version I ported was Python 2.0 somewhere in the 2000's. 
Always nice
to hear people actually used it :)

-irmen

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


Re: Out of memory while reading excel file

2017-05-10 Thread Irmen de Jong
On 10-5-2017 17:12, Mahmood Naderan wrote:

> So, I think numpy is unable to manage the memory.

That assumption is very likely to be incorrect.


>> np.array([[i.value for i in j] for j in p.rows])

I think the problem is in the way you feed your excel data into the numpy array
constructor. The code above builds many redundant python lists from the data 
you already
have in memory, before even calling the numpy array function.

I strongly suggest finding a proven piece of code to read large excel files 
like the
example from Peter Otten's reply.

Irmen

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


Re: Install python via MS batch file

2017-05-06 Thread Irmen de Jong
On 6-5-2017 7:14, Mahmood Naderan wrote:
> Hello,
> I have downloaded python-3.6.1-amd64.exe and it is fine to install it through 
> GUI. However, I want to write a batch file to install it via command line. 
> Since the installation process is interactive, it seems that the auto-install 
> batch file is difficult. What I want to do is:
> 
> set python path
> install in the default location.
> 
> Any idea about that?
> 
> 
>  Regards,
> Mahmood
> 


Yeah, there should be extensive support for this.
See https://docs.python.org/3/using/windows.html#installing-without-ui

(I haven't tried it myself though)

Irmen

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


Re: write arrays to disk

2017-04-16 Thread Irmen de Jong
On 16-4-2017 14:28, jorge.conr...@cptec.inpe.br wrote:
> Hi,
> 
> I'm new on Python software. I would like to write on disk arrays in binary or 
> ascii
> format. Can someone please help me?
> 
> Thanks,
> 
> Conrado

What kind of data is in the arrays?
Who or what will be reading the files?
And most importantly: what have you tried yourself so far?

Irmen

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


Re: IOError: [Errno 12] Not enough space

2017-04-12 Thread Irmen de Jong
On 12-4-2017 7:54, LnT wrote:
> 
> Hi Irmen,
> 
> you may please find full log @ https://pastebin.mozilla.org/9018753

I have no idea what I'm looking at.

But my initial response was wrong, see the reply by eryk sun; your error has 
nothing to
do with disk space but rather, a lack of system memory.

Irmen

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


Re: IOError: [Errno 12] Not enough space

2017-04-11 Thread Irmen de Jong
On 11-4-2017 14:30, LnT wrote:
> Hi,
> 
> version information
> 
> python 27

Please be more precise, there is no Python 27. (Yeah it is clear you meant 2.7 
but still)

> java version "1.8.0_111"
That should not be relevant

> OS -Win 10 , 64Bit , 8GB RAM , 60GB HD

60 GB is not a lot of space for windows...


> executing python test script (robotframework) for a we bapplication 
> Application url will be invoked by Firefox 38.0
> 
> Please find below log:
> 
> Opening browser 'firefox' to base url 'https://onbdev.nbpa.com/zae'
> [ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No 
> browser is open
> | FAIL |
> IOError: [Errno 12] Not enough space
> 

That's not much information. Is there really not anything else in the log? Like 
a
traceback, that may give some clues what the application is doing when it is 
running out
of disk space?


> 
> I have cleared %TEMP% and reran the script.
> But still I see this.
> 
> Could you please show me some Light ?
> 

Based on the info you provided, the only solution I can think of is: free more 
space.
Something in your application is trying to write stuff and there's simply not 
enough
space on the disk to do so.


-i


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


Re: python and databases

2017-03-14 Thread Irmen de Jong
On 14-3-2017 20:59, Xristos Xristoou wrote:
> I have a database in  microsoft ACCESS with about 150 records.. if I want to 
> get some
> data from this database using  a query in python and i want to store in some
> variables in python that will do this ? to avoid the 150 if ...: Using the 
> standard
> library the python? know easily put it an SQL query but i canot use additional
> library python.
> 

Is the data in the Access database static? 150 records is not much data. You 
might be
able to extract it ONCE, and store it directly in Python data structures 
instead. Or
extract it and store it in a sqlite database instead, which you can use from 
Python
using the standard library's sqlite3 module.

If the data is dynamic however because it is being changed by other sources, 
you'll have
to use a third party library to get to it I think


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


Re: Error installing python on Windows

2017-02-24 Thread Irmen de Jong
On 24-2-2017 12:18, Michelle Tan wrote:
> Hello all
> 
> I am new to python.
> 
> Trying to install Python and encountered this error message : "The program
> can't start because api-ms-win-crt-runtime-I1-1-0.dll is missing from your
> computer."
> 
> Tried to repair and reinstall Python however i may have missed out some
> installation. What should I do to resolve this issue?  Thanks for your
> help!
> 

Make sure your windows is up to date! That dll should be installed as part of 
one of the
regular windows updates. Google may be able to tell you the specific KB number 
of the
particular update.


Irmen

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


Re: Python 3.6 installation doesn't add launcher to PATH

2017-02-24 Thread Irmen de Jong
On 24-2-2017 13:38, ChrisW wrote:
> The installation guidelines for Python 3.6 say:
> 
> "Per-user installations of Python do not add the launcher to PATH unless the 
> option was selected on installation." 
> (https://docs.python.org/3/using/windows.html#from-the-command-line).
> 
> However, I've installed Python 3.6 with the 'include PATH' checkbox ticked 
> for my user only, and although C:\Windows\py.exe exists, it has not been 
> added to my PATH. 
> 
> I also tried installing for all users, and this also doesn't add it to the 
> PATH.
> 
> Is this a bug, or have I done something wrong?!
> 

Hm, I don't remember having this issue when installing this myself.

Are you sure you're checking it from a newly opened cmd.exe *after* the install
finished?  Already opened windows won't see the change until restarted.

Irmen

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


Re: How to create a Python 3.6 traceroute without SOCK RAW?

2017-02-23 Thread Irmen de Jong
On 24-2-2017 0:20, Juan C. wrote:
> On Thu, Feb 23, 2017 at 7:42 PM, Irmen de Jong <irmen.nos...@xs4all.nl> wrote:
>>
>> import os
>> os.system("traceroute www.google.com")
> 
> Indeed, that would work, but it isn't a great approach in my opinion
> because I would rely on a system command, in this case Windows uses
> tracert while UNIX uses traceroute, one could fix that with a if-else
> to check the os and then use the correct command, but it just make it
> feel even more like a workaround and not a definitive solution.
> 

I don't consider this a workaround at all. Why reinvent the wheel?
Also: once you're going to deal with low level socket API you're going to run 
into
platform differences anyway.

Irmen

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


Re: How to create a Python 3.6 traceroute without SOCK RAW?

2017-02-23 Thread Irmen de Jong
On 23-2-2017 22:33, Juan C. wrote:
> I need to implement a traceroute inside my script but I can't escalate 
> privileges.  Unix uses UDP for traceroute, but I didn't find any material 
> regarding UDP traceroute in Python.

import os
os.system("traceroute www.google.com")

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


Re: python decorator

2017-02-22 Thread Irmen de Jong
On 22-2-2017 8:39, Argentinian Black ops lll wrote:
> Thanks for the quick response...! you saved me a lot of time, thank you!
> 

I don't know if you want/have to use your own custom caching decorator, but are 
you
aware of the lru_cache decorator that's part of the standard library?

https://docs.python.org/3/library/functools.html#functools.lru_cache


Irmen

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


Re: CSV

2017-02-22 Thread Irmen de Jong
On 22-2-2017 18:26, Braxton Alfred wrote:
> Why does this not run?  It is right out of the CSV file in the Standard Lib.

What does "not run" mean.
We can't help if you are not telling us the exact error message you're getting 
(if any)


> filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv'

That being said, there's at least a problem with this line because you're not 
escaping
the backslashes. So the resulting filename string is not what you intended it 
to be (try
printing it to see what I mean).

Several solutions possible:
- switch to using forward slashes /  this works on windows too.
- use a raw string literal  r'.'
- or escape the backslashes \\


Irmen

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


Re: WANT: bad code in python (for refactoring example)

2017-02-14 Thread Irmen de Jong
On 14-2-2017 23:44, Makoto Kuwata wrote:
> Hi,
> 
> Is there any *just right* python code to refactor?
> In other words, I'm finding bad code example in python.
> 
> (background)
> I'm teaching Python to some novice programmer, and
> want to show refactoring example to them.
> 
> (required)
> * not good code
> * not too large (for novice programmer)
> * not too complex (for novice programmer)
> * released under open source license
> 
> If you know good material in github or bitbucket to refactor,
> let me know it.
> 
> --
> regards,
> kwatch
> 


No code in text form, but I find the following video by Raymond Hettinger very 
clear
about the values of refactoring otherwise seemingly fine code

https://youtu.be/wf-BqAjZb8M?t=12m39s

code starts at 12 min. 40 sec.

It does require a bit of background knowledge about Python and the PEP8 code 
style and
API design.

Irmen

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


Re: What library/package to use for parsing XML?

2017-01-30 Thread Irmen de Jong
On 30-1-2017 18:58, Chris Green wrote:
> I want to parse some XML data, it's the address book data from the
> linux program osmo.  The file I want to parse is like this:-
> 

[snip]

> 
> I basically want to be able to extract the data and output in other
> formats - e.g. write to a Sqlite3 database and/or CSV.
> 
> So what do I need to import (and probably install first) to do this?

No need to install anything. Python has batteries included.

Parse your XML with xml.etree.ElementTree
[https://docs.python.org/3/library/xml.etree.elementtree.html]
Read/write CSV with csv
[https://docs.python.org/3/library/csv.html]
Put stuff in sqlite3 database and query it using sqlite3
[https://docs.python.org/3/library/sqlite3.html]


-irmen


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


Re: What are your opinions on .NET Core vs Python?

2017-01-30 Thread Irmen de Jong
On 30-1-2017 21:33, Joseph L. Casale wrote:
>> Python still has my heart, but .NET Core tempts me. One great thing of
>> coding in C# would be no GIL.
> 
> Seriously, check out the benchmarks at https://github.com/aspnet/benchmarks.

Results vary quite a bit there.
For instance take the json serialization benchmark:
https://www.techempower.com/benchmarks/#section=data-r13=ph=json
There's 6 python frameworks performing better than aspcore in this chart...


Irmen

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


Re: Cannot import GDAL

2017-01-11 Thread Irmen de Jong
On 11-1-2017 18:31, Falter, Donald [USA] wrote:
> I am new to Python and I am trying to utilize GDAL.  I installed Python 3.6.
> I installed the following: gdal-201-1800-core.msi and 
> GDAL-2.1.2.win32-py3.4.msi.

Those don't match. You'll have to use a MSI built for py3.6, one thinks.

Either install and use Python 3.4 with this (rather than 3.6) or find the 
approprite
installer for python 3.6. It seems that you can get one here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal


Irmen

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


Re: Work between multiple processes

2017-01-11 Thread Irmen de Jong
On 10-1-2017 23:57, Patrick Zhou wrote:
> Hi Irmen,
> 
> I have successfully got it to work with both side as python but so far having 
> trouble with pyrolite.jar which is downloaded from 
> https://mvnrepository.com/artifact/net.razorvine/pyrolite/4.4
> 
> 

[...]

> 
> which "getDst" works on Java but hangs on handshake() in the call function. 
> 
> Any thought? Thanks. -P
> 

Yeah, don't use the oldest version of the library available, use the newest ;-)
https://mvnrepository.com/artifact/net.razorvine/pyrolite/4.15


Irmen

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


Re: Announcement: TLSv1.2 will become mandatory in the future for Python.org Sites

2017-01-10 Thread Irmen de Jong
On 10-1-2017 16:01, Donald Stufft wrote:
>> TypeError: the JSON object must be str, not ‘bytes'
> Huh, just tested, my original snippet works on Python 3.6 but fails on Python 
> 3.5. 


My guess is that is due to an improvement in 3.6 mentioned here:
https://docs.python.org/3/whatsnew/3.6.html#json

Irmen


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


Re: Work between multiple processes

2017-01-06 Thread Irmen de Jong
On 4-1-2017 23:14, zxpat...@gmail.com wrote:
> Hi everyone,
>
> I ran into a case that I need to create a work process of an application
(Jython so has to call using java.exe) which will collect the data based on 
what main process indicates.
>
> (1) I tried multiprocessing package, no luck. Java.exe can't be called from
Process class?
>
> (2) I tried subprocess. subprocess.communicate function will wait for the
work process to terminate so to return.
>
>
> either (1) or (2) doesn't work out well. Please suggest.  Global system
queue?
>
> Thanks,
> Patrick.
>


Is it a requirement that the workdf process is also Jython?

If not: you could spawn a Python subprocess that hosts a Pyro4 daemon. 
Utilizing the Pyrolite java client library you can call methods in it from the 
java/jython side.  (Unfortunately it is not yet possible (due to jython 
incompatibilities) to use the full Pyro4 library on the Jython side as well). 
Not sure if it meets your set of requirements but have a look at 
http://pythonhosted.org/Pyro4/
http://pythonhosted.org/Pyro4/pyrolite.html


Irmen

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


Re: Work between multiple processes

2017-01-05 Thread Irmen de Jong
On 4-1-2017 23:14, zxpat...@gmail.com wrote:
> Hi everyone,
> 
> I ran into a case that I need to create a work process of an application 
> (Jython so has to call using java.exe) which will collect the data based on 
> what main process indicates. 
> 
> (1) I tried multiprocessing package, no luck. Java.exe can't be called from 
> Process class?
> 
> (2) I tried subprocess. subprocess.communicate function will wait for the 
> work process to terminate so to return.
> 
>  
> either (1) or (2) doesn't work out well. Please suggest.  Global system queue?
> 
> Thanks,
> Patrick.
> 


Is it a requirement that the workdf process is also Jython?

If not: you could spawn a Python subprocess that hosts a Pyro4 daemon.
Utilizing the Pyrolite java client library you can call methods in it from the
java/jython side.  (Unfortunately it is not yet possible (due to jython
incompatibilities) to use the full Pyro4 library on the Jython side as well).
Not sure if it meets your set of requirements but have a look at
http://pythonhosted.org/Pyro4/
http://pythonhosted.org/Pyro4/pyrolite.html


Irmen

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-02 Thread Irmen de Jong
On 2-1-2017 12:38, Antonio Caminero Garcia wrote:

> The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ, 
> Pycharm)
> is that they look like a space craft dashboard and that unwarranted resources
> consumption and the unnecessary icons. I want my IDE to be minimalistic but 
> powerful.
> My screen should be mostly “made of code” as usually happens in Vim, Sublime 
> or Atom.
> However, Pycharm is really cool and python oriented.

[...]

> Sublime is my current and preferred code editor. 


If you like Sublime, and its minimalistic 'Distraction Free Mode', you'll be 
delighted
to know that this exact same feature is in PyCharm as well.
Select it (View->Enter distraction free mode), and gone is all the screen 
clutter and
even the menu bar if you so desire. You can focus on just your code. And all of
PyCharm's features are still there a mouse click or keyboard shortcut away.


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


Re: Printing a generator returns "", need to print its values

2016-12-05 Thread Irmen de Jong
On 5-12-2016 19:39, vmaha...@centerpointmedia.com wrote:
> On Wednesday, November 16, 2016 at 3:25:39 PM UTC-5, Peter Otten wrote:
>> vmaha...@centerpointmedia.com wrote:
>>
>>> I am running Python2.7, wherein I am running the following price of code:
>>>
>>> y = m.predict(input_fn=lambda:input_fn(df_predict), as_iterable=True)
>>> print ('Predictions: {}'.format(str(y)))
>>>
>>> The output of the following is "">> 0x7f0476373e10>"
>>>
>>> However, the desired output must be in the format [1 0 0 1 1 0 0 1].
>>>
>>> Can someone help me print the output in this format
>>
>> You give no context, but my suggestion would be to try and omit the 
>>
>> as_iterable=True
>>
>> part...
> 
> 
> Can someone help me print a generator object?
> 

Have you tried Peter's suggestion?

If that didn't work (but what is that as_iterable argument for then?) just 
iterate over
the result and print each value as it comes out of the generator:

print("Predictions:")
for value in y:
print(value)


Irmen

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


[issue28673] pyro4 with more than 15 threads often crashes 2.7.12

2016-11-24 Thread Irmen de Jong

Irmen de Jong added the comment:

The 28673-reproduce.py didn't crash on any of the systems I've tried it on. Are 
you sure it is complete? It looks like a part is missing.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28673>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28673] pyro4 with more than 15 threads often crashes 2.7.12

2016-11-23 Thread Irmen de Jong

Irmen de Jong added the comment:

Due to lack of example code to reproduce the issue, and because I'm mildly 
interested in this bug because it mentions Pyro4 (because I'm the author of 
that) I've tried to crash my system myself using Pyro4 and a simple torture 
test but it trucked on just fine. 
Pyro4 is not doing any "strange" things as far as I am aware. It does have its 
own (simple) thread pool of regular Python threads that are handling incoming 
proxy connections.
(Had Pyro4 been doing weird things I suppose Python itself still should never 
core dump on the user but rather raise a regular exception if something was 
wrong)

--
nosy: +irmen

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28673>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Result is not Displayed

2016-11-22 Thread Irmen de Jong
On 22-11-2016 9:18, prihantoro2...@gmail.com wrote:
> Dear all, 
> 
> i am new to Python and have this problem
> 
> =
> import nltk
> puzzle_letters = nltk.FreqDist('egivrvonl')
> obligatory = 'r'
> wordlist = nltk.corpus.words.words()
> [w for w in wordlist if len(w) >= 6
> and obligatory in w
> and nltk.FreqDist(w) <= puzzle_letters]
> print puzzle_letters
> ==
> 
> this gives me 
> while the expected outcome is ['glover', 'govern', ...]
> did i miss something?


Review your code carefully. You're printing the wrong thing at the end, and 
you're doing
nothing with the list comprehension that comes before it.

-irmen

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


Re: First security bug related to f-strings

2016-11-05 Thread Irmen de Jong
On 5-11-2016 19:08, eryk sun wrote:
> On Sat, Nov 5, 2016 at 5:33 PM, Irmen de Jong <irmen.nos...@xs4all.nl> wrote:
>> I think perhaps we should have a command line option / environment variable 
>> to be able
>> to disable 'eval' altogether
> 
> I don't think that's practical. exec and eval are commonly used by
> shells and IDEs such as IDLE and IPython. In the standard library,
> importlib and namedtuple are two important users of exec. Just try
> `import builtins; del builtins.exec, builtins.eval`.
> 

Perhaps. But in those cases you could just leave things on the default.
If you choose to run the interpreter with eval (and exec) disabled, you should 
be aware
that you'll break tools like that. But for other situations (web server etc) it 
could
still be useful? I do agree that not being able to use namedtuple (and perhaps 
other
things from the stdlib) is a problem then.


It was just a thought

Irmen

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


Re: First security bug related to f-strings

2016-11-05 Thread Irmen de Jong
On 5-11-2016 18:12, Steve D'Aprano wrote:
> Well, that didn't take very long at all.
> 
> Here's the first security bug which is related to the new (and badly
> misnamed) f-string feature:
> 
> http://bugs.python.org/issue28563


I think perhaps we should have a command line option / environment variable to 
be able
to disable 'eval' altogether

Irmen

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


Re: Reading Fortran Ascii output using python

2016-10-31 Thread Irmen de Jong
On 31-10-2016 19:24, Irmen de Jong wrote:
> So there must be something in that line in your file that it considers an EOF.

I meant to type EOL there. (end-of-line/newline).

Irmen

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


Re: Reading Fortran Ascii output using python

2016-10-31 Thread Irmen de Jong
On 31-10-2016 18:46, Heli wrote:

> Thanks Irmen, 
> 
> I tried with "rU" but that did not make a difference. The problem is a line 
> that with one single write statement in my fortran code :
> 
> write(UNIT=9,FMT="(99g20.8)")  value
> 
> seems to be read in two python inputfile.readline(). 
> 
> Any ideas how I should be fixing this?
> 
> Thanks, 
> 

We don't speak Fortran here (at least I don't).
Please show your Python code. What is 'inputfile'?
Also, in Python, the readline method is defined as:

>>> help(io.TextIOBase.readline)
Help on method_descriptor:

readline(...)
Read until newline or EOF.

Returns an empty string if EOF is hit immediately.

So there must be something in that line in your file that it considers an EOF.
Have you tried opening it in a regular text editor and inspecting what the 
characters
are on that particular line?


Irmen

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


Re: Reading Fortran Ascii output using python

2016-10-31 Thread Irmen de Jong
On 31-10-2016 18:20, Heli wrote:
> Hi all, 
> 
> I am trying to read an ascii file written in Fortran90 using python. I am 
> reading this file by opening the input file and then reading using:
> 
> inputfile.readline()
> 
> On each line of the ascii file I have a few numbers like this:
> 
> line 1: 1
> line 2: 1000.834739 2000.38473 3000.349798 
> line 3: 1000 2000 5000.69394 99934.374638 54646.9784
> 
> The problem is when I have more than 3 numbers on the same line such as line 
> 3, python seems to read this using two reads. This makes the above example 
> will be read like this:
> 
> line 1: 1
> line 2: 1000.834739 2000.38473 3000.349798 
> line 3: 1000 2000 5000.69394 
> line 4: 99934.374638 54646.9784
> 
> How can I fix this for each fortran line to be read correctly using python?
> 
> Thanks in Advance for your help, 
>  
> 

You don't show any code so it's hard to say what is going on.
My guess is that your file contains spurious newlines and/or CRLF combinations.

Try opening the file in universal newline mode and see what happens?

with open("fortranfile.txt", "rU") as f:
for line in f:
print("LINE:", line)


Irmen

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


Re: 3.5.2

2016-10-25 Thread Irmen de Jong
On 25-10-2016 2:11, Kenneth L Stege wrote:
> Im running windows 7 pro, 64 bit. I downloaded 3.5.2 64 bit and when I try to 
> run I get the error message  api-ms-win-crt-runtime-l1-1-0.dll is missing. I 
> loaded that file and still will not run.   
> suggestions?
> thanks
> 

http://lmgtfy.com/?q=api-ms-win-crt-runtime-l1-1-0.dll+missing+windows+7
-- 
https://mail.python.org/mailman/listinfo/python-list


Pyro4 now with remote iterators

2016-10-19 Thread Irmen de Jong
Hi,

I have just released Pyro4 version 4.49; https://pypi.python.org/pypi/Pyro4

(super short description: it is a library that allows you to transparently call 
methods
on objects that are running on other machines, as if they were local)

Pyro now also supports remote iterators. This means you can loop over a remote 
iterator
(or generator) that is running on another machine, and get the items on demand 
as they
are consumed by your client code.

Server:

class RemoteObject:
@Pyro4.expose
def numbers(self):
i = 0
while i<10:
yield i
i += 1

Client:

r = Pyro4.Proxy(".")
for number in r.numbers():
print(number)


When used correctly this feature can avoid having to build large data 
structures and
returning those all at once from a remote call. Instead, you now can return them
piecemeal and only that which is actually used by the client.

The feature is also supported by the Pyrolite client library for Java and 
.NET/C#.
I think it is pretty nifty and interesting enough to post about it here :)


Regards
Irmen de Jong
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: cannot import name pyhop

2016-10-18 Thread Irmen de Jong
On 18-10-2016 19:14, Gipper wrote:
> On Friday, October 14, 2016 at 1:05:03 PM UTC-5, Irmen de Jong wrote:
>> On 14-10-2016 7:31, Gipper wrote:
>>> I'm trying to run a script that calls pyhop (from pyhop import pyhop).  
>>> Details here > https://docs.extrahop.com/5.0/extrahop-python-api/#metrics
>>>
>>> I've followed the directions to install and import pyhop, but no matter 
>>> what I do, I always get the following error when running a script that 
>>> calls pyhop >
>>>
>>> Traceback (most recent call last):
>>>   File "Migration.py", line 1, in 
>>> from pyhop import pyhop
>>> ImportError: cannot import name pyhop
>>>
>>> Any ideas where I'm going wrong?  
>>>
>>
>> What does:
>>
>> import pyhop
>> print(pyhop.__file__)
>>
>> tell you?
>>
>> -Irmen
> 
> 
> C:\Python27\Lib\site-packages\pyhop\__init__.pyc

   ^^^
Are you sure it says .pyc? That looks weird to me, usually you get a .py file 
here.
It seems the installation of the module didn't go as it should have.
Have a look in your C:\Python27\Lib\site-packages\pyhop\ directory to get a 
clue why
there's no 'pyhop' symbol made available.  Is there a pyhop.py[c] there? Is 
there even a
readable __init__.py in there that you can study to see why there's no 'pyhop' 
symbol in
there?


Irmen

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


Re: Writing library documentation?

2016-10-16 Thread Irmen de Jong
On 16-10-2016 19:41, tshep...@rcsreg.com wrote:
> Is there a standard or best way to write documentation for
> a particular python library?  I'd mostly target HTML, I guess.
> 
> Thanks!
> 
> 
> Tobiah
> 

I guess most people use Sphinx for this task
http://www.sphinx-doc.org/

You can use various themes to customize your html output.

Irmen

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


Re: trying to make a simple program help please :)

2016-10-14 Thread Irmen de Jong
Right, another troll.

plonk


Irmen

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


Re: trying to make a simple program help please :)

2016-10-14 Thread Irmen de Jong
On 14-10-2016 20:11, LongHairLuke wrote:
> Hi, l l am trying to make a simple guess program. This is my script: 
> 
> def main():
> print ("Guess a letter between a and e")
> randomNumber = b
> 
> userGuess = input("Your guess: ")
> 
> if userGuess == randomNumber:
>  print("You got it")
> else:
>  print ("That's not it")
> 
> main()
> 
> 
> When l run the program l get error: userGuess is not defined, but l defined 
> userGuess at line 5. I don't get it someone plese help :) 
> 
> Lukas Alberts 
> 

The indentation of the if/else statement in your program is off.  Fix it by 
properly
indenting the if-else to be at the same indentation level as the other lines 
that should
be part of the main() function.


Irmen

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


Re: cannot import name pyhop

2016-10-14 Thread Irmen de Jong
On 14-10-2016 7:31, Gipper wrote:
> I'm trying to run a script that calls pyhop (from pyhop import pyhop).  
> Details here > https://docs.extrahop.com/5.0/extrahop-python-api/#metrics
> 
> I've followed the directions to install and import pyhop, but no matter what 
> I do, I always get the following error when running a script that calls pyhop 
> >
> 
> Traceback (most recent call last):
>   File "Migration.py", line 1, in 
> from pyhop import pyhop
> ImportError: cannot import name pyhop
> 
> Any ideas where I'm going wrong?  
> 

What does:

import pyhop
print(pyhop.__file__)

tell you?

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


Re: Without compilation, how to find bugs?

2016-10-13 Thread Irmen de Jong
On 14-10-2016 1:07, pozz wrote:
> All the tricks have a common goal: to discover bugs as soon as possible, 
> mostly during
> compilation process. Indeed I usually find some bugs during compilation (or 
> static
> analysis). It seems to me very important.

I wanted to reply a bit more to this paragraph as well.

I agree that finding bugs as soon as possible is nice, but the thing to keep in 
mind is
that the kind of bugs you find during compilation are almost always syntactic 
errors,
typos or other simple mistakes. I think semantic and logic errors are usually 
the ones
that have the biggest impact and take by far the most time to debug and fix. 
These bugs
mostly cannot be detected by compilers anyway. A syntactically valid program 
can do
something completely bogus (and almost always does because humans make mistakes 
when
designing and building it)

In my personal experience I find that I make a lot LESS syntactic errors and 
simple
mistakes in Python than in other languages. Mostly because Python produces very 
clear
and concise programs when compared to other languages (especially languages as 
low level
as C).  A function of 30 lines in Python has a lot less chance to have a bug 
than an
equivalent function that requires 300 lines to write elsewhere.

Bottom line: >I< don't really need static compiler checks when working in 
Python.  I do
miss them sometimes when refactoring stuff, but that's where a solid unit test 
suite
comes to the rescue.


Irmen

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


Re: Without compilation, how to find bugs?

2016-10-13 Thread Irmen de Jong
On 14-10-2016 1:07, pozz wrote:
> I come from the C language, that is a compiled and strongly typed language. 

C is far from a strongly typed language, IMO...
You can convert (cast) almost anything to anything else without compiler errors.
Have a a float? Ah yes no I mean treat it as a pointer to a function taking a 
char*
instead. Things can blow up majorly at runtime (segfault or worse)
Python is much more strongly typed than this. You can never do something to an 
object
that is not defined in its interface, and an object is always exactly known to 
be of one
particular type.

Perhaps you're thinking about statically typed versus dynamically typed?

> I learned
> many good tricks to write good code in C: choose a coding style, turn on as 
> many
> warnings as possible, explicitly declare static variables and functions (when 
> needed),
> explicitly declare const variables (if the piece of code will not change 
> them),
> explicitly declare all the functions, and so on.
> 
> All the tricks have a common goal: to discover bugs as soon as possible, 
> mostly during
> compilation process. Indeed I usually find some bugs during compilation (or 
> static
> analysis). It seems to me very important.
> 
> Now I'm learning Python and it appears to me very simple, but at the same 
> time highly
> dangerous. For example, I can write a function that accepts two arguments and 
> call it
> with only one argument. I can execute the script without any problem and I 
> will not
> notice the bug until I test exactly the erroneous line of code (the call with 
> only one
> argument).
> 
> However, I think the language interpreter could emit the error before 
> launching the
> script even without executing the wrong instruction, because it perfectly 
> knows how many
> arguments the function wants and that one instruction calls it with a wrong 
> number of
> arguments.
> 
> Are the things exactly how I understood, or do I miss something in Python?

Python is a *very* dynamic language so static checks are usually extremely hard 
to do.
Recent IDEs and tools (checkers, linters) have made some progress though, and 
type hints
have been added to the language recently to support this.

The biggie I think is that in the Python world the concept of *unit tests* is an
extremely important one. That is (I feel) the major tool being used to not only 
find
existing bugs, but also to avoid introducing new ones while changing the 
program.

Something which I believe you need everywhere else as well, regardless of 
programming
language. Proper unit testing (and testing in general) is much more powerful 
than
placing a lot of trust in the compiler.


Irmen

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


Re: [RELEASE] Python 3.6.0b2 is now available

2016-10-13 Thread Irmen de Jong
On 13-10-2016 23:43, MRAB wrote:
> On 2016-10-13 20:42, Irmen de Jong wrote:
>> On 12-10-2016 12:56, Robin Becker wrote:
>>
>>> I notice an extra space at the windows command prompt compared with 3.5, is 
>>> that
>>> deliberate?
>>>
>>>> C:\ux\XB33>\python35\python
>>>> Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 
>>>> bit (AMD64)]
>>>> on win32
>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>>> import sys
>>>>>>>
>>>
>>>> C:\ux\XB33\repos\pyRXP>..\..\py36_amd64\Scripts\python.exe
>>>> Python 3.6.0b2 (default, Oct 10 2016, 21:15:32) [MSC v.1900 64 bit 
>>>> (AMD64)] on win32
>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>>>  import sys
>>>
>>
>> I'm not seeing this... (using the 32 bits version on win7)
>>
>> Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit 
>> (Intel)] on
>> win32
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import sys
>>>>>
>>
> That's Python 3.5.1. The issue is with Python 3.6.0b2.
> 

Wow that was stupid, sorry. Anyway, I'm not seeing it with 3.6.0b2 either:

Python 3.6.0b2 (v3.6.0b2:b9fadc7d1c3f, Oct 10 2016, 20:36:51) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>>


Irmen

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


Re: [RELEASE] Python 3.6.0b2 is now available

2016-10-13 Thread Irmen de Jong
Anyone else having problems with pip and python 3.6.0b2?
Pip now fails to create launcher scripts:

  File "c:\python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 
351, in
_get_launcher
result = finder(distlib_package).find(name).bytes
  File "c:\python36\lib\site-packages\pip\_vendor\distlib\resources.py", line 
324, in finder
raise DistlibException('Unable to locate finder for %r' % package)
pip._vendor.distlib.DistlibException: Unable to locate finder for 
'pip._vendor.distlib'


Using latest pip and distlib versions.
Python 3.6.0b2 32-bits on Windows 7.


Irmen

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


Re: [RELEASE] Python 3.6.0b2 is now available

2016-10-13 Thread Irmen de Jong
On 12-10-2016 12:56, Robin Becker wrote:

> I notice an extra space at the windows command prompt compared with 3.5, is 
> that
> deliberate?
> 
>> C:\ux\XB33>\python35\python
>> Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit 
>> (AMD64)]
>> on win32
>> Type "help", "copyright", "credits" or "license" for more information.
> import sys
>
> 
>> C:\ux\XB33\repos\pyRXP>..\..\py36_amd64\Scripts\python.exe
>> Python 3.6.0b2 (default, Oct 10 2016, 21:15:32) [MSC v.1900 64 bit (AMD64)] 
>> on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>  import sys
> 

I'm not seeing this... (using the 32 bits version on win7)

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit 
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>>

Irmen

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


Re: Python Data base help

2016-10-09 Thread Irmen de Jong
On 9-10-2016 20:56, Risat Haque wrote:
> Hey, i have a data base filled with numbers from a recent drone flight. IT 
> contains, alt, long, lat, and time.
> In python, i want to ask the user to put in a time : 
> askTime = (input("Choose a time (HourMinSec):"))
> 
> With this, I need it to search through the entire data base to find that 
> number. 
> 
> ("UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h") 
> 
> EX: 
> 
> Choose a time (HourMinSec):8:58:24
> Data: UTC: 8:58:24 lat: 50.97 long: -114.05  Alt: 1047.40m  SOG: 1.04 km/h"
> 
> How can I do this? 
> 

What is your 'database'?
>From the little information you provided it seems that it is just a text file 
>where
every drone measurement is on a line. So simply read every line and check if 
the time
entered is in that line, then print it.


Irmen

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


Re: rocket simulation game with just using tkinter

2016-10-05 Thread Irmen de Jong
On 5-10-2016 2:43, Dennis Lee Bieber wrote:
>   Or do what I once did with the Lunar Lander game on my college
> computer... Target accuracy: Excellent... Landing gear? somewhere on the
> other side of the moon. My vertical velocity was sub-inches per second --
> the horizontal velocity was in multi-feet per second.

My lander game takes the magnitude of the velocity into account and not the 
direction,
so you will still crash when going down a pixel per second but strafing like 
mad :)


>   I also used to crash with more fuel than I started with... Game didn't
> do a sign check on "lbs of fuel to burn", so -10lbs @ 180deg had the same
> effect as 10lbs @ 0deg, but gained fuel.

I forgot to add a fuel gauge! My rocket can fly for all eternity if you manage 
to keep
it in the air :P

The first rocket landing game I ever came across must have been a text only 
version
running on my commodore 64 where it was only printing your current altitude and 
velocity
and fuel level, and then stopped to ask for input. I think it asked for values 
for how
long to burn the engine and for how many seconds. Then it recomputed everything 
and
stopped again for input until you landed safely or crashed...
It must have been a short BASIC listing I copied over from a magazine or 
something.


Irmen

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


Re: rocket simulation game with just using tkinter

2016-10-04 Thread Irmen de Jong
On 4-10-2016 10:20, Christian Gollwitzer wrote:

> Thanks! It works now with the cursor keys as intended. I'm still having 
> trouble, but
> only because my game playing skills are not very good ;)

Have you managed to land the rocket again at all after a takeoff?
You can practice landing a bit by touching down anywhere on the ground, for 
instance
just a little bit to the right of the starting launchpad.
The real challenge is of course to land it on the other launchpad without 
touchdowns in
between.


>> Also I've discovered that there seems to be an issue with some Tkinter 
>> versions; it
>> sometimes doesn't update the screen fast enough. On OSX this problem is not 
>> present but
>> it is on Python 2.7 on Windows for example. I don't know what is causing it 
>> or how to
>> fix it at this time.   The FPS counter in the top right of the window should 
>> say 30,
>> that is when the game is updating at the intended speed.
> 
> Maybe if the system is simply too slow for your intended speed ?

Python 2.7 on my windows box shows the slow update behavior, while Python 3.5 
on the
same windows box runs fine at 30 fps (or even 60 if you tell it to).
I concluded that it is an implementation problem.

> I see that you are
> using after_idle if the delay is less than 1 ms. after_idle performs a 
> different task
> than after. I think, instead you should skip frames, i.e. compute how many 
> frames you
> are behind the clock and advance the physics by that and draw the next frame 
> instead.
> Otherwise the delay might build up.

Yes you're right but the computer is not too slow I believe, see above.

> The drawing itself has also different speed on different system. And, the 
> canvas is not
> intended to redraw everything on each frame. Instead, updating the objects 
> using the
> coords() method is usually faster. (It should also be easier)

I didn't want to tie it too much to the implementation details of Tkinter 
canvases.
Usually I think games have some graphics area that has to be redrawn every 
frame.
That, and Tkinter canvas cannot rotate a polygon so I have to redraw the rocket 
anyway!

Thanks for your interest in this little game :)
Irmen

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


Re: rocket simulation game with just using tkinter

2016-10-02 Thread Irmen de Jong
On 1-10-2016 22:07, Irmen de Jong wrote:
> On 1-10-2016 15:44, Christian Gollwitzer wrote:
>> Am 01.10.16 um 00:59 schrieb Irmen de Jong:
>>> Hi,
>>>
>>> I've made a very simple rocket simulation game, inspired by the recent 
>>> success of SpaceX
>>
>>> You can get the code here if you want to give it a try:
>>> https://github.com/irmen/rocketsimulator
>>
>> Nice! I'll have to rebind the keys before I can successfully play this, 
>> though. My []
>> "keys" are in fact combinations of Alt+5 and Alt+6 on a German Macbook 
>> keyboard (on a
>> German PC, it is AltGr+8, AltGr+9). Why not using the arrow keys? These 
>> should be pretty
>> universal
> 
> Oh, I'm sorry about that, my little knowledge of non-US keyboard layouts 
> shows.
> Arrow keys could be an option.   For my education what are the 2 keys to the 
> right of
> the P then on your keyboard?
> 
> Rebinding the keys should be easy though just change them in the keypress and 
> keyrelease
> methods.
> 
> Irmen


I've updated the keybindings and you can now use [ and ] but also the cursor 
keys to
control the rocket's rotation.

Also I've discovered that there seems to be an issue with some Tkinter 
versions; it
sometimes doesn't update the screen fast enough. On OSX this problem is not 
present but
it is on Python 2.7 on Windows for example. I don't know what is causing it or 
how to
fix it at this time.   The FPS counter in the top right of the window should 
say 30,
that is when the game is updating at the intended speed.


Irmen

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


Re: rocket simulation game with just using tkinter

2016-10-01 Thread Irmen de Jong
On 1-10-2016 15:44, Christian Gollwitzer wrote:
> Am 01.10.16 um 00:59 schrieb Irmen de Jong:
>> Hi,
>>
>> I've made a very simple rocket simulation game, inspired by the recent 
>> success of SpaceX
> 
>> You can get the code here if you want to give it a try:
>> https://github.com/irmen/rocketsimulator
> 
> Nice! I'll have to rebind the keys before I can successfully play this, 
> though. My []
> "keys" are in fact combinations of Alt+5 and Alt+6 on a German Macbook 
> keyboard (on a
> German PC, it is AltGr+8, AltGr+9). Why not using the arrow keys? These 
> should be pretty
> universal

Oh, I'm sorry about that, my little knowledge of non-US keyboard layouts shows.
Arrow keys could be an option.   For my education what are the 2 keys to the 
right of
the P then on your keyboard?

Rebinding the keys should be easy though just change them in the keypress and 
keyrelease
methods.

Irmen

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


rocket simulation game with just using tkinter

2016-09-30 Thread Irmen de Jong
Hi,

I've made a very simple rocket simulation game, inspired by the recent success 
of SpaceX
where they managed to land the Falcon-9 rocket back on a platform.

I was curious if you can make a simple graphics animation game with just using 
Tkinter,
instead of using other game libraries such as PyGame.
As it turns out, that works pretty well and it was quite easy to write. 
Granted, there's
not much going on on the screen, but still the game runs very smoothly and I 
think it is
fun for a little while where you try to learn to control the rocket and attempt 
to
successfully land it on the other launchpad!

The physics simulation is tied to the game's frame rate boohoo, but the upside 
is that
you can change the framerate to control the game's difficulty. It's easy at 
<=20, fun at
30 and impossible at 60 :)  It's running on 30 by default.


You can get the code here if you want to give it a try:
https://github.com/irmen/rocketsimulator

So you just need python 2/3 with tkinter to play this!


Have fun
Irmen
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pypy on windows much slower than linux/mac when using complex number type?

2016-09-23 Thread Irmen de Jong
On 20-9-2016 22:38, Irmen de Jong wrote:
> Hi,
> 
> I've stumbled across a peculiar performance issue with Pypy across some 
> different
> platforms. It was very visible in some calculation heavy code that I wrote 
> that uses
> Python's complex number type to calculate the well-known Mandelbrot set.
> 
> Pypy running the code on my Windows machine is doing okay, but when running 
> the same
> code on Pypy on different systems, the performance difference is so big it is 
> not even
> funny. The other implementations are MUCH faster than the windows one. Which 
> is quite
> unexpected because the other machines I've tested on have the same or much 
> lower
> physical CPU specs than the windows machine.  Here's the comparison:
> 
> Machine specs:
>  Windows: 64 bits Windows 7, Intel Core 2 Quad 3.4 Ghz
>  Linux: 32 bits Mint 18, Virtualbox VM on above windows machine
>  Mac mini: OS X 10.11.6, Intel Core 2 Duo 2.53 Ghz
> 
> The test code I've been using is here:
>  https://gist.github.com/irmen/c6b12b4cf88a6a4fcf5ff721c7089078
> 
> Test results:
>   function:  mandel   / iterations
>  Mac mini, Pypy 5.4.1 (64-bit):  0.81 sec / 0.65 sec
>  Linux, Pypy 5.1 (32-bit):   1.06 sec / 0.64 sec
>  Windows, Pypy 5.4.1 (32-bit):   5.59 sec / 2.87 sec
> 
> 
> What could cause such a huge difference?
> 
> Is it perhaps a compiler issue (where gcc/clang are MUCH better at optimizing 
> certain
> things, although I wonder how much of a factor this is because Pypy is doing 
> JITting by
> itself as far as I am aware)?   Or is something strange going on with the way 
> the
> complex number type is implemented?   (the difference doesn't occur when 
> using only floats)
> 
> 
> Regards
> Irmen de Jong
> 


The problem boiled down to a performance issue in window's 32 bits 
implementation of the
hypot() function   (which abs(z) uses when z is a complex number type).
The 64 bits windows crt lib version is much faster (on par with what is to be 
expected
from the linux or osx version), but  unfortunately there's no 64 bits pypy
implementation for windows.
Replacing abs(z) by sqrt(r*r+i*i) avoids the problem and is even faster still.

More details here https://bitbucket.org/pypy/pypy/issues/2401

Cheers
Irmen de Jong

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


Re: pypy on windows much slower than linux/mac when using complex number type?

2016-09-21 Thread Irmen de Jong
On 21-9-2016 1:20, Chris Kaynor wrote:

> 
> Regarding the performance decrease, it may be worthwhile to push the report
> to a PyPy specific forum - a PyPy developer will probably see it here, but
> you may get a faster response on a forum specific to PyPy.


You're right.
I don't know the best place for that, but I've made a bug report about it here:
https://bitbucket.org/pypy/pypy/issues/2401


Irmen

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


Re: pypy on windows much slower than linux/mac when using complex number type?

2016-09-20 Thread Irmen de Jong
On 20-9-2016 22:43, Chris Angelico wrote:
> On Wed, Sep 21, 2016 at 6:38 AM, Irmen de Jong <irmen.nos...@xs4all.nl> wrote:
>>  Windows: 64 bits Windows 7, Intel Core 2 Quad 3.4 Ghz
>>  Linux: 32 bits Mint 18, Virtualbox VM on above windows machine
>>  Mac mini: OS X 10.11.6, Intel Core 2 Duo 2.53 Ghz
>>
>> The test code I've been using is here:
>>  https://gist.github.com/irmen/c6b12b4cf88a6a4fcf5ff721c7089078
>>
>> Test results:
>>   function:  mandel   / iterations
>>  Mac mini, Pypy 5.4.1 (64-bit):  0.81 sec / 0.65 sec
>>  Linux, Pypy 5.1 (32-bit):   1.06 sec / 0.64 sec
>>  Windows, Pypy 5.4.1 (32-bit):   5.59 sec / 2.87 sec
>>
>>
>> What could cause such a huge difference?
> 
> Dunno if it's the cause or not, but you're running a 32-bit PyPy on a
> 64-bit Windows. I could well imagine that that has some odd
> significance.
> 
> ChrisA


Perhaps. Though I can't really imagine what's going on there then. The one on 
Linux is
32 bits as well and it's also much faster...
Unfortunately there's no 64 bits pypy expected for windows, so I can't test that

Irmen


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


pypy on windows much slower than linux/mac when using complex number type?

2016-09-20 Thread Irmen de Jong
Hi,

I've stumbled across a peculiar performance issue with Pypy across some 
different
platforms. It was very visible in some calculation heavy code that I wrote that 
uses
Python's complex number type to calculate the well-known Mandelbrot set.

Pypy running the code on my Windows machine is doing okay, but when running the 
same
code on Pypy on different systems, the performance difference is so big it is 
not even
funny. The other implementations are MUCH faster than the windows one. Which is 
quite
unexpected because the other machines I've tested on have the same or much lower
physical CPU specs than the windows machine.  Here's the comparison:

Machine specs:
 Windows: 64 bits Windows 7, Intel Core 2 Quad 3.4 Ghz
 Linux: 32 bits Mint 18, Virtualbox VM on above windows machine
 Mac mini: OS X 10.11.6, Intel Core 2 Duo 2.53 Ghz

The test code I've been using is here:
 https://gist.github.com/irmen/c6b12b4cf88a6a4fcf5ff721c7089078

Test results:
  function:  mandel   / iterations
 Mac mini, Pypy 5.4.1 (64-bit):  0.81 sec / 0.65 sec
 Linux, Pypy 5.1 (32-bit):   1.06 sec / 0.64 sec
 Windows, Pypy 5.4.1 (32-bit):   5.59 sec / 2.87 sec


What could cause such a huge difference?

Is it perhaps a compiler issue (where gcc/clang are MUCH better at optimizing 
certain
things, although I wonder how much of a factor this is because Pypy is doing 
JITting by
itself as far as I am aware)?   Or is something strange going on with the way 
the
complex number type is implemented?   (the difference doesn't occur when using 
only floats)


Regards
Irmen de Jong

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


Re: DLL Error from a beginner

2016-09-13 Thread Irmen de Jong
On 13-9-2016 23:59, srfp...@gmail.com wrote:
> Running Pyscripter and  Python version 2.7.12 on Win10 Home on a 64bit Laptop
> 1. A simple Python application runs successfully.
> 2. WxPython(wxPython3.0-win64-3.0.2.0-py27(1).exe executed  successfully
> 3. To the simple app above, I add   import wx  and  an Error Dialog occurs:
> ImportError: DLL load failed: %1 is not a valid 32 application
> If I see win64 in the exe filename I think I have the correct wxPython 
> install.
> What have a done wrong ?
> 



Is your python installation itself of the 64-bit kind?
Otherwise, you have to install the 32 bits wxpython library rather than the 64 
bits one
you showed us above. (Or switch to a 64 bit python implementation)


Irmen

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


Re: docs on pythonhosted.org not updating with new version?

2016-08-16 Thread Irmen de Jong
On 16-8-2016 0:11, Irmen de Jong wrote:
> Hi,
> as I've always done for a new release I've uploaded new versions of my 
> package's
> documentation files, but they are not showing up on Pythonhosted.org - the 
> previous
> version is still there.
> 
> Is there something wrong with the update mechanism?
> 
> I've been using "python3 setup.py build_sphinx upload_docs" to build and 
> upload the docs
> and it comes back with a 200 Ok response from the pypi server. The same 
> commands used to
> work fine on previous occasions...


Btw, manually uploading a zip file with the documentation via the web form on my
project's Pypi page *did* work as advertised and updated the documentation. So 
it seems
to me as if the setuptools upload_docs task is no longer working?

I tried to extract more information from setuptools but adding the -v option 
didn't
result in more diagnostic info. So I have no idea what is happening with it 
behind the
curtains yet.


Irmen

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


docs on pythonhosted.org not updating with new version?

2016-08-15 Thread Irmen de Jong
Hi,
as I've always done for a new release I've uploaded new versions of my package's
documentation files, but they are not showing up on Pythonhosted.org - the 
previous
version is still there.

Is there something wrong with the update mechanism?

I've been using "python3 setup.py build_sphinx upload_docs" to build and upload 
the docs
and it comes back with a 200 Ok response from the pypi server. The same 
commands used to
work fine on previous occasions...


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


Re: Network protocols, sans I/O,(Hopefully) the future of network protocols in Python

2016-08-08 Thread Irmen de Jong
On 8-8-2016 12:37, Mark Lawrence wrote:
> This may be of interest to some of you 
> http://www.snarky.ca/network-protocols-sans-i-o
> 

I sure find it interesting. Will also watch Cory's PyCon presentation that is 
mentioned!
Thanks for the link.


Irmen

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


Re: Setting up Python WinXP

2016-06-22 Thread Irmen de Jong
On 22-6-2016 18:41, Michael Smolen wrote:
> Folks:
> I can't wait to start programming with Python. However, I am having 
> difficulty installing on my XP operating system. I downloaded Python-3.4.5ci 
> as that seems like the version that will run on my operating system. The 
> latest version will not as per mention on the website. I downloaded the 
> compacted version  (*.tar), converted it to a *.tgz and extracted the 
> software into a folder Python-3.4.5ci. That subdirectory contains numerous 
> files (11) and 13 subdirectories. The README file states that "On Windows, 
> see PCbuild/readme.txt.". That link was not found. 
> 
> So, I am clueless on what I need to do to successfully install Python3.4 on 
> my computer. Any advice would be greatly appreciated.
> mike
> 

Don't try to install from the source archive which it seems you have downloaded.
Get the MSI installer instead from https://www.python.org/downloads/windows/
I think you want to get the Python 3.4.3 "windows x86 msi installer", its about 
one
third down the page.

That being said, you probably already noticed that to stay with the game,  XP 
isn't
going to cut it anymore as it is no longer supported by Microsoft.

Irmen

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


Re: pytz and Python timezones

2016-06-11 Thread Irmen de Jong
On 11-6-2016 13:37, Johannes Bauer wrote:
> Hi there,
> 
> first off, let me admit that I have a hard time comprehensively wrapping
> my head around timezones. Everything around them is much more
> complicated than it seems, IMO.

They might not seem complicated, but actually they are. Mindbogglingly so:
https://www.youtube.com/watch?v=-5wpm-gesOY

> pytz.timezone("Europe/Berlin").localize(datetime.datetime(2016,1,1))
> 
> Gives me the expected result of:
> 
> datetime.datetime(2016, 1, 1, 0, 0, tzinfo= CET+1:00:00 STD>)
> 
> Can someone explain what's going on here and why I end up with the weird
> "00:53" timezone? Is this a bug or am I doing things wrong?

I ran into the same issue a while ago and have since accepted that "the right 
way to do
it" is indeed not passing a tzinfo into the datetime constructor, but to always 
use the
second form with tz.localize(datetime).
I suppose it is a problem (not so much a bug) caused by the way timezones are 
done
internally in pytz and/or datetime but haven't looked into the details. Mostly 
because
of what is said the video I linked above :)

Irmen

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


Re: What should Python apps do when asked to show help?

2016-04-28 Thread Irmen de Jong
On 28-4-2016 18:33, Steven D'Aprano wrote:


> but I was thinking of doing both: give my application a subcommand or an
> option to display help directly in a pager, while -h and --help print to
> stdout as normal.
> 
> What do you think? Too clever?

An idea: Use just one help option, then

if sys.stdout.isatty():
#use a pager to display help text
else:
#print all help text normally


Irmen

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


Re: Introducing the secrets module

2016-04-17 Thread Irmen de Jong
On 17-4-2016 4:36, Steven D'Aprano wrote:

> And the documentation:
> 
> https://docs.python.org/3.6/library/secrets.html
> 
> 
> Comments requested.

I've read about the "How many bytes should tokens use?" consideration. It 
suggests that
to be secure, tokens need to have sufficient randomness. The default token 
length is
subject to change at any time to remain secure against brute-force.
However the API allows you to supply any token length, even one that is (a lot) 
shorter
than the default.
In view of the rationale for this new module ("Python's standard library makes 
it too
easy for developers to inadvertently make serious security errors") should it 
perhaps
not be allowed to use a value that is less than the default?

Hm, perhaps it should not; enforcing this could break code suddenly in the 
future when
the default is raised...

Irmen

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


  1   2   3   4   5   6   7   >