Re: People choosing Python 3

2017-09-10 Thread Chris Warrick
On 10 September 2017 at 09:30, Marko Rauhamaa  wrote:
> INADA Naoki :
>
>> I can't wait Python 3 is the default Python of Red Hat, and "python"
>> command means Python 3 on Debian and Ubuntu.
>
> I can't wait till Python 3 is available on Red Hat.

Python 3.4 is available in EPEL. RHEL 8 will switch to Python 3 as the
main Python interpreter (assuming dnf replaces yum, as it did in
Fedora a while back).

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: People choosing Python 3

2017-09-10 Thread Chris Warrick
On 10 September 2017 at 11:24, Leam Hall  wrote:
> On 09/10/2017 04:19 AM, Chris Warrick wrote:
>>
>> On 10 September 2017 at 09:30, Marko Rauhamaa  wrote:
>>>
>>> INADA Naoki :
>>>
>>>> I can't wait Python 3 is the default Python of Red Hat, and "python"
>>>> command means Python 3 on Debian and Ubuntu.
>>>
>>>
>>> I can't wait till Python 3 is available on Red Hat.
>>
>>
>> Python 3.4 is available in EPEL. RHEL 8 will switch to Python 3 as the
>> main Python interpreter (assuming dnf replaces yum, as it did in
>> Fedora a while back).
>>
>
> I'm not sure that RHEL 8 will be Python 3 for the OS tools. Even if it is,
> which version?

RHEL’s release process starts at forking a recent Fedora release. It
wouldn’t make much sense for them to undo the Python 3 progress that
happened over the past few years in Fedora — including dnf, an
improved package manager written in Python 3. If the fork happened
today, the base release would be Fedora 26, which includes Python 3.6,
and some install options don’t include Python 2.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python dress

2017-09-12 Thread Chris Warrick
On 12 September 2017 at 21:15, Stephan Houben
 wrote:
> Op 2017-09-12, Jona Azizaj schreef :
>> It looks very nice, thanks for sharing :)
>
>print(insertionSort)
>
> It's even Python3-compliant!
>
> Stephan
> --
> https://mail.python.org/mailman/listinfo/python-list

Meh. That should be a return statement, the thing is not PEP
8-compliant, and Courier is an ugly font.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stdlib, what's in, what's out

2017-09-20 Thread Chris Warrick
On 20 September 2017 at 17:16, Dennis Lee Bieber  wrote:
> On Tue, 19 Sep 2017 11:58:47 -0700 (PDT), John Ladasky
>  declaimed the following:
>
>>
>>And of course I have found some other third-party packages: scipy, pandas, 
>>matplotlib, and PyQt5 are important for my work.  I helped a student of mine 
>>get selenium running.  In the case of PyQt, I found TKinter unsatisfactory 
>>many years ago, and went looking for better choices.  I used wxPython first, 
>>when I was working in Py2.  When wxPython was slow to migrate to Py3, I went 
>>searching again.
>>
>
> And if wxPython had been part of the stdlib, it would have meant 
> Python
> 3 would have been delayed years until wxPython had been ported -- or
> wxPython would have been pulled from the stdlib and something else put in
> its place...
>
> So no help to those migrating.

If wxPython had been part of the stdlib, there would be much more
manpower to port it to 3. Also, the project underwent a complete
rewrite, which dooms many projects to failure. Perhaps they wouldn’t
try the rewrite, or they would port the older codebase to Python 3 so
that it could be shipped. (They’re currently at Beta 2 of the
post-rewrite 4.0.0 version.)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Boolean Logic

2017-09-23 Thread Chris Warrick
On 23 September 2017 at 06:46, Cai Gengyang  wrote:
> Output :
>
> ('bool_one = ', False)
> ('bool_two = ', False)
> ('bool_three = ', False)
> ('bool_four = ', True)
> ('bool_five = ', False)

You’re using Python 2 with Python 3-style print statements. To make it
look good, start your code with:

from __future__ import print_function

Or use the Python 2 form (without parentheses), or even better: switch
to Python 3.

Now, Codecademy is a peculiar place. They still teach Python 2 (that
sucks!) and have a specific teaching style. The way you’re supposed to
solve this is to just assign your answers to bool_one through
bool_five. You should just type True or False in each blank, using
Python to evaluate this expression is kinda cheating. Codecademy will
then tell you if you got the right answer. Don’t print stuff you
aren’t asked to print.

However, you should not depend only on Codecademy’s interpreter.
Install Python on your computer and work with that. I also recommend
learning using different resources, and learning Python 3. It’s the
future.

~~~

On 23 September 2017 at 07:01, Bill  wrote:
> Your answers appear correct, but you could write Python statements to test
> them (or any you encounter in the future). For instance,
>
> if (20 - 10)  > 15 :
> print("true")
> else:
> print("false");
>
> Or,
>
> s='(20 - 10)  > 15'
> b=(20 - 10)  > 15
> print(s, " is ", ("true" if b else "false") );  ## inside parentheses may be
> removed.

This outputs "False is false", because you used the variable in your
expression. You can just do this:

>>> print("s is", s)

This will print "s is False".

You can also replace your earlier `if` with:

>>> print((20 - 10) > 15)

(False will appear upper-case, of course.)

PS. don’t use semicolons with Python. Avoid eval() as well.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Line terminators in Python?

2017-09-29 Thread Chris Warrick
On 29 September 2017 at 19:54, Stefan Ram  wrote:
>   In some languages, printing »'\n'«, the Unicode code point 10,
>   will have the effect of printing a line terminator, which might
>   mean that the output device actually receives »\r\n«.
>
>   The line terminator ostensibly depends on the operating
>   system, but actually it depends on the output system. E.g.,
>   under one operating system the console might accept another
>   set of line separators than an editor. (Under Windows,
>   »wordpad« accepts »\n«, while »notepad« requires »\r\n«.)
>
>   What is the recommended way to terminate a line written with
>   Python? Is it »\n« or something else? For example, in Java,
>   in some cases, one should terminate the line with the value
>   of »java.lang.System.lineSeparator()« which might or might
>   not be equal to the value of »"\n"«.
>
>   Does it possibly depend on the entity being written to, which
>   might be
>
>   - the Python console,
>   - the IDLE console,
>   - the operating system console or
>   - a text file?

It depends on the mode used to open the output file.
https://docs.python.org/3/library/functions.html#open

sys.stdout is opened in 'w' mode by default (writing, text mode). Text
mode means that non-Unix newlines (\r\n, \r) are translated to '\n'
when reading, and '\n' is translated to the system local newline when
writing. So, if you’re working in text mode (which also handles
encodings and returns Unicode strings on Python 3), you can just
assume '\n'.

If you’re curious what the local newline is, look at os.linesep:
https://docs.python.org/3/library/os.html#os.linesep

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: choice of web-framework

2017-10-22 Thread Chris Warrick
On 22 October 2017 at 12:24, Patrick Vrijlandt  wrote:
> Hello list,
>
> I would like your recommendation on the choice of a web framework.
>
> The project is completely new, there are no histories to take into account
> (current solutions are paper-based). The website involves questionnaires
> that will be developed, filled out and stored. Users are not programmers or
> developers. They should be authenticated. Version control is required.
> Internationalization is not an issue. I expect that the project will add
> additional requirements and complexity later on that I can not foresee yet.
> I'm targeting a single deployment (maybe a second on a development machine).
> I usually work on Windows, but Linux can be considered.

If you intend to put this on a server, and you probably do since
you’re talking about web frameworks, a Linux machine is your best bet
for that. Windows isn’t a good platform for making web servers out of.
(Your development machine can probably run Windows.)

> I'm not afraid to learn a (=one) new framework (that would actually be fun)
> but trying out a lot of them is not feasible. My current goal is a
> demonstration version of the project as a proof of concept. I may want to
> hand it over to a commercial solution at that stage.
>
> I'm an experienced python programmer but not an experienced web developer. A
> few years ago I read some books about Zope and Plone, but never did serious
> development with those. I currently maintain an intranet site in MoinMoin. I
> assume Zope could still be a potential choice, but it may have lost the
> vibrancy of a few years ago. Also, I would not know which version to choose
> (Zope 4, BlueBream, or something like Grok). The problem seems too
> complicated for micro frameworks like bottle of Flask. Django could be the
> next alternative.

Zope is effectively dead these days. IMO your best bet would be Django:

* built-in database support
* built-in user authentication support
* built-in administrator panel
* i18n support available for when you need it
* it’s a modern, friendly web framework

If you went with Flask, you’d end up with a pile of plugins (for auth,
for databases, for other things) and reimplement half of Django,
badly.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: choice of web-framework

2017-10-22 Thread Chris Warrick
On 22 October 2017 at 13:25, Lele Gaifax  wrote:
> Chris Warrick  writes:
>
>> Zope is effectively dead these days.
>
> Except it's alive and kicking: https://blog.gocept.com/
>
> :-)
>
> ciao, lele.

A few people still care, sure. But how alive is a project with 16
(sixteen) people on IRC (freenode #zope), 85 (eighty-five) stars on
GitHub, and 205 issues on GitHub (since 2013)?

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: choice of web-framework

2017-10-22 Thread Chris Warrick
On 22 October 2017 at 13:48, Chris Angelico  wrote:
> On Sun, Oct 22, 2017 at 10:34 PM, Chris Warrick  wrote:
>> On 22 October 2017 at 13:25, Lele Gaifax  wrote:
>>> Chris Warrick  writes:
>>>
>>>> Zope is effectively dead these days.
>>>
>>> Except it's alive and kicking: https://blog.gocept.com/
>>>
>>> :-)
>>>
>>> ciao, lele.
>>
>> A few people still care, sure. But how alive is a project with 16
>> (sixteen) people on IRC (freenode #zope), 85 (eighty-five) stars on
>> GitHub, and 205 issues on GitHub (since 2013)?
>>
>
> I'm not too bothered by number of stars, nor necessarily by the issue
> count (maybe a lot of their work is discussed by email, not the
> tracker). Most important, to me, is the number of commits. And that
> doesn't look too bad; there aren't a huge number of them, but they're
> fairly consistently being made. So I'd say the project isn't dead,
> though you could very well argue that it's merely playing catch-up. (I
> didn't look at the content of the commits in detail or anything.)
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list

Mailing lists are quiet as well:
https://mail.zope.org/pipermail/zope/
https://mail.zope.org/pipermail/zope-dev/

For a web framework, the daily commit count is much less important
than the size of the active community. An active community means more
people that can offer support, fix bugs, write docs, provide
ready-made modules to achieve common tasks. Zope’s community is
nonexistent. Django has 1483 contributors and 29k stars on GitHub.
Zope has 83 and 85 respectively.

https://blog.gocept.com/2016/10/04/zope-resurrection-part-2-defibrillation/

> Zope is not dead. On the sprint there were nearly 20 people who use Zope for 
> their daily work.

Oh my, twenty people! That’s a lot! A lot!

Yeah, no. Zope is dead. With a few folks going through the “denial”
phase. Or the “I’ve got legacy code from last decade I can’t be
bothered to rewrite” phase.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: choice of web-framework

2017-10-23 Thread Chris Warrick
On 23 October 2017 at 21:37, John Black  wrote:
> Chris, thanks for all this detailed information.  I am confused though
> with your database recommendation.  You say you teach SQLAlchemy but
> generally use PostgreSQL yourself.  I can maybe guess why there seems to
> be this contradiction.  Perhaps PostgreSQL is better but too advanced for
> the class you are teaching?  Can you clarify on which you think is the
> better choice?  Thanks.

Different Chris, but I’ll answer. Those are two very different things.

PostgreSQL is a database server. It talks SQL to clients, stores data,
retrieves it when asked. The usual stuff a database server does.
Alternatives: SQLite, MySQL, MS SQL, Oracle DB, …

SQLAlchemy is an ORM: an object-relational mapper, and also a database
toolkit. SQLAlchemy can abstract multiple database servers/engines
(PostgreSQL, SQLite, MySQL, etc.) and work with them from the same
codebase. It can also hide SQL from you and instead give you Python
classes. If you use an ORM like SQLAlchemy, you get database support
without writing a single line of SQL on your own. But you still need a
database engine — PostgreSQL can be one of them. But you can deploy
the same code to different DB engines, and it will just work™
(assuming you didn’t use any DB-specific features). Alternatives:
Django ORM.

psycopg2 is an example of a PostgreSQL client library for Python. It
implements the Python DB-API and lets you use it to talk to a
PostgreSQL server. When using psycopg2, you’re responsible for writing
your own SQL statements for the server to execute. In that approach,
you’re stuck with PostgreSQL and psycopg2 unless you rewrite your code
to be compatible with the other database/library. Alternatives (other
DBs): sqlite3, mysqlclient. There are also other PostgreSQL libraries
available.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Repairing Python installation?

2017-10-29 Thread Chris Warrick
On 28 October 2017 at 22:41, Martin Schöön  wrote:
> It seems something is amiss with my Python 2.7 installation. Revisiting
> Nikola (static web site generator written in Python) for the first time
> in several years the other day I experience some unexpected problems. I
> got some help form the Nikola people and the conclusion is something
> is broken with my Python 2.7. Pip list throws exceptions at me while
> pip3 list works the way I expect it to do.
>
> All this is happening on a Debian machine.
>
> Questions:
>
> Should I try to pinpoint what is broken (and how is that done) or should
> I just remove everything Python 2.7 and re-install?
>
> Could mixing pip installs with Debian distro installs of Python
> packages lead to conflicts or other problems?

Yes, it does, you should avoid that at all cost. The best way to do it
is by using virtualenv.

> Today I tried pip --version and got the following:
> /usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py:1892:
> UserWarning: /usr/lib/pymodules/python2.7/rpl-1.5.5.egg-info could not
> be properly decoded in UTF-8
>   warnings.warn(msg)

That’s a warning, and it happens to be caused by the `rpl` apt
package. Remove it from your system and try `pip --version` again:
https://github.com/certbot/certbot/issues/3795

Now, onto fixing Nikola issues:

As discussed on IRC, Nikola recommends (and will soon require) Python
3. And you’ll be better off with a virtualenv: install `virtualenv`
from apt and follow the Getting started guide for Nikola:
https://getnikola.com/getting-started.html

If you still get unicode issues when compiling posts, make sure
they’re saved as UTF-8, and that your locale is configured properly:
https://chriswarrick.com/blog/2017/06/18/unix-locales-vs-unicode/

(Nikola’s co-maintainer over here.)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Repairing Python installation?

2017-10-29 Thread Chris Warrick
On 29 October 2017 at 18:11, Martin Schöön  wrote:
> I have installed Python 3 virtualenv and Nikola according to those
> instructions. I now have a working Nikola but I sure don't know what
> I am doing :-) How do I get back into that nikola python environment
> next time?

