Re: [Tutor] How to write a function which reads files

2018-08-07 Thread Chris Warrick
unction name, since the latter is typically used for classes, and perhaps call it read_file to better describe it? -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subs

Re: [Tutor] A Question Regarding the Documentation Format

2017-09-24 Thread Chris Warrick
planation > for this. This indicates the return type: input() returns a string. -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] subprocess.getstatusoutput : UnicodeDecodeError

2017-09-22 Thread Chris Warrick
es. Instead of tail, you should use Python’s standard file operations (open()) to accomplish your task. [advertisement] Extra reading on security (shell=False) and the necessity of calling subprocesses: https://chriswarrick.com/blog/2017/09/02/spawning-subprocesses-smartly-and-securely/ [/advert

Re: [Tutor] How is database creation normally handled?

2017-09-10 Thread Chris Warrick
exist.) ¹ Progressive enhancement: adding more features that need extra columns I didn’t think of first. Or removing features that weren’t cool. Or restoring them the next day. -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor

Re: [Tutor] Help

2017-09-06 Thread Chris Warrick
()) search_key = str(input("> ")) if search_key in data: print(search_key, ":", data[search_key]) else: print("Not in dictionary.") (I also cleaned it up a little) -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python 3 for Beginners was: (Re: intro book for python)

2017-09-03 Thread Chris Warrick
t; an hour, maybe forty five minutes later and my little project did what I was > trying to do. This was before I really knew any python; the language was > that clean and easy to learn. You can still do that with Python 3. (Although you’ll be better off using asyncio and some IRC li

Re: [Tutor] intro book for python

2017-09-01 Thread Chris Warrick
utorial/index.html [1] http://greenteapress.com/wp/think-python-2e/ [2] https://automatetheboringstuff.com/ [3] https://learnpythonthehardway.org/book/nopython3.html [4] https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/ -- Chris Warrick <https://ch

Re: [Tutor] Percentage of installations without setuptools (Was if __name__=='__main__' ...)

2017-08-11 Thread Chris Warrick
ip some unrelated stuff] dependency: python3-pip provider: python3-pip-9.0.1-9.fc26.noarch dependency: python3-setuptools provider: python3-setuptools-36.2.0-1.fc26.noarch On other distributions, it usually isn’t, although many users will eventually end up with a copy. -- Chris Warri

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-10 Thread Chris Warrick
On 9 August 2017 at 23:15, Steven D'Aprano <st...@pearwood.info> wrote: > On Tue, Aug 08, 2017 at 12:56:56PM +0200, Chris Warrick wrote: > >> While setuptools is not officially part of the stdlib, > > This is the critical factor. How can you use *by default* something

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-08 Thread Chris Warrick
e top 360 packages on PyPI use wheels. It means that at least that many use setuptools; sometimes with a distutils fallback, but often without one. Moreover, many of the packages without wheels use setuptools as well. The sane default choice is entry_points.

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-04 Thread Chris Warrick
; basis for application plugin systems > * the ability to automatically generate Windows command line executables at > installation time rather than needing to prebuild them And, as eryk sun mentioned, recent Python 2.7 and 3.4 versions ship setuptools and pip, via the ensurepip module. -- Ch

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-03 Thread Chris Warrick
running your script by opening the created .exe files does not show a console window. Note that stdout/stderr do not work in that mode under Windows, which can lead to spurious application crashes. (GUI-only processes cannot use stdout/stderr because they don’t have a console attached) I’ll take the liberty to link my (better) blog post about this: https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/ -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Chris Warrick
’re making things more akin to shell scripts, using just entry_points makes stuff harder, because you need to install the code (and write a setup.py), as opposed to just putting the script somewhere in $PATH. -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16

Re: [Tutor] Recommended Python Compiler

2017-07-31 Thread Chris Warrick
ature, and a necessity for debugging (tracebacks!) On the other hand, some of the better editors (eg. Visual Studio Code) provide .zip packages that do not require installation and can even run off a USB stick. -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 _

Re: [Tutor] Can a virtual environment be renamed?

2017-04-16 Thread Chris Warrick
On 16 April 2017 at 18:16, Jim <jf_byr...@comcast.net> wrote: > On 04/16/2017 10:10 AM, Chris Warrick wrote: >> >> On 16 April 2017 at 16:45, Jim <jf_byr...@comcast.net> wrote: >>> >>> My system python is 2.7.12 so I created a virtual environment using

Re: [Tutor] Can a virtual environment be renamed?

2017-04-16 Thread Chris Warrick
r 3.5.2 without > breaking things? No. You need to delete your existing virtualenv and create a new one. You can just use `pip freeze > requirements.txt` in the old one and run `pip install -r requirements.txt` in the new one to ”move” all the packages you had. -- Chris Warrick <https:

Re: [Tutor] How to run a python script

2016-02-21 Thread Chris Warrick
(cmd.exe). DOS is not part of Windows NT/2000/XP and better, and rightfully so. [0]: In Windows 8?/10, available from the File menu. Otherwise: http://www.askvg.com/enable-open-command-window-here-option-in-context-menu-in-windows-vista/ -- Chris Warrick <https://chriswarrick.com/> PGP:

Re: [Tutor] How to run a python script

2016-02-20 Thread Chris Warrick
ion options: > https://mail.python.org/mailman/listinfo/tutor Please paste the full error message, and your complete source code. Also, make sure you are running the commands in the regular command prompt window, and not in a Python-specific one. Also, your scripts should not live in C:\Pyt

Re: [Tutor] AWS /Django/Apache/Python/Github

2016-02-13 Thread Chris Warrick
ensive tutorial on deploying a Python application on a Linux server: https://chriswarrick.com/blog/2016/02/10/deploying-python-web-apps-with-nginx-and-uwsgi-emperor/ -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist

Re: [Tutor] What is the square brackets about?

2016-01-16 Thread Chris Warrick
thing[loc[0]] means “check what the 0th element of `loc` (`loc[0]`) is, and use it as an index for `thing` (`thing[…]`). -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or c

Re: [Tutor] idle??

2016-01-14 Thread Chris Warrick
On 13 January 2016 at 21:49, Mark Lawrence <breamore...@yahoo.co.uk> wrote: > On 09/01/2016 10:38, Chris Warrick wrote: >> >> On 8 January 2016 at 20:07, bruce <badoug...@gmail.com> wrote: >>> >>> So, where does IDLE fit into this >> >

Re: [Tutor] idle??

2016-01-09 Thread Chris Warrick
han the basic interpreter, and even have more features than IDLE. -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] To FORMAT or not to

2016-01-03 Thread Chris Warrick
ng print() with commas adds spaces between all entries, which might look bad (and it does in this example); the only way to prevent that is by setting `sep=`, but then you need to remember about a space after "visited" and around the ampersand… * Easy to localize (translate into different languag

Re: [Tutor] Debugging in Python

2015-11-16 Thread Chris Warrick
the normal `python3` shell, ipython or bpython. The correct fix is to exit() from the python3 shell and start it again. Alternatively, add some main code at the end of your file and use `python3 hlibert.py`: if __name__ == '__main__': hilbert(3)

Re: [Tutor] command line list arguments

2015-11-07 Thread Chris Warrick
gument parsing solution, and implement it with two arguments. -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] generate a list/dict with a dynamic name..

2015-09-27 Thread Chris Warrick
it, just create a dict and use it — you can have arbitrary variable names just fine: things = {} a = "aabb" things[a] = [] PS. why are you creating a out of two strings? Why not just a = "aabb"? -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16

Re: [Tutor] Python application with same name as its corresponding project

2015-07-31 Thread Chris Warrick
/mailman/listinfo/tutor Don’t create custom bin/ scripts, use setuptools entry points. I described it on my blog: https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/ -- Chris Warrick https://chriswarrick.com/ PGP: 5EAAEA16

Re: [Tutor] trouble with stringio function in python 3.2

2015-05-04 Thread Chris Warrick
in this case, regular strings will do it equally well and are more readable. -- Chris Warrick https://chriswarrick.com/ PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo

Re: [Tutor] Decode and Encode

2015-01-28 Thread Chris Warrick
system locale is set correctly. If it isn’t, p = b你好.decode('utf-8') would do it. -- Chris Warrick https://chriswarrick.com/ PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org

Re: [Tutor] syntax error with raw input

2014-11-12 Thread Chris Warrick
subscription options: https://mail.python.org/mailman/listinfo/tutor In Python 3, raw_input() was renamed to input(). a = input(Write down your name: ) Note that input() is also a thing in Python 2, but you shouldn’t use that one for security reasons. Python 3’s is fine though. -- Chris Warrick

Re: [Tutor] Remove artca...@google.com from mailing list, PLEASE

2014-11-04 Thread Chris Warrick
Do it yourself at https://mail.python.org/mailman/listinfo/tutor . Besides, your email is @gmail.com, not @google.com. -- Chris Warrick http://chriswarrick.com/ PGP: 5EAAEA16 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription