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

Re: Retrying to send message

2015-06-03 Thread MRAB
On 2015-06-03 17:15, Cecil Westerhof wrote: Op Wednesday 3 Jun 2015 15:29 CEST schreef Chris Angelico: On Wed, Jun 3, 2015 at 10:27 PM, Cecil Westerhof ce...@decebal.nl wrote: def send_message(account_id, message, max_tries, terminate_program): error_msg = 'Something went wrong with: ' +

Re: Parser needed.

2015-06-02 Thread MRAB
On 2015-06-02 05:45, Skybuck Flying wrote: Example for python: MyString = Hello World print MyString.rfind(World) if MyString.rfind(World): print yes else: print no Pretty cool. .rfind returns the index if found, -1 if not found. World.rfind(World) returns 0, which will be treated as

Re: What is considered an advanced topic in Python?

2015-06-01 Thread MRAB
On 2015-06-01 12:57, Marko Rauhamaa wrote: Laura Creighton l...@openend.se: Von Neumann recommended against floating-point numbers for the 1951 IAS machine, arguing that fixed-point arithmetic is preferable. I agree, but, if John von Neumann couldn't win that argument, then there is no way on

Re: [RELEASED] Python 3.5.0b2 is now available

2015-06-01 Thread MRAB
On 2015-06-01 05:37, Larry Hastings wrote: On behalf of the Python development community and the Python 3.5 release team, I'm relieved to announce the availability of Python 3.5.0b2. Python 3.5.0b1 had a major regression (see http://bugs.python.org/issue24285 for more information) and as such

Re: What is considered an advanced topic in Python?

2015-06-01 Thread MRAB
On 2015-06-01 16:51, Laura Creighton wrote: In a message of Mon, 01 Jun 2015 15:26:49 -, alister writes: I don't think anyone programmed a Sinclair computer to use pre-decimal currency, we converted to decimal in 1971 (although the last pre-decimal coin did not go out of use untill 1993)

Re: [RELEASED] Python 3.5.0b2 is now available

2015-06-01 Thread MRAB
On 2015-06-01 21:57, Terry Reedy wrote: On 6/1/2015 7:48 AM, MRAB wrote: I've just run Windows x86 executable installer and Windows x86-64 executable installer. While installing, the progress messages overwrote each other without clearing the background each time. I saw something like

Re: Pyton re module and POSIX equivalence classes

2015-06-01 Thread MRAB
On 2015-06-01 23:48, Mark Lawrence wrote: On 01/06/2015 21:29, Tim Chase wrote: Is Python supposed to support POSIX equivalence classes? I tried the following in Py2 and Py3: re.sub('[[=a=]]', 'A', 'aáàãâä', re.U) 'aáàãâä' which suggests that it doesn't (I would have expected AA

Re: Where is 'palindrome' defined?

2015-06-01 Thread MRAB
On 2015-06-02 01:55, fl wrote: On Sunday, May 31, 2015 at 9:46:56 PM UTC-7, fl wrote: Hi, When I search solution of reverse a string/number, I came across a short function online: def palindrome(num): return str(num) == str(num)[::-1] I thought that it is a general function. And

Re: Getting an image from a file on windows

2015-05-28 Thread MRAB
On 2015-05-29 01:03, IronManMark20 wrote: Hello, I have been working on a function that gets a bitmap of the thumbnail for a file. I have had problems getting a large image (256x256) and I was wondering if someone could help me on one object initialization that is driving me nuts. I have code

Re: Decoding JSON file using python

2015-05-27 Thread MRAB
On 2015-05-28 00:51, Karthik Sharma wrote: I tried modifying the program as follows as per your suggestion.Doesn't seem to work. import simplejson as json import cjson json_input = { msgType: 0, tid: 1, data: [{\Severity\:\warn\,\Subject\:\Reporting

Re: Decoding JSON file using python