cd into your virtualenv directory and run `source bin/activate`.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Chris Warrick
On 28 January 2018 at 20:19, Chris Angelico  wrote:
> The vanilla Windows console (conhost.exe IIRC) is far from ideal for
> copying and pasting from

It’s been fixed in recent Windows 10 releases (select and Ctrl+C works now).

> Windows error popups are *impossible* to copy text from.

Most standard error popups support pressing Ctrl+C to copy the text
displayed in them.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting "ValueError: need more than 1 value to unpack" while trying to read a value from dictionary in python

2018-02-15 Thread Chris Warrick
On 15 February 2018 at 12:07, Sum J  wrote:
> Below is my code. Here I want to read the "ip address" from s
>
>
>  s= '''
> Power On Enabled = On
> State: connected
> Radio Module: Unknown
> noise: -097
> signalStrength: -046
> ip address: 192.168.75.147
> subnet mask: 255.255.255.0
> IPv4 address configured by DHCP
> Mac Addr: ac:e2:d3:32:00:5a
> Mode: infrastrastructure
> ssid: Cloudlab
> Channel: 1
> Regulatory: World Safe
> Authencation: WPA2/PSK
> Encryption:  AES or TKIP
> '''
>
>s = s.replace("=",":")
># s = s.strip()
>print s
>
>   d = {}
>   for i in s:
>  key, val = i.split(":")
>  d[key] = val.strip()
>
>   print d
>   print d["ip address"]
>
>
> Getting below error :
>  key, val = i.split(":")
> ValueError: need more than 1 value to unpack
> --
> https://mail.python.org/mailman/listinfo/python-list

If you iterate over a string, you are iterating over individual
characters. Instead, you need to split it into lines, first stripping
whitespace (starts and ends with an empty line).

s = s.strip().replace("=",":")
print s

d = {}
for i in s.split('\n'):
try:
key, val = i.split(":")
d[key.strip()] = val.strip()
except ValueError:
print "no key:value pair found in", i


(PS. please switch to Python 3)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: read Unicode characters one by one in python2

2018-02-25 Thread Chris Warrick
On 24 February 2018 at 17:17, Peng Yu  wrote:
> Here shows some code for reading Unicode characters one by one in
> python2. Is it the best code for reading Unicode characters one by one
> in python2?
>
> https://rosettacode.org/wiki/Read_a_file_character_by_character/UTF8#Python

No, it’s terrible. So is the Python 3 version. All you need for both
Pythons is this:

import io
with io.open('input.txt', 'r', encoding='utf-8') as fh:
for character in fh:
print(character)

(and please make sure you need to read character-by-character first)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TCL/TK as default UI toolkit, and wayland

2016-10-14 Thread Chris Warrick
On 14 October 2016 at 13:40, kerbingamer376  wrote:
> Python's "standard" (and bundled on most platforms) UI tookkit is TCL/TK. 
> However, this has A LOT of drawbacks:
>
> * It's eyesore on a lot of platforms
> * It's non-pythonic
> * It just flat out fails on some desktop environments
> * On linux it requires X, however lots of distros are now using wayland
> and so on.
>
> I think python needs a new "standard" UI toolkit.
> --
> https://mail.python.org/mailman/listinfo/python-list

Okay. What else do you suggest?

* PyQt/PySide requires massive Qt packages, and has licensing issues.
* GTK looks bad outside of GNOME.
* wxPython claims to be back to development, but it wasn’t for the past 2 years.
* Kivy doesn’t even try to feel native anywhere.

I think we’ve just run out of reasonable cross-platform GUI libraries
for Python… You are free to use any of those four, though (or anything
less cross-platform). You don’t have to use Tkinter if you don’t like
it. And it’s not a hard requirement on many Linux distributions.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to python

2016-10-18 Thread Chris Warrick
On 17 October 2016 at 21:51, Bill Cunningham  wrote:
> I just installed python I might start with 3. But there is version 2 out
> too. So far I can '3+4' and get the answer. Nice. I typed the linux man page
> and got a little info. So to learn this language is there an online
> tutorial? I am interested in the scripting too.
>
> Bill

Learn Python 3. Good resources (that I can actually vouch for being
good…) include:

https://docs.python.org/3/tutorial/index.html (if you can already program)
http://greenteapress.com/wp/think-python/
https://automatetheboringstuff.com/

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: advanced SimpleHTTPServer?

2016-11-02 Thread Chris Warrick
On 2 November 2016 at 08:27, Ulli Horlacher
 wrote:
> "python -m SimpleHTTPServer" is really cool :-)
>
> But I need some more features:
>
> - some kind of a chroot, to prevent file access higher then the base
>   directory
>
> - a directory listing mit date and size information
>
> - an upload possibility
>
> I could modify /usr/lib/python2.7/SimpleHTTPServer.py by myself, but maybe
> someone already has implemented these features?
>
> Use case: users with notebooks in a foreign (WiFi) LAN want to exchange
> some files on-the-fly, quick-and-dirty. Using USB sticks is a no-go! :-)

SimpleHTTPServer is meant to be used for development and testing. It
should not be used for anything remotely serious for security and
speed reasons.

Instead, you should use a real web server, such as nginx or apache.
Those will do the first two properly, and the last one could be
handled by a simple-ish PHP script. Or a full-fledged app in Django or
Flask if you feel like it.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: advanced SimpleHTTPServer?

2016-11-02 Thread Chris Warrick
On 2 November 2016 at 17:56, Eric S. Johansson  wrote:
>> Instead, you should use a real web server, such as nginx or apache.
>> Those will do the first two properly, and the last one could be
>> handled by a simple-ish PHP script. Or a full-fledged app in Django or
>> Flask if you feel like it.
> or bottle.  why does everyone seem to forget bottle? simple to set up,
> easy to learn and useful for small to medium projects.

The other frameworks are simple to set up, too. I’ve personally had
Unicode issues with Bottle, and it doesn’t even do sessions. Unlike
Flask, or of course Django.

Because, as the old saying goes, any sufficiently complicated Bottle
or Flask app contains an ad hoc, informally-specified, bug-ridden,
slow implementation of half of Django.

(In the form of various plugins to do databases, accounts, admin panels etc.)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Case Against Python 3

2016-11-25 Thread Chris Warrick
On 25 November 2016 at 12:11, Fabien  wrote:
> I'd be interested to read what the community thinks about the fact that his
> book (learn the hard way) is extremely influential among beginners, and what
> tools do we have to avoid that beginners stumble across such opinions in
> their very first steps with python...

His book is slowly on the way out. #python on freenode and /r/python
stopped recommending the book. Other places should follow suit, and
actively discourage an outdated (easy_install, distribute, nosetests,
python 2) book written by an asshole and a xenophobe.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: print() with no newline

2016-12-18 Thread Chris Warrick
On 18 December 2016 at 13:25, ElChino  wrote:
> In this snippet:
>   import sys
>   PY3 = (sys.version_info[0] >= 3)
>
>   def print_no_nl (s):
> if PY3:
>   print (s, end="")
> else:
>   print (s),
>
> I'm getting a syntax error in Python2. Python3 is fine.
> How can I make this Py2+3 compatible?

With a __future__ import, the Python 3 syntax will work with both Pythons:

from __future__ import print_function
print(s, end="")

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Let ipython3 use the latest python3

2017-01-21 Thread Chris Warrick
On 21 January 2017 at 12:30, Cecil Westerhof  wrote:
> I built python3.6, but ipython3 is still using the old one (3.4.5).
> How can I make ipython3 use 3.6?

All packages you have installed are tied to a specific Python version.
If you want to use IPython with Python 3.6, you need to install it for
that version (most likely, with pip) and make sure there is an
ipython3 executable in your $PATH pointing at 3.6. You don’t need to
remove IPython for 3.4 (but you can if you want to get rid of it).

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is requests[security] required for python 3.5+ ?

2017-02-02 Thread Chris Warrick
On 2 February 2017 at 20:41, Thomas Nyberg  wrote:
> Hello,
>
> I'm trying to understand whether requests[security] or just plain requests
> should be installed for python 3.5. I.e. do the following packages need to
> be installed: pyOpenSSL, cryptography,idna.
>
> The reason I'm asking is because I'm moving an application to python 3 and I
> am testing out which requirements continue to be required in the version.

No, requests[security] is only needed for old Python 2.7 versions
(before 2.7.9).

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am a student studying Python in Korea. I found strange thing while studying through idle

2018-03-09 Thread Chris Warrick
On 9 March 2018 at 01:07, 노연수  wrote:
> If you type print (" hello\ rpython ") into the python 3.7.0.b2, only the 
> python is printed and i learned it's a crystal. However, if you type print (" 
> hello\ rpython ") in the python 3.7.0.b2 idle, it is output as hellopython. I 
> wonder why it prints like this. I would appreciate your answer.
>
> I have attached the file so I would appreciate your reference.
> --
> https://mail.python.org/mailman/listinfo/python-list

In both cases, 'hellopython' is printed, only the behavior of the
cursor changes. The `\r` means “move cursor to the start of the line”
in some places, including Terminal/Command Prompt. But not everyone
processes the backspace character — IDLE ignores it, as do many other
text editors.

Another important thing to note about \r is this:

>>> print("python\rhi")
hithon

(PS. it’s better to use a stable version, especially when you’re
learning. PPS. file attachments do not work on this list.)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16On
9 March 2018 at 01:07, 노연수 <mailto:clear0...@naver.com";
target="_blank">clear0...@naver.com>
wrote:If you type print ("
hello\ rpython ") into the python 3.7.0.b2, only the python is printed
and i learned it's a crystal. However, if you type print (" hello\
rpython ") in the python 3.7.0.b2 idle, it is output as hellopython. I
wonder why it prints like this. I would appreciate your answer.

I have attached the file so I would appreciate your reference.
--
https://mail.python.org/mailman/listinfo/python-list";
data-saferedirecturl="https://www.google.com/url?hl=en-GB&q=https://mail.python.org/mailman/listinfo/python-list&source=gmail&ust=1520708438742000&usg=AFQjCNGayj8GjRvThJd0aWdvjz6jUEPsgA";
rel="noreferrer"
target="_blank">https://mail.python.org/mailman/listinfo/python-list
--
Chris Warrick <https://chriswarrick.com/";
target="_blank">https://chriswarrick.com/>PGP:
5EAAEA16

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


Re: venv: make installed modules visible

2018-05-01 Thread Chris Warrick
On Tue, 1 May 2018 at 19:15, Paul Moore  wrote:
> Maybe you need  --system-site-packages?

DO NOT use this option. The entire point of a virtualenv is to be separate
from both other environments and the system Python site-packages.

The correct way to handle this is to install the modules using the
virtualenv’s pip.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ipython does not work with latest version of prompt-toolkit

2018-06-03 Thread Chris Warrick
On Sun, 3 Jun 2018 at 10:32, Cecil Westerhof  wrote:
>
> When executing:
> pip3 list --no-cache-dir --outdated
>
> I got:
> prompt-toolkit 1.0.152.0.1wheel
> PyGObject  3.28.23.28.3   sdist
> youtube-dl 2018.5.30 2018.6.2 wheel
>
> So I executed:
> pip3 install --upgrade prompt-toolkit PyGObject youtube-dl
>
> This gave:
> Successfully installed PyGObject-3.28.3 prompt-toolkit-2.0.1 
> youtube-dl-2018.6.2
> ipython 6.4.0 has requirement prompt-toolkit<2.0.0,>=1.0.15, but you'll 
> have prompt-toolkit 2.0.1 which is incompatible.
>
> And when I now execute ipython3, I get:
> Traceback (most recent call last):
>   File "/usr/local/bin/ipython3", line 7, in 
> from IPython import start_ipython
>   File "/usr/local/lib/python3.5/dist-packages/IPython/__init__.py", line 
> 55, in 
> from .terminal.embed import embed
>   File 
> "/usr/local/lib/python3.5/dist-packages/IPython/terminal/embed.py", line 16, 
> in 
> from IPython.terminal.interactiveshell import TerminalInteractiveShell
>   File 
> "/usr/local/lib/python3.5/dist-packages/IPython/terminal/interactiveshell.py",
>  line 22, in 
> from prompt_toolkit.shortcuts import create_prompt_application, 
> create_eventloop, create_prompt_layout, create_output
> ImportError: cannot import name 'create_prompt_application'
>
> When I now execute:
> pip3 list --no-cache-dir --outdated
>
> I do not get output. So pip3 thinks everything is OK.
>
> How do I fix this? Or is the expected that ipython3 will be updated
> shortly?

Start by reading the warning from pip:

> ipython 6.4.0 has requirement prompt-toolkit<2.0.0,>=1.0.15, but you'll 
> have prompt-toolkit 2.0.1 which is incompatible.

To fix this, downgrade prompt-toolkit. `pip list --outdated` (not)
having output isn’t a “good” or “bad” thing. prompt-toolkit v2 has
changed its API from v1, and ipython doesn’t support the new one yet.

Don’t randomly upgrade pip packages without knowing what the upgrade
entails, especially if the version changed from 1.x to 2.x (x.y →
x+1.y) — that usually means an API change and possible
incompatibilities in dependent packages. Upgrading a tool like
youtube-dl should be fine, and so should be a x.y.z → x.y.z+1 upgrade,
but it’s still best to know what you’re doing.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyCharm

2018-07-22 Thread Chris Warrick
On Sat, 21 Jul 2018 at 05:17,  wrote:
>
> Win7
>
> I was watching some tutorial videos on Python that recommended I use
> PyCharm and it worked pretty well until I tried to use input.
>
> I found this:
> https://youtrack.jetbrains.com/issue/PY-27891
>
> It says..
> Pavel Karateev   commented 10 Jan 2018 11:57
> Hi Calvin Broadus! I am sorry for the inconvenience, this is the
> problem on PyCharm side, the fix is in progress, should be included in
> the next minor update 2017.3.3, release candidate build is planned on
> this week.
>
> Since I just installed the program yesterday, I assume that the fix
> has not been implemented yet.
>
> Most of my practice programs I always just enter a set value for
> inputs instead of taking inputs from the keyboard, but I would like to
> pause so find out why my program is broken.
>
> Is there another way to insert a pause that will work with PyCharm?
> --
> https://mail.python.org/mailman/listinfo/python-list

How does it fail? What PyCharm version are you on?

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fishing from PyPI ?

2018-08-06 Thread Chris Warrick
On Mon, 6 Aug 2018 at 19:31, MRAB  wrote:
> > https://pypi.us18.list-manage.com/track/[snip]
> If you want to be sure, ignore the links in the email, and check PyPI at
> the URL that you know is correct.
>
> Given that the email says "https://pypi.us18.list-manage.com"; and PyPI
> is at "https://pypi.org/";, it does look suspicious.
> --
> https://mail.python.org/mailman/listinfo/python-list

Those e-mails are legitimate. See [1] and [2].

The unusual domain is a common staple of Mailchimp, which is an e-mail
newsletter platform (it was used to mail out the announcement), and
they replace all links with tracking ones in their list-manage.com
domain. (They also implement the GDPR in an anti-user/pro-spam
fashion, but I digress.)

[1]: https://status.python.org/incidents/nk7cyn2vh4wr
[2]: https://github.com/pypa/warehouse/issues/3632

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fishing from PyPI ?

2018-08-07 Thread Chris Warrick
On Tue, 7 Aug 2018 at 00:52, Gregory Ewing  wrote:
>
> Chris Warrick wrote:
> > The unusual domain is a common staple of Mailchimp, which is an e-mail
> > newsletter platform (it was used to mail out the announcement), and
> > they replace all links with tracking ones in their list-manage.com
> > domain.
>
> Sounds like you need to find a mail service that doesn't
> screw around with the contents of your messages. This is
> really quite obnoxious, IMO.

For the record, I’m not in any way affiliated with the PyPA. I’m just
linking to official resources that prove the legitimacy of these
e-mails.

As for finding a better host, it’s not easy. MailChimp, as annoying as
they might be, has built up a good reputation with mail hosts* (of
course, there are a bunch of other services that have such reputation
as well.) However, if you send the e-mail yourself, and big mail hosts
notice you have sent a ton of e-mail, they will probably consider you
a spammer and make your life harder. Especially if your e-mail server
is misconfigured in even the slightest way.

* https://mailchimp.com/features/email-delivery/

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Connection refused when tryign to run bottle/flask web framweworks

2018-08-20 Thread Chris Warrick
On Mon, 20 Aug 2018 at 18:15, Νίκος  wrote:
>
> Τη Δευτέρα, 20 Αυγούστου 2018 - 9:49:00 π.μ. UTC+3, ο χρήστης Miki Tebeka 
> έγραψε:
> > If you're trying to access the machine from another machine, you need to 
> > change the host to '0.0.0.0'. 'localhost' is the internal interface.
> >
> > On Sunday, August 19, 2018 at 10:36:25 PM UTC+3, Νίκος wrote:
> > > Hello,
> > >
> > > i just installed bottle and flask web frameworks in my CentOS environment 
> > > but i canno get it working even with the simpleste xample. The coonection 
> > > is refused always.
> > >
> > > from bottle import route, run, template
> > >
> > > @route('/hello/')
> > > def index(name):
> > > return template('Hello {{name}}!', name=name)
> > >
> > > run(host='localhost', port=8080)
> > >
> > >
> > > Any ideas as to why i cannot access it?
> > > I dont have sme firewall blocking the ports 8080 or 5000.
> > >
> > > Thank you.
>
> 0.0.0.0 is used when you want your app to lsiten to all available interfaces. 
> Even with that still i cannot access the hello app.

You should avoid exposing the built-in web server to the Internet.
Either way, are you sure you don’t have any firewall set up on the
server?

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My environment doesn't load

2018-10-09 Thread Chris Warrick
On Tue, 9 Oct 2018 at 11:18,  wrote:
>
> Here are the ouput during sourcing:
>
> > [ftg @ localhost] [/var/www/ffablob]
> > % source env-p3/bin/activate
> > [ftg @ localhost] [/var/www/ffablob]
> > % which python
> > /usr/bin/python
>
> and if I run some of my code that import beautyfulsoup it fails (python 
> mycode.py), althoug running
> directly ./env-p3/python3.5 mycode.py is working...

Was the virtualenv copied between machines or directories? If yes: you
can’t do that, you must create a new virtualenv in the desired
location and install dependencies to it.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikipedia on Python

2018-10-16 Thread Chris Warrick
On Tue, 16 Oct 2018 at 20:11, Chris Angelico  wrote:
>
> On Wed, Oct 17, 2018 at 5:05 AM Spencer Graves
>  wrote:
> >Beyond that, I'd like to encourage people on this list to review
> > the Wikipedia article on "Python (programming language)",[1] especially
> > the claim that "a package is a Python module with an __path__
> > attribute", which I added on 2018-09-24 to help me understand the
> > distinction.
> >
>
> You're welcome to put whatever you like into Wikipedia, but
> personally, I don't think that particular piece of terminology is all
> that helpful to the typical reader. Technical distinctions aren't
> important to someone who's trying to find out what Python's all about,
> or why s/he should learn the language.

Seconded. This is not useful at all on Wikipedia.
I took the liberty to remove this paragraph, because I don’t think
anyone would find it useful; in fact, it would only confuse people.
Here’s a diff for anyone interested in the original content:
https://en.wikipedia.org/w/index.php?title=Python_(programming_language)&diff=prev&oldid=861064627

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Advice on Python build tools

2016-04-13 Thread Chris Warrick
On 12 April 2016 at 11:48, Sayth Renshaw  wrote:
> Hi
>
> Looking at the wiki list of build tools
> https://wiki.python.org/moin/ConfigurationAndBuildTools
>
> Has anyone much experience in build tools as i have no preference or 
> experience to lean on.
>
> Off descriptions only i would choose invoke.
>
> My requirements, simply i want to learn and build a simple static website 
> generator. Many i am not liking design of or are overkill so its a good 
> opportunity to learn, logya is a good starting point for what i think a good 
> python static generator should be.
>
> Second i want to use Jade templates (js) as i think they are more pythonic 
> than jinja and mako so being able to have mixed js and python support would 
> be needed.
>
> Thoughts?
>
> Sayth
> --
> https://mail.python.org/mailman/listinfo/python-list

Here’s a great static site generator (disclaimer, I’m a core dev over there):

https://getnikola.com/

We use doit, which is on that list. With doit, we get an existing
build system, and incremental rebuilds — for free. I recommend you try
Nikola, and if you don’t like it and still want to build something
yourself, doit is going to be a great way to do it. That said,
incremental builds often involve trial-and-error and subtle bugs when
you start working on it. And if you don’t like doit, you can always
write your own build micro-system. Because if you want to write
something simple and minimal, an existing large build system will just
make things harder.

As for Jade templates, you can’t do that reasonably. You would need to
produce some hack to spawn a JavaScript subprocess, and it would limit
what you can use in templates. Instead, look for a template system
that is written in Python and that has similar syntax.

(also, I wouldn’t consider such weird-thing-into-real-HTML template
engines pythonic)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pypi download links (e.g. for ansible)

2016-05-09 Thread Chris Warrick
On 9 May 2016 at 13:35, Michael Ströder  wrote:
> Steven D'Aprano wrote:
>> On Mon, 9 May 2016 08:00 pm, Michael Strc3b6der wrote:
>>
>>> HI!
>>>
>>> Deep-links for downloading a specific version from PyPI seemed to work
>>> like this:
>>>
>>> $ wget
>>> https://pypi.python.org/packages/source/a/ansible/ansible-2.0.1.0.tar.gz
>>> [..]
>>> Saving to: ‘ansible-2.0.1.0.tar.gz’
>>>
>>> But this recent version does not work:
>>>
>>> $ wget
>>> https://pypi.python.org/packages/source/a/ansible/ansible-2.0.2.0.tar.gz
>>> [..]
>>> HTTP request sent, awaiting response... 404 Not Found
>>
>>
>> Do you have a question, or are you just sharing?
>>
>> The Download button for 2.0.2.0 links to:
>>
>> https://pypi.python.org/packages/b3/0e/5f3ee8884866a3d5e3b8ba86e9caa85ecdec75adabac8924b1c122339e7f/ansible-2.0.2.0.tar.gz
>
> Yes, but in .spec files of openSUSE RPMs the more readable links above are 
> used
> and I'd like to keep it that way. And openSUSE build service checks whether 
> it's
> downloadable. It works for ansible-2.0.1.0 but not for 2.0.2.0.
>
> Ciao, Michael.
>
> --
> https://mail.python.org/mailman/listinfo/python-list

PyPI URLs were changed recently. There is, however, a new supported
way to get dependable URLs:
https://bitbucket.org/pypa/pypi/issues/438/backwards-compatible-un-hashed-package

The current link:
https://files.pythonhosted.org/packages/source/a/ansible/ansible-2.0.1.0.tar.gz

(URLs in the pypi.io domain were used briefly and will still work)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: not able to install mysqldb-python

2016-06-25 Thread Chris Warrick
On 24 June 2016 at 09:46, Arshpreet Singh  wrote:
> On Thursday, 23 June 2016 23:18:27 UTC+5:30, Joaquin Alzola  wrote:
>> >ImportError: No module named 'ConfigParser'
>>  It is telling you the error
>> This email is confidential and may be subject to privilege. If you are not 
>> the intended recipient, please do not copy or disclose its content but 
>> contact the sender immediately upon receipt.
>
> Thanks but somehow it fixed itself. :P now able to install mysql-python 
> without any problem.
> --
> https://mail.python.org/mailman/listinfo/python-list

It didn’t. mysql-python is installable with Python 2 only, so you
probably installed it for your system Python 2 install instead of your
Python 3 django virtualenv.
Either way, please use mysqlclient instead, as recommended by the
Django developers.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating a calculator

2016-07-01 Thread Chris Warrick
On 1 July 2016 at 05:08, Elizabeth Weiss  wrote:
> while True:
> print("Options:")
> print("Enter 'add' to add two numbers")
> print("Enter 'subtract' to subtract two numbers")
> print("Enter 'multiply' to multiply two numbers")
> print("Enter 'divide' to divide two numbers")
> print("Enter 'quit' to end the program")
> user_input=input(":")
> if user_input=="quit":
> break
> elif user_input=="add":
> num1=float(input("Enter a number"))
> num2=float(input("Enter another number"))
> result=str(num1+num2)
> print("The answer is"+ result)
> elif user_input=="subtract":
> num1=float(input("Enter a number"))
> num2=float(input("Enter another number"))
> result=str(num1-num2)
> print("The answer is"+result)
>
> Two questions:
> 1. Why do I need to put ' ' around the words add, subtract, multiply, quit, 
> etc. when it is already in quotes in print()? When the calculator asks me 
> which option I would like to choose I do not write 'add'- I only write add.

This is used for display. The single quotes will be displayed as part
of the string. This is so that people notice the commands, for
example.

>>> print("Enter 'add' to add two numbers")
Enter 'add' to add two numbers
>>> print("Enter add to add two numbers")
Enter add to add two numbers
>>> print('Enter "add" to add two numbers')
Enter "add" to add two numbers

> 2. The program I am using to help me learn python mentions that the output 
> line could be put outside the if statements to omit repetition of code. What 
> does this mean and how would I write the code differently according to this?

Look at your current code. The following three lines appear twice (and
will appear 4 times if you add multiplication and division):

> num1=float(input("Enter a number"))
> num2=float(input("Enter another number"))
> print("The answer is"+ result)

This is code repetition. It’s discouraged, because if you have 4
copies of a longer segment, and you want to change something, you
would have to remember to change it in 4 places. In this case, you can
avoid code reuse like this:

1. Check if user said 'quit', and if yes, break from the loop. (Ignore
invalid input for now)
2. Ask the user for two numbers.
3. Make an if/elif/else structure to calculate the result.
4. Print out the result outside of `if`.

Example for 3. and 4.:
if user_input == 'add':
result = num1 + num2  # no need to call str() if you use commas in print()
elif user_input == 'subtract':
result = num1 - num2
# other elif clauses go here
print("The result is", result)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating a calculator

2016-07-01 Thread Chris Warrick
On 1 July 2016 at 11:34, Pierre-Alain Dorange
 wrote:
> DFS  wrote:
>
>> Here's a related program that doesn't require you to tell it what type
>> of operation to perform.  Just enter 'num1 operator num2' and hit Enter,
>> and it will parse the entry and do the math.
>>
>> ---
>> ui=raw_input('Enter calculation to perform: ')
>> n1=float(ui.split(' ')[0])
>> op=ui.split(' ')[1]
>> n2=float(ui.split(' ')[2])
>> if op=='+':c=n1+n2
>> if op=='-':c=n1-n2
>> if op=='*':c=n1*n2
>> if op=='/':c=n1/n2
>> print(ui+' = '+str(c))
>> ---
>
> More reduced :
> --
> u=raw_input('Enter calculation:")
> print eval(u)
> --
> works and compute :
> 1+2+3+4-1+4*2
> 2+3.0/2-0.5
>
> Perform better and shorter, but less educationnal of course...

No, this is awful. It’s a great way to compromise your system’s
security. Never use eval() for any reason, especially with user input
— if you were to type in __import__('os').system('…') with some
particularly dangerous command (rm, format, …), you would kill your
system.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Structure of program development

2016-07-04 Thread Chris Warrick
On 4 July 2016 at 18:07, Michael Smolen <8smo...@tds.net> wrote:
> Folks:
>
> I am new to this programming adventure. I've gotten past the introductory 
> chapters in 'How to..." books and now want to start developing a much more 
> complicated program that I will use repeated for different applications. When 
> I worked in Perl there was an option to write a program in a text editor, 
> save it, and then run in with Perl. Is such a thing possible in Python? If 
> not, how do I develop a 500+ lines of code?

Yes, the same way it works in Perl. Use the .py file extension and run
the `python` interpreter from command line, or use an IDE that would
help you with that.

> A second question of the basic design. If I write a program, can I move it to 
> a computer that is without any Python software, or does that machine have to 
> download the Python software? Does Python products contain all parts of a 
> developed program or is it a series of 'call' statements?

You must either install a Python interpreter on that machine, or
distribute one with your program.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Packages Survey

2019-01-19 Thread Chris Warrick
On Sat, 19 Jan 2019 at 01:22, Cameron Davidson-Pilon
 wrote:
>
> Hello! I invite you to participate in the Python Packages Survey - it takes
> less than a minute to complete, and will help open source developers
> understand their users' better. Thanks for participating!
>
> https://python-packages-survey.com/

The site says:

> Completing the survey is as easy as running a Python script

No, thanks. A better way to get meaningful results is to just create a
good old web form, where you can ask people more detailed questions
than just mining the installed package list. Also, even if you promise
to filter out private packages, they *do* reach your server, and many
people would prefer that didn’t happen.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: preferences file

2019-01-24 Thread Chris Warrick
On Thu, 24 Jan 2019 at 20:50, Dave  wrote:
>
> I'm doing a small application and want to add user preferences.  Did
> some googling to see if there are standard Python ways/tools, but it
> seems not so much.  My specific questions are:
>
> 1. Best practices for a user preference file/system?

Put them in the appropriate config directory (see answer to Q3).
Windows has the registry and macOS has User Defaults, but a custom
format is fine, especially if you’re making something multi-platform.

> 2. File format favored and why - ini, JSON, etc?

If you want/expect humans to edit it, go with INI (configparser).
Otherwise (if the editing is done via your app with a nice UI), JSON
can express more than just key-value mappings, although there are no
comments, and its strict syntax requirements can be problematic for
non-programmers trying to edit the file. Randomly loading .py or
pickle files can potentially be unsafe; writing .py files in an
automated way is not trivial. I wouldn’t bother with any other
formats, mainly since they are not supported in stdlib, although if
you need human editing and more advanced structures, then maybe
YAML/TOML (they aren’t as foolproof as INI though).

> 3. File location?  I'm using Ubuntu and I believe that the correct
> location would be home/.config/ .  What about Mac and Windows?

https://pypi.org/project/appdirs/

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sys.modules

2019-02-21 Thread Chris Warrick
On Thu, 21 Feb 2019 at 18:57, ast  wrote:
>
> Hello
>
> Is it normal to have 151 entries in dictionary sys.modules
> just after starting IDLE or something goes wrong ?
>
>  >>> import sys
>  >>> len(sys.modules)
> 151
>
> Most of common modules seems to be already there,
> os, itertools, random 
>
> I thought that sys.modules was containing loaded modules
> with import command only.

sys.modules contains all modules that have been imported in the
current session. Some of those imports happen in the background,
without your knowledge — for example, because these modules are
required by the interpreter itself, or are part of IDLE. The number
you see depends on the environment (I got 530 in ipython3, 34 in
python3, 45 in python2) and is not in any way important.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: # type: a

2019-09-15 Thread Chris Warrick
On Sun, 15 Sep 2019 at 16:53, Hongyi Zhao  wrote:
>
> Hi,
>
> In pycharm, when I commented out the following line:
>
> # type: a
>
> The pycharm still told me that:
>
> Unresolved reference 'a'

PyCharm interprets PEP 484 type annotations and type comments, as well
as PEP 526 variable annotations. The comment you wrote is a type
comment that says 'a' is the expected type of something. The 'type:'
part is special here, `# foo: a` won’t trigger this warning. PyCharm
expects stuff in type comments to exist, because otherwise, there’s no
way to know what type you mean.

Type comments are now best replaced by Python 3.6+ variable
annotations, but the comments are still valid, and can be used in some
contexts where annotations are not supported.

https://www.python.org/dev/peps/pep-0484/#type-comments

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-12 Thread Chris Warrick
On 12 December 2015 at 11:29, Harbey Leke  wrote:
> oh oh okay start it for me please
> thanks or guide me about it then.
> --
> https://mail.python.org/mailman/listinfo/python-list

class BankAccount(object):
# your code goes here

Seriously: read the materials you got with your course, or the Python
tutorial and documentation at https://docs.python.org/ .

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to use python 3.5

2015-12-23 Thread Chris Warrick
On 23 December 2015 at 07:38, Ankit Deshmukh  wrote:
> Hi there,
>
>
>
> I am maters student in India,

We don’t care (expect that you made a typo there).

> I have installed python 3.5 in my windows 10
> 64bit machine. Everything works fine except package installing. When in use
> “pip install numpy” is shows unable to find *‘vcvarsall.bat’* I don’t know
> how to fix it. I tried several things nothing works.

You clearly haven’t tried enough, as this question is answered by a
simple Google search. You need to:

(a) install Visual Studio 2015 and configure it; or
(b) find a binary package, eg. here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

A student who wants to work in programming should be able to find
answers to their questions online. And know better than putting a
phone number in their e-mail signature for the whole world to see.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-24 Thread Chris Warrick
On 24 December 2015 at 20:39, Aaron Christensen
 wrote:
> Hi all,
>
> I am not sure if this is the correct venue for my question, but I'd like to
> submit my question just in case.  I am not a programmer but I do have an
> incredible interest in it, so please excuse my lack of understanding if my
> question isn't very thorough.
>
> As an example, a website backend is developed using Python.  Users can
> submit their input through the website and PHP (or some other language)

Cut out the middle man! Write your web app in Python, which is much
saner and more modern than PHP ever will be. Write it in Django, or
Flask, or Pyramid, or [insert favorite web framework here].

> transfers the user input from the website fields to a database such as
> MySQL.  There is a main script called main_script.py which extracts the
> user data from MySQL, processes it, stores output in MySQL and sends output
> to the user (via webpage and email).
>
> About main_script.py
> # main_script.py extracts user input from MySQL, processes it, stores
> output in MySQL and send output to user (via webpage and email).
> # Inputs: User personal information such as age, dob, nationality, hobbies,
> and 20 or 30 other fields
> # Output: main_script.py is going to do something with it such as access
> the database and some shelve files or other py scripts. I have no clue what
> it's going to do, but my point is that the processing of the input to
> output will take longer than simply a print('Hello, %r!' %user_name).

Well then, figure it out first.You shouldn’t be using shelve, it’s
really unsafe and error-prone — and you already have a perfectly
serviceable database! (PS. PostgreSQL is better)

> My question:  I am curious to know how Python handles something like this.
> Let's say that there are 10, 20, 50, or even 1000 users accessing the
> website.  They all put in their 20 to 30 pieces of input and are waiting on
> some fancy magic output.  How exactly does that work?  Can multiple users
> access the same script?  Does the Python programmer need to code in a
> manner that supports this?  Are requests to the script handled serially or
> in parallel?

We don’t know how you will structure your application.
If you do the “fancy magic” in your web app, which you should if it
won’t take more than, say, 5 seconds, this will be handled by your
WSGI server (eg. uwsgi), which typically can spawn threads and
processes for your web application. Otherwise, you might need to use
an async framework or a task queue with multiple workers.
It would be better to have some idea of the desired output, though.

There are many Python-based web services out there, eg. YouTube,
Instagram or DISQUS. And they work well under constant load.
-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Chris Warrick
[Forwarding your message to the mailing list — please use the Reply
All (or Reply to List) button in the future]

On 25 December 2015 at 05:02, Aaron Christensen
 wrote:
> Hi Chris,
>
> Thank you for your response and information.  I enjoy doing Python on my
> free time so when I get closer to some kind of web application, then I can
> provide more information.
>
> Thanks for pointing me in the right direction so far.  I will replace any
> shelve usage with the database.  I also started looking at WSGI servers and
> just found a great deal of information on fullstackpython.com.

Full Stack Python is a good resource, which teaches many things
considered best practices in the Python web world (I personally
recommend uWSGI instead of Gunicorn, but that’s mainly just my
preference)

> I have some experience in PHP (which is why I mentioned it).  I am
> unfamiliar with Django, Flask, or Pyramid.  I am looking into Django, but am
> a little hesitant because of all the time I spent learning PHP.

I’m sorry, but you wasted your time. PHP is an awful language with
multiple problems and bad design decisions. Here’s some laughing
stock:

http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
http://reddit.com/r/lolphp
http://phpsadness.com/

On the other hand, Python web frameworks are really fun and easy to
learn, even though their general design is a bit different from PHP’s:

https://docs.djangoproject.com/en/1.9/intro/tutorial01/
http://tutorial.djangogirls.org/en/

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Chris Warrick
On 25 December 2015 at 13:15, Aaron Christensen
 wrote:
> LOL. Thanks!  PHP was definitely not very easy to pick up and I'm still
> having some issues. Last night I watched some tutorials on Django and plan
> on reading all of the links on the docs page of Django.  I will also look at
> your recommendation.  I think that will give me a good understanding.
> Hopefully Django isn't a copy/paste kinda "put your website together" like
> WordPress because my objective is to actually learn Python.

That’s not what WordPress is. WordPress is a blog engine that can be
used as a general-purpose CMS, full stop. You don’t need any coding
skills to build a website with WordPress. Many people have done that —
especially on wordpress.com or shared hosting services with one-click
WP installers; and even without an installer, setting up WordPress on
shared hosting requires a FTP client and reading comprehension
anyways.

On the other hand, Django is nothing like this. Django can do anything
you tell it to, and you need to write code. While Django handles some
things for you (eg. the admin panel or the ORM), you still need to
write models, views, URL configuration, etc. yourself. You need an
understanding of relational databases, HTTP, HTML/CSS, the template
engine, and you do need to write actual code.

And while there are tons of ready-made blog applications for Django
that you can install and use, you can (and should!) write your own in
an hour or two.  And it’s a lot more fun to do that than lazily
downloading something.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CGI

2015-12-27 Thread Chris Warrick
On 27 December 2015 at 18:59, Laurent Delacroix  wrote:
> On 26/12/15 10:41, Pol Hallen wrote:
>>
>> How can I execute a local command (like ls or similar) and show output
>> via browser?
>>
>
> Either you use a proper web framework (Flask, Bottle, Django in order of
> complexity) or you set up a web server with FastCGI support (e.g. nginx)
> and run a WSGI application behind it.
>
> Useful link:
> https://docs.python.org/2/howto/webservers.html#setting-up-fastcgi
>
> Lau
> --
> https://mail.python.org/mailman/listinfo/python-list

Better yet, use a real WSGI server like uWSGI and its associated nginx
module. (there are plenty of tutorials around the Internet)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I can not install matplotlib, numpy, scipy, and pandas.

2016-01-06 Thread Chris Warrick
On 5 January 2016 at 07:57, Omar Ray via Python-list
 wrote:
> I have version 3.5 of Python for Windows.  I have MS Visual C++ and also MS
> Visual Studio 2015.
>
> When I enter into the command window "pip install matplotlib", it reads this
> below (this is not the full version of it):
>
> [snip]
>
> How do I download matplotlib and the other packages mentioned in the subject
> line?
>
>
>
> -Omar Ray
>
> --
> https://mail.python.org/mailman/listinfo/python-list

On Windows, using prebuilt binaries is recommended instead of building
things yourself:

1. Installing matplotlib and pandas using pip, without mentioning
scipy and numpy just yet.
2. Install scipy and numpy from
http://www.lfd.uci.edu/~gohlke/pythonlibs/ (download matching files
and run pip install c:\path\to\file.whl ).

If anything in 1. fails, get a wheel package from the website mentioned in 2.

Alternatively, try:
https://www.scipy.org/install.html#individual-binary-and-source-packages

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Chris Warrick
On 8 February 2016 at 16:53, Random832  wrote:
> On Mon, Feb 8, 2016, at 10:46, Chris Angelico wrote:
>> > I still think we should just retroactively declare 3.5 to be python 5,
>> > and then keep going with python 6, 7, etc...
>>
>> http://dirtsimple.org/2004/12/python-is-not-java.html
>
> Java's hardly the only, or even the first, project to drop a version
> number. (I think the first may actually have been GNU Emacs), and it's
> certainly not the only one with a release schedule that frequently
> increments the major version number.
> --
> https://mail.python.org/mailman/listinfo/python-list

In fact, this was done by a very popular Python project two years ago.
That project is pip, which went from 1.5.6 to 6.0, and is now at
8.0.2.

And its best friend setuptools is up to version 20.0.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Chris Warrick
On 28 February 2016 at 14:49, Rustom Mody  wrote:
> On Sunday, February 28, 2016 at 6:54:40 PM UTC+5:30, Gordon Levi wrote:
>> Rustom Mody  wrote:
>> >Glade generates XML (last I saw)
>> >XML is text... kinda... but not quite
>> >eg XML is sometimes/somewhere space sensitive, sometimes not
>> >This can generate messy diffs
>>
>> That is also true of Python code but does not preclude effective
>> source control.
>
> Yes as I said its not satisfactory but not impossible to manage
>
> Heck Current state of art VCSes cannot even manage mismatching EOL conventions
> cleanly.
> And as usual they make a virtue out of the lack:
> "git stores binary data not text"
>
> which means that opening a file created on windows on linux and saving it in
> WITHOUT a SINGLE CHANGE
> can give you a 10,000 line diff!!

You clearly haven’t ever done that.

1. git can manage EOL changing if you want to enforce a newline style that way.
2. A good editor can read and write any newline style. It should also
not convert without asking the user.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Chris Warrick
On 28 February 2016 at 15:11, Rustom Mody  wrote:
> On Sunday, February 28, 2016 at 7:30:57 PM UTC+5:30, Chris Warrick wrote:
>> On 28 February 2016 at 14:49, Rustom Mody  wrote:
>> > On Sunday, February 28, 2016 at 6:54:40 PM UTC+5:30, Gordon Levi wrote:
>> >> Rustom Mody  wrote:
>> >> >Glade generates XML (last I saw)
>> >> >XML is text... kinda... but not quite
>> >> >eg XML is sometimes/somewhere space sensitive, sometimes not
>> >> >This can generate messy diffs
>> >>
>> >> That is also true of Python code but does not preclude effective
>> >> source control.
>> >
>> > Yes as I said its not satisfactory but not impossible to manage
>> >
>> > Heck Current state of art VCSes cannot even manage mismatching EOL 
>> > conventions
>> > cleanly.
>> > And as usual they make a virtue out of the lack:
>> > "git stores binary data not text"
>> >
>> > which means that opening a file created on windows on linux and saving it 
>> > in
>> > WITHOUT a SINGLE CHANGE
>> > can give you a 10,000 line diff!!
>>
>
>>
>> 2. A good editor can read and write any newline style. It should also
>> not convert without asking the user.
>
> git is a *collaborative* tool and should work when the other party is using
> notepad.

What should git do if someone saves, say, Ruby code as a .py file?
Should it rename it? Or should it figure out an equivalent snippet of
Python?

You probably have some rules in your project such as “Code must be
written in Python” or “Use 4-space soft tabs”. Your rulebook should
also include “Use an editor that understands LF line endings”. Notepad
is a joke that you should not tolerate. Problem solved.

(Notepad does not understand LF line endings and replaces them with
boxes. I also don’t think a Notepad user is likely to provide good
contributions, but that’s another thing)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question

2016-03-07 Thread Chris Warrick
On 7 March 2016 at 19:09, Jon Ribbens  wrote:
> On 2016-03-07, Ian Kelly  wrote:
>> On Mon, Mar 7, 2016 at 9:39 AM, Ben Morales  wrote:
>>> I am trying to download Python but I have windows 10 and I do not see a 64
>>> bit download for my operating system. Do you have a 64 bit for windows?
>>
>> What page are you looking at?
>> https://www.python.org/downloads/release/python-351/ has downloads for
>> both Windows x86 and Windows x86-64.
>
> It only appears to have downloads for 32-bit, or 64-bit AMD processors,
> not 64-bit Intel processors.
> --
> https://mail.python.org/mailman/listinfo/python-list

Modern Intel processors use the amd64 (aka x86_64) architecture.
Intel’s Itanium architecture (IA-64) never really took off, and was
not supported by the consumer versions of Windows (other than XP x64).

(Not to mention 32-bit processors are sometimes called i386…i686,
where the i stands for Intel, and those processors were also
manufactured by AMD and others)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pdf version of python tutorial

2016-03-13 Thread Chris Warrick
On 13 March 2016 at 14:45, kamaraju kusumanchi
 wrote:
> Is there a pdf version of the python tutorial
> https://docs.python.org/3/tutorial/index.html that I can download? The
> idea is to have everything in one file so I can search easily, be able
> to work offline.
>
> thanks
> raju
> --
> Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog
> --
> https://mail.python.org/mailman/listinfo/python-list

There is a download link on the documentation index:

https://docs.python.org/3/download.html

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: E-commerce system in Python

2016-03-18 Thread Chris Warrick
On 18 March 2016 at 05:25, Arshpreet Singh  wrote:
> I am looking for an E-commerce system in python to sell things things online, 
> which can also be responsive for Android and IOS.
>
> A  quick Google search brought me  http://getsaleor.com/ it uses Django, Is 
> there any available one using Flask or newly born asyncio based framework?
> --
> https://mail.python.org/mailman/listinfo/python-list

asyncio is, as you said, brand new — probably nothing exists.
Why not use the existing Django solution though? What is your problem
with it? It’s a great framework that does a lot of the hard work for
you. Flask is low-level.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginner Python Help

2016-03-19 Thread Chris Warrick
On 18 Mar 2016 08:05, "Alan Gabriel"  wrote:
>
> Hey there,
>
> I just started out python and I was doing a activity where im trying to
find the max and min of a list of numbers i inputted.
>
> This is my code..
>
> num=input("Enter list of numbers")
> list1=(num.split())
>
> maxim= (max(list1))
> minim= (min(list1))
>
> print(minim, maxim)
>
>
>
> So the problem is that when I enter numbers with an uneven amount of
digits (e.g. I enter 400 20 36 85 100) I do not get 400 as the maximum nor
20 as the minimum. What have I done wrong in the code?

You're dealing with strings (text) and not integers. And when comparing
strings, '1' is earlier than '2', thus '100' < '20'.

To fix this, you can use a list comprehension:

list1 = [int(i) for i in num]

You also don't need (parentheses) around functions when assigning to
variables:

maxim = max(list1)
minim = min(list1)

(Also, list1 is not a good variable name. Try something that describes its
contents.)

-- 
Chris Warrick <https://chriswarrick.com/>
Sent from my Galaxy S3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python boilerplate

2016-03-19 Thread Chris Warrick
On 19 March 2016 at 13:43, Fernando Felix do Nascimento Junior
 wrote:
> A simple boilerplate for those who don't know the structure of a project. 
> https://goo.gl/lJRvS6
>
> ## Features
>
> * Build and distribute with setuptools
> * Check code style with flake8
> * Make and run tests with pytest
> * Run tests on every Python version with tox
> * Code coverage with coverage.py
>
> [snip]
>
> Fernando Felix

I would recommend using cookiecutter, a tool that automates things
like these. I have my own template, based on cookiecutter:
https://github.com/Kwpolska/python-project-template — it has a
comprehensive `release` script, and follows best practices (including
entry_points or packages instead of modules). It also uses .rst
instead of .md documents.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WP-A: A New URL Shortener

2016-03-19 Thread Chris Warrick
Please use reply-all in the future so that the list sees your message.

On 17 March 2016 at 11:38, Vinicius  wrote:
> Thanks for replying Chris,
>
> Enviado do meu iPad
>
>> Em 16 de mar de 2016, às 1:18 PM, Chris Warrick  
>> escreveu:
>>
>>> On 15 March 2016 at 20:56, Vinicius Mesel  wrote:
>>> Hey guys,
>>>
>>> I'm a 16 year old Python Programmer that wanted to do something different.
>>> But, like we know, ideas are quite difficult to find.
>>> So I decided to develop a URL Shortener to help the Python community out 
>>> and share my coding knowledge, and today the project was launched with its 
>>> first stable version.
>>> So if you want to see the software working, go check it out at: 
>>> http://wp-a.co/
>>> Or if you want to see the source code to contribute and help the project: 
>>> https://github.com/vmesel/WP-A.CO
>>>
>>>
>>> Hugs,
>>> Vinicius Mesel
>>> Brazilian and Portuguese Speaker
>>> http://www.vmesel.com
>>>
>>>
>>>
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>
>> This is a great exercise — however, your code is bad. You use string
>> formatting to create SQL, which leads to SQL injection
>> vulnerabilities. Please educate yourself on what those mean and how to
>> avoid that in Python (hint: prepared statements). Also, you should not
>> commit your sqlite database to git.
>>
> Thanks for checking out my code and answering me, I will do the corrections 
> for the SQL Injection vulnerabilities with prepared statements like you said.
>
> The database in the git is to show to everyone how the URL is stored.

You can show people a schema and write a small script that imports it.
You may add some demo URLs if you insist.

>> That said, an URL shortener can be written in Django in less than an
>> hour, and it will be even neater.
>>
>
> I did not make it in Django because I was in need to learn flask for other 
> projects.
>
>
>> (PS. the page’s really ugly. Consider using Bootstrap or some other
>> existing framework if you’re not good at designing pretty things.)
>
> I'll consider it.
>
>> --
>> Chris Warrick <https://chriswarrick.com/>
>> PGP: 5EAAEA16
>
> @vmesel



-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WP-A: A New URL Shortener

2016-03-19 Thread Chris Warrick
On 15 March 2016 at 20:56, Vinicius Mesel  wrote:
> Hey guys,
>
> I'm a 16 year old Python Programmer that wanted to do something different.
> But, like we know, ideas are quite difficult to find.
> So I decided to develop a URL Shortener to help the Python community out and 
> share my coding knowledge, and today the project was launched with its first 
> stable version.
> So if you want to see the software working, go check it out at: 
> http://wp-a.co/
> Or if you want to see the source code to contribute and help the project: 
> https://github.com/vmesel/WP-A.CO
>
>
> Hugs,
> Vinicius Mesel
> Brazilian and Portuguese Speaker
> http://www.vmesel.com
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

This is a great exercise — however, your code is bad. You use string
formatting to create SQL, which leads to SQL injection
vulnerabilities. Please educate yourself on what those mean and how to
avoid that in Python (hint: prepared statements). Also, you should not
commit your sqlite database to git.

That said, an URL shortener can be written in Django in less than an
hour, and it will be even neater.

(PS. the page’s really ugly. Consider using Bootstrap or some other
existing framework if you’re not good at designing pretty things.)
-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python boilerplate

2016-03-21 Thread Chris Warrick
On 21 March 2016 at 00:36, Fernando Felix do Nascimento Junior
 wrote:
> I made the boilerplate with intent that everyone can understand, download and 
> use quickly. So, I didn't put extra dependence like cookiecutter (that 
> depends jinja, that depends markupsafe) to **just** replace fields and then 
> run the project.

I used “replace manually” before, and it was painful.

> I also preferred to use .md instead .rst because it's more clean in my 
> opinion and used by default in platforms like GitHub and Stackoverflow. See 
> mkdocs to generate documentation with markdown.

The vast majority of the Python community uses Sphinx and reST. In
fact, that’s the only thing accepted on readthedocs.org, which is a
popular documentation platform.

> I didn't understand why packages are best than modules... both can be 
> reusable and not every project needs packages.

It might not need it today, but it will probably grow. At which point
you will notice that a module is not enough. You can also easily
separate code with packages.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make Python interpreter a little more strict?

2016-03-26 Thread Chris Warrick
On 25 March 2016 at 13:06, Aleksander Alekseev  wrote:
> Hello
>
> Recently I spend half an hour looking for a bug in code like this:
>
> eax@fujitsu:~/temp$ cat ./t.py
> #!/usr/bin/env python3
>
> for x in range(0,5):
> if x % 2 == 0:
> next
> print(str(x))
>
> eax@fujitsu:~/temp$ ./t.py
> 0
> 1
> 2
> 3
> 4
>
> Is it possible to make python complain in this case? Or maybe solve
> such an issue somehow else?
>
> --
> Best regards,
> Aleksander Alekseev
> http://eax.me/
> --
> https://mail.python.org/mailman/listinfo/python-list

You were probably looking for `continue`. This is just bad memory on
your part, and Python can’t help. In the REPL, typing an object name
is legal and helpful. Other languages might crash, sure — but they
usually don’t have a REPL like Python does.

That said, this code is designed badly. Here’s a better idea (also,
note the fixed print statement):

for x in range(0, 5):
if x % 2 != 0:
print(x)

Or even with a more suitable range() that adds 2 instead of 1 in each step:

for x in range(1, 5, 2):
print(x)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] how to make program suggest to install missing modules

2014-12-12 Thread Chris Warrick
On Dec 12, 2014 11:56 AM, "hugocoolens"  wrote:
>
> On Monday, December 8, 2014 9:00:13 PM UTC+1, sohca...@gmail.com wrote:
> > On Monday, December 8, 2014 10:46:47 AM UTC-8, Jean-Michel Pichavant
wrote:
> > > - Original Message -
> > > > From: sohcahto...@gmail.com
> > > > try:
> > > > import someModule
> > > > except ImportError:
> > > > print "Module is missing"
> > > > # handle it!
> > > >
> > > > Just make sure to attempt to import it again after making the call
to
> > > > pip to install it.
> > >
> > > Note that ImportError may be raised for other reasons than a missing
module.
> > >
> > > Check https://docs.python.org/2/library/imp.html and the
imp.find_module, it could be a safer way to check for a missing module.
> > >
> > > JM
> > >
> > >
> > > -- IMPORTANT NOTICE:
> > >
> > > The contents of this email and any attachments are confidential and
may also be privileged. If you are not the intended recipient, please
notify the sender immediately and do not disclose the contents to any other
person, use it for any purpose, or store or copy the information in any
medium. Thank you.
> > Good point.
> > Of course, imp.find_module ALSO throws ImportError if the module can't
be found, but at least in that case, you'd know the exact cause.
>
> Thanks for the suggestions, you can see here below what I came up with.
> All suggestions/corrections welcome:
>
> #!/usr/bin/env python
> import imp
> import os
> import sys
> try:
> imp.find_module('rtlsdr')
> except ImportError:
> print('Module rtlsdr is missing')
> print("I'll try to install it")
> os.system('sudo pip install pyrtlsdr')
> try:
> imp.find_module('rtlsdr')
> except ImportError:
> sys.exit('Sorry could not install module rtlsdr, contact your
> local Python-guru')
> import rtlsdr
> print('Module rtlsdr succesfully imported')
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

This is bad practice. The user should install it themselves: sudo pip may
interfere with virtualenv and OS package managers. Just tell the user what
to install and call it a day.

-- 
Chris Warrick <https://chriswarrick.com/>
Sent from my Galaxy S3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Run Programming ?????

2014-12-12 Thread Chris Warrick
On Dec 12, 2014 1:40 PM, "Delgado Motto"  wrote:
>
> I travel alot, if not just interested in things of pocketable
portability, and was curious if you can tell me if Python can be LEARNED
from beginner on an IOS device ( with interest of being able to test my
code, possibly even if a free website is capable of reviewing scripts ) but
if not then I prefer if you can suggest a language that can be used from
such a machine. My ultimate goal is to be able to create web pages and
internet bots capable of searching specific things for me, simply to save
me time in my day as little as crawling Youtube for a song that fails to be
uploaded or other related examples. Please advise me. Thanks.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Get a real computer. An iOS device won't work, unless you care to buy a
vps, use ssh and can stand the onscreen keyboard. It's easier to buy a
notebook.

-- 
Chris Warrick <https://chriswarrick.com/>
Sent from my Galaxy S3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to use the .isalpha() function correctly

2014-12-14 Thread Chris Warrick
On Sun, Dec 14, 2014 at 6:16 PM, Luke Tomaneng  wrote:
> Here a very small program that I wrote for Codecademy. When I finished, 
> Codecademy acted like it was correct, but testing of this code revealed 
> otherwise.
> --
> print 'Welcome to the Pig Latin Translator!'
>
> # Start coding here!
> raw_input("Enter a word:")
> original = str(raw_input)
> if len(original) > 0 and original.isalpha():
> print original
> else:
> print "empty"
> --
> No matter what I type in, the result is "empty." What do I need to do in 
> order for it to accept words?
> --
> https://mail.python.org/mailman/listinfo/python-list

That’s not where the error is, actually.  You are:

1. taking input with "Enter a word: " and NOT SAVING IT
2. setting original to a string representation of the function
`raw_input`, which is something like

>>> str(raw_input)
''

The correct way to do this is:

original = raw_input("Enter a word: ")

as raw_input already outputs a string.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-16 Thread Chris Warrick
On Tue, Dec 16, 2014 at 4:01 PM, Veek M  wrote:
> Has anyone got the thing to work? I want to run some python database scripts
> on nginx. Because that will have a simple web-UI, i decided to go with
> uWSGI. It's proving to be a massive pain.
>
> I found a decent book for nginx and got that bit working. The query gets
> sent to uWSGI but for some reason it can't find my script.
>
> Most of the documentation on the web is utterly horrid and will take a 4
> year PhD to understand. I don't undertsand the architecture of uWsgi - he's
> got a bunch of modules and I don't undertsand what exactly is going on
> inside it!
>
> less /etc/nginx/sites-enabled/default
> location / {
> include uwsgi_params;
> uwsgi_pass unix:/run/uwsgi/app/uwsgi/sockete;
> uwsgi_param UWSGI_PYHOME /usr/share/nginx/cgi;
> uwsgi_param UWSGI_CHDIR /usr/share/nginx;
> uwsgi_param UWSGI_SCRIPT index; #NOT SURE WHAT THIS DOES?
>
>
> less /etc/uwsgi/apps-enabled/uwsgi.ini
> [uwsgi]
> plugins=python
> socket=/tmp/uwsgi.socket
> pythonpath=/usr/share/nginx/cgi/
>
> Tue Dec 16 20:43:21 2014 - Python main interpreter initialized at 0x95cde0
> Tue Dec 16 20:43:21 2014 - your server socket listen backlog is limited to
> 100 connections
> Tue Dec 16 20:43:21 2014 - *** Operational MODE: preforking ***
> Tue Dec 16 20:43:21 2014 - added /usr/share/nginx/cgi/ to pythonpath.
> Tue Dec 16 20:43:21 2014 - *** no app loaded. going in full dynamic mode ***
> Tue Dec 16 20:43:21 2014 - *** uWSGI is running in multiple interpreter mode
> ***
> Tue Dec 16 20:43:21 2014 - spawned uWSGI master process (pid: 18792)
> Tue Dec 16 20:43:21 2014 - spawned uWSGI worker 1 (pid: 18818, cores: 1)
> Tue Dec 16 20:43:21 2014 - spawned uWSGI worker 2 (pid: 18819, cores: 1)
>
>
> ::1 - - [16/Dec/2014:21:08:03 +0530] "GET /foo.py HTTP/1.1" 502 172 "-"
> "Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0"
> --
> https://mail.python.org/mailman/listinfo/python-list

This is NOT how uwsgi works!  You cannot use plain .py files with it,
and for good reason — CGI should be long dead.

What you need to do is, you must write a webapp — in Flask, for
example.  Then you must craft an .ini file that mentions this.

With the http://flask.pocoo.org/ demo as /var/flask/hello.py
(copy-pasting from my working site):

--- nginx config --
location {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}

--- /etc/uwsgi/apps-enabled/hello.ini ---

[uwsgi]
emperor = true
socket = 127.0.0.1:3031
chdir = /var/flask/
master = true
threads = 5
module = %n
callable = app
plugins = python
uid = http
gid = http
processes = 3


--- If /var/flask is a virtualenv, add:

binary-path = /var/flask/bin/uwsgi
virtualenv = /var/flask

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-22 Thread Chris Warrick
On Mon, Dec 22, 2014 at 4:36 PM, Jussi Piitulainen
 wrote:
> Steven D'Aprano writes:
>
>> Don't try this at home!
>>
>> # download_naked_pictures_of_jennifer_lawrence.py
>> import os
>> os.system("rm ――rf /")
>
> Not sure what that character is (those characters are) but it's not
> (they aren't) the hyphen that rm expects in its options, so:
>
>   >>> os.system("rm ――rf /")
>   rm: cannot remove `――rf': No such file or directory
>   rm: cannot remove `/': Is a directory
>   256

Let‘s ask Python: (polyglot 2.6+/3.3+ code!)

from __future__ import print_function
import unicodedata
command = u"rm ――rf /"
for i in command:
print(hex(ord(i)), unicodedata.name(i))

0x72 LATIN SMALL LETTER R
0x6d LATIN SMALL LETTER M
0x20 SPACE
0x2015 HORIZONTAL BAR
0x2015 HORIZONTAL BAR
0x72 LATIN SMALL LETTER R
0x66 LATIN SMALL LETTER F
0x20 SPACE
0x2f SOLIDUS

There’s your answer: it’s U+2015 HORIZONTAL BAR, twice.  And `rm`
wants U+002D HYPHEN-MINUS instead.

Moreover, it wants only one HYPHEN-MINUS and not two:

Linux:
$ rm --rf /
rm: unrecognized option '--rf'
Try 'rm --help' for more information.

BSD:
$ rm --rf /
rm: illegal option -- -
usage: rm [-f | -i] [-dIPRrvWx] file ...
   unlink file

That’s two-step “protection”.

(This e-mail brought to you by Unicode.)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem with for and if

2015-01-05 Thread Chris Warrick
On Mon, Jan 5, 2015 at 3:27 PM, Dariusz Mysior  wrote:
> I want search count of szukana in zmienna but code below counting all 12 
> letters from "traktorzysta" word

First off, I recommend that you do not write code in Polish — use
English so that everyone can understand your code.

Your error is here:
> for a in zmienna:
> if szukana in zmienna:

You shouldn’t be looking in `zmienna`, you should be checking `a` —
the letter of the word used in the current iteration.  Moreover, you
should use == for the comparison — compare the letter in the current
iteration to 't'.  The correct line WOULD be

if a == szukana:

BUT there is actually a better solution.  You see, Python is a
language with “batteries included” — that is, many things are already
available for you to use without need to re-implement them.  Just use
str.count, which will do it for you:

zmienna = 'traktorzysta'
szukana = 't'
print("Literka '",szukana,"' w słowie ",zmienna,
  "wystąpiła ",zmienna.count(szukana)," razy")

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: application console with window

2015-01-08 Thread Chris Warrick
On Thu, Jan 8, 2015 at 5:18 PM, adam  wrote:
> I just learn python. If you write in Polish it will be easier for me to
> explain any problem, because my English is very thin.

You cannot really learn to program without speaking English well.  If
you can’t speak English, you will have lots of issues: it will be
harder to memorize things, you will be writing function/… names
brainlessly and, most importantly, you won’t be able to communicate
with other programmers (as demonstrated here).  English IS the
official language of technology, period. You should improve your
English first if you want to succeed in the industry (or create
anything advanced).

This Usenet newsgroup/mailing list is for English-language discussion
only.  Polish-language communities exist, you can search around if you
want.

As Emil said, urwid is the package to use to create a CLI
(command-line interface).  However, the list of OSes you provided
includes Windows, which makes it very problematic (you would have to
install Cygwin).  You could also switch to a GUI (graphical user
interface) with eg. Tkinter or something else that looks much better
than ugly old Tkinter (eg. PyQT).

---

Nie możesz się nauczyć programować bez dobrej znajomości angielskiego.
Jeśli nie umiesz mówić po angielsku, będziesz miał wiele problemów:
trudniej będzie Ci zapamiętać wszystko, będziesz zapisywał nazwy
funkcji/… bezmyślnie i, co najważniejsze, nie będziesz mógł się
komunikować z innymi programistami (co zostało tu zademonstrowane).
Angielski JEST językiem oficjalnym technologii.  Powinieneś
podszlifować swój angielski jeśli chcesz odnieść sukces w branży (lub
nawet napisać coś bardziej zaawansowanego)

Ta grupa Usenetowa/lista dyskusyjna jest przeznaczona tylko do
dyskusji w języku angielskim.  Grupy w języku polskim na pewno
istnieją, możesz poszukać.

Jak powiedział Emil, powinienieś użyć pakietu urwid jeśli chcesz
utworzyć CLI (interfejs wiersza poleceń).  Na liście systemów
operacyjnych jest Windows, co bardzo utrudnia sprawę (musiałbyś
zainstalować Cygwina).  Możesz też przejść na GUI (graficzny interfejs
użytkownika), np. przy użyciu biblioteki Tkinter lub czegoś innego co
wygląda lepiej niż stary brzydki Tkinter (np. PyQT)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-10 Thread Chris Warrick
On Sat, Jan 10, 2015 at 2:02 AM, André Roberge  wrote:
> On Friday, 9 January 2015 19:09:15 UTC-4, stephen...@gmail.com  wrote:
>> One issue is the format returned for the calendar selection. For today, the 
>> string returned is "Fri Jan 9 2015". My script needs to convert the date to 
>> a datetime.date, and having the month returned as a string instead of an 
>> integer makes this harder.
>
> Would today's date be represented as the string "09.01.2015" useful to you? 
> (I found out how to do this.)  If so, I could perhaps add an argument like 
> numeric_format = True.

The correct way to handle this is to use cal.date.toPyDate(), which
helpfully returns a datetime.date object — and make this the default
output of the calendar function, because that’s the only useful output
for anyone asking for a date.

>>> date
'Sat Jan 10 2015'
>>> cal.date
PyQt4.QtCore.QDate(2015, 1, 10)
>>> cal.date.toPyDate()
datetime.date(2015, 1, 10)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] absolute vs. relative URI

2015-01-23 Thread Chris Warrick
On Fri, Jan 23, 2015 at 4:40 PM, Grant Edwards  wrote:
> On 2015-01-23, Marko Rauhamaa  wrote:
>> Grant Edwards :
>>
>>> I'm not an HTLM/HTTP guru, but I've tinkered with web pages for 20+
>>> years, and for links within sites, I've always used links either
>>> relative to the current location or an absolute _path_ relative to the
>>> current server:
>>>
>>>   Whatever
>>>
>>> I've never had any problems with links like that.  Is there some case
>>> where that doesn't work right and I've just been stupidly lucky?
>>
>> An ancient HTML spec (https://tools.ietf.org/html/rfc1866>)
>> specifies:
> [...]
>> It refers to the URI spec (https://tools.ietf.org/html/rfc1630>):
> [...]
>>
>> Bottom line: you are safe.

Technically, there is one way to break things:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

However, nobody really uses that.  Determining the protocol and server
URL is a lot of effort, but it does not give any advantages over plain
"/Whatever".  Moreover, it would be safer and more future-proof to use
a protocol-relative "//example.com/Whatever" URL instead of
determining the protocol by ports (why 8433?  I can serve (insecure)
HTTP there; hell: I can be a complete jerk and swap ports 80 and
443!).

But, this webapp completely ignores a pitfall in the process: it
assumes the app lives in the web server root.  You can easily change
this via your favorite HTTP daemon.

> Thanks, I was pretty sure that was the case. But, I'm still baffled
> why the original author(s) went to the extra work to always generate
> absolute URIs.  The pages were originally developed by a web
> development company we contracted to do the initial design for us. We
> were _assuming_ they knew more about that sort of thing than we
> old-school EE types.

Hah!  Those people certainly don’t look “experienced”.

   "

Re: Is there a more elegant way to spell this?

2015-01-27 Thread Chris Warrick
On Jan 27, 2015 2:16 PM, "Neal Becker"  wrote:
>
> Is there a more elegant way to spell this?
>
> for x in [_ for _ in seq if some_predicate]:

for x in seq:
if some_predicate:
do_something_to(x)

-- 
Chris Warrick <https://chriswarrick.com/>
Sent from my Galaxy S3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use à Python 2 module with Python 3

2015-03-11 Thread Chris Warrick
On Wed, Mar 11, 2015 at 8:20 PM, Michael Torrie  wrote:
> My biggest complaint with PySide is that for historical reasons (looking
> at you, PyQt), it does not use pep8 naming conventions, which makes for
> some really ugly function and method names.

This isn’t PyQt’s fault.  Both are more-or-less straight bindings to
the underlying C++ Qt library, which does not follow Python’s naming
conventions.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Chris Warrick
On Thu, May 14, 2015 at 8:11 PM, Grant Edwards  wrote:
> On 2015-05-14, Dave Farrance  wrote:
>> Steven D'Aprano  wrote:
>>
>>>I'd like to do a little survey, and get a quick show of hands.
>>>
>>>How many people have written GUI or text-based applications or scripts where
>>>a "Move file to trash" function would be useful?
>>>
>>>Would you like to see that in the standard library, even if it meant that
>>>the library had feature-freeze and could gain no more functionality?
>>
>> It's bad enough when things are filesystem-dependent but this is
>> OS-dependent or even desktop-version-dependent in the case of Linux
>> distros, so not easy.
>
> Or even file-manager dependent.  I think some desktops support
> multiple file-manager (at least XFCE always used to) -- and there's
> probably no requirement that they all handle "trash" the same way.

Actually, there is. There are actual STANDARDS in Linux desktops. One
of them is the Trash Specification:
http://standards.freedesktop.org/trash-spec/trashspec-1.0.html

This spec is implemented by Xfce, KDE, GNOME, PCManFM and probably many others.

And if you are looking for a mostly-compliant Python library/app (and
a shameless plug): https://pypi.python.org/pypi/trashman/1.5.0

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using "import math".

2015-06-06 Thread Chris Warrick
On 7 Jun 2015 00:06, "Steve Burrus"  wrote:
>
> I need some help/assistance with using the python "import math" function.
Like I am trying to do a = math.sqrt(1000)
>   a.sqrt
> but it fails. what am I doing wrong? Thanx for anyone's help.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Here's what your code did:

import math  # make the math module accessible
a = math.sqrt(1000)  # set `a` to the square root of 1000 (≈31.62...)
a.sqrt  # get a reference to the sqrt method/attribute of a float, which
does not exist; moreover you are not calling the method/discarding the
value so it would be useless anyways

-- 
Chris Warrick <https://chriswarrick.com>
Sent from my Galaxy S3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is it a newsgroup or a list?

2015-06-07 Thread Chris Warrick
On Sun, Jun 7, 2015 at 1:45 PM, Steven D'Aprano  wrote:
> As far as I know, python-list a.k.a. comp.lang.python is the only one of the
> Python mailing lists with an official newsgroup mirror.

comp.lang.python.announce also exists.

Sent via mailing list.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Chris Warrick
On Tue, Jun 9, 2015 at 8:08 PM, Neal Becker  wrote:
> One of the most annoying problems with py2/3 interoperability is that the
> pickle formats are not compatible.  There must be many who, like myself,
> often use pickle format for data storage.
>
> It certainly would be a big help if py3 could read/write py2 pickle format.
> You know, backward compatibility?

Don’t use pickle. It’s unsafe — it executes arbitrary code, which
means someone can give you a pickle file that will delete all your
files or eat your cat.

Instead, use a safe format that has no ability to execute code, like
JSON. It will also work with other programming languages and
environments if you ever need to talk to anyone else.

But, FYI: there is backwards compatibility if you ask for it, in the
form of protocol versions. That’s all you should know — again, don’t
use pickle.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New Python student needs help with execution

2015-06-11 Thread Chris Warrick
On Thu, Jun 11, 2015 at 10:52 AM, Laura Creighton  wrote:
> In a message of Wed, 10 Jun 2015 21:50:54 -0700, c me writes:
>>I installed 2.7.9 on a Win8.1 machine. The Coursera instructor did a simple 
>>install then executed Python from a file in which he'd put a simple hello 
>>world script.  My similar documents folder cannot see the python executable.  
>>How do I make this work?
>>--
>>https://mail.python.org/mailman/listinfo/python-list
>
> You need to set your PYTHONPATH.
> Instructions here should help.
> https://docs.python.org/2.7/using/windows.html
>
> It is possible that you need to do some other things too, but again
> that's the doc for it.
>
> Laura
> --
> https://mail.python.org/mailman/listinfo/python-list

It’s actually %PATH%. %PYTHONPATH% does something different and is not
really useful to newcomers (especially since there are much better
ways to accomplish what it does)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to configure Apache and Python 2.7 on Red Hat I get 403 Forbidden

2015-06-16 Thread Chris Warrick
On Tue, Jun 16, 2015 at 12:11 PM, Néstor Boscán  wrote:
> I disabled selinux completely and the page worked.

So, selinux was the problem (which is typical, it’s a really dumb
piece of software)

The command to disable enforcing temporarily is actually "setenforce
0". Though you would need to issue it on every restart if you did not
change the config file.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to configure Apache and Python 2.7 on Red Hat I get 403 Forbidden

2015-06-16 Thread Chris Warrick
On Tue, Jun 16, 2015 at 8:14 PM, Néstor Boscán  wrote:
> I tried that but it didn't work.
>
>  I had to change /etc/selinux/config and reboot to make it work. It would be
> nice if the wsgi module generated some log that explains why you get the
> 403. There are several posibilities.

Well, that’s not wsgi’s fault.  There was a “permission denied” error,
that’s everything wsgi ever knew.
As a RHEL sysadmin, you should know that this is most likely caused by
braindead syslinux and to read the audit log.

PS. please don’t top-post.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] PySWITCH 0.2

2015-06-26 Thread Chris Warrick
On 26 June 2015 at 04:42, Godson Gera  wrote:
>
> =
> pyswitch 0.2
> =
>
> PySWITCH 0.2 is released
>
> Please, note that PySWITCH 0.2 is not available on PyPI because of name 
> conflict

This is not a good idea. You should just change your name, or upload
under a slightly different name to PyPI. Everyone is on PyPI, everyone
expects to be able to type `pip install`, so please work on that.

> [snip]
> Project website: http://pyswitch.sf.net
> Download Page: http://pyswitch.sourceforge.net/pages/download.html

You are not going to get a lot of downloads with that. SourceForge
spreads malware, and lots of people avoid them nowadays.

Upload to PyPI and switch to GitHub, or you won’t be successful in this world.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: understanding why there is no setup.py uninstall

2015-07-06 Thread Chris Warrick
On 5 July 2015 at 11:04,   wrote:
> This question is not technical.
> I know that there is no 'uninstall' Option in a setup.py.
> I know this discussions and workarounds for that problem, too.
> <http://stackoverflow.com/questions/1550226/python-setup-py-uninstall>
>
> I want to understand the design concept behind it.
>
> Why isn't there no uninstall routine implemented?
>
> For me as a user and admin it feels quite dirty when installing
> something with the setup.py but then not being able to remove it clean
> like I would do it with packages of my system-package-manager (e.g. with
> apt-get on a debianized system).
> --
> https://mail.python.org/mailman/listinfo/python-list

Don’t use setup.py, use pip. If you are working with a pypi package,
just use pip install foo. If you have a local package, you can point
pip to a tarball, or to an unpacked directory:

$ pip install foo-0.1.0.tar.gz
$ pip install /home/kwpolska/bar
$ cd baz; pip install .

pip has an uninstall option. (It should also work with packages
installed with plain setup.py.)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [setuptools] install data-file in users home-dir

2015-07-10 Thread Chris Warrick
On 10 July 2015 at 03:11,   wrote:
> I am using setuptools to create a wheel file.
>
> There is a conf-file I want to install into the users config-diretory.
> e.g. /home/user/.config/appname/app.conf
>
> setup(...,
>   data_files = [ ('~/.config/appname/', ['app.conf']) ]
>  )
>
> I see two problems here:
>
> 1.
> I don't know the users "name". So I have to use a placeholder here.
> Does '~' work here in that case?

It doesn’t.  You would have to use os.path.expanduser, but don’t do that.

> 2.
> To install the wheel-file with pip I need sudo-privilegs on Ubuntu
> 14.04.2. That means while the install script runs I can not ask for the
> users name because it is "root" in that case.
> --
> https://mail.python.org/mailman/listinfo/python-list

You should NEVER use sudo with pip.  Instead, use virtualenvs as a
regular user, or create your own .deb packages.

And you should not create the files in your install script.  Instead,
install them to a different data dir (somewhere in 'share/appname', or
alongside your package). When someone runs your app, only then you
should copy this file to user’s config directory (use pkg_resources to
help you get it) if it does not exist yet.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [setuptools] install data-file in users home-dir

2015-07-10 Thread Chris Warrick
CC’ing the mailing list; please use Reply All in the future.

On 10 July 2015 at 16:36,   wrote:
> Hi Chris,
>
> thank you for your answer.
>
> On 2015-07-10 09:39 Chris Warrick  wrote:
>> You should NEVER use sudo with pip.  Instead, use virtualenvs as a
>> regular user, or create your own .deb packages.
>
> I am not sure, but maybe this is an Ubuntu-specific "problem"?
> When I don't use sudo I got errors like this
> "PermissionError: [Errno 13] Permission denied:
> '/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.0.6.dist-info"
>
> And it make sense for me.

This is correct.  Don’t install things system-wide with pip.

> Don't tell me about deb-Packages! :D I am stuck with that currently. I
> would be glad to have a correct working whl-file for my local needs.
> After that - maybe! - I will start again with thinking about a deb.
>
> How can virtualenv help here? I need to install
> python-software/packages to the system and not to a different
> environment or sandbox.
> I never used virtualenv but as I understand it it is for testing
> purpose not for productive system.

virtualenv should be used for both testing AND production
environments. Your projects can have different versions of
dependencies, and this is what virtualenv helps with: they are
separate from each other. You can also modify the system packages
without messing with your system packages.

You can also use pip install --user to install to ~/.local

>> And you should not create the files in your install script.  Instead,
>> install them to a different data dir (somewhere in 'share/appname'
>
> What do you mean with "data dir"? For a default config-file it could
> be /etc/appname/default.conf. But I have no rights for that.

https://pythonhosted.org/setuptools/setuptools.html#including-data-files

Makes your package installable through wheel files and friendly for
all environments.

>> should copy this file to user’s config directory (use pkg_resources to
>> help you get it) if it does not exist yet.
>
> I will look at this package.

https://pythonhosted.org/setuptools/setuptools.html#accessing-data-files-at-runtime

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble getting to windows My Documents directory

2015-07-11 Thread Chris Warrick
On 11 July 2015 at 02:24,   wrote:
> The My Documents directory is not guaranteed to be named "Documents". On
> older versions of windows it was "My Documents", and on foreign versions
> of windows it is a name in their language.

That’s not necessarily “older”.

Windows XP/7/8: My Documents
Windows Vista/8.1: Documents

As for localized versions, Vista and up do the translation in Windows
Explorer but use English names on disk.

…but even with all that, users (or their administrators) can move the
My Documents folder away from the home directory (to a file server,
for example).

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip

2015-08-31 Thread Chris Warrick
On 31 August 2015 at 11:43, chenc...@inhand.com.cn
 wrote:
> hi:
> Python 2.7.9 and later (on the python2 series), and Python 3.4 and later
> include pip by default.But i can not find it in python2.7.10 package. What's
> the matter? How can i install pip on my Embedded device?
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

The inclusion is handled by the ensurepip module. Run this:

python -m ensurepip

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need Help w. PIP!

2015-09-04 Thread Chris Warrick
On 4 September 2015 at 15:14, Dennis Lee Bieber  wrote:
> On Fri, 4 Sep 2015 04:27:47 +0100, Mark Lawrence 
> declaimed the following:
>
>
>>python3 just doesn't exist on Windows, it's always python.exe or
>
> Really?
>
> [snip]
> 09/17/2013  12:37 AM40,448 python.exe
> 09/17/2013  12:37 AM40,448 python3.3.exe
> 09/17/2013  12:37 AM40,448 python3.exe
> 09/17/2013  12:37 AM40,960 pythonw.exe
> 09/17/2013  12:37 AM40,960 pythonw3.3.exe
> 09/17/2013  12:37 AM40,960 pythonw3.exe
> [snip]
>
> I did not create those variant files, they were part of my original
> install from ActiveState.

You are using an unofficial build of Python; the official one (from
python.org) does not have `python3.exe`.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can anyone help me run python scripts with http.server?

2015-09-06 Thread Chris Warrick
On 6 September 2015 at 13:50,   wrote:
> Hello everyone,
>
> I want to use python for web development but I
> could not configure my Apache server to run python
> with the guides I found on the internet.
>
> Can anyone help me configure http.server
> to run python scripts?
>
> I ran the command python -m http.server --cgi to start the http server,
> and if I put index.html, I will see the page but if I use
> index.py, it doesn't show the page, I can only see the
> directory listing of the files and when I click on
> index.py, it doesn't run the code, I can see it just
> like in the editor.
>
> Can anyone help me out?
>
> Thanks in advance.
> --
> https://mail.python.org/mailman/listinfo/python-list

Don’t use http.server. Don’t use CGI. This is not how things work in Python.

In Python, you should use a web framework to write your code. Web
frameworks include Flask, Django, Pyramid… Find one that’s popular and
that you like, and learn that. You won’t have any `.py` URLs, instead
you will have modern pretty URLs with no extensions. And a lot of
things will be abstracted — no manual header creation, help with safe
forms and databases.

And then you will need to figure out how to run it. I personally use
nginx and uwsgi for this, you may need to look for something else.

Examples for Django:

https://docs.djangoproject.com/en/1.8/#first-steps
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for loop

2015-09-20 Thread Chris Warrick
On 20 September 2015 at 09:55, shiva upreti  wrote:
> https://ideone.com/BPflPk
>
> Please tell me why 'print s' statement is being executed inside loop, though 
> I put it outside.
> Please help. I am new to python.
> --
> https://mail.python.org/mailman/listinfo/python-list

You have mixed indentation. Your code contains both tabs and spaces.
Python interprets tabs as 8 spaces, while your other indentation is 4
spaces, leading to bad parsing.

Please make sure you use only spaces (reconfigure your editor to
always insert 4 spaces and reindent everything with tabs)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: Django Tutorial (Database setup) Question

2015-09-27 Thread Chris Warrick
Forwarding to list (forgot about this stupid reply all thing, sorry).


-- Forwarded message --
From: Chris Warrick 
Date: 27 September 2015 at 19:50
Subject: Re: Django Tutorial (Database setup) Question
To: Cai Gengyang 


On 27 September 2015 at 19:39, Cai Gengyang  wrote:
> http://pastebin.com/index/RWt1mp7F  Looking through my code , can't seem
> to find any errors yet. All the parentheses seem to be in place too, this is
> weird ...
>
> On Mon, Sep 28, 2015 at 1:01 AM, Chris Warrick  wrote:
>>
>> On 27 September 2015 at 18:18, Cai Gengyang  wrote:
>> > I believe I am already in the same directory that contains manage.py ,
>> > but I
>> > still get an error (a syntax error). Checked the lines in settings.py
>> > and
>> > can't find anything wrong with them either. Posted my entire code below
>> > :
>>
>> >   File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45
>> > 'django.middleware.csrf.CsrfViewMiddleware',
>> >   ^
>> > SyntaxError: invalid syntax
>>
>> There’s a typo on or before line 45. Pastebin your full settings.py
>> file, and try looking for errors (like missing parentheses) yourself.
>>
>> --
>> Chris Warrick <https://chriswarrick.com/>
>> PGP: 5EAAEA16
>
>

On further inspection, this might be a Django or Python problem… try
re-installing Django. I don’t really know what could be wrong here.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide window does not resize to fit screen

2015-10-01 Thread Chris Warrick
On 1 October 2015 at 15:44, Hedieh Ebrahimi  wrote:
> Dear all,
>
> I am using Pyside to create a user interface for my app.
> The app works fine on my computer with big screen, but when I take it to my 
> laptop with smaller screen size, it does not resize to match the screen size.
>
> How can I make my main widget get some information about the screen size and 
> resize automatically?
>
> Thanks in Advance for your answers.
> --
> https://mail.python.org/mailman/listinfo/python-list

The correct way to do this is to lay your application out using a
layout.  The available layouts are:

* QHBoxLayout
* QVBoxLayout
* QGridLayout
* QFormLayout

The exact layout to use depends on your needs.

What are you using to create your Qt code? Are you using Qt Designer
or are you writing the code by hand?  If you are using Qt Designer,
use the “Lay Out…” buttons in the Form menu or on the tool bar.  If
you are writing Qt code by hand, it looks roughly like this (for a
VBox; Grid and Form are more complicated as they involve positioning):

lay = QtGui.QVBoxLayout(self)  # your central widget, dialog, main
window — whichever one exists
btn = QtGui.QButton("Hello", lay)
lay.addWidget(btn)

Please check with Qt documentation for more details

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Chris Warrick
The Nikola developers decided to deprecate Python 2.7 support.
Starting with v7.7.2, Nikola will display a warning if Python 2.7 is
used (but it will still be fully supported). In early 2016, Nikola
v8.0.0 will come out, and that release will not support Python 2.7
officially.

The decision was made on the basis of a user survey, with 138
participants. The vast majority of them claimed that they either use
Python 3 already, or can switch really easily. The main reason for the
switch was the fact that supporting both requires a lot of extra
effort, especially because Python 2.7’s Unicode support is abysmal.

Full results: 
https://getnikola.com/blog/env-survey-results-and-the-future-of-python-27.html

What is Nikola?
===

Nikola is a static site and blog generator, written in Python.
It can use Mako and Jinja2 templates, and input in many popular markup
formats, such as reStructuredText and Markdown — and can even turn
Jupyter (IPython) Notebooks into blog posts! It also supports image
galleries, and is multilingual. Nikola is flexible, and page builds
are extremely fast, courtesy of doit (which is rebuilding only what
has been changed).

Find out more at the website: https://getnikola.com/

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Chris Warrick
On 1 October 2015 at 18:43,   wrote:
> Python 3 has venv in the kit. Is there a reason users should get the
> virtualenv add-on?

Both can be used; I wrote about virtualenv because it’s the
tried-and-true solution (and is it guaranteed in all Linux distros
anyway?)

On 1 October 2015 at 19:02, Stefan Behnel  wrote:
> Chris Warrick schrieb am 01.10.2015 um 18:26:
>> The Nikola developers decided to deprecate Python 2.7 support.
>
> I wonder why it took the Nikola project so long to take that decision.
> Python 3.3 came out almost exactly three(!) years ago and seems to have all
> major features that they would require. Nikola's PyPI page claims support
> of Python 3.3 for just about as long, since version 5.4 or so, which means
> that all of their dependencies were already available back then.
>
> It's a different thing for *libraries* that Python 2.x users still depend
> on, but for an *application* that has all its (necessary) dependencies
> available in Python 3.x, I can't see a general reason to keep supporting
> both language versions.
>
> Stefan

We did it now because it all started with frustration with 2.7 [0].
Also, doing it back in 2012/2013 would be problematic, because back
then not all Linux distros had an easily installable Python 3 stack
(and RHEL 7 still doesn’t have one in the default repos)

[0]: http://ralsina.me/weblog/posts/floss-decision-making-in-action.html

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-02 Thread Chris Warrick
On 2 October 2015 at 01:59, Terry Reedy  wrote:
> On 10/1/2015 12:26 PM, Chris Warrick wrote:
>>
>> The Nikola developers decided to deprecate Python 2.7 support.
>> Starting with v7.7.2, Nikola will display a warning if Python 2.7 is
>> used (but it will still be fully supported). In early 2016, Nikola
>> v8.0.0 will come out, and that release will not support Python 2.7
>> officially.
>
>
> How sane ;-)
>
>> The decision was made on the basis of a user survey, with 138
>> participants. The vast majority of them claimed that they either use
>> Python 3 already, or can switch really easily.
>
>
> From the survey and description below, 'using Python 3' means having Python
> 3 installed, not writing Python 3 code.  Correct?

Correct. We asked about Nikola users, who don’t really have to write
any Python code.  This is, however, an useful information for OSS
developers, who want to know if they can/should target Python 3
instead of Python 2.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide window does not resize to fit screen

2015-10-02 Thread Chris Warrick
On 2 October 2015 at 15:10, Hedieh Ebrahimi  wrote:
> Thanks Laura,
>
> In my user interface I have many group boxes that are located inside the main 
> widget. All the group boxes and their child widgets have fixed sizes.
>
> How can I use the width and height I get from availableGeometry or 
> ScreenGeometry to multiply
>
> screenGeometry = QApplication.instance().desktop().screenGeometry()
> availGeometry = QApplication.instance().desktop().availableGeometry()
> width, height = availGeometry.width(), availGeometry.height()
>
> to resize my geometry by a ratio? Is this a good approach?
> --
> https://mail.python.org/mailman/listinfo/python-list

This is NOT a good approach.  A good approach involves using a layout.
See my previous e-mail for details.

Geometry is not going to help you here, especially since you would
need a ton of code to resize everything on **any** window size change
event.  And you especially do not need the screen size, because it
would still hinder changing window sizes.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide window does not resize to fit screen

2015-10-05 Thread Chris Warrick
On 5 October 2015 at 13:20, Hedieh Ebrahimi  wrote:
> is this free to use for commercial use?
> --
> https://mail.python.org/mailman/listinfo/python-list

Yeah, you can use Qt Designer to create a nice layout and the
pyside-uic tool to generate code (that you will need to clean up
later).

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Script To Remove Files Made Either By Python Or Git

2015-10-09 Thread Chris Warrick
On 9 October 2015 at 12:08, Joshua Stokes  wrote:
> Hi
>
> Is there an available script to remove file created by either using the 
> Python module or by using git?

There’s no such script, but we could help you write one.

Now, what “Python module” do you mean?  Unless it’s a git module, it’s
impossible.  And I really hope that “by using git” really means “that
are part of the git repo”.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip trouble

2015-10-30 Thread Chris Warrick
On 30 October 2015 at 13:14, Neal Becker  wrote:
> I have a custom-compiled numpy 1.10.0.  But as you see, pip wants to install
> a new numpy, even though the requirement (numpy>=1.6) was already satisfied.
> WTF?
>
> All are installed into --user.
>
> This is on fedora 22 linux.
>
> pip install --up --user matplotlib
> Collecting matplotlib
>   Using cached matplotlib-1.5.0.tar.gz
> Collecting numpy>=1.6 (from matplotlib)
>   Using cached numpy-1.10.1.tar.gz
> Requirement already up-to-date: python-dateutil in
> ./.local/lib/python2.7/site-packages (from matplotlib)
> Collecting pytz (from matplotlib)
>   Using cached pytz-2015.7-py2.py3-none-any.whl
> Collecting cycler (from matplotlib)
>   Using cached cycler-0.9.0-py2.py3-none-any.whl
> Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib)
>   Using cached pyparsing-2.0.5-py2.py3-none-any.whl
> Collecting six>=1.5 (from python-dateutil->matplotlib)
>   Using cached six-1.10.0-py2.py3-none-any.whl
> Installing collected packages: numpy, pytz, six, cycler, pyparsing,
> matplotlib
>   Found existing installation: numpy 1.10.0
> DEPRECATION: Uninstalling a distutils installed project (numpy) has been
> deprecated and will be removed in a future version. This is due to the fact
> that uninstalling a distutils project will only partially uninstall the
> project.
> Uninstalling numpy-1.10.0:
>   Successfully uninstalled numpy-1.10.0
>   Running setup.py install for numpy
>
> --
> https://mail.python.org/mailman/listinfo/python-list

You used --up (aka -U, --upgrade).  That option tries to upgrade the
package you asked for *and* all dependencies. And since numpy 1.10.1
is newer than what you have installed, pip will try to install that.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: installer user interface glitch ?

2015-11-01 Thread Chris Warrick
On 1 November 2015 at 09:23, t_ciorba--- via Python-list
 wrote:
>
> hi,
> i am not sure what is wrong, but after launching the installer for windows 
> XPsp3 python-3.5.0.exe i couldnt see what i have to select, it was a white 
> board and the only button on it was "cancel". here is a screen of it:

Windows XP is not supported. Please upgrade to a modern version of
Windows, or switch to Linux. (you could also use 3.4.3, but Windows XP
is insecure, and more apps will follow suit.)

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python doesn't install

2015-11-02 Thread Chris Warrick
On 2 November 2015 at 09:28, Dave Farrance  wrote:
> Yes, I've read the justifications. Why list all the non-supported OSs?
> And the explanation about each version of Python being supported just
> for the supported versions of Windows upon its release is in the
> documentation -- somewhere.  But it still seems to me that stating the
> minimum requirements in a place that people would tend to look for it is
> a... minimum requirement.
>
> If the developers really are determined not to mention specific versions
> of Windows (If it was me, I'd have probably mentioned that the most
> recent version required Vista somewhere on the download page), then
> maybe adding the comment about matching the release date of Python to
> the supported versions of Windows to the download pages would give
> people some sort of clue as to what's going on.
> --
> https://mail.python.org/mailman/listinfo/python-list

This could be resolved in one line of HTML or reST. Windows XP is
still in use, and it was supported one minor version ago. Surely it
wouldn’t hurt to add a “Warning: Windows XP is ancient, and Python 3.5
does not support it — upgrade to a newer OS or use 3.4.3 instead”
notice to the download page?

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python PNG Viewer(Browser Based)

2015-11-03 Thread Chris Warrick
On 3 November 2015 at 12:54, Arshpreet Singh  wrote:
> Hello Everyone,
>
> I am looking for Browser-based PNG file viewer written in
> Python.(Flask framework preferably)
>
> Following project(Flask-Based) provides many things(File manager as
> well as file viewer)  but it does not support PNG files.
>
> https://github.com/vmi356/filemanager
>
> Any idea if I have to write my own browser based PNG viewer from
> scratch(Using PIL or other required library)
>
> On the other side if I have to write only Desktop-based only two lines
> are enough to do many things:
>
> Like,
>
> from PIL import Image
> f = Image.open("file.png").show()
>
>
> But I am not getting right sense that how to make possible using Python+Flask.
>
> Hope I am able to tell my problem?
> --
> https://mail.python.org/mailman/listinfo/python-list

Your problem is lack of basic understanding of the Internet. Because
EVERY graphical web browser supports PNG files NATIVELY. With a single
 tag.

Just figure out where to add the PNG handler code and read any random
“how to add images to a webpage” tutorial.
You might need a new template and some code that is aware of the file
being an image. But absolutely no PNG viewer is necessary.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >