Re: BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread MRAB
On 2017-08-27 20:35, Christopher Reimer via Python-list wrote: On 8/27/2017 11:54 AM, Peter Otten wrote: The documentation https://www.crummy.com/software/BeautifulSoup/bs4/doc/#making-the-soup says you can make the BeautifulSoup object from a string or file. Can you give a few more details

Re: Reading the documentation

2017-08-25 Thread MRAB
On 2017-08-25 15:40, Dennis Lee Bieber wrote: On Thu, 24 Aug 2017 21:47:41 -0700 (PDT), Rustom Mody declaimed the following: This was true of Britain 100 years ago It was true of Rome 1000 years ago Rome was still a problem in 1017? That's only 50 years away

Re: Reading the documentation

2017-08-24 Thread MRAB
On 2017-08-25 02:58, Ben Bacarisse wrote: Chris Angelico writes: On Fri, Aug 25, 2017 at 11:25 AM, Ben Bacarisse wrote: The use as a noun is not covered here, though it is only a small step from other places where membership of a mathematical set has

Re: Reading the documentation

2017-08-24 Thread MRAB
On 2017-08-24 20:24, Stefan Ram wrote: This is a transcript: from math import floor floor( "2.3" ) Traceback (most recent call last): File "", line 1, in TypeError: must be real number, not str help(floor) Help on built-in function floor in module math: floor(...) floor(x)

Re: requests.{get,post} timeout

2017-08-22 Thread MRAB
On 2017-08-22 19:43, Chris Angelico wrote: On Wed, Aug 23, 2017 at 4:14 AM, Jon Ribbens wrote: On 2017-08-22, Chris Angelico wrote: On Wed, Aug 23, 2017 at 2:58 AM, Jon Ribbens wrote: Yes. There is no timeout feature

Re: Proposed new syntax

2017-08-20 Thread MRAB
On 2017-08-21 03:00, Steve D'Aprano wrote: On Fri, 18 Aug 2017 04:55 pm, Marko Rauhamaa wrote: Is a Python implementation allowed to parallelize or otherwise reorder the evaluation loop? No. [snip] Well, I suppose an implementation _could_ parallelise, or whatever, _provided that_ it

Re: Ask for help about a tkinter problem

2017-08-20 Thread MRAB
On 2017-08-21 01:28, jf...@ms4.hinet.net wrote: Peter Otten at 2017/8/20 UTC+8 PM 5:52:24 wrote: [snip] That is just a peculiarity of TCL; a "-" is added to the option by the Python wrapper before passing it along This extra "-" confuses people when showing up in the Traceback info. Can't

Re: how to create root with treelib?

2017-08-19 Thread MRAB
On 2017-08-20 01:58, Ho Yeung Lee wrote: http://treelib.readthedocs.io/en/latest/examples.html tree = Tree() #create root tree.create_node((0,0), "root") result = [aa[0]] previousnode = (0,0) #create root ... tree.create_node((0,0), "root") Traceback (most recent call last): File "", line

Re: What extended ASCII character set uses 0x9D?

2017-08-18 Thread MRAB
On 2017-08-18 04:46, John Nagle wrote: On 08/17/2017 05:53 PM, Chris Angelico wrote:> On Fri, Aug 18, 2017 at 10:30 AM, John Nagle wrote: >> On 08/17/2017 05:14 PM, John Nagle wrote: >>> I'm cleaning up some data which has text description fields from >>> multiple

Re: What extended ASCII character set uses 0x9D?

2017-08-17 Thread MRAB
On 2017-08-18 01:30, John Nagle wrote: On 08/17/2017 05:14 PM, John Nagle wrote: > I'm cleaning up some data which has text description fields from > multiple sources. A few more cases: bytearray(b'miguel \xe3\x81ngel santos') bytearray(b'lidija kmeti\xe4\x8d')

Re: What extended ASCII character set uses 0x9D?

2017-08-17 Thread MRAB
On 2017-08-18 01:53, Chris Angelico wrote: On Fri, Aug 18, 2017 at 10:30 AM, John Nagle wrote: On 08/17/2017 05:14 PM, John Nagle wrote: I'm cleaning up some data which has text description fields from multiple sources. A few more cases: bytearray(b'\xe5\x81ukasz

Re: What extended ASCII character set uses 0x9D?

2017-08-17 Thread MRAB
On 2017-08-18 01:14, John Nagle wrote: I'm cleaning up some data which has text description fields from multiple sources. Some are are in UTF-8. Some are in WINDOWS-1252. And some are in some other character set. So I have to examine and sanity check each field in a database dump, deciding

Re: Request Help With Gdk.Display

2017-08-16 Thread MRAB
On 2017-08-16 18:57, Wildman via Python-list wrote: I am working on a program for the Linux platform that reports system information. The program reports screen information, number of monitors, resolution of each one and the total resolution. It does it using a couple of external utils, Xrandr

Re: A question on modification of a list via a function invocation

2017-08-14 Thread MRAB
On 2017-08-14 20:21, Mok-Kong Shen wrote: [snip] I could more or less understand that in test() alist is interpreted as local but in the extended program below in test2() I first write the same as in test1(), after which I logically assume that the name alist is now known as global and then I

Re: Proposed new syntax

2017-08-12 Thread MRAB
On 2017-08-12 09:54, Marko Rauhamaa wrote: Jussi Piitulainen : Rustom Mody writes: [ My conjecture: The word ‘comprehension’ used this way in English is meaningless and is probably an infelicious translation of something which makes sense in German] From a

Re: Proposed new syntax

2017-08-10 Thread MRAB
On 2017-08-10 20:11, Jussi Piitulainen wrote: MRAB writes: [snip] How about these? [x + y for x in (0, 1, 2, 999, 3, 4) while x < 5 for y in (100, 200)] [x + y for x in (0, 1, 2, 999, 3, 4) if x < 5 for y in (100, 200)] Thanks for your comments! There's a subtlety there. Initi

Re: Proposed new syntax

2017-08-10 Thread MRAB
On 2017-08-10 15:28, Steve D'Aprano wrote: Every few years, the following syntax comes up for discussion, with some people saying it isn't obvious what it would do, and others disagreeing and saying that it is obvious. So I thought I'd do an informal survey. What would you expect this syntax to

Re: Validating regexp

2017-08-08 Thread MRAB
On 2017-08-08 17:37, Larry Martell wrote: Anyone have any code or know of any packages for validating a regexp? I have an app that allows users to enter regexps for db searching. When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it causes downstream issues. I'd like to flag it

Re: Question About When Objects Are Destroyed (continued)

2017-08-05 Thread MRAB
On 2017-08-05 22:41, Tim Daneliuk wrote: On 08/05/2017 11:16 AM, Ned Batchelder wrote: It uses reference counting, so most objects are reclaimed immediately when their reference count goes to zero, such as at the end of local scopes. Given this code: class SomeObject: . for foo

Re: Challenge: find the first value where two functions differ

2017-08-04 Thread MRAB
On 2017-08-04 15:51, Steve D'Aprano wrote: This is a challenge for which I don't have a complete answer, only a partial answer. Here are two functions for calculating the integer square root of a non-negative int argument. The first is known to be exact but may be a bit slow: def

Re: how to fast processing one million strings to remove quotes

2017-08-02 Thread MRAB
On 2017-08-02 16:05, Daiyue Weng wrote: Hi, I am trying to removing extra quotes from a large set of strings (a list of strings), so for each original string, it looks like, """str_value1"",""str_value2"",""str_value3"",1,""str_value4""" I like to remove the start and end quotes and extra

Re: Issues with Python

2017-07-30 Thread MRAB
On 2017-07-30 22:31, Ode Idoko via Python-list wrote: Hi, I am new to Python and though I have been able to download the 3.6 version on my laptop , I still have issues with the syntax. While writing a program to execute, it will display syntax error with different shades of color usually

Re: Need some advice please

2017-07-29 Thread MRAB
On 2017-07-29 17:59, Rick Johnson wrote: On Saturday, July 29, 2017 at 4:59:26 AM UTC-5, Steve D'Aprano wrote: On Sat, 29 Jul 2017 06:34 pm, Kryptxy wrote: > Would it get me around legal issues, that is making this > tool completely legal? Do you think we are lawyers? We're not. Even if we

Re: Need help to understand not the answer

2017-07-29 Thread MRAB
On 2017-07-29 20:16, new_to_c0ding wrote: Hello all, I have been scratching my head since morning but could not understand this quiz question. I would appreciate if someone could help me understand what is it asking me to do. I dont need the answer but just the right direction to look at. ###

Re: Basic python understanding

2017-07-26 Thread MRAB
On 2017-07-26 20:04, Stefan Ram wrote: monica.sn...@gmail.com writes: Hi I am in need some understanding on how to become more knowledgeable while interviewing a candidate that requires Python The only noun preceding "that" is "candidate". So, are you using "that" to refer to the

Re: JSON encoding PDF or Excel files in Python 2.7

2017-07-21 Thread MRAB
On 2017-07-21 19:52, Skip Montanaro wrote: I would like to JSON encode some PDF and Excel files. I can read the content: pdf = open("somefile.pdf", "rb").read() but now what? json.dumps() insists on treating it as a string to be interpreted as utf-8, and bytes == str in Python 2.x. I can't

Re: Grapheme clusters, a.k.a.real characters

2017-07-19 Thread MRAB
On 2017-07-19 09:29, Marko Rauhamaa wrote: Gregory Ewing : Marko Rauhamaa wrote: * a final "v" receives a superfluous "e" ("love") It's not superfluous there, it's preventing "love" from looking like it should rhyme with "of". I'm pretty sure that wasn't the

Re: Combining every pair of list items and creating a new list.

2017-07-17 Thread MRAB
On 2017-07-17 21:10, aaron.m.weisb...@gmail.com wrote: Hi, I'm having difficulty thinking about how to do this as a Python beginner. But I have a list that is represented as: [1,2,3,4,5,6,7,8] and I would like the following results: [1,2] [3,4] [5,6] [7,8] Any ideas? Thanks Those are

Re: Grapheme clusters, a.k.a.real characters

2017-07-15 Thread MRAB
On 2017-07-16 02:20, Rick Johnson wrote: On Saturday, July 15, 2017 at 7:29:14 PM UTC-5, Chris Angelico wrote: [...] Also, that doesn't deal with U+200B or U+180E, which have well-defined widths *smaller* than typical Latin letters. (200B is a zero-width space. Is it a character?) Of *COURSE*

Re: Better Regex and exception handling for this small code

2017-07-12 Thread MRAB
On 2017-07-12 23:49, Nick Mellor wrote: On Wednesday, 12 July 2017 02:32:29 UTC+10, Ganesh Pal wrote: Dear Python friends I am trying to open a file and check if there is a pattern has changed after the task got completed? file data:

Re: About the implementation of del in Python 3

2017-07-06 Thread MRAB
On 2017-07-06 15:29, Jussi Piitulainen wrote: Marko Rauhamaa writes: While talking about addresses might or might not be constructive, let me just point out that there is no outwardly visible distinction between "address" or "identity". With a generational or otherwise compacting garbage

Re: EuroPython 2017: Free Intel Distribution for Python

2017-07-04 Thread MRAB
On 2017-07-04 23:05, Terry Reedy wrote: On 7/4/2017 10:22 AM, M.-A. Lemburg wrote: We are very pleased to have Intel as Diamond Sponsor for EuroPython 2017. You can visit them at the most central booth in our exhibit area, the Sala della Piazza, and take the opportunity to chat with their

Re: python script is slowly after use multiprocessing

2017-07-04 Thread MRAB
On 2017-07-04 18:24, Xristos Xristoou wrote: @MRAB tell me your proposal for this ? I don't have any suggestions because you haven't given any details about the function. @Ben Bacarisse i dont get some error,i have wrong map ? That code will call the function and then try to pass its

Re: python script is slowly after use multiprocessing

2017-07-03 Thread MRAB
On 2017-07-03 20:47, Xristos Xristoou wrote: i have create an image processing python function. my system have 4 cores + 4 threads. i want to use multiprocessing to speed up my function,but anytime to use multiprocessing packages my function is not faster and is 1 minute slowly. any idea why

Re: Teaching the "range" function in Python 3

2017-06-30 Thread MRAB
On 2017-07-01 03:12, Stefan Ram wrote: Terry Reedy writes: range is a class, not a function in the strict sense. »the built-in function range() returns an iterator of integers« The Python Language Reference, Release 3.6.0, 8.3 The for statement Python 3.6.1

Re: sys.exc_info

2017-06-29 Thread MRAB
On 2017-06-29 19:19, Thomas Jollans wrote: [snip] Ah, Python history. Back in the old days, it was possible to raise strings instead of the classes that took over later. Python 2.4.6 (#1, Jun 29 2017, 19:23:06) [GCC 5.4.0 20160609] on linux4 Type "help", "copyright", "credits" or "license"

Re: os.walk the apostrophe and unicode

2017-06-24 Thread MRAB
On 2017-06-24 20:47, Rod Person wrote: On Sat, 24 Jun 2017 13:28:55 -0600 Michael Torrie wrote: On 06/24/2017 12:57 PM, Rod Person wrote: > Hi, > > I'm working on a program that will walk a file system and clean the > id3 tags of mp3 and flac files, everything is working

Re: os.walk the apostrophe and unicode

2017-06-24 Thread MRAB
On 2017-06-24 19:57, Rod Person wrote: Hi, I'm working on a program that will walk a file system and clean the id3 tags of mp3 and flac files, everything is working great until the follow file is found '06 - Todd's Song (Post-Spiderland Song in Progress).flac' for some reason that I can't

Re: How to store some elements from a list into another

2017-06-12 Thread MRAB
On 2017-06-12 19:32, José Manuel Suárez Sierra wrote: Hello, I am stuck with a (perhaps) easy problem, I hope someone can help me: My problem is: I have a list of lists like this one: [[55, 56, 57, 58, 83, 84, 85, 86, 89, 90, 91, 92, 107, 108, 109, 110, 111, 117, 118, 119, 120, 128, 129, 130,

Re: Hello from a super noob!

2017-06-07 Thread MRAB
On 2017-06-08 00:56, CB wrote: Hi everyone, I am taking a python class and I'm stuck in an exercise. what am i doing wrong? Can anyone try to run it? Thanks so much! #Description:Input validation and while loops. import random def main(): #main function need in all programs for automated

Re: [OT] How to improve my programming skills?

2017-06-01 Thread MRAB
On 2017-06-01 16:26, Mirko via Python-list wrote: [snip] I'm looking for a way (*the* way, ie. the "BEST(tm)" way) to improve my coding skills. While I'm a quite hard-core computer geek since 25 years and a really good (hobbyist) Linux-SOHO-Admin, my programming skills are less than sub-par. I

Re: problems installing library (xlsxwriter)

2017-05-31 Thread MRAB
On 2017-06-01 03:35, teni...@g.clemson.edu wrote: I've in need of using xlsxwriter. when running "pip install xlsxwriter" in my command prompt I get the following: "Requirement already satisfied: xlsxwriter in c:\programdata\anaconda3\lib\site-packages" But when running "import xlsxwriter" I

Re: Working with dictionaries and keys help please!

2017-05-31 Thread MRAB
On 2017-06-01 01:29, David D wrote: I have a dictionary with a 10 people, the key being a number (0-10) and the value being the people's name. I am in the processing of Insert, Adding and deleting from the dictionary. All seems well until I delete a person and add a new one. The numbers

Re: How to make sure the result of Pandas.to_csv does not have non-ASCII code?

2017-05-31 Thread MRAB
On 2017-05-31 17:52, David Shi via Python-list wrote: How to make sure the result of Pandas.to_csv does not have non-ASCII code? Specify the encoding as 'ascii': df.to_csv(path, encoding='ascii') If there's a non-ASCII character that it can't write, it'll raise an exception. --

Re: How to install Python package from source on Windows

2017-05-30 Thread MRAB
On 2017-05-30 23:04, Deborah Swanson wrote: I never said it was pip's fault, so there's nothing for you to accept my word on. It could easily have been something that Anaconda3 did in the process of upgrading pip. But you're just trying drag this on as long as possible by manufacturing an

Re: Circular iteration on tuple starting from a specific index

2017-05-30 Thread MRAB
On 2017-05-30 17:25, Beppe wrote: hi all I've a tuple, something like x = ("A","B","C","D","E","F","G","H",) I would want to iterate on all tuple's elements starting from a specific index something like Python 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2] on linux2 Type "help",

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread MRAB
On 2017-05-30 16:03, Jon Ribbens wrote: On 2017-05-30, Joseph L. Casale wrote: There's no difference I'm aware of in the implementations I've used, but having a consistent API does allow for constructions such as: try: do_stuff(conn) except: conn.rollback()

Re: Issue with zipfile and symbolic link

2017-05-30 Thread MRAB
On 2017-05-30 08:45, loial wrote: I am reading a list of pdf files from a directory which is a symbolic link and adding them to a zip file. Issue I have is that the zip files are being added as empty directories rather than the actual pdf files. My code is below. Any idea why this happening?

Re: How to `eval` code with `def`?

2017-05-28 Thread MRAB
On 2017-05-29 02:03, Peng Yu wrote: Hi, I got the following error when I try to eval the following code with def. Does anybody know what is the correct way to evaluation python code that contains `def`? Thanks. $ cat ./main.py #!/usr/bin/env python # vim: set noexpandtab tabstop=2 shiftwidth=2

Re: How to install Python package from source on Windows

2017-05-25 Thread MRAB
On 2017-05-26 02:59, Michael Torrie wrote: On 05/25/2017 04:37 PM, Deborah Swanson wrote: Here's a question: does Anaconda have a special build of Python, or is it a standard Python bundled with extra stuff? I'm not sure, and it's an excellent question. Anaconda stopped installing Python

Re: How to install Python package from source on Windows

2017-05-25 Thread MRAB
On 2017-05-26 00:11, Deborah Swanson wrote: breamore...@gmail.com wrote, on Thursday, May 25, 2017 3:23 PM On Thursday, May 25, 2017 at 10:32:56 PM UTC+1, Deborah Swanson wrote: > > Michael Torrie wrote, on Thursday, May 25, 2017 1:57 PM > > > I didn't see a traceback where you tried to

Re: How to install Python package from source on Windows

2017-05-25 Thread MRAB
On 2017-05-25 21:24, Chris Angelico wrote: On Fri, May 26, 2017 at 6:16 AM, Deborah Swanson wrote: Anyway I can confirm that VS is not required for installing and using pip on XP, nor is it required for recordclass, since it's available in wheel form. See my

Re: How to install Python package from source on Windows

2017-05-25 Thread MRAB
On 2017-05-25 21:24, Chris Angelico wrote: On Fri, May 26, 2017 at 6:16 AM, Deborah Swanson wrote: Anyway I can confirm that VS is not required for installing and using pip on XP, nor is it required for recordclass, since it's available in wheel form. See my

Re: Nested Loop to Generate Triangle

2017-05-25 Thread MRAB
On 2017-05-25 17:28, Victor Demelo wrote: I need the triangle to be in reverse. The assignment requires a nested loop to generate a triangle with the user input of how many lines. Currently, I get answers such as: OOO OO O When I actually need it to be like this: OOO OO O I

Re: I need help with making my claculator

2017-05-24 Thread MRAB
On 2017-05-25 00:02, woo...@gmail.com wrote: How do you then run the mainloop, i.e. get it to do something? tkinter.mainloop() -- https://mail.python.org/mailman/listinfo/python-list

Re: Concatenating files in order

2017-05-23 Thread MRAB
On 2017-05-23 22:14, Mahmood Naderan via Python-list wrote: OK guys thank you very much. It is better to sort them first. Here is what I wrote files = glob.glob('*chunk*') Here you're making a list of (index, name) pairs: sorted=[[int(name.split("_")[-1]), name] for name in files] but

Re: Concatenating files in order

2017-05-23 Thread MRAB
On 2017-05-23 21:16, Mahmood Naderan via Python-list wrote: Yup. Make a list of all the file names, write a key function that extracts the numbery bits, sort the list based on that key function, and go to town. Alternatively, when you create the files in the first place, make sure to use

Re: update python 3.4.2 to 3.4.6 on Windows X64

2017-05-21 Thread MRAB
On 2017-05-21 22:23, Daiyue Weng wrote: okay, I see, I will uninstall 3.4 and install 3.6. You don't have to uninstall 3.4 until you really don't need it, when you've fulling moved to the new version and you need the disk space; just don't install 3.6 into the same folder (they default to

Re: I need help with making my calculator

2017-05-19 Thread MRAB
On 2017-05-20 02:42, gars...@gmail.com wrote: m using Python 3.4.2 This is my code: from tkinter import* def iCalc(source, side): storeObj= Frame(source, borderwidth= 1, bd= 4, bg="powder blue") storeObj.pack(side=side, expand=YES, fill=BOTH) return storeObj def button

Re: How to install Python package from source on Windows

2017-05-15 Thread MRAB
On 2017-05-16 02:19, Deborah Swanson wrote: [snip] I'll accept that, though I still don't quite understand the recent dependence on Visual C++, after Python has been building its releases with the tools you and others mention from the beginning until shortly after the first 3 build was

Re: How to install Python package from source on Windows

2017-05-15 Thread MRAB
On 2017-05-15 21:40, eryk sun wrote: On Mon, May 15, 2017 at 7:43 PM, MRAB <pyt...@mrabarnett.plus.com> wrote: > On 2017-05-15 13:52, eryk sun wrote: >> >> The wheel doesn't need a compiler. It has an ABI tag because it >> already includes the compiled extens

Re: How to install Python package from source on Windows

2017-05-15 Thread MRAB
On 2017-05-15 13:52, eryk sun wrote: On Mon, May 15, 2017 at 6:37 AM, Deborah Swanson wrote: Where did you find recordclass-0.4.3-cp34-cp34m-win32.whl? There weren't any win32 builds on https://pypi.python.org/pypi/recordclass. It's in the middle of the file

Re: Rosetta: Zebra puzzle (2.)

2017-05-13 Thread MRAB
On 2017-05-13 22:03, Jan van den Broek wrote: On 2017-05-13, Robert L. wrote: [Schnipp] def build_permutations things if block_given? things.permutation.select{|x| yield x} else things.permutation.to_a end end I fail to recognize the

Re: Iterating through a list. Upon condition I want to move on to next item in list

2017-05-10 Thread MRAB
On 2017-05-10 20:25, aaron.m.weisb...@gmail.com wrote: Good afternoon, I have a list that I'm iterating thorough in Python. Each item in the list will have between 1-200 urls associated with it. My goal is to move on to the next. I have a variable "associationsCount" that is counting the

Re: Python 2.7 on Windows: Copy install

2017-05-04 Thread MRAB
On 2017-05-04 21:27, jeff saremi wrote: I have scoured the net for any hints on this. We have some prod machines where we're not able to run MSI installations. Is it possible to copy Python2.7 from say c:\Python2.7 from one machine to another? What other steps do we need beyond the following

Re: Elegant way to merge dicts without overwriting keys?

2017-05-04 Thread MRAB
On 2017-05-05 02:23, Malcolm Greene wrote: I have a bunch of pickled dicts I would like to merge. I only want to merge unique keys but I want to track the keys that are duplicated across dicts. Is there a newer dict-like data structure that is fine tuned to that use case? Short of an optimized

Re: I encounter a problem during installations!!!

2017-04-26 Thread MRAB
On 2017-04-26 12:52, SUMIT SUMAN wrote: I have reinstall windows 8.1 for some reasons, and when I installed Python 3.6.1 then, it shows error that"The program can't start because api-ms-win-crt-runtime-I1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem."

Re: How to port a python package to a embedded system

2017-04-25 Thread MRAB
On 2017-04-25 07:28, chenchao wrote: Hi, all: I installed it by 'pip install numpy' or 'python setup.cfg install' on my PC, but I do not know how to do this on my arm board. Because of my arm board does not have tool of pip. could you please tell me any idea? Thanks! This might help:

Re: any suggestion on this code

2017-04-23 Thread MRAB
On 2017-04-23 09:21, Ganesh Pal wrote: Hello Team, I have a sample code that runs through the list of dictionary and return a dictionary if the search value matched *Sample Program:* #!/usr/bin/python def return_matched_owner(dict_list,search_block): """Accepts a list of

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread MRAB
On 2017-04-22 23:30, Mikhail V wrote: On 20 April 2017 at 23:54, MRAB <pyt...@mrabarnett.plus.com> wrote: > On 2017-04-20 22:03, Mikhail V wrote: >> >> On 20 April 2017 at 22:43, Random832 <random...@fastmail.com> wrote: >>> [snip] >>> >>&

Re: combine if filter terms from list

2017-04-21 Thread MRAB
On 2017-04-22 01:17, Rory Schramm wrote: Hi, I'm trying to use python list comprehensions to combine multiple terms for use by a for loop if condition. filters = [ 'one', 'two', 'three'] for line in other_list: if ' and '.join([item for item in filters]) not in line[2]: print

Re: textwrap.fill algorithm? (Difference with vim)

2017-04-21 Thread MRAB
On 2017-04-21 23:17, Matěj Cepl wrote: On 2017-04-21, 21:54 GMT, Peter Otten wrote: It's not the algorithm, it's the width. Try textwrap.fill(text, 72). I don’t understand. Why 72? I have set tw=65 in vim. textwrap.fill counts characters. It won't put "grown so" on the first line because

Re: Rawest raw string literals

2017-04-20 Thread MRAB
On 2017-04-21 01:11, Tim Chase wrote: On 2017-04-20 16:40, Grant Edwards wrote: How can there exist a "universal solution" even in theory? There has to be some sort of "end of literal" terminator character sequence. That means there has to be some sort of escaping mechanism when that "end of

Re: Rawest raw string literals

2017-04-20 Thread MRAB
On 2017-04-20 22:03, Mikhail V wrote: On 20 April 2017 at 22:43, Random832 <random...@fastmail.com> wrote: On Thu, Apr 20, 2017, at 16:01, Grant Edwards wrote: On 2017-04-20, MRAB <pyt...@mrabarnett.plus.com> wrote: > There _is_ a "universal solution"; it's ca

Re: Rawest raw string literals

2017-04-20 Thread MRAB
On 2017-04-20 17:40, Grant Edwards wrote: On 2017-04-20, Mikhail V wrote: On 20 April 2017 at 17:59, Grant Edwards wrote: On 2017-04-20, Mikhail V wrote: Quite often I need raw string literals for concatenating console

Re: match.groupdict() into a single dict

2017-04-19 Thread MRAB
On 2017-04-19 14:26, Ganesh Pal wrote: Hello friends, I am learning regex and trying to use this to my scripts I need some suggestion on the below code. I need to match all lines of a file that have a specific pattern and return them as a dictionary. Sample line: 'NODE=ADAM-11: |

Re: Looping [was Re: Python and the need for speed]

2017-04-17 Thread MRAB
On 2017-04-18 02:09, Paul Rubin wrote: Ben Bacarisse writes: ? I get "AttributeError: 'itertools.dropwhile' object has no attribute 'next'" from your example. Hmm, .next() worked ok for me in Python 2.7.5. Not sure what happened. Maybe something went wrong with my

Re: Namedtuples: some unexpected inconveniences

2017-04-14 Thread MRAB
On 2017-04-14 20:34, Deborah Swanson wrote: Peter, Retracing my steps to rewrite the getattr(row, label) code, this is what sent me down the rabbit hole in the first place. (I changed your 'rows' to 'records' just to use the same name everywhere, but all else is the same as you gave me.) I'd

Re: Python and the need for speed

2017-04-13 Thread MRAB
On 2017-04-13 09:08, Steven D'Aprano wrote: On Wed, 12 Apr 2017 16:30:38 -0700, bart4858 wrote: (Although I think Python would have difficulty in turning x+=1 into a single opcode, if using normal object references and a shared object model.) You know, since Python actually exists and isn't

Re: homework confusion

2017-04-12 Thread MRAB
On 2017-04-13 03:13, Lauren Fugate wrote: [snip] Read the last 2 paragraphs again: ""So you should be able to create Lockable objects with commands* like Lockable("front door", "in the foyer", house_key, False, True) (returning an object that starts out closed and locked), or

Re: Python Command Line Arguments

2017-04-12 Thread MRAB
On 2017-04-13 02:59, ian.steg...@gmail.com wrote: I have this code which I got from https://www.tutorialspoint.com/python/python_command_line_arguments.htm The example works fine but when I modify it to what I need, it only half works. The problem is the try/except. If you don't specify an

Re: Passing parameters thru decorators

2017-04-12 Thread MRAB
On 2017-04-12 21:42, andrew.hol...@otternetworks.de wrote: Hi, I'm trying to work out how to pass parameters through decorators: class Meow(): def __init__(self, arg1, arg2): print("INIT ClassBasedDecoratorWithParams") print(arg1) print(arg2) def

Re: Namedtuples: some unexpected inconveniences

2017-04-12 Thread MRAB
On 2017-04-12 20:57, Deborah Swanson wrote: I won't say the following points are categorically true, but I became convinced enough they were true in this instance that I abandoned the advised strategy. Which was to use defaultdict to group the list of namedtuples by one of the fields for the

Re: Python and the need for speed

2017-04-11 Thread MRAB
On 2017-04-12 01:28, Nathan Ernst wrote: [snip] I worked on http://www.marketswiki.com/wiki/CMDX - in particular I wrote most of the Migration Utility mentioned to migrate paper CDS trades to standardized CDS contracts against CME. Most of the migration util was written in native Python 2.5 (it

Re: Python and the need for speed

2017-04-11 Thread MRAB
On 2017-04-11 21:58, Mikhail V wrote: On 11 April 2017 at 16:56, Steve D'Aprano wrote: On Tue, 11 Apr 2017 07:56 pm, Brecht Machiels wrote: [...] DropBox and Google seem to agree that there are no good solutions, since they are moving to Go. That's a good

Re: Problem installing 3.6.1 AMD64

2017-04-05 Thread MRAB
On 2017-04-05 19:46, Colin J. Williams wrote: Successful install reported, but: Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\Users\CJW>cd\python The system cannot find the path specified. C:\Users\CJW>cd\

Re: Appending data to a json file

2017-04-04 Thread MRAB
On 2017-04-04 21:00, Dennis Lee Bieber wrote: On Tue, 4 Apr 2017 13:23:52 -0400, Dave declaimed the following: I don't care for the idea of replacing the data file for every save. My preference would to append to the existing data file - makes more sense. However, that

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-01 Thread MRAB
On 2017-04-02 02:38, Rick Johnson wrote: On Saturday, April 1, 2017 at 3:08:20 PM UTC-5, Mikhail V wrote: On 1 April 2017 at 06:38, Rick Johnson wrote: > On Thursday, March 30, 2017 at 9:14:54 AM UTC-5, Steve D'Aprano wrote: > > - and making band names look ǨØØĻ

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-01 Thread MRAB
On 2017-04-01 17:43, Marko Rauhamaa wrote: Steve D'Aprano : Open your eyes, there is a whole world past the borders of your insular, close-minded little country. 95% of the world is not American, and there are millions of Americans who want to use non-ASCII

Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-30 Thread MRAB
On 2017-03-30 19:04, INADA Naoki wrote: Maybe, this commit make this regression. https://github.com/python/cpython/commit/4897300276d870f99459c82b937f0ac22450f0b6 Old: minused = (so->used + other->used)*2 (L619) New: minused = so->used + other->used (L620) minused = (minused > 5) ?

Re: Multiprocessing queue in py2.7

2017-03-28 Thread MRAB
On 2017-03-28 19:51, Frank Miles wrote: I tried running a bit of example code from the py2.7 docs (16.6.1.2. Exchanging objects between processes) only to have it fail. The code is simply: # from multiprocessing import Process, Queue def f(q): q.put([42, None, 'hello']) if

Re: Python question

2017-03-25 Thread MRAB
On 2017-03-25 20:10, Terry Reedy wrote: On 3/25/2017 6:50 AM, Steve D'Aprano wrote: On Sat, 25 Mar 2017 10:09 am, Cameron Simpson wrote: On 24Mar2017 18:08, Abdul Abdul wrote: I hope you are doing fine. I have added a question on StackOverflow and thought you might

Re: Python.NET question?

2017-03-21 Thread MRAB
On 2017-03-21 07:27, Tristan B. Kildaire wrote: Is Python.NET a version of Python that compiles Python source code to Microsoft's IR for running by a MS runtime? Is this what you're talking about? https://github.com/pythonnet/pythonnet It says """Python for .NET is a package that gives

Re: python script Non-ASCII character

2017-03-19 Thread MRAB
On 2017-03-20 02:50, eryk sun wrote: On Sun, Mar 19, 2017 at 11:06 PM, MRAB <pyt...@mrabarnett.plus.com> wrote: If you're using Unicode string literals, your choices are: 1. Raw string literals: var1 = ur"C:\Users\username\Desktop\η γλωσσα μου\mylanguage\myfile" Raw

Re: python script Non-ASCII character

2017-03-19 Thread MRAB
On 2017-03-19 20:10, Xristos Xristoou wrote: Τη Κυριακή, 19 Μαρτίου 2017 - 7:38:19 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: @Terry non-ascii in pathnames i need for ex :var1="C:\Users\username\Desktop\my language\mylanguage\myfile" and for the blank ? Your choices are: 1. Raw string

Re: crc method for a serial driver for fiscal cash register

2017-03-15 Thread MRAB
On 2017-03-16 00:08, Chris Angelico wrote: On Thu, Mar 16, 2017 at 9:31 AM, MRAB <pyt...@mrabarnett.plus.com> wrote: 3.2. If the carry bit from S1 is 1, the MSB of S1 and LSB of S0 are inverted. Points 2 and 3 are executed for all bytes, included in the calculation of the CRC - from the

Re: crc method for a serial driver for fiscal cash register

2017-03-15 Thread MRAB
On 2017-03-15 18:18, Bogdan Radu Bolchis wrote: hi, i'm developing a Point Of Sale app in python for my company, and we need to integrate the fiscal cash register driver in python. The original driver is only for windows and no longer supported, we want to switch to Linux. We managed to

Re: Dynamically replacing an objects __class__; is it safe?

2017-03-15 Thread MRAB
On 2017-03-15 22:03, Gregory Ewing wrote: Steve D'Aprano wrote: You probably can't make a whale fly just by changing the class to bird. It will need wings, and feathers, at the very least. Some things succeed in flying with neither wings nor feathers. Helicopters, for example. Could you

Re: python and pyqt4

2017-03-14 Thread MRAB
On 2017-03-14 21:03, Vincent Vande Vyvre wrote: Le 14/03/17 à 20:56, Xristos Xristoou a écrit : i will want to create a simple python script with pyqt4 and Q designer where the user put a number (line_edit) and if that number is something the user take back three new

Re: Extraction of model and date created tag from own picture/video recordings

2017-03-14 Thread MRAB
On 2017-03-14 07:34, zljubi...@gmail.com wrote: I am looking for the way to extract two simple information from pictures/videos that I have recorded with different devices that I own: model (of the device that has recorded) and recordings (local) creation time. So far, I tried different

<    5   6   7   8   9   10   11   12   13   14   >