2015-05-27 Thread MRAB
On 2015-05-27 23:23, Karthik Sharma wrote: I have the JSON structure shown below and the python code shown below to manipulate the JSON structure. import json json_input = { msgType: 0, tid: 1, data: [{\Severity\:\warn\,\Subject\:\Reporting

Re: PUDB Traceback

2015-05-27 Thread MRAB
On 2015-05-27 21:01, Piyush Verma wrote: Hi, I'm facing traceback when using pudb python debugger to debug. Any help to resolve it. # python -m pudb file.py input Traceback (most recent call last): File /usr/lib/python2.7/runpy.py, line 162, in _run_module_as_main __main__, fname,

Re: remote control of a cmd.Cmd() loop (help requested)

2015-05-22 Thread MRAB
On 2015-05-23 01:27, Benjamin Risher wrote: First, the snippet provided is a contrived example of a much larger program. http://pastebin.com/xRqBE5BY (written in python3 with access to 3.4 if necessary) The goal: To connect to a listening socket and send commands to the cmd.Cmd() loop

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread MRAB
On 2015-05-22 20:14, Laura Creighton wrote: The first time you discover that in javascript typeof(null) is 'object' and not 'null' you will scream. I wonder how many home versions of typeof to replace the system one exist out in the wild? I don't think that typeof(null) should be 'null'. If

Re: need help with an accessibility prototype

2015-05-22 Thread MRAB
On 2015-05-22 17:29, Eric S. Johansson wrote: 2 needs. first is determining if NaturallySpeaking injects keycodes or ascii char into the windows input queue. second is building a test widget to capture and display text. ASCII? :-) I think I can solve both of these by building a simple text

Re: How to do integers to binary lists and back

2015-05-21 Thread MRAB
On 2015-05-21 23:20, John Pote wrote: Hi everyone. I recently had the problem of converting from an integer to its representation as a list of binary bits, each bit being an integer 1 or 0, and vice versa. E.G. 0x53 becomes [ 0, 1, 0, 1, 0, 0, 1, 1 ] This I wanted to do for integers of many

Re: Slices time complexity

2015-05-21 Thread MRAB
On 2015-05-21 14:34, bartc wrote: On Thursday, 21 May 2015 06:19:39 UTC+1, Steven D'Aprano wrote: On Wednesday 20 May 2015 19:56, Bartc wrote: What you *shouldn't* do is implement your own argument convention, (That's exactly what I did for my static language compiler which generates x64

Re: Find if a file existing within 1000s of folder/sub-folder - each file has a unique presence

2015-05-21 Thread MRAB
On 2015-05-21 17:31, Grant Edwards wrote: On 2015-05-21, Chris Angelico ros...@gmail.com wrote: On Fri, May 22, 2015 at 12:14 AM, Grant Edwards invalid@invalid.invalid wrote: On 2015-05-21, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: import glob

Re: 'NoneType' in contextmanager prevent proper RuntimeError to be raised

2015-05-20 Thread MRAB
On 2015-05-21 00:20, Daniel Gonçalves wrote: When you decorate a function with contextmanager that didn't yield you got an AttributeError instead of a proper RuntimeError generator didn't yield. For example: @contextlib.contextmanager def foo(): ... pass ... with foo(): ...

Re: Best way to rewrite Popen

2015-05-19 Thread MRAB
On 2015-05-19 23:23, Cecil Westerhof wrote: Op Tuesday 19 May 2015 23:28 CEST schreef Jon Ribbens: On 2015-05-19, Cecil Westerhof ce...@decebal.nl wrote: It looks like that this does what I want (the dot is needed so that it also works with 2.7): files = sorted(os.listdir('.')) p =

Re: Building CPython

2015-05-15 Thread MRAB
On 2015-05-16 01:43, BartC wrote: On 15/05/2015 23:44, Marko Rauhamaa wrote: BartC b...@freeuk.com: What /is/ a method lookup? Is it when you have this: A.B() and need to find whether the expression A (or its class or type) has a name B associated with it? (And it then needs to check

Re: Building CPython

2015-05-14 Thread MRAB
On 2015-05-14 22:55, BartC wrote: On 14/05/2015 17:29, Marko Rauhamaa wrote: BartC b...@freeuk.com: That's a shame because I wanted to tinker with the main dispatcher loop to try and find out what exactly is making it slow. Nothing that seems obvious at first sight. My guess is the main

Re: Looking for direction

2015-05-13 Thread MRAB
On 2015-05-14 01:06, Ethan Furman wrote: On 05/13/2015 04:24 PM, 20/20 Lab wrote: I'm a beginner to python. Reading here and there. Written a couple of short and simple programs to make life easier around the office. That being said, I'm not even sure what I need to ask for. I've never

Re: itertools py3.4 - filter list using not equal - fails as bool

2015-05-12 Thread MRAB
On 2015-05-12 23:43, Sayth Renshaw wrote: why can't I filter a list based on an itertools condition using dropwhile? This is the docs and the example. https://docs.python.org/3/library/itertools.html#itertools.dropwhile def less_than_10(x): return x 10 itertools.takewhile(less_than_10,

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-08 Thread MRAB
On 2015-05-08 20:00, zljubisic...@gmail.com wrote: The script is very simple (abc.txt exists in ROOTDIR directory): import os import shutil ROOTDIR = 'C:\Users\zoran' file1 = os.path.join(ROOTDIR, 'abc.txt') file2 = os.path.join(ROOTDIR, 'def.txt') shutil.move(file1, file2) But it returns

Re: Writing list of dictionaries to CSV

2015-05-06 Thread MRAB
On 2015-05-06 06:32, Kashif Rana wrote: Hello guys thanks for the feedback. I think its problem with excel itself, showing wrong value. Because when I opened the csv file in text editor, I can see correct value but opening in excel showing wrong value. What I can do to see correct in excel

Re: Writing list of dictionaries to CSV

2015-05-05 Thread MRAB
On 2015-05-05 18:09, Kashif Rana wrote: Hello Experts When I am writing list of dictionaries to CSV file, the key 'schedule' has value 'Mar 2012' becomes Mar-12. I really do not have clue why thats happening. Below is the code. dic_1 = {'action': 'permit', 'dst-address':

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread MRAB
On 2015-05-03 16:32, Jon Ribbens wrote: On 2015-05-03, Chris Angelico ros...@gmail.com wrote: On Mon, May 4, 2015 at 12:40 AM, Jon Ribbens jon+use...@unequivocal.co.uk wrote: If I have a string containing surrogate pairs like this in Python 3.4: \udb40\udd9d How do I convert it into the

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread MRAB
On 2015-05-03 17:26, Jon Ribbens wrote: On 2015-05-03, MRAB pyt...@mrabarnett.plus.com wrote: On 2015-05-03 16:32, Jon Ribbens wrote: That would, unfortunately, be tell the Unicode Consortium to format their documents differently, which seems unlikely to happen. I'm trying to read in: http

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread MRAB
On 2015-05-02 22:06, Cecil Westerhof wrote: Op Saturday 2 May 2015 22:17 CEST schreef Tim Chase: [dangit, had Control down when I hit enter and it sent prematurely] On 2015-05-02 13:02, vasudevram wrote: http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html

Re: seek operation in python

2015-04-29 Thread MRAB
On 2015-04-29 19:08, siva sankari R wrote: file=open(input,r) line=file.seek(7) print line The above code is supposed to print a line but it prints none. I don't know where the mistake is. Help.! 'seek' will seek to position 7 in the file. It doesn't read. That's what 'read' is for! :-) --

Re: Python re to extract useful information from each line

2015-04-29 Thread MRAB
On 2015-04-29 22:22, Emile van Sebille wrote: On 4/29/2015 1:49 PM, Kashif Rana wrote: pol_elements =

Re: HELP! How to return the returned value from a threaded function

2015-04-18 Thread MRAB
On 2015-04-18 18:50, D. Xenakis wrote: This sounds like homework... what have you tried, and what happened? heheh naaah no cheating here. I just provided the example this way to make as clear as possible what I want to do. Return the returned value from a threaded function. apparently this

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-12 23:49, Pippo wrote: I have a text as follows: #D{#C[Health] #P[Information] - means any information, including #ST[genetic information], whether #C[oral | (recorded in (any form | medium))], that (1)#C[Is created or received by] a #A[health care provider | health plan | public

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 01:55, Pippo wrote: On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: constraint = re.compile(r'(#C\[\w*\]')) result = constraint.search(content[j],re.MULTILINE) text.append(result) print(text) [...] result is empty! Although it

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 00:47, Pippo wrote: On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: On 2015-04-12 23:49, Pippo wrote: I have a text as follows: #D{#C[Health] #P[Information] - means any information, including #ST[genetic

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 01:25, Pippo wrote: On Sunday, 12 April 2015 20:06:08 UTC-4, MRAB wrote: On 2015-04-13 00:47, Pippo wrote: On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: On 2015-04-12 23:49, Pippo wrote: I have a text

Re: Best search algorithm to find condition within a range

2015-04-09 Thread MRAB
On 2015-04-09 16:21, Steven D'Aprano wrote: On Fri, 10 Apr 2015 01:02 am, Chris Angelico wrote: On Fri, Apr 10, 2015 at 12:53 AM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Ouch, you're right, I tried to stick with Marko's example and forgot the basics. I meant signed ints, but the

Re: Get the numbering of named regex groups

2015-04-08 Thread MRAB
On 2015-04-08 15:28, Peter Otten wrote: Mattias Ugelvik wrote: Example: re.match('(?Pfirsta?)(?Psecondb?)', '') How can I find out that the group 'first' correlates to the positional regex group 1? I need to know this to resolve crucial ambiguities in a string manipulation tool I'm making.

Re: Best search algorithm to find condition within a range

2015-04-07 Thread MRAB
On 2015-04-07 15:36, jonas.thornv...@gmail.com wrote: Den tisdag 7 april 2015 kl. 16:30:15 UTC+2 skrev Denis McMahon: On Tue, 07 Apr 2015 09:29:59 -0400, Dave Angel wrote: On 04/07/2015 05:44 AM, jonas.thornv...@gmail.com wrote: I want todo faster baseconversion for very big bases like

Re: Best search algorithm to find condition within a range

2015-04-07 Thread MRAB
On 2015-04-07 16:05, Grant Edwards wrote: On 2015-04-07, Chris Angelico ros...@gmail.com wrote: On Wed, Apr 8, 2015 at 12:36 AM, jonas.thornv...@gmail.com wrote: Integers are internally assumed to be base 10 otherwise you could not calculate without giving the base. All operations on

Re: [SerialConnection] Help

2015-04-07 Thread MRAB
On 2015-04-07 16:42, Hugo Caldas wrote: Hi. I want to connect to a serial port, read and write the port values with multi threading and save them in random variables in python 3.4. Where can I found information to do that? Use the pyserial module. The module is on PyPI:

Re: Error in processing JSON files in Python

2015-03-30 Thread MRAB
On 2015-03-30 22:27, Karthik Sharma wrote: I have the following python program to read a set of JSON files do some processing on it and dump them back to the same folder. However When I run the below program and then try to see the output of the JSON file using `cat file.json | python -m

Re: test1

2015-03-25 Thread MRAB
On 2015-03-25 22:36, Chris Angelico wrote: On Thu, Mar 26, 2015 at 6:49 AM, Tiglath Suriol tiglathsur...@gmail.com wrote: Two possibilities: You are a moderator. If you are a moderator you are welcome to delete my tests posts. This is of course improbably because this newsgroup is not

Re: how should i add extension and unzip again?

2015-03-18 Thread MRAB
On 2015-03-18 23:22, PK Khatri wrote: This script untars .gz file to file without extension import gzip import glob import os.path import tarfile source_dir = C:\\TEST dest_dir = C:\\TEST for src_name in glob.glob(os.path.join(source_dir, '*.gz')): base =

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-17 Thread MRAB
On 2015-03-18 02:41, Chris Kavanagh wrote: I have a simple script that takes user input (for an Employee) such as name, age, etc then puts in an sqlite3 database. The script worked fine until I realized one problem. The age input field is defined in SQLAlchemy as an Integer, so if a user inputs

Re: PSF news - BBC launches MicroBit

2015-03-15 Thread MRAB
On 2015-03-15 07:26, Dave Farrance wrote: Mark Lawrence breamore...@yahoo.co.uk wrote: http://pyfound.blogspot.co.uk/2015/03/bbc-launches-microbit.html may be of interest to some of you. Python is one of the three languages that work with the device. That's cool, and the article says that

Re: regex help

2015-03-13 Thread MRAB
On 2015-03-13 16:05, Larry Martell wrote: I need to remove all trailing zeros to the right of the decimal point, but leave one zero if it's whole number. For example, if I have this:

Re: (Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-02 Thread MRAB
On 2015-03-03 01:44, Mark Lawrence wrote: On 03/03/2015 00:23, Sturla Molden wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Variations in idiom and spelling are a good thing. They open our minds to new possibilities, remind us that we aren't all the same, and keep life

Re: rst and pypandoc

2015-03-02 Thread MRAB
On 2015-03-02 13:51, alb wrote: Hi Steven, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: [] Since \r is an escape character, that will give you carriage return followed by ef{fig:abc. The solution to that is to either escape the backslash: i = '\\ref{fig:abc}' or use a raw

Re: rst and pypandoc

2015-03-02 Thread MRAB
On 2015-03-02 14:08, Dave Angel wrote: On 03/02/2015 08:51 AM, alb wrote: Hi Steven, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: [snip] Oh, by the way, i is normally a terrible variable name for a string. Not only doesn't it explain what the variable is for, but there is a

Re: Python Worst Practices

2015-03-02 Thread MRAB
On 2015-03-02 04:49, Dave Angel wrote: On 03/01/2015 08:59 PM, MRAB wrote: On 2015-03-02 01:37, Dennis Lee Bieber wrote You'd be able to run it on a TI99/4 (in which the BASIC interpreter, itself, was run on an interpreter... nothing like taking the first 16-bit home computer

Re: Python Worst Practices

2015-03-01 Thread MRAB
On 2015-03-02 01:37, Dennis Lee Bieber wrote: On Sun, 1 Mar 2015 13:43:50 +1100, Chris Angelico ros...@gmail.com declaimed the following: losing performance. Conversely, I'm sure Python could also have been implemented on top of BASIC if someone felt like it, though what the advantages might

Re: Python Worst Practices

2015-02-28 Thread MRAB
On 2015-02-28 16:03, Cousin Stanley wrote: From : Tim Chase A quick google-and-tally for languages and their corresponding number of keywords: re-sorted 21 : Lua 31 : Python2.x 33 : Python3.x 33 : C 37 : Pike 40 : Perl 40 :

Re: Newbie question about text encoding

2015-02-27 Thread MRAB
On 2015-02-27 16:45, alister wrote: On Sat, 28 Feb 2015 03:12:16 +1100, Chris Angelico wrote: On Sat, Feb 28, 2015 at 3:00 AM, alister alister.nospam.w...@ntlworld.com wrote: I think there is a case for bringing back the overlay file, or at least loading larger programs in sections only

Re: Installing PIL without internet access

2015-02-26 Thread MRAB
On 2015-02-26 15:23, Larry Martell wrote: I have a host that has no access to the internet and I need to install PIL on it. I have an identical host that is on the internet and I have installed it there (with pip). Is there a way I can copy files from the connected host to a flash drive and then

Re: Python Worst Practices

2015-02-25 Thread MRAB
On 2015-02-25 20:45, Mark Lawrence wrote: http://www.slideshare.net/pydanny/python-worst-practices Any that should be added to this list? Any that be removed as not that bad? We don't have numeric ZIP codes in the UK, but the entire world has numeric telephone numbers, so that might be a

Re: Python Worst Practices

2015-02-25 Thread MRAB
On 2015-02-25 22:59, Joel Goldstick wrote: On Wed, Feb 25, 2015 at 4:28 PM, MRAB pyt...@mrabarnett.plus.com wrote: On 2015-02-25 20:45, Mark Lawrence wrote: http://www.slideshare.net/pydanny/python-worst-practices Any that should be added to this list? Any that be removed

Re: Bug in timsort!?

2015-02-24 Thread MRAB
On 2015-02-24 21:40, Zachary Ware wrote: On Tue, Feb 24, 2015 at 3:34 PM, Roy Smith r...@panix.com wrote: http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/ http://bugs.python.org/issue23515 Note that the article does mention that Python

Re: urgent help

2015-02-20 Thread MRAB
On 2015-02-21 00:16, ms.isma...@gmail.com wrote: On Saturday, February 21, 2015 at 8:14:43 AM UTC+8, ms.is...@gmail.com wrote: On Friday, February 20, 2015 at 4:41:57 PM UTC+8, Mark Lawrence wrote: On 20/02/2015 08:24, ismaham...@gcuf.edu.pk wrote: Would you please give your requests a

Re: urgent help

2015-02-20 Thread MRAB
On 2015-02-21 00:20, ms.isma...@gmail.com wrote: On Saturday, February 21, 2015 at 8:17:06 AM UTC+8, ms.is...@gmail.com wrote: On Saturday, February 21, 2015 at 8:14:43 AM UTC+8, ms.is...@gmail.com wrote: On Friday, February 20, 2015 at 4:41:57 PM UTC+8, Mark Lawrence wrote: On 20/02/2015

Re: urgent help

2015-02-20 Thread MRAB
On 2015-02-21 00:14, ms.isma...@gmail.com wrote: On Friday, February 20, 2015 at 4:41:57 PM UTC+8, Mark Lawrence wrote: On 20/02/2015 08:24, ismaham...@gcuf.edu.pk wrote: Would you please give your requests a meaningful subject. sir these errors whats mean by it warning (from warnings

Re: What the Pythons docs means by container ?

2015-02-18 Thread MRAB
On 2015-02-18 02:14, candide wrote: Le mercredi 18 février 2015 01:50:16 UTC+1, Chris Angelico a écrit : So, what's a container? It's a thing that you put other objects into. I agree with this approach. The important point to consider here is the last word in your definition : into. There is

Re: Printing to printer, windows 7

2015-02-17 Thread MRAB
On 2015-02-18 01:41, Dennis Lee Bieber wrote: On Mon, 16 Feb 2015 22:02:33 -0500, Dave Angel da...@davea.name declaimed the following: It is a simple problem. All you have to do is send the correct bytes to a file object that will transfer those bytes to the printer. It's been a long time

Re: A question about a list and subprocess.check_call()

2015-02-16 Thread MRAB
On 2015-02-16 17:07, David Aldrich wrote: Hi Peter Thanks very much for your reply. I have added one more question below. The straightforward approach is to pass a list or tuple: def build(build_options=()): subprocess_check_call((make,) + build_options) build((flagA=true, flagB=true))

Re: Odd version scheme

2015-02-12 Thread MRAB
On 2015-02-12 17:35, Ian Kelly wrote: On Thu, Feb 12, 2015 at 10:19 AM, Skip Montanaro skip.montan...@gmail.com wrote: I believe this sort of lexicographical comparison wart is one of the reasons the Python-dev gang decided that there would be no micro versions 9. There are too many similar

Re: Group by interval time

2015-02-12 Thread MRAB
On 2015-02-12 12:34, charles.sart...@gmail.com wrote: Hello there! I`m trying to group by a list of Row() objects in 12days interval and sum(). values. Here is an example of the list [Row(time=datetime.datetime(2013, 1, 1, 0, 0), sum=4676557380615), Row(time=datetime.datetime(2013, 1, 2, 0,

Re: parsing tree from excel sheet

2015-01-29 Thread MRAB
On 2015-01-29 21:02, alb wrote: Hi Peter, Peter Otten __pete...@web.de wrote: [] def show2(self): yield str(self) for child in self.children: yield from child.show2() here is what I get: SyntaxError: invalid syntax debian@debian:example$ python3 export_latex.py

Re: Python is DOOMED! Again!

2015-01-29 Thread MRAB
On 2015-01-29 23:25, Chris Kaynor wrote: On Thu, Jan 29, 2015 at 2:57 PM, BartC b...@freeuk.com wrote: [snip] Putting in hints, (as as I implemented them using primitive types), meant that functions and code no longer worked in a generic (or polymorphic) manner. Code also changes, but the type

Re: write file to a server

2015-01-28 Thread MRAB
On 2015-01-28 13:22, luca72 wrote: Hello i'm under windows, i have to write a file from my computer to a local server like taht \\DOCUMENTALE\my_folder\. How i have to proceed ? That's a path to a folder that just happens to be on another computer on your network. Treat it the same way you

Re: Beginner question - class definition error

2015-01-28 Thread MRAB
On 2015-01-28 11:10, David Aldrich wrote: Hi I am just getting started with Python 3.3.3 and Kivy 1.8. I am using the Kivy development environment on Windows (open a command prompt and call kivy.bat). With this minimal code: import kivy kivy.require('1.8.0') from kivy.app import App from

Re: Object destruction delayed on interactive prompt

2015-01-25 Thread MRAB
On 2015-01-25 18:23, Mario Figueiredo wrote: Consider the following class: class A: def __init__(self, value): self.value = value def __del__(self): print('A' instance being collected...) def __repr__(self): return

Re: Idiomatic backtracking in Python

2015-01-25 Thread MRAB
On 2015-01-26 00:32, Ben Finney wrote: Johannes Bauer dfnsonfsdu...@gmx.de writes: So, I would like to ask if you have a Pythonic approach to backtracking problems? If so, I'd love to hear your solutions! I'm not aware of what the problem is. “Back-tracking” doesn't have a general meaning I

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread MRAB
On 2015-01-24 19:55, Chris Angelico wrote: On Sun, Jan 25, 2015 at 5:56 AM, Ethan Furman et...@stoneleaf.us wrote: If the non-generic is what you're concerned about: # not tested dispatch_table_a = {} dispatch_table_b = {} dispatch_table_c = {} class dispatch: def __init__(self,

Re: Python Sanity Proposal: Type Hinting Solution

2015-01-22 Thread MRAB
On 2015-01-23 01:15, Rick Johnson wrote: Note: This is the closest you're going to get to a PEP from me! Okay, i have found a solution to the type hinting problem that will appease both sides. On one side we have those who are proposing type hinting annotations within function sigs, and on the

Re: Python is DOOMED! Again!

2015-01-22 Thread MRAB
On 2015-01-22 20:23, Rick Johnson wrote: On Thursday, January 22, 2015 at 4:32:04 AM UTC-6, Mario Figueiredo wrote: Rick, Python is the only thing that is pure in the programming world. The only language that offers the cleanest and most intuit-able syntax, AND YOURE JUST GOING TO THROW IT

Re: Concerning Dictionaries and += in Python 2.x

2015-01-19 Thread MRAB
On 2015-01-20 00:12, Luke Tomaneng wrote: I have been having a bit of trouble with the things mentioned in the title. I have written the following script for a Codecademy course: stock = { banana: 6, apple: 0, orange: 32, pear: 15 } prices = { banana: 4, apple: 2,

Re: extracting numbers with decimal places from a string

2015-01-11 Thread MRAB
On 2015-01-12 00:04, Mark Lawrence wrote: On 11/01/2015 23:07, Thomas 'PointedEars' Lahn wrote: Store Makhzan wrote: I have this script which can calculate the total of numbers given in a string […] total = 0 for c in '0123456789': total += int(c) print total […] How should I modify this

Re: problem with for and if

2015-01-05 Thread MRAB
On 2015-01-05 14:27, Dariusz Mysior wrote: I want search count of szukana in zmienna but code below counting all 12 letters from traktorzysta word szukana=t zmienna=traktorzysta def gen(): count=int(0) for a in zmienna: if szukana in zmienna: count+=1

Re: How do I remove/unlink wildcarded files

2015-01-02 Thread MRAB
On 2015-01-02 10:21, Cameron Simpson wrote: On 02Jan2015 10:00, Ervin Hegedüs airw...@gmail.com wrote: On Thu, Jan 01, 2015 at 05:13:31PM -0600, Anthony Papillion wrote: I have a function I'm writing to delete wildcarded files in a directory. I tried this: def unlinkFiles():

Re: Multiprocessing process termination

2014-12-31 Thread MRAB
On 2014-12-31 19:33, Charles Hixson wrote: In order to allow multiple processes to access a database (currently SQLite) I want to run the process in a separate thread. Because it will be accessed from multiple processes I intent to use Queues for shifting messages back and forth. But none of

Re: Python 3.4.2 64-bit Installer

2014-12-30 Thread MRAB
On 2014-12-30 22:45, Toni Bajer wrote: When I try to run the Python 3.4.2 64-bit Installer on Windows 7 it gets about 90% through and then a new box pops up with the following message... There is a problem with this Windows Installer package. A program required for this install to complete

Re: smtplib not working as expected

2014-12-26 Thread MRAB
On 2014-12-27 00:39, Juan Christian wrote: I have the following test code: import smtplib fromaddr = 'mksfjnsfji4433j4...@bk.ru mailto:mksfjnsfji4433j4...@bk.ru' toaddrs = ['mksfjnsfji4433j4...@bk.ru mailto:mksfjnsfji4433j4...@bk.ru'] msg = (From: %s\r\nTo: %s\r\n\r\n % (fromaddr, ,

Re: object has no attribute 'ecrire'

2014-12-23 Thread MRAB
On 2014-12-24 00:42, fulga...@gmail.com wrote: Hello, I wrote this code (it was on a book) class TableauNoir: def __init__(self): self.surface= def ecrire(self, message_a_ecrire): if self.surface != : self.surface += \n

Re: Hello World

2014-12-22 Thread MRAB
On 2014-12-22 18:51, Mark Lawrence wrote: On 22/12/2014 16:23, Grant Edwards wrote: On 2014-12-21, Roy Smith r...@panix.com wrote: In article 54974ed7$0$12986$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Obviously you don't write

Re: Hello World

2014-12-22 Thread MRAB
On 2014-12-23 01:03, sohcahto...@gmail.com wrote: On Monday, December 22, 2014 4:56:13 PM UTC-8, Roy Smith wrote: In article mailman.17133.1419276169.18130.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: On 2014-12-22 19:05, MRAB wrote: On 2014-12-22 18:51, Mark

Re: why can't download file from linux server into local window disk c:

2014-12-09 Thread MRAB
To: pengsir On 2014-12-09 08:14, pengsir wrote: My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server into my local window disk c: . import paramiko host = x.y.z.w port = 22 transport = paramiko.Transport((host, port)) password = mykey username = root

Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread MRAB
On 2014-12-09 08:14, pengsir wrote: My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server into my local window disk c: . import paramiko host = x.y.z.w port = 22 transport = paramiko.Transport((host, port)) password = mykey username = root transport.connect(username =

Re: Question on lambdas

2014-12-08 Thread MRAB
On 2014-12-08 23:58, Ben Finney wrote: memilanuk memila...@gmail.com writes: What I'm having trouble finding a concrete answer to is the difference between: (Note that where you write “some_func” the syntax requires an expression, not a function. I've changed your examples to be clear).

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread MRAB
On 2014-12-08 01:00, Chris Angelico wrote: On Mon, Dec 8, 2014 at 11:45 AM, Roy Smith r...@panix.com wrote: I take it as result, which makes plenty of sense to me. OK, so spell it out. Three more keystrokes (well, plus another three when you use it on the next line). And one of them is a

Re: I love assert

2014-11-29 Thread MRAB
On 2014-11-29 09:31, Steven D'Aprano wrote: MRAB wrote: On 2014-11-29 01:30, Steven D'Aprano wrote: [snip] I stress that assertions aren't a replacement for unit testing, but they compliment unit testing: assertions can help cover code missed by your unit tests, and check that your unit tests

Re: I love assert

2014-11-28 Thread MRAB
On 2014-11-29 01:30, Steven D'Aprano wrote: [snip] I stress that assertions aren't a replacement for unit testing, but they compliment unit testing: assertions can help cover code missed by your unit tests, and check that your unit tests are correct. [snip] I think you meant complement. :-)

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