Re: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc?

2015-10-14 Thread MRAB
On 2015-10-14 20:05, John S. James wrote: I installed 3.5.0 today and it's working fine -- either from the command prompt, or running a .py script. But the Python 3.4 that was previously installed on the computer had a Python34 folder, which contained DDLs, Doc, include, Lib, and various other

Re: Problem with copy.deepcopy and multiprocessing.Queue

2015-10-14 Thread MRAB
On 2015-10-14 18:41, James DeVincentis wrote: I’ve got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here:

Re: Relaxed, or best-efforts JSON parser for Python?

2015-10-11 Thread MRAB
On 2015-10-12 01:56, Victor Hooi wrote: Hi, I'm attempting to parse MongoDB loglines. The formatting of these loglines could best be described as JSON-like... For example - arrays Anyhow, say I had the following logline snippet: { Global: { acquireCount: { r: 2, w: 2 } }, Database: {

Re: Finding Blank Columns in CSV

2015-10-06 Thread MRAB
On 2015-10-06 12:24, Jaydip Chakrabarty wrote: On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote: On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase wrote: That way, if you determine by line 3 that your million-row CSV file has no blank columns, you can get away

Re: Finding Blank Columns in CSV

2015-10-06 Thread MRAB
On 2015-10-06 18:23, Jaydip Chakrabarty wrote: On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote: [snip] I downloaded gmail contacts in google csv format. There are so many columns. So I was trying to create another csv with the required columns. Now when I tried to open the gmail csv

Re: Linux Mint installation of Python 3.5

2015-09-30 Thread MRAB
On 2015-09-30 04:15, Chris Angelico wrote: On Wed, Sep 30, 2015 at 1:00 PM, Mario Figueiredo wrote: Personally, I use the regular 'make install', but that's because I'm on Debian - the system Python is 2.7. Unfortunately Ubuntu based distros are going through a 2.x to 3.x

Re: Python program on induction heating

2015-09-26 Thread MRAB
On 2015-09-27 02:32, Steven D'Aprano wrote: Hi, and welcome, On Sun, 27 Sep 2015 06:28 am, Roïya souissi wrote: Hello, I have realized last year a mini project on induction heating and its application onto thermoelectricity. To back up my theoretical work, I created a python program ( I used

Re: Python, convert an integer into an index?

2015-09-24 Thread MRAB
On 2015-09-23 10:01, Anssi Saari wrote: Dennis Lee Bieber writes: On Wed, 23 Sep 2015 00:21:22 +0200, Laura Creighton declaimed the following: You need to convert your results into a string first. result_int=1234523 result_list=[] for digit in

Re: Learning Modules, Arguments, Parameters (imma noob)

2015-09-24 Thread MRAB
On 2015-09-24 19:45, codyw...@gmail.com wrote: I seem to be having a problem understanding how arguments and parameters work, Most likely why my code will not run. Can anyone elaborate on what I am doing wrong? ''' Cody Cox 9/16/2015 Programming Exercise 1 - Kilometer Converter Design a

Re: Readlines returns non ASCII character

2015-09-23 Thread MRAB
On 2015-09-24 00:51, paul.hermeneu...@gmail.com wrote: If this starts at the beginning of the file, then it indicates that the file is UTF-16 (LE). UTF-8[t 1] EF BB BF 239 187 191 UTF-16 (BE)FE FF 254 255 UTF-16 (LE)FF FE 255 254 UTF-32 (BE)00 00 FE FF

Re: Readlines returns non ASCII character

2015-09-23 Thread MRAB
On 2015-09-24 02:37, Ian Kelly wrote: On Wed, Sep 23, 2015 at 6:09 PM, MRAB <pyt...@mrabarnett.plus.com> wrote: On 2015-09-24 00:51, paul.hermeneu...@gmail.com wrote: If this starts at the beginning of the file, then it indicates that the file is UTF-16 (LE). UTF-8[t 1] EF

Re: A little test for you Guys

2015-09-22 Thread MRAB
On 2015-09-23 00:32, Mark Lawrence wrote: On 22/09/2015 19:43, Python_Teacher via Python-list wrote: you have 10 minutes Good luck!! 1. What is PEP8 ? It's the one between PEP7 and PEP9. 2. What are the different ways to distribute some python source code ? Write on sheet of paper,

Re: Python, convert an integer into an index?

2015-09-22 Thread MRAB
On 2015-09-22 23:21, Laura Creighton wrote: In a message of Tue, 22 Sep 2015 14:43:55 -0700, Chris Roberts writes: (How do I make it into an index? ) Preferably something fairly easy to understand as I am new at this. results = 134523 #(Integer) Desired: results = [1, 2, 3, 4, 5, 2, 3]

Re: Lightwight socket IO wrapper

2015-09-21 Thread MRAB
On 2015-09-21 09:47, Marko Rauhamaa wrote: Michael Ströder : Marko Rauhamaa wrote: Michael Ströder : Marko Rauhamaa wrote: I recommend using socket.TCP_CORK with socket.TCP_NODELAY where they are available (Linux). If these options are not

Re: Problem with lists

2015-09-15 Thread MRAB
On 2015-09-16 00:45, Rafael David wrote: Hi guys, I'm newbie in Python (but not a newbie developer). I'm facing a problem with a bidimensional list (list of lists) containing dictionaries. I don't know if I didn't understand how lists and dictionaries work in Python or if there is a mistake in

Re: Python handles globals badly.

2015-09-12 Thread MRAB
On 2015-09-12 06:22, Skybuck Flying wrote: "Michael Torrie" wrote in message news:mailman.384.1442016089.8327.python-l...@python.org... On 09/11/2015 03:50 PM, Skybuck Flying wrote: Something which python does not seem to do currently ?! So that's weird. I will leave it at that for now.

Re: Python handles globals badly.

2015-09-12 Thread MRAB
On 2015-09-12 17:29, Dennis Lee Bieber wrote: On Sat, 12 Sep 2015 05:11:46 +0100, Mario Figueiredo declaimed the following: On 12-09-2015 03:35, Mark Lawrence wrote: Ada took over from CORAL in the UK, at least in military projects. It was also used in the aircraft

Re: RPI.GPIO Help

2015-09-11 Thread MRAB
On 2015-09-11 19:24, John McKenzie wrote: Hello. Thanks to the help of people here and in other newsgroups I seem to have something working doing the basics. (Buttons work, colours light up appropriately.) When I followed MRAB's instructions and read about scopes of variables that

Re: Python handles globals badly.

2015-09-11 Thread MRAB
On 2015-09-11 22:26, t...@freenet.de wrote: Reflecting latest answers to global and "proposals" [snip] But you can say, the "general" sample is: You have to specify global that the compiler can distinguish between local and global Other words: global is needed to distinct global from local.

Re: Python handles globals badly.

2015-09-10 Thread MRAB
On 2015-09-11 01:35, Ian Kelly wrote: On Thu, Sep 10, 2015 at 4:25 PM, wrote: [snip] It is correct that there have to be a decision for spaces or tabs. But sure not necessarily the exact same indentation to the right for each block. Jus more same inserter to the right and

Re: RPI.GPIO Help

2015-09-09 Thread MRAB
On 2015-09-09 20:03, John McKenzie wrote: Hello. As per the suggestion of two of you I went to the Raspberry Pi newsgroup. Dennis is also there and has been posting in response to my problems. Between there and the Raspberry Foundation website I discovered that my wiring did not match my

Re: Python handles globals badly.

2015-09-09 Thread MRAB
On 2015-09-09 18:59, William Ray Wing wrote: On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: [byte] I think my favourite is the guy who claims that the reason natural languages all count from 1 is because the Romans failed to invent zero. (What about languages

Re: Python handles globals badly.

2015-09-08 Thread MRAB
On 2015-09-08 23:41, Mark Lawrence wrote: On 08/09/2015 18:41, MRAB wrote: On 2015-09-08 15:31, Ian Kelly wrote: On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov <kmis...@gmail.com> wrote: I had some experience programming in Lua and I'd say - that language is bad example to follow. I

Re: Python handles globals badly.

2015-09-08 Thread MRAB
On 2015-09-08 15:31, Ian Kelly wrote: On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov wrote: I had some experience programming in Lua and I'd say - that language is bad example to follow. Indexes start with 1 (I am not kidding) What is so bad about that? It's different

Re: Program in or into (was Python handles globals badly)

2015-09-05 Thread MRAB
On 2015-09-06 03:35, Steven D'Aprano wrote: On Sat, 5 Sep 2015 01:18 pm, Rustom Mody wrote: Here's mergesort written in various languages http://rosettacode.org/wiki/Sorting_algorithms/Merge_sort You could look at the java if you like but I think C# takes the cake. And of course also there's

Re: Need Help w. PIP!

2015-09-04 Thread MRAB
On 2015-09-05 01:35, Rob Hills wrote: On 05/09/15 01:47, Cody Piersall wrote: > On Fri, Sep 4, 2015 at 12:22 PM, Steve Burrus > wrote: <..> >> "echo %path% >> >> C:\Python34;C:\Python34\python.exe;C:\Python34\Scripts; It's a long

Re: Python handles globals badly.

2015-09-03 Thread MRAB
On 2015-09-03 17:43, Michael Torrie wrote: On 09/03/2015 10:15 AM, Ian Kelly wrote: The only person whom I see talking about this in this thread is you disclaiming that you're not talking about it. (And I guess Skybuck is talking about it, but I don't see those.) I have a vague memory of

Re: No request in module urllib ?

2015-09-03 Thread MRAB
On 2015-09-04 03:17, Vincent Vande Vyvre wrote: Le 04/09/2015 04:08, Chris Angelico a écrit : On Fri, Sep 4, 2015 at 11:56 AM, Vincent Vande Vyvre wrote: Python 3.2.3 (default, Jun 18 2015, 21:46:42) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or

Re: Strange location for a comma

2015-09-03 Thread MRAB
On 2015-09-03 13:28, ast wrote: "ast" a écrit dans le message de news:55e83afb$0$3157$426a7...@news.free.fr... Hello, At the end of the last line of the following program, there is a comma, I dont understand why ? Thx from cx_Freeze import setup, Executable # On

Re: Need Help w. PIP!

2015-09-03 Thread MRAB
On 2015-09-04 02:04, Steve Burrus wrote: On Thursday, September 3, 2015 at 7:06:27 PM UTC-5, Mark Lawrence wrote: On 03/09/2015 23:20, Steve Burrus wrote: > Well I hjave certainly noted more than once that pip is cont ained in Python 3.4. But I am having the most extreme problems with simply

Re: Python handles globals badly.

2015-09-02 Thread MRAB
On 2015-09-02 21:08, Sven R. Kunze wrote: On 02.09.2015 20:47, t...@freenet.de wrote: I agree with Skybuck Flying. I am aware if a var is a module function var or a module global var. If I want read or write a global var. Using the keyword global inside each(!) function only to mark the global

Re: Reading \n unescaped from a file

2015-09-02 Thread MRAB
On 2015-09-02 03:03, Rob Hills wrote: Hi, I am developing code (Python 3.4) that transforms text data from one format to another. As part of the process, I had a set of hard-coded str.replace(...) functions that I used to clean up the incoming text into the desired output format, something

Re: RPI.GPIO Help

2015-08-31 Thread MRAB
On 2015-08-31 18:41, John McKenzie wrote: Dennis, Hakugin, I tried your scripts and had to alter a typo here or there, but once the basic errors disappeared I had the same error message. "Conflicting edge detection already enabled for this GPIO channel". Are you still calling

Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought

2015-08-30 Thread MRAB
On 2015-08-30 17:31, kbtyo wrote: On Saturday, August 29, 2015 at 10:50:18 PM UTC-4, MRAB wrote: On 2015-08-30 03:05, kbtyo wrote: I am using Jupyter Notebook and Python 3.4. I have a data structure in the format, (type list): [{'AccountNumber': N, 'Amount': '0', 'Answer': '12:00:00 PM

Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought

2015-08-29 Thread MRAB
On 2015-08-30 03:05, kbtyo wrote: I am using Jupyter Notebook and Python 3.4. I have a data structure in the format, (type list): [{'AccountNumber': N, 'Amount': '0', 'Answer': '12:00:00 PM', 'ID': None, 'Type': 'WriteLetters', 'Amount': '10', {'AccountNumber': Y,

Re: Issue 19904

2015-08-27 Thread MRAB
On 2015-08-27 20:02, CFK wrote: Does anyone know where issue 19904 (http://bugs.python.org/issue19904) is at? I don't see it as being in python 3.5, but I was wondering if I just missed it. I could use support for __uint128_t so that I can interface with external C code via ctypes. It looks

Re: Exception AttributeError: 'NoneType' object has no attribute 'population'

2015-08-24 Thread MRAB
On 2015-08-24 06:49, 344276105 wrote: Hi all, I am a python learner. I encountered a problem when i was testing the following code. What is strange is that if I replace the object name with zhang, the program would be ok. And if I replace the Person.population with self.__class__.population, it

Re: Sometimes bottle takes a lot of time

2015-08-23 Thread MRAB
On 2015-08-23 16:20, Cecil Westerhof wrote: On Sunday 23 Aug 2015 16:05 CEST, Johannes Bauer wrote: On 22.08.2015 16:15, Christian Gollwitzer wrote: Probably yes. You should take a look at the OP again and compare the time stamps. It says that in between two consecutive calls of the same

Re: RPI.GPIO Help

2015-08-20 Thread MRAB
On 2015-08-20 16:12, John McKenzie wrote: Thanks for the reply. Also, thanks to Laura who replied via email. Tried a bunch of things based off these comments and I always ended up with one of two situations, the channel conflict error, or an instant run and quit issue. This new version of

Re: Check if dictionary empty with == {}

2015-08-19 Thread MRAB
On 2015-08-20 00:15, Skip Montanaro wrote: Comparison against {} will be less efficient. You need to create a dictionary every time instead of just checking the length of your dictionary, which is likely stored in the header. So, it will work, but certainly isn't idiomatic Python. Well, that

Re: Regular expression and substitution, unexpected duplication

2015-08-18 Thread MRAB
On 2015-08-18 22:42, Laurent Pointal wrote: Hello, I want to make a replacement in a string, to ensure that ellipsis are surrounded by spaces (this is not a typographycal problem, but a preparation for late text chunking). I tried with regular expressions and the SRE_Pattern.sub() method, but

Re: regex recursive matching (regex 2015.07.19)

2015-08-18 Thread MRAB
On 2015-08-18 22:55, Ben Bacarisse wrote: Neal Becker ndbeck...@gmail.com writes: Trying regex 2015.07.19 I'd like to match recursive parenthesized expressions, with groups such that '(a(b)c)' would give group(0) - '(a(b)c)' group(1) - '(b)' but that's not what I get import regex #r =

Re: regex recursive matching (regex 2015.07.19)

2015-08-18 Thread MRAB
On 2015-08-18 15:25, Neal Becker wrote: Trying regex 2015.07.19 I'd like to match recursive parenthesized expressions, with groups such that '(a(b)c)' would give group(0) - '(a(b)c)' group(1) - '(b)' but that's not what I get import regex #r = r'\((?[^()]|(?R))*\)' r = r'\(([^()]|(?R))*\)'

Re: no module named kivy import error in ubuntu 14.04

2015-08-16 Thread MRAB
On 2015-08-16 20:16, shiva upreti wrote: Hi I am new to linux. I tried various things in attempt to install kivy. I installed python 2.7.10 (I think python3 was already installed in ubuntu 14.04). Then i downloaded kivy from https://pypi.python.org/packages/source/K/Kivy/Kivy-1.9.0.tar.gz,

Re: RPI.GPIO Help

2015-08-16 Thread MRAB
On 2015-08-16 20:40, John McKenzie wrote: Hello, all. I am hoping some people here are familiar with the RPi.GPIO python module for the Raspberry Pi. Very new to Python and electronics. Not to computing in general though. I posted for help about accepting key presses and then discovered

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-12 04:05, Ltc Hotspot wrote: Chris, Check the code and the visualize execution of the code, available at http://tinyurl.com/p8tgd5h message reads: NameError: name 'collections' is not defined You didn't import the module. Regards, Hal On Tue, Aug 11, 2015 at 5:49 PM, Chris

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-12 06:03, Ltc Hotspot wrote: Message heard loud and clear: There are no error messages, the output is the issue. Question: What sorted function should I write to produce the desired output, below: Instead of iterating over count.items(), iterate over sorted(count.items()).

Re: Ensure unwanted names removed in class definition

2015-08-12 Thread MRAB
On 2015-08-12 10:01, Ben Finney wrote: How can I ensure incidental names don't end up in the class definition, with code that works on both Python 2 and Python 3? With the following class definition, the incidental names `foo` and `bar`, only needed for the list comprehension, remain in the

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-13 00:46, Ltc Hotspot wrote: How do I define the file name in order to remove the traceback? At this point I think I'll just let you figure that out for yourself... -- https://mail.python.org/mailman/listinfo/python-list MRAB, How do I define X

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-12 22:16, Denis McMahon wrote: [snip] c = [0 for i in range(24)] f = open(filename,'r') for l in f: h = int(l.strip().split()[X].split(':')[Y]) c[h] = c[h] + 1 f.close() for i in range(24): print '{:02d} {}'.format(i, c[i]) There's no need to strip whitespace just

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-13 00:05, Ltc Hotspot wrote: On Wed, Aug 12, 2015 at 3:35 PM, MRAB pyt...@mrabarnett.plus.com wrote: On 2015-08-12 22:16, Denis McMahon wrote: [snip] c = [0 for i in range(24)] f = open(filename,'r') for l in f: h = int(l.strip().split()[X].split(':')[Y]) c[h] = c[h

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-12 17:29, Ltc Hotspot wrote: Denis, Using the attached file of a diagram as a frame, why is there an attribute message? The code in the error report doesn't match the revised code.

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-12 19:35, Ltc Hotspot wrote: Emile How do I define time in the revised code ? Have a look at assignment_10_2_v_06.py. --- Traceback Message reads: In [66]: %run assignment_10_2_v_07 NameError Traceback

Re: AttributeError

2015-08-12 Thread MRAB
On 2015-08-12 17:57, Ltc Hotspot wrote: MRAB, I ran the code, and the output: Raw data code: handle = From stephen.marqu...@uct.ac.za Sat Jan 5 09:14:16 2008 From lo...@media.berkeley.edu Fri Jan 4 18:10:48 2008 .split(\n) # Snippet file data: mbox-short.txt count = dict() #fname

Re: AttributeError

2015-08-12 Thread MRAB
= line.rstrip() count[hours] = count.get(hours, 0) + 1 # counter lst = [(val,key) for key,val in count.items()] print key, val On Wed, Aug 12, 2015 at 11:59 AM, MRAB pyt...@mrabarnett.plus.com wrote: On 2015-08-12 19:35, Ltc Hotspot wrote: Emile How do I define time in the revised

Re: AttributeError

2015-08-11 Thread MRAB
On 2015-08-12 01:01, Ltc Hotspot wrote: Hi Everyone, What is the list equivalent to line 12: ncount.sort(reverse=True) count = dict() fname = raw_input(Enter file name: )# handle = open (fname, 'r')# for line in handle: if line.startswith(From ): address = line.split()[5]

Re: AttributeError

2015-08-11 Thread MRAB
code, available at http://tinyurl.com/qhm4ppq Visualization URL link, available at http://tinyurl.com/ozzmffy Regards, Hal On Tue, Aug 11, 2015 at 5:26 PM, MRAB pyt...@mrabarnett.plus.com mailto:pyt...@mrabarnett.plus.com wrote: On 2015-08-12 01:01, Ltc Hotspot wrote: Hi Everyone

Re: Importing is partially working...

2015-08-10 Thread MRAB
On 2015-08-10 11:11, Chris Angelico wrote: On Sun, Aug 9, 2015 at 3:45 PM, Dwight GoldWinde dwi...@goldwinde.com wrote: name = 'Jim' coach = 'Dwight' import importlib sentence = 'Hi, there, ' + name + '. My name is ' + coach + '. I will be your coach today.' from Functions.py import humprint

Re: Linux script to get most expensive processes

2015-08-04 Thread MRAB
On 2015-08-04 22:30, Cecil Westerhof wrote: On Tuesday 4 Aug 2015 22:52 CEST, Emile van Sebille wrote: On 8/4/2015 1:19 PM, Cecil Westerhof wrote: Under Linux I like to get the most expensive processes. The two most useful commands are: ps -eo pid,user,pcpu,args --sort=-pcpu and: ps -eo

Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter?

2015-07-28 Thread MRAB
On 2015-07-28 15:09, Victor Hooi wrote: On Tuesday, 28 July 2015 23:59:11 UTC+10, m wrote: W dniu 28.07.2015 o 15:55, Victor Hooi pisze: I know the regex library also has a split, unfortunately, that does not collapse consecutive whitespace: In [19]: re.split(' |', f) Try ' *\|' p. m.

Re: Concatenating columns via Python

2015-07-28 Thread MRAB
On 2015-07-28 19:50, hannahgracemcdonal...@gmail.com wrote: I extracted a table from a PDF so the data is quite messy and the data that should be in 1 row is in 3 colums, like so: year color location 1 1997 blue, MD 2green, 3

Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?]

2015-07-23 Thread MRAB
On 2015-07-23 22:50, Mark Lawrence wrote: On 23/07/2015 22:29, Marko Rauhamaa wrote: Chris Angelico ros...@gmail.com: Fortunately, we don't need to completely understand it. New Horizons reached Pluto right on time after a decade of flight that involved taking a left turn at Jupiter... we can

Re: Optimizing if statement check over a numpy value

2015-07-23 Thread MRAB
On 2015-07-23 10:21, Heli Nix wrote: Dear all, I have the following piece of code. I am reading a numpy dataset from an hdf5 file and I am changing values to a new value if they equal 1. There is 90 percent chance that (if id not in myList:) is true and in 10 percent of time is false.

Re: Integers with leading zeroes

2015-07-22 Thread MRAB
On 2015-07-22 16:50, Grant Edwards wrote: On 2015-07-22, MRAB pyt...@mrabarnett.plus.com wrote: On 2015-07-22 16:27, Antoon Pardon wrote: Does the same condition hold for strings? If you are not performing string operations on something, it is not a string? Tkinter comes to mind. You

Re: Integers with leading zeroes

2015-07-22 Thread MRAB
On 2015-07-22 16:27, Antoon Pardon wrote: On 07/22/2015 11:09 AM, alister wrote: On Wed, 22 Jul 2015 09:12:59 +0200, Laura Creighton wrote: The biggest use I have for decimal numbers that begin with 0 is in credit card numbers, account numbers and the like where the first check you do is

Re: Fast 12 bit to 16 bit sample conversion?

2015-07-20 Thread MRAB
On 2015-07-20 14:10, Peter Heitzer wrote: I am currently writing a python script to extract samples from old Roland 12 bit sample disks and save them as 16 bit wav files. The samples are layouted as follows 0 [S0 bit 11..4] [S0 bit 3..0|S1 bit 3..0] [S1 bit 11..4] 3 [S2 bit 11..4] [S2 bit

Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?]

2015-07-19 Thread MRAB
On 2015-07-19 22:16, Chris Angelico wrote: On Mon, Jul 20, 2015 at 5:55 AM, Tim Chase python.l...@tim.thechases.com wrote: On 2015-07-20 04:07, Chris Angelico wrote: The int() and float() functions accept, if I'm not mistaken, anything with Unicode category Nd (Number, decimal digit). In your

Re: Proposed keyword to transfer control to another function

2015-07-19 Thread MRAB
On 2015-07-19 17:13, Chris Angelico wrote: On Mon, Jul 20, 2015 at 2:05 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: I've only seen one other application using HHMLL -- and that was the Amiga file system. Okay, I'll bite. What does HHMLL stand for? Google didn't answer my

Re: how to play

2015-07-19 Thread MRAB
On 2015-07-19 20:01, Aron Barsam wrote: i have trouble trying to play python please can you respond soon You'll need to provide some details. Saying i have trouble isn't helpful. Help us to help you. Which operating system are you using? Windows, MacOS, Linux? Which version? Which version

Re: Need assistance

2015-07-19 Thread MRAB
On 2015-07-19 01:59, Denis McMahon wrote: On Sat, 18 Jul 2015 12:35:10 +0200, Sibylle Koczian wrote: Am 18.07.2015 um 02:40 schrieb Denis McMahon: Having a list of words, get a copy of the list in reverse order. See the reversed function (and maybe the list function). That won't really

Re: Noob in Python. Problem with fairly simple test case

2015-07-19 Thread MRAB
On 2015-07-19 18:25, Rick Johnson wrote: On Sunday, July 19, 2015 at 4:18:31 AM UTC-5, Laura Creighton wrote: And, despite Norway not being part of the EU, Scandinavia is still in Europe. This is a bit off topic: But i don't consider Scandinavia to be a part of the EU. Not anymore than i

Re: A new module for performing tail-call elimination

2015-07-18 Thread MRAB
On 2015-07-18 23:39, Gregory Ewing wrote: Marko Rauhamaa wrote: At any rate, it demonstrates how the idiom has its place in Python. Perhaps it does, but I think I'd still prefer it to be explicit. The call in Marko's example is not actually a tail call as written. To make it a tail call, a

Re: Need assistance

2015-07-18 Thread MRAB
On 2015-07-18 19:28, William Ray Wing wrote: On Jul 18, 2015, at 1:34 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: [byte] What is an {HP calculator} roll operation? The original Hewlett Packard “Scientific” calculators (HP-35, 45, 65, etc) that used Polish notation (operand,

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-15 Thread MRAB
On 2015-07-15 12:22, Mark Lawrence wrote: On 15/07/2015 10:13, Gregory Ewing wrote: Chris Angelico wrote: I'm still interested in the explicit replace current stack frame with this call operation. Calling it goto seems wrong, as most languages with goto restrict it to _within_ a function,

Re: Python backreference replacing doesn't work as expected

2015-07-12 Thread MRAB
On 2015-07-12 10:40, Yonggang Chen wrote: There are two named groups in my pattern: myFlag and id, I want to add one more myFlag immediately before group id. Here is my current code: ## code begin # i'm using Python 3.4.2 import re import os contents = b''' xdlg::xdlg(x_app* pApp, CWnd*

Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread MRAB
On 2015-07-12 18:33, Simon Evans wrote: Dear Peter Otten, I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got: Python 2.7.6 (default,

Re: 0 + not 0

2015-07-11 Thread MRAB
On 2015-07-11 17:02, Stefan Ram wrote: Serhiy Storchaka storch...@gmail.com writes: On 11.07.15 13:26, candide wrote: 0 + not 0 File stdin, line 1 0 + not 0 ^ SyntaxError: invalid syntax What is syntactically wrong with 0 + not 0? This looks as a bug to me. Please file a

Re: Trouble getting to windows My Documents directory

2015-07-10 Thread MRAB
On 2015-07-10 15:27, Mark Storkamp via Python-list wrote: I'm just learning Python, and I've run into trouble trying to change directory to the windows My Documents directory. There's likely a better way to do this, but this is what I've tried so far:

Re: Mysterious tkinter bug: tk.Button doesn't think it passed event 1

2015-07-02 Thread MRAB
On 2015-07-02 23:33, Ben Elam wrote: I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '3' but not event '1'. That is, the function the event is passed to receives the event and can even print the address of the event

Re: Bug in floating point multiplication

2015-07-02 Thread MRAB
On 2015-07-02 15:52, Steven D'Aprano wrote: Despite the title, this is not one of the usual Why can't Python do maths? bug reports. Can anyone reproduce this behaviour? If so, please reply with the version of Python and your operating system. Printing sys.version will probably do. x = 1 -

Re: Python 3 resuma a file download

2015-07-02 Thread MRAB
On 2015-07-02 21:27, zljubi...@gmail.com wrote: This is my final version which doesn't work. :( Actually, it works with another file on another server, but doesn't work with mp4 files on this particular server. I really don't know what to do? Regards. import os import urllib.request def

Re: normalizing a value

2015-07-01 Thread MRAB
On 2015-07-02 01:12, bvdp wrote: Not sure what this is called (and I'm sure it's not normalize). Perhaps scaling? Anyway, I need to convert various values ranging from around -50 to 50 to an 0 to 12 range (this is part of a MIDI music program). I have a number of places where I do:

Re: how to replace some methods with instrumented ones

2015-06-26 Thread MRAB
On 2015-06-26 18:12, georgeryo...@gmail.com wrote: [python 2.7, linux] I have a python app. I cannot modify the file. But I can import it and mess with it. I need to perform brief tasks before and after some of the member functions. I'd like to do this in as clear and maintainable way as

Re: Why does the unit test fail of the pyPDF2 package?

2015-06-24 Thread MRAB
On 2015-06-24 18:52, fl wrote: On Wednesday, June 24, 2015 at 9:54:12 AM UTC-7, fl wrote: Hi, I want to learn some coding on PDF. After I download and install pyPDF2, it cannot pass unit test, which is coming from the package. I put a screen shot link here to show the console message:

Re: Looking up a dictionary _key_ by key?

2015-06-23 Thread MRAB
On 2015-06-24 01:21, Dan Stromberg wrote: I know that sounds strange: usually we look up values by key, not keys. But suppose you have a strange key type that despite being equal, is not identical in some fields, and you need to see those fields. Is there a way of getting the key used by the

Re: How to construct matrix from vectors?

2015-06-20 Thread MRAB
On 2015-06-21 02:57, Nasser M. Abbasi wrote: I just started to learn some python today for first time, so be easy on me. I am having some trouble figuring how do the problem shown in this link http://12000.org/my_notes/mma_matlab_control/KERNEL/KEse44.htm Given 4 column vectors, v1,v2,v3,v4,

Re: help in understanding the stackless code

2015-06-18 Thread MRAB
On 2015-06-18 08:41, ravi wrote: hi, I am new to python and need to know why the calling of switch(1) invokes the function listen twice in the below program? import stackless class EventHandler: def __init__(self,*outputs): if outputs==None: self.outputs=[]

Re: Python File as the Default PDF handler for Windows

2015-06-18 Thread MRAB
On 2015-06-19 02:18, Chris Angelico wrote: On Fri, Jun 19, 2015 at 11:03 AM, Naftali nmichalow...@gmail.com wrote: I may be missing something in your reply, but I am *not* wondering how to associate python with the .pdf file extension. That I know how to do. What I want to know is how from

Re: Why this list of dictionaries doesn't work?

2015-06-18 Thread MRAB
On 2015-06-18 18:57, Gilcan Machado wrote: Hi, I'm trying to write a list of dictionaries like: people = ( {'name':'john', 'age':12} , {'name':'kacey', 'age':18} ) That's not a list; it's a tuple. If you want a list, use '[' and ']'. I've thought the code below

Re: Testing random

2015-06-16 Thread MRAB
On 2015-06-17 00:45, Thomas 'PointedEars' Lahn wrote: Ned Batchelder wrote: On Tuesday, June 16, 2015 at 6:01:06 PM UTC-4, Thomas 'PointedEars' Lahn wrote: Your programmatic proof, as all the other intuitive-empirical proofs, and all the other counter-arguments posted before in this thread,

Re: Set a flag on the function or a global?

2015-06-15 Thread MRAB
On 2015-06-16 01:53, Ethan Furman wrote: On 06/15/2015 05:37 PM, Paul Rubin wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Thoughts and feedback? Please vote: a module global, or a flag on the object? Please give reasons, and remember that the function is intended for

Re: Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread MRAB
On 2015-06-16 03:00, Malik Rumi wrote: On Saturday, June 13, 2015 at 1:25:52 PM UTC-5, MRAB wrote: On 2015-06-13 05:48, Malik Rumi wrote: On Friday, June 12, 2015 at 3:31:36 PM UTC-5, Ian wrote: On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: I am trying to find a list of strings

Re: Set a flag on the function or a global?

2015-06-15 Thread MRAB
On 2015-06-16 01:24, sohcahto...@gmail.com wrote: On Monday, June 15, 2015 at 4:57:53 PM UTC-7, Steven D'Aprano wrote: I have a function in a module which is intended to be used by importing that name alone, then used interactively: from module import edir edir(args) edir is an enhanced

Re: Path, strings, and lines

2015-06-13 Thread MRAB
On 2015-06-13 05:48, Malik Rumi wrote: On Friday, June 12, 2015 at 3:31:36 PM UTC-5, Ian wrote: On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: I am trying to find a list of strings in a directory of files. Here is my code: # -*- coding: utf-8 -*- import os import fileinput s2 =

Re: A basic dictionary question

2015-06-11 Thread MRAB
On 2015-06-11 11:10, David Aldrich wrote: Hi I am fairly new to Python. I am writing some code that uses a dictionary to store definitions of hardware registers. Here is a small part of it: import sys register = { 'address' : 0x3001c, 'fields' : { 'FieldA' : {

Re: I don't like the OO part of python. In particular the self keyword everywhere.

2015-06-11 Thread MRAB
On 2015-06-11 12:27, Skybuck Flying wrote: Then again... I also believe the highest goal for a programming language is natural spoken language. Natural language is full of ambiguities. If self.somefield equals 10 then... Does have some understandable ring to it. However... time

Re: I just need this question explained.

2015-06-11 Thread MRAB
On 2015-06-11 13:03, Adebayo Abraham wrote: I am not requesting for a solution. I just need the question explained. I am a beginner python developer and i do not know where to start from to solve this problem. So anybody, somebody: please explain this question. Am i to create a testcase or

Re: Testing random

2015-06-07 Thread MRAB
On 2015-06-08 02:42, Chris Angelico wrote: On Mon, Jun 8, 2015 at 11:34 AM, random...@fastmail.us wrote: In general, as the number of trials increases, the probability of having e.g. at least one of each value never _reaches_ 1, but it gets arbitrarily close. And by arbitrarily close, you

Re: Using import math.

2015-06-06 Thread MRAB
On 2015-06-06 23:03, 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. In what way does it fail? If it printed an error

Re: Multiple thread program problem

2015-06-03 Thread MRAB
On 2015-06-03 21:41, Mohan Mohta wrote: Hello I am trying to create multiple thread through the below program but I am getting an error #! /usr/bin/python import os import subprocess import thread import threading from thread import start_new_thread def proc(f) : com1=ssh -B

<    9   10   11   12   13   14   15   16   17   18   >