Re: [Tutor] Python Imported Code

2019-07-20 Thread Albert-Jan Roskam
On 25 Jun 2019 15:50, stephen.m.sm...@comcast.net wrote: Introduction: I have written a 'program' that does some reasonable screen scraping off of a specific website. The program has gotten too large so I have tried to segment it into logical pieces (tkinter logic as a start) but I am having pr

Re: [Tutor] How would I replace the data of a Pandas Series with the values of a dictionary?

2019-07-18 Thread Albert-Jan Roskam
On 16 Jul 2019 23:31, Daniel Bosah wrote: Hi all, I have a problem trying to match items in a dict and pandas series in Python. I have a dict ( called city_dict )of cities and city_id's ; for each city ( which is a key in the dict ), a unique city_id is a value in that dict. So for example,

[Tutor] Fwd: Re: Unexpected result when running flask application.

2019-06-28 Thread Albert-Jan Roskam
Ooops, forgot to 'reply all' -- Forwarded message ------ From: Albert-Jan Roskam Date: 28 Jun 2019 21:31 Subject: Re: [Tutor] Unexpected result when running flask application. To: Cameron Simpson Cc: On 20 Jun 2019 00:56, Cameron Simpson wrote: On 19Jun2019 09:54,

Re: [Tutor] Interoperating with Excel, was Re: Questions

2019-04-08 Thread Albert-Jan Roskam
On 7 Apr 2019 14:07, Peter Otten <__pete...@web.de> wrote: Diana Katz wrote: > 1) Can you use python from excel? Or just export to excel? > 2) I am trying to see if there's a way using python to automate all of > this work that I need to do. I have to collect quarterly segment data for > hundre

Re: [Tutor] is there a graphics library for common tkinter Button functions?

2019-03-21 Thread Albert-Jan Roskam
On 21 Mar 2019 12:11, Alan Gauld via Tutor wrote: On 21/03/19 00:28, Chris Roy-Smith wrote: > Yes I knew that buttons need a function to do anything. > > I was hoping that the wheel didn't need re-inventing. ===>> A few are available: https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/b

Re: [Tutor] Question for tutoring page

2019-03-16 Thread Albert-Jan Roskam
On 13 Mar 2019 18:14, Alan Gauld via Tutor wrote: On 11/03/2019 16:10, Diana Katz wrote: > What is the best way to ..program using python - that could recognize > a 3D object and then rank drawings of the object as to which are more > accurate. ===>> check this out: https://pytorch.org/tutor

Re: [Tutor] schedulers

2019-03-04 Thread Albert-Jan Roskam
On 28 Feb 2019 15:45, nathan tech wrote: Hi there, I recently started working on a backup program, and the one big feature everyone wants in backup programs is the ability to schedule backups, right? but I'm thinking, should I do this? ==》 this might interest you: https://docs.python.org/3/

Re: [Tutor] Putting a Bow on It

2019-02-10 Thread Albert-Jan Roskam
On 8 Feb 2019 19:18, Chip Wachob wrote: Hello, I've been off working on other projects, but I'm finally back to the project that so many here have helped me work through. Thank you to the group at large. So, this leads me to my question for today. I'm not sure what the "correct" term is for

Re: [Tutor] best way to dynamically set class variables?

2018-11-09 Thread Albert-Jan Roskam
On 10 Nov 2018 01:03, Steven D'Aprano wrote: On Thu, Nov 08, 2018 at 11:34:35AM -0500, Avi Gross wrote: > An interesting discussion that is outside the scope of a group like this is > HOW malicious things can be done and perhaps how to avoid them. > Isn't the rule, simply: this_is_stupid = e

Re: [Tutor] best way to dynamically set class variables?

2018-11-09 Thread Albert-Jan Roskam
On 8 Nov 2018 17:34, Avi Gross wrote: > What can you do to minimize risks in such > situations? ast.literal_eval, with a smallish maximum string length? https://docs.python.org/3/library/ast.html. (That's exactly the only ast function that know! :-)

Re: [Tutor] Regex for Filesystem path (Asad)

2018-11-08 Thread Albert-Jan Roskam
From: Tutor on behalf of Alan Gauld via Tutor Sent: Thursday, November 8, 2018 10:49 AM To: tutor@python.org Subject: Re: [Tutor] Regex for Filesystem path (Asad) On 08/11/2018 02:55, Asad wrote: > Why is it putting \ this breaks the unix path it should be: > > /a/b/c/d/test/2

Re: [Tutor] best way to dynamically set class variables?

2018-11-07 Thread Albert-Jan Roskam
On 7 Nov 2018 20:36, Mats Wichmann wrote: Not sure what you're after, but what's wrong with just setting them? Parent.avar = "a class var" Hi Alan, Mats, I should have mentioned that the code is part of a function sql_to_hdf5. So it should be able to convert an *arbitrary* Sql server table

[Tutor] best way to dynamically set class variables?

2018-11-07 Thread Albert-Jan Roskam
Hi, Background: In my code I use sqlalchemy to read SQL server data. I want to write that data to HDF5 using pytables (see 'declaring a column descriptor': https://www.pytables.org/usersguide/tutorials.html). My question is not about pytables or sqlalchemy per se, but I thought it would be info

Re: [Tutor] (no subject)

2018-10-19 Thread Albert-Jan Roskam
On 19 Oct 2018 18:09, Pat Martin wrote: TLDR; How do you figure out if code is inefficient (if it isn't necessarily obvious) and how do you find a more efficient - Hi, check this: https://docs.python.org/3/library/profile.html. Also, the timeit module is handy for smaller snippets. _

Re: [Tutor] what does the forward slash mean in this function signature?

2018-10-16 Thread Albert-Jan Roskam
From: eryk sun Sent: Monday, October 15, 2018 12:10 PM To: tutor@python.org Cc: sjeik_ap...@hotmail.com Subject: Re: [Tutor] what does the forward slash mean in this function signature?   On Mon, Oct 15, 2018 at 6:00 AM Albert-Jan Roskam wrote: > > In Python 3.6 (Windows) I often

[Tutor] what does the forward slash mean in this function signature?

2018-10-15 Thread Albert-Jan Roskam
Hello, In Python 3.6 (Windows) I often see a forward slash in a function signature, see below. What does it mean? I vaguely remember reading something about new possbilities in python 3, something like "def foo(x, *, y)". Perhaps it's related to that? >>> help({}.fromkeys) Help on built-in f

Re: [Tutor] need help generating table of contents

2018-08-28 Thread Albert-Jan Roskam
From: Tutor on behalf of Peter Otten <__pete...@web.de> Sent: Monday, August 27, 2018 6:43 PM To: tutor@python.org Subject: Re: [Tutor] need help generating table of contents   Albert-Jan Roskam wrote: > > From: Tutor on behalf > of Peter Otten <__pete...@web.de> Se

Re: [Tutor] need help generating table of contents

2018-08-27 Thread Albert-Jan Roskam
From: Tutor on behalf of Peter Otten <__pete...@web.de> Sent: Friday, August 24, 2018 3:55 PM To: tutor@python.org > The following reshuffle of your code seems to work: > > print('\r\n** Table of contents\r\n') > pattern = '/Title \((.+?)\).+?/Page ([0-9]+)(?:\s+/Count ([0-9]+))?' > > def pr

[Tutor] need help generating table of contents

2018-08-24 Thread Albert-Jan Roskam
Hello, I have Ghostscript files with a table of contents (toc) and I would like to use this info to generate a human-readable toc. The problem is: I can't get the (nested) hierarchy right. import re toc = """\ [ /PageMode /UseOutlines   /Page 1   /View [/XYZ null null 0]   /DOCVIEW pdfmark [ /

Re: [Tutor] Building a Package

2018-08-23 Thread Albert-Jan Roskam
On 21 Aug 2018 15:10, Glenn Schultz via Tutor wrote: All, I have a project pthon(3.7) I have followed the python setup instructions. I get a dist folder with the correct files. Now, I would like to install locally from my local machine (note I am not using virtual enviroment as our firewall

Re: [Tutor] Questions about the formatting of docstrings

2018-07-28 Thread Albert-Jan Roskam
On 27 Jul 2018 06:34, boB Stepp wrote: I am near the end of reading "Documenting Python Code: A Complete Guide" by James Mertz, found at https://realpython.com/documenting-python-code/ This has led me to a few questions: (1) The author claims that reStructuredText is the official Python doc

Re: [Tutor] Iteration issues

2018-05-11 Thread Albert-Jan Roskam
Op 11 mei 2018 21:43 schreef Neil Cerutti : On 2018-05-10, Albert-Jan Roskam wrote: > If a punctuation symbol is in your string: Replace that symbol > with an empty string. > >=>>> maybe something like > > import re > no_interpunction = re.sub("[

Re: [Tutor] Iteration issues

2018-05-10 Thread Albert-Jan Roskam
Verzonden vanaf mijn Samsung Galaxy-smartphone. Oorspronkelijk bericht Van: boB Stepp Datum: 10-05-18 21:53 (GMT+08:00) Aan: tutor Onderwerp: Re: [Tutor] Iteration issues On Wed, May 9, 2018 at 6:27 PM, Roger Lea Scherer wrote: > Hello, again. > > I want to count words in

Re: [Tutor] pandas read sql query advice

2018-04-28 Thread Albert-Jan Roskam
On Apr 28, 2018 06:54, Glenn Schultz wrote: > > All, > > I have the following set-up (below) which will be used to call data from > multiple sectors. There is a sql query (transact sql) and connection. This > works fine. However, I would like to parametrize the query so I can enter > differ

Re: [Tutor] XML Programs

2018-04-21 Thread Albert-Jan Roskam
On Apr 21, 2018 09:06, Peter Otten <__pete...@web.de> wrote: > > Glen wrote: > > > Thank you for your comprehensive reply. It was very helpful! > > Just to clarify one point, is it not possible to search for a node > > directly in the element / elementTree or do you first need to pull the > > data

Re: [Tutor] pythonic

2018-04-04 Thread Albert-Jan Roskam
0:58:51PM +0100, Alan Gauld via Tutor wrote: > > >>> On01/04/18 20:20, Albert-Jan Roskam wrote: > > >>>> fmt="%Y-%m-%d %H:%M\n" > > >>>> f.write(now.strftime(fmt)) > > >>>> Lately I've been using forma

Re: [Tutor] pythonic

2018-04-01 Thread Albert-Jan Roskam
On Mar 30, 2018 10:39, Alan Gauld via Tutor wrote: > > On 30/03/18 03:48, Pat Martin wrote: > > > the "right" way to do it in python? > > More or less, a couple of comments below... > > > def Main(): > > Python function names begin with a lowercase letter by convention. > > > """Run if run as

Re: [Tutor] Problem with testing - container

2018-03-29 Thread Albert-Jan Roskam
Op 29 mrt. 2018 21:06 schreef "Shall, Sydney" : > > I have a problem with a specific test, I think. > > I use a Mac with OS X 10.13.3 > I use Anaconda with Python 3.5 > > I have been writing tests for a Class that I have written. I am not > finished yet, but there are already nearly 400 tests. The

Re: [Tutor] Regex not working as desired

2018-03-06 Thread Albert-Jan Roskam
On Feb 27, 2018 09:50, Alan Gauld via Tutor wrote: > > On 27/02/18 05:13, Cameron Simpson wrote: > > > hard to debug when you do. That's not to say you shouldn't use them, but > > many > > people use them for far too much. > > > > Finally, you could also consider not using a regexp for this part

Re: [Tutor] question about metaclasses

2018-01-18 Thread Albert-Jan Roskam
On Jan 10, 2018 19:32, Peter Otten <__pete...@web.de> wrote: > > Albert-Jan Roskam wrote: > > > Why does following the line (in #3) > > > # 3- > > class Meta(type): > > def __new__(cls, name, b

Re: [Tutor] question about metaclasses

2018-01-18 Thread Albert-Jan Roskam
On Jan 10, 2018 18:57, Steven D'Aprano wrote: > > On Wed, Jan 10, 2018 at 04:08:04PM +0000, Albert-Jan Roskam wrote: > > > In another thread on this list I was reminded of > > types.SimpleNamespace. This is nice, but I wanted to create a bag > > class with cons

Re: [Tutor] When is and isn't "__file__" set?

2018-01-12 Thread Albert-Jan Roskam
On Jan 11, 2018 03:47, Steven D'Aprano wrote: > > On Wed, Jan 10, 2018 at 08:02:24PM -0600, boB Stepp wrote: > > > I am still puzzling over things from the thread, "Why does > > os.path.realpath('test_main.py') give different results for unittest > > than for testing statement in interpreter?" T

[Tutor] question about metaclasses

2018-01-10 Thread Albert-Jan Roskam
Hi, In another thread on this list I was reminded of types.SimpleNamespace. This is nice, but I wanted to create a bag class with constants that are read-only. My main question is about example #3 below (example #2 just illustrates my thought process). Is this a use case to a metaclass? Or can

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-10 Thread Albert-Jan Roskam
From: eryk sun Sent: Wednesday, January 10, 2018 3:56 AM To: tutor@python.org Cc: Albert-Jan Roskam Subject: Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?   On Tue, Jan 9, 2018 at 2:48 PM, Albert-

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-09 Thread Albert-Jan Roskam
From: Tutor on behalf of Steven D'Aprano Sent: Tuesday, January 9, 2018 8:47 AM To: tutor@python.org Subject: Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?   > The Python 3.5 source code for os.path.realpat

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-07 Thread Albert-Jan Roskam
On Jan 7, 2018 09:08, Steven D'Aprano wrote: > > On Sun, Jan 07, 2018 at 12:49:59AM -0600, boB Stepp wrote: > > > Win7, Python 3.6.2 > > > > If I run a unit test with the following embedded: > > > > print('realpath =', os.path.realpath('test_main.py')) > > > > I get the following in my test outpu

Re: [Tutor] Installing python and numpy on the Mac (OSX)

2017-12-23 Thread Albert-Jan Roskam
Op 23 dec. 2017 09:47 schreef Peter Hodges : > > Hi. I downloaded Python 3.6 from the python site, then followed online > directions for pip to install numpy (in users? —user was in the example). > When I start IDLE in the Python 3.6 in Applications and then type import > numpy as np I get the f

Re: [Tutor] Problem in python online class

2017-12-23 Thread Albert-Jan Roskam
On Dec 21, 2017 09:58, Tim Cordsen via Tutor wrote: > > Hello everybody, > I am doing a python online class and I am lost. The "teacher" is a little > chaotic and doesn't provide his code, so everyone must type on their own. > > Now the class reached a point where I am lost. It is about doing a s

Re: [Tutor] Installing python and numpy on the Mac (OSX)

2017-12-23 Thread Albert-Jan Roskam
Op 23 dec. 2017 09:47 schreef Peter Hodges : > > Hi. I downloaded Python 3.6 from the python site, then followed online > directions for pip to install numpy (in users? —user was in the example). > When I start IDLE in the Python 3.6 in Applications and then type import > numpy as np I get the f

Re: [Tutor] restructuredtext's documentation

2017-12-12 Thread Albert-Jan Roskam
Op 12 dec. 2017 10:52 schreef Steven D'Aprano : > > On Mon, Dec 11, 2017 at 02:04:59PM +, adil gourinda wrote: > > Hi > > Please I have two questions: > > > > 1) Why restructuredtext's documentation is not included as a part of > > the official Python's documentation? > > Because RestructuredT

Re: [Tutor] How to test for the existence of a table in a sqlite3 db?

2017-10-18 Thread Albert-Jan Roskam
On Oct 16, 2017 15:12, Neil Cerutti wrote: > > On 2017-10-15, boB Stepp wrote: > > Some things I am still pondering: > > > > 1) If I adopt the incremental approach to creating and > > initializing the working db, then it seems that the list, > > "sql_scripts", should not be hard-coded into the

Re: [Tutor] ctypes wintypes

2017-10-04 Thread Albert-Jan Roskam
(sorry for top-posting) Perhaps this? https://pythonhosted.org/psutil/ From: Tutor on behalf of Michael C Sent: Tuesday, October 3, 2017 9:30:43 PM To: python tutor Subject: [Tutor] ctypes wintypes Hi all: I am trying to create SYSTEM_INFO structure and MEMOR

[Tutor] OT: how to best follow the posting style on this list

2017-09-29 Thread Albert-Jan Roskam
Hi, I often read messages to this list from my Android from the mobile Hotmail page. On other occasions I would read from my browser, from a Windows or a Linux desktop. Howver, Hotmail pretty much sucks when it comes to obeying the posting style [1]. It's even worse than Yahoo mail, which I've

Re: [Tutor] logging to cmd.exe

2017-09-29 Thread Albert-Jan Roskam
Dear Mats, Peter and Eryk, THANK YOU for your replies. What a wealth of information! Have a great weekend! Albert-Jan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] logging to cmd.exe

2017-09-26 Thread Albert-Jan Roskam
From: Tutor on behalf of Peter Otten <__pete...@web.de> Sent: Monday, September 25, 2017 2:59 PM To: tutor@python.org Subject: Re: [Tutor] logging to cmd.exe Albert-Jan Roskam wrote: > Hi, > > > With Python 3.5 under Windows I am using the logging module to

Re: [Tutor] logging to cmd.exe

2017-09-26 Thread Albert-Jan Roskam
From: Tutor on behalf of Mark Lawrence via Tutor Sent: Monday, September 25, 2017 4:19 PM To: tutor@python.org Subject: Re: [Tutor] logging to cmd.exe   On 25/09/2017 14:20, Albert-Jan Roskam wrote: > Hi, > > > With Python 3.5 under Windows I am using the logging module to

[Tutor] logging to cmd.exe

2017-09-25 Thread Albert-Jan Roskam
Hi, With Python 3.5 under Windows I am using the logging module to log messages to stdout (and to a file), but this occasionally causes logging errors because some characters cannot be represented in the codepage used by cmd.exe (cp850, aka OEM codepage, I think). What is the best way to preve

Re: [Tutor] How to write database-agnostic python code? (Is this even possible?)

2017-09-12 Thread Albert-Jan Roskam
(sorry for top posting) There are various SQL abstraction layers for this. I have only used Sqlalchemy. This package has two APIs: query and ORM. You might want to look at the query API. This is closer to SQL than ORM. You can use straight(obj) to inspect the SQL that's emitted

Re: [Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread Albert-Jan Roskam
From: Tutor on behalf of GMX Sent: Monday, September 11, 2017 9:38 AM To: tutor@python.org Subject: [Tutor] How to create an object in database only if the object is not already there? Now when I create a Course object like this:     >>> Course(title=‘A new course’) An object is create in

Re: [Tutor] [Python2.7] Convert (2,188,1) into (188,1)

2017-07-04 Thread Albert-Jan Roskam
From: Tutor [tutor-bounces+sjeik_appie=hotmail@python.org] on behalf of Alan Gauld via Tutor [tutor@python.org] Sent: Tuesday, July 4, 2017 8:37 AM To: tutor@python.org Subject: Re: [Tutor] [Python2.7] Convert (2,188,1) into (188,1) On 28/06/17 16:48,

Re: [Tutor] Matplotlib in Tkinter

2017-02-26 Thread Albert-Jan Roskam
my_plot.grid(row=0, column=0) # use grid here button = Button (root, text="quit", fg='red', command=root.quit) button.grid(row=1, column=0) root.mainloop() From: Pooja Bhalode Sent: Sunday, February 26, 2017 3:47:37 PM To: Albert-Jan Roskam Subje

Re: [Tutor] Matplotlib in Tkinter

2017-02-25 Thread Albert-Jan Roskam
(Sorry for top-posting) Hi, I recently ran into the same problem when I wanted to embed an interactive Matplotlib choropleth in my Tkinter app. I solved it by creating a separate class MyPlot for plot + toolbar (it inherited from Tkinter.Frame). MyPlot internally uses the pack geometry manager

[Tutor] ReadableInt

2016-12-30 Thread Albert-Jan Roskam
Hi, Why does the call to str() below return '1' and not 'one'? Should I implement __new__ because int is immutable? I have a datafile that contains values and an associated metadata file with the associated labels. I need to recode the values. Because just using the values is a bit error prone

[Tutor] Array of Tkinter objects?

2016-09-22 Thread Albert-Jan Roskam
Hi, I have created a grid of Tkinter Entry object that looks a bit like a sheet in MS Excel. The data come from a pandas.DataFrame. I use a nested loop, one for rows and one for cols. Inside the loop, I create the Entry instances which I also grid() right away. This works nicely, though a litt

Re: [Tutor] __init__

2016-09-05 Thread Albert-Jan Roskam
From: Tutor on behalf of Steven D'Aprano Sent: Thursday, September 1, 2016 1:24 AM To: tutor@python.org Subject: Re: [Tutor] __init__   On Wed, Aug 31, 2016 at 06:35:44PM +0000, Albert-Jan Roskam wrote: > > >In Python 3, old-style classes are gone. Even in Python 2, they'

Re: [Tutor] __init__

2016-08-31 Thread Albert-Jan Roskam
>In Python 3, old-style classes are gone. Even in Python 2, they're >discouraged. This suggests that old-style classes are still used, even in Python 3, doesn't it? albertjan@debian:~$ python3.5 Python 3.5.0 (default, Apr 13 2016, 20:39:27) [GCC 4.9.2] on linux Type "help", "copyright", "cred

[Tutor] capture output from a subprocess while it is being produced

2016-06-14 Thread Albert-Jan Roskam
Hi, I have a Tkinter program where I can fire up a commandline program which could run for quite a while (let's say 15 minutes or more). While the program is running, I would like to show the output that I normally see in the terminal (actually, the target platform is windows but now I am on Li

Re: [Tutor] Urgent: unicode problems writing CSV file

2016-06-08 Thread Albert-Jan Roskam
> Date: Thu, 9 Jun 2016 03:57:21 +1000 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Urgent: unicode problems writing CSV file > > On Wed, Jun 08, 2016 at 01:18:11PM -0400, Alex Hall wrote: >> >> csvWriter.writerow([info.encode("utf8") if type(info)is unicode else

Re: [Tutor] Getting started in testing

2016-05-21 Thread Albert-Jan Roskam
(sorry for top-posting) I liked https://www.packtpub.com/application-development/python-testing-beginners-guide though perhaps it was a bit too basic. It covers forest, unit test, nose. > Date: Thu, 19 May 2016 12:34:27 -0700 > From: carr...@tjc.com > To: tutor@python.org > Subject: [Tutor] Get

Re: [Tutor] question about __copy__ and __deepcopy__

2016-04-15 Thread Albert-Jan Roskam
> From: oscar.j.benja...@gmail.com > Date: Thu, 14 Apr 2016 21:34:39 +0100 > Subject: Re: [Tutor] question about __copy__ and __deepcopy__ > To: sjeik_ap...@hotmail.com > CC: tutor@python.org > > On 14 April 2016 at 20:38, Albert-Jan Roskam wrote: > > Hi, > >

Re: [Tutor] question about __copy__ and __deepcopy__

2016-04-15 Thread Albert-Jan Roskam
> Date: Fri, 15 Apr 2016 16:30:16 +1000 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] question about __copy__ and __deepcopy__ > > On Thu, Apr 14, 2016 at 07:38:31PM +, Albert-Jan Roskam wrote: > > Hi, > > > > Lately I hav

[Tutor] question about __copy__ and __deepcopy__

2016-04-14 Thread Albert-Jan Roskam
Hi, Lately I have been using the "mutable namedtuple"  shown below a lot. I found it somewhere on StackOverflow or ActiveState or something. In its original form, it only had an __init__ method. I noticed that copying Record objects sometimes failed. So I implemented __copy__ and __deepcopy__, I

Re: [Tutor] Alan G Week 10 warmup assignment help

2016-04-02 Thread Albert-Jan Roskam
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Sat, 2 Apr 2016 09:08:04 +0100 > Subject: Re: [Tutor] Alan G Week 10 warmup assignment help > > On 02/04/16 02:21, Daniella Sapozhnikova wrote: > > I changed the file to this: > > > DATA = {2: 7493945, > > 76: 4654320, > .

Re: [Tutor] __str__ vs. sys.displayhook

2016-03-20 Thread Albert-Jan Roskam
> Date: Mon, 21 Mar 2016 02:50:17 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] __str__ vs. sys.displayhook > > On Sun, Mar 20, 2016 at 01:53:04PM +, Albert-Jan Roskam wrote: >> Hi, >>

[Tutor] __str__ vs. sys.displayhook

2016-03-20 Thread Albert-Jan Roskam
Hi, The other day I was playing with this to make a convenient string version of a named tuple: >>> from collections import namedtuple as nt >>> Record = nt("Record", "x y z") >>> Record.__str__ = lambda self: "| %s |" % " | ".join([item + ": " + >>> str(getattr(self, item)) for item in self._f

Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???

2016-03-20 Thread Albert-Jan Roskam
< snip lots of useful info > Hi all, Thanks a lot for all your replies. I am whole lot wiser now :) Best wishes, Albert-Jan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription optio

Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???

2016-03-15 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Sun, 13 Mar 2016 13:58:46 -0500 > Subject: Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ??? > To: tutor@python.org > CC: sjeik_ap...@hotmail.com > > On Sun, Mar 13, 2016 at 3:14 AM, Albert-Jan R

Re: [Tutor] Pmw/Tkinter question

2016-03-15 Thread Albert-Jan Roskam
> Date: Sun, 13 Mar 2016 19:19:55 -0500 > From: robertvst...@gmail.com > To: tutor@python.org > Subject: Re: [Tutor] Pmw/Tkinter question > > I just cannot leave this problem alone; however, I *do* believe I have > found the correct way to do what Albert-Jan desires within the > publicly accessib

Re: [Tutor] Pmw/Tkinter question

2016-03-13 Thread Albert-Jan Roskam
> Date: Sat, 12 Mar 2016 23:08:20 -0600 > Subject: Re: [Tutor] Pmw/Tkinter question > From: robertvst...@gmail.com > To: sjeik_ap...@hotmail.com > CC: tutor@python.org > > On Sat, Mar 12, 2016 at 2:17 AM, Albert-Jan Roskam > wrote:

Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???

2016-03-13 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Sun, 13 Mar 2016 01:39:11 -0600 > To: tutor@python.org > Subject: Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ??? > > On Sat, Mar 12, 2016 at 12:46 AM, boB Stepp wrote: > > I did with the non-printing control character, but not with '\u25ba

Re: [Tutor] OT: (Continuous) integration testing: Can a solo developer with very limited resources truly do this?

2016-03-13 Thread Albert-Jan Roskam
> From: d...@hashcollision.org > Date: Sat, 12 Mar 2016 18:34:02 -0800 > To: robertvst...@gmail.com > Subject: Re: [Tutor] OT: (Continuous) integration testing: Can a solo > developer with very limited resources truly do this? > CC: tutor@python.org > > On Sat, Mar 12, 2016 at 10:10 AM, boB Ste

Re: [Tutor] Pmw/Tkinter question

2016-03-12 Thread Albert-Jan Roskam
> To: tutor@python.org > From: __pete...@web.de > Date: Sat, 12 Mar 2016 10:28:36 +0100 > Subject: Re: [Tutor] Pmw/Tkinter question > > Albert-Jan Roskam wrote: > > > Hello, > > > > Below is a slightly modified example about Pmw/Tkinter from > > ht

[Tutor] Pmw/Tkinter question

2016-03-12 Thread Albert-Jan Roskam
Hello, Below is a slightly modified example about Pmw/Tkinter from http://pmw.sourceforge.net/doc/howtouse.html. I changed the geometry manager from 'pack' to 'grid', because I use that in all other parts of my program. The problem is, 'broccoli' won't display nicely under vege_menu. I want it t

Re: [Tutor] Recommendations for best tool to write/run Python :p:

2016-03-04 Thread Albert-Jan Roskam
> Date: Thu, 3 Mar 2016 15:54:56 -0600 > From: da...@graniteweb.com > To: tutor@python.org > Subject: Re: [Tutor] Recommendations for best tool to write/run Python :p: > > * Alan Gauld [2016-03-03 11:02]: > > On 03/03/16 09:31, Thomas C. Hicks wrote: > > > On 03/03/2016 02:26 AM, Lisa Hasler Wate

Re: [Tutor] lc_ctype and re.LOCALE

2016-01-31 Thread Albert-Jan Roskam
> From: oscar.j.benja...@gmail.com > Date: Fri, 29 Jan 2016 16:32:57 + > Subject: Re: [Tutor] lc_ctype and re.LOCALE > To: sjeik_ap...@hotmail.com > CC: tutor@python.org > > On 28 January 2016 at 20:23, Albert-Jan Roskam > wrote: > > > > Out of curi

Re: [Tutor] lc_ctype and re.LOCALE

2016-01-31 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Fri, 29 Jan 2016 07:14:07 -0600 > Subject: Re: [Tutor] lc_ctype and re.LOCALE > To: tutor@python.org > CC: sjeik_ap...@hotmail.com > > On Thu, Jan 28, 2016 at 2:23 PM, Albert-Jan Roskam > wrote: > > Out of curiosity, I wrote the t

Re: [Tutor] lc_ctype and re.LOCALE

2016-01-31 Thread Albert-Jan Roskam
> Subject: Re: [Tutor] lc_ctype and re.LOCALE > > To: sjeik_ap...@hotmail.com > > CC: tutor@python.org > > > > On 28 January 2016 at 20:23, Albert-Jan Roskam > > wrote: > > > > > > Out of curiosity, I wrote the throw-away script below to find

Re: [Tutor] http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html

2016-01-31 Thread Albert-Jan Roskam
> Date: Fri, 29 Jan 2016 14:50:57 + > Subject: [Tutor] http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html sorry, I did not intend to send this to Python Tutor (the link is awesome, though) ___ Tutor ma

[Tutor] http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html

2016-01-29 Thread Albert-Jan Roskam
from sqlalchemy import * db = create_engine('sqlite:///joindemo.db') db.echo = True metadata = BoundMetaData(db) users = Table('users', metadata, autoload=True) emails = Table('emails', metadata, autoload=True) # These are the empty classes that will become our data classes class User(object

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-28 Thread Albert-Jan Roskam
> Date: Wed, 27 Jan 2016 02:24:35 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On Sun, Jan 24, 2016 at 07:47:47PM +, Albert-Jan Roskam wrote: > >>&

[Tutor] lc_ctype and re.LOCALE

2016-01-28 Thread Albert-Jan Roskam
Hi, Out of curiosity, I wrote the throw-away script below to find a character that is classified (--> LC_CTYPE) as digit in one locale, but not in another. I ran it with 5000 locale combinations in Python 2 but did not find any (somebody shut down my computer!). I just modified the code so it al

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-24 Thread Albert-Jan Roskam
> To: tutor@python.org > From: __pete...@web.de > Date: Sun, 24 Jan 2016 11:22:19 +0100 > Subject: Re: [Tutor] Change datatype for specific columns in an 2D array & > computing the mean > How do you want to convert the second and third column to int? Are A4 and B2 > hex numbers? Then try > >

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> From: oscar.j.benja...@gmail.com > Date: Thu, 21 Jan 2016 11:02:40 + > To: ben+pyt...@benfinney.id.au > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > CC: tutor@python.org > > On 21 January 2016 at 09:19, Ben Finney wrote: > > Albert-Jan Roskam

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> To: tutor@python.org > From: ben+pyt...@benfinney.id.au > Date: Fri, 22 Jan 2016 04:12:08 +1100 > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > Ben Finney writes: > > > Oscar Benjamin writes: > > > > > According to a narrow definition of indexed access. I would say that > > >

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> Date: Fri, 22 Jan 2016 11:00:00 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > Further thoughts on your question... > > > On Wed, Jan 20, 2016 at 01:33:17PM +, Albert-Jan Roskam wrote

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Fri, 22 Jan 2016 00:12:18 + > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On 22/01/16 00:00, Steven D'Aprano wrote: > > > Also, you have a problem -- what happens if the incomplete postcode is > > missing t

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> To: tutor@python.org > From: breamore...@yahoo.co.uk > Date: Thu, 21 Jan 2016 21:02:03 + > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On 20/01/2016 13:33, Albert-Jan Roskam wrote: > > Hi, > > > > Like the subject says: Why is an

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Albert-Jan Roskam
> Date: Thu, 21 Jan 2016 12:00:29 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On Wed, Jan 20, 2016 at 01:33:17PM +, Albert-Jan Roskam wrote: > > Hi, > > > > Like the sub

[Tutor] Why is an OrderedDict not sliceable?

2016-01-20 Thread Albert-Jan Roskam
Hi, Like the subject says: Why is an OrderedDict not sliceable? (From the collections library). Was that an intentional omission, or a mistake? [1] Background: I do not use OrderedDict very often, but I thought I could use it to look up street and city names using postcodes ([0-9]{4} [a-z]{2} f

Re: [Tutor] str.strip strange result...?

2016-01-18 Thread Albert-Jan Roskam
regex more > > readable (!): > >>>> re.sub(r"_1$", "", "V01_1") > > 'V01' > > > Hi Albert-Jan Roskam, > > Here's a minor counterpoint to using regexes here: they're sometimes a > bit too powerful. Yes, cert

Re: [Tutor] me, my arm, my availability ...

2016-01-17 Thread Albert-Jan Roskam
> To: tutor@python.org > From: cmgcom...@gmail.com > Date: Thu, 14 Jan 2016 09:37:02 +0530 > Subject: Re: [Tutor] me, my arm, my availability ... > > take care, get well soon, > > regards > > CMG > > On Thursday 14 January 2016 02:17 AM, Laura Creighton wrote: > > I fell recently. Ought to b

Re: [Tutor] Question about the memory manager

2016-01-17 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Thu, 14 Jan 2016 04:42:57 -0600 > Subject: Re: [Tutor] Question about the memory manager > To: tutor@python.org > CC: sjeik_ap...@hotmail.com > > On Thu, Jan 14, 2016 at 3:03 AM, Albert-Jan Roskam > wrote: > > > > These two p

Re: [Tutor] str.strip strange result...?

2016-01-17 Thread Albert-Jan Roskam
> To: tutor@python.org > From: __pete...@web.de > Date: Fri, 15 Jan 2016 17:37:25 +0100 > Subject: Re: [Tutor] str.strip strange result...? > > Jignesh Sutar wrote: > > > #python2.7 > > > s="V01_1" > s.strip("_1") > > 'V0' > > > > > > Wouldn't you expect the result to be "V01" ? > >

Re: [Tutor] Question about the memory manager

2016-01-14 Thread Albert-Jan Roskam
Subject: Re: [Tutor] Question about the memory manager > > To: sjeik_ap...@hotmail.com > > CC: tutor@python.org > > > > [Albert-Jan Roskam ] > > > I just found a neat trick to free up an emergency stash of memory in > > > a funtion that overrides sys.excep

Re: [Tutor] Question about the memory manager

2016-01-13 Thread Albert-Jan Roskam
> From: tim.pet...@gmail.com > Date: Sun, 10 Jan 2016 10:54:10 -0600 > Subject: Re: [Tutor] Question about the memory manager > To: sjeik_ap...@hotmail.com > CC: tutor@python.org > > [Albert-Jan Roskam ] > > I just found a neat trick to free up an emergency stash of m

Re: [Tutor] Question about the memory manager

2016-01-13 Thread Albert-Jan Roskam
> To: tutor@python.org > From: __pete...@web.de > Date: Sun, 10 Jan 2016 18:29:06 +0100 > Subject: Re: [Tutor] Question about the memory manager > > Albert-Jan Roskam wrote: > > > Hi, > > > > I just found a neat trick to free up an emergency stash of

[Tutor] Question about the memory manager

2016-01-10 Thread Albert-Jan Roskam
Hi, I just found a neat trick to free up an emergency stash of memory in a funtion that overrides sys.excepthook. The rationale is that all exceptions, including MemoryErrors will be logged. The code is below. My question: is that memory *guaranteed* to be freed right after the 'del' statement?

Re: [Tutor] a class that may not be instantiated

2015-11-25 Thread Albert-Jan Roskam
Hi all, Thanks a lot for your replies! > Date: Wed, 25 Nov 2015 05:19:57 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] a class that may not be instantiated > > On Tue, Nov 24, 2015 at 03:36:21PM +, Albert-Jan Roskam wrote: > >

[Tutor] a class that may not be instantiated

2015-11-24 Thread Albert-Jan Roskam
Hi, I have two classes with a number of methods that are the same, so I want to define a super class that holds these methods. But the super class (below called _Generic) should not be instantiated, because it serves no purpose other than the DRY principle. I raise a NotImplementedError in case

Re: [Tutor] Missing posts

2015-11-15 Thread Albert-Jan Roskam
(Sorry for top-posting) Could it be related to this? https://www.emailonacid.com/blog/article/industry-news/could_yahoo_and_aols_dmarc_policies_destroy_your_deliverability Albert-Jan > To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Sun, 15 Nov 2015 00:08:37 + > Subject: [Tut

  1   2   3   4   5   6   >