Re: Using PIP in Python 3.10 on Windows 10

2022-01-14 Thread MRAB
On 2022-01-14 17:40, Jonathan Gossage wrote: I have installed Python 3.10.1 on Windows 10 using the recommended Windows Installer. When I try to access PIP from the command line, I get the following result, even though Python itself is accessible. C:\Users\jgoss>python Python 3.10.1 (tags/v3.10

Re: keep getting a syntax error on the very first program I am running

2022-01-14 Thread MRAB
On 2022-01-15 01:12, Bob Griffin wrote: I am running this program and keep getting this error. Is this normal? Invalid syntax. Perhaps you forgot a comma? Also the t in tags is highlighted. I even tried different versions of Python also. Python 3.10.1 (tags/v3.10

Re: Puzzling behaviour of Py_IncRef

2022-01-25 Thread MRAB
On 2022-01-25 23:50, Tony Flury via Python-list wrote: On 25/01/2022 22:28, Barry wrote: On 25 Jan 2022, at 14:50, Tony Flury via Python-list wrote:  On 20/01/2022 23:12, Chris Angelico wrote: On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote: On 20/01/22 12:09 am, Chris Angelico wrote:

Re: Openning Python program

2022-02-06 Thread MRAB
On 2022-02-06 08:14, createkmontalb...@gmail.com wrote: I cannot open python after downloading it keeps going to modify/uninstall ?? please help It sounds like you're just re-running the installer. The installer should've installed IDLE. Try that for editing programs. -- https://mail.p

Re: Can't get iterator in the C API

2022-02-08 Thread MRAB
On 2022-02-09 01:12, Jen Kris via Python-list wrote: I am using the Python C API to load the Gutenberg corpus from the nltk library and iterate through the sentences.  The Python code I am trying to replicate is: from nltk.corpus import gutenberg for i, fileid in enumerate(gutenberg.fileids()):

Re: PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'

2022-02-09 Thread MRAB
On 2022-02-09 12:45, Christian Gollwitzer wrote: Am 09.02.22 um 08:46 schrieb NArshad: When I enter data using Tkinter form in an Excel file when the excel file is closed there is no error but when I enter data using Tkinter form when the excel is already open following error comes: Permiss

Re: C API PyObject_Call segfaults with string

2022-02-09 Thread MRAB
On 2022-02-10 01:37, Jen Kris via Python-list wrote: I'm using Python 3.8 so I tried your second choice: pSents = PyObject_CallFunctionObjArgs(pSentMod, pListItem); but pSents is 0x0.  pSentMod and pListItem are valid pointers. 'PyObject_CallFunction' looks like a good one to use: """PyObjec

Re: GCP Copy Files - Data Export

2022-02-10 Thread MRAB
On 2022-02-10 17:20, BmoreIT wrote: I did a data export from Google to export all company data - Google Data Export It shows the root folder and to download, I run this command (it automatically enters this command) gsutil -m cp -r \ "gs://takeout-export-myUniqueID" \. But I have no idea where

Re: C API PyObject_Call segfaults with string

2022-02-10 Thread MRAB
On 2022-02-10 20:00, Jen Kris via Python-list wrote: With the help of PyErr_Print() I have it solved.  Here is the final code (the part relevant to sents):    Py_ssize_t listIndex = 0;    pListItem = PyList_GetItem(pFileIds, listIndex);    pListStrE = PyUnicode_AsEncodedString(pListItem, "UT

Re: One-liner to merge lists?

2022-02-27 Thread MRAB
On 2022-02-27 08:51, Barry Scott wrote: On 22 Feb 2022, at 09:30, Chris Angelico wrote: On Tue, 22 Feb 2022 at 20:24, Frank Millman mailto:fr...@chagford.com>> wrote: Hi all I think this should be a simple one-liner, but I cannot figure it out. I have a dictionary with a number of keys,

Re: [python-uk] Fwd: It Will Never Work in Theory: live!

2022-03-04 Thread MRAB
On 2022-03-04 20:48, BELAHCENE Abdelkader wrote: hi, I receive a lot of email from the python-list, I want to disable it, when I want to read the email, I want to go to he List. Please How to disable it. Regards This page explains how to unsubscribe: https://mail.python.org/mailman/listinfo/p

Re: Help: Unable to find IDLE folder inside the Python Lib folder

2022-03-05 Thread MRAB
On 2022-03-05 20:36, Deji Olofinboba via Python-list wrote: Dear Python officer, Please I am new to programming. I have justinstalled the python 3.10.2. After the installation, I was able to locate thePython Shell but unable to locate IDLE despite checking it before downloading in the python i

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-06 Thread MRAB
On 2022-03-07 00:32, Jen Kris via Python-list wrote: I am using the C API in Python 3.8 with the nltk library, and I have a problem with the return from a library call implemented with PyObject_CallFunctionObjArgs. This is the relevant Python code: import nltk from nltk.corpus import gutenber

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread MRAB
On 2022-03-07 17:05, Jen Kris wrote: Thank you MRAB for your reply. Regarding your first question, pSentence is a list.  In the nltk library, nltk.word_tokenize takes a string, so we convert sentence to string before we call nltk.word_tokenize: >>> sentence = " ".jo

Re: always return the same pdf

2022-03-07 Thread MRAB
On 2022-03-07 14:08, Gonzalo V wrote: Hello everyone. i had upload a Django app to an ubuntu 18.04 server and it gives me the same pdf everytime the view is called. To generate the pdf it receipts differents string buy it gives me the same pdf. Could you give some idea what is happening? thanks

Re: Problem slicing a list with the C API

2022-03-12 Thread MRAB
On 2022-03-12 21:24, Jen Kris via Python-list wrote: I have a C API project where I have to slice a list into two parts.   Unfortunately the documentation on the slice objects is not clear enough for me to understand how to do this, and I haven’t found enough useful info through research.  The

Re: code blocks in Python

2022-03-25 Thread MRAB
On 2022-03-25 10:12, jlfivn wrote: On Monday, 24 November 2003 at 23:54:49 UTC, John Roth wrote: "Hung Jung Lu" wrote in message news:8ef9bea6.03112...@posting.google.com... > Skip Montanaro wrote in message news:... > > > I come back again to repeat it one more time: the compile() function >

Re: pyinstaller is not a internal or external command

2022-04-04 Thread MRAB
On 2022-04-04 20:28, Andrew Pierson wrote: I ran pip install pyinstaller fine but after then I type in pyinstaller and it says pyinstaller is not a internal or external command Have you tried using the Python launcher? py pyinstaller ... -- https://mail.python.org/mailman/listinfo/pytho

Re: The Cython compiler is 20 years old today !

2022-04-05 Thread MRAB
On 2022-04-05 04:47, Dan Stromberg wrote: On Mon, Apr 4, 2022 at 7:42 AM Stefan Behnel wrote: Dear Python community, it's now 20 years since Greg Ewing posted his first announcement of Pyrex, the tool that is now known and used under the name Cython. https://mail.python.org/pipermail/python-

Re: Comparing sequences with range objects

2022-04-07 Thread MRAB
On 2022-04-07 16:16, Antoon Pardon wrote: Op 7/04/2022 om 16:08 schreef Joel Goldstick: On Thu, Apr 7, 2022 at 7:19 AM Antoon Pardon wrote: I am working with a list of data from which I have to weed out duplicates. At the moment I keep for each entry a container with the other entries that are

Re: Issues

2022-04-08 Thread MRAB
On 2022-04-08 20:35, Stevenson, John B via Python-list wrote: Hello, As a quick disclaimer, I am sorry if you have received this message multiple times over from me. I've been having technical difficulties trying to reach this email. Thank you. I'm trying to install Python on a computer so th

Re: the downloaded version is not being detected

2022-04-08 Thread MRAB
On 2022-04-08 17:28, Putsala Bhavani Maha Laxmi wrote: The purpose of this mail is the problem encountered while using it through an IDE platform. While using an IDE this version of python is not getting detected even though it is already downloaded and a suggestion box to install python appea

python-list@python.org

2022-04-13 Thread MRAB
On 2022-04-14 02:07, Chris Angelico wrote: On Thu, 14 Apr 2022 at 11:00, Kevin M. Wilson via Python-list wrote: MS Edge settings are displayed in the first picture, the error I encountered is the second picture...not sure how I get around this!I reloaded the browser after checking the se

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-14 Thread MRAB
On 2022-04-14 16:22, Jon Ribbens via Python-list wrote: On 2022-04-14, Paul Bryan wrote: I think because minutes and hours can easily be composed by multiplying seconds. days is separate because you cannot compose days from seconds; leap seconds are applied to days at various times, due to irre

Re: Python app on a Mac

2022-04-15 Thread MRAB
On 2022-04-15 11:51, Alan Gauld wrote: I've just migrated from a Linux PC to a Mac mini running Monterey. I have a Python GUI(Tkinter) app that I wrote on Linux and have managed to get working on MacOS except When I start the program I get a Terminal window as well as the GUI. On Windows I'

Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread MRAB
On 2016-08-09 19:57, Chris Angelico wrote: On Wed, Aug 10, 2016 at 4:51 AM, Michael Selik wrote: "File-like" is a good example. Rather than go through the frustration of a formal definition for what is file-like, stay productive and flexible with duck typing. Objects that don't have the appropr

Re: Print function not working

2016-08-11 Thread MRAB
On 2016-08-11 18:18, Chris Angelico wrote: On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra wrote: I have installed IDLE 3.5.1 and wrote the following to check if print is working. When it runs, I do not see anything is printed: class Base: #{ def __init__( self ): #{ print("Hello

Re: ctypes And The WACAH Principle

2016-08-11 Thread MRAB
On 2016-08-11 20:41, Roel Schroeven wrote: Lawrence D’Oliveiro schreef op 2016-08-10 03:45: ... so WACAH very much applies here. Pardon my ignorance, but what is the WACAH Principle? I believe he means "€œWe're All Consenting Adults Here". (I don't think I've ever seen that acronym before.)

Re: Why my image cannot be displayed?

2016-08-12 Thread MRAB
On 2016-08-13 02:40, huey.y.ji...@gmail.com wrote: Hi All, Image display drives me crazy. After I get it displayed, and want to do the job with a class, display failed again. Please take a look at my trial code: from Tkinter import * class imageDisplay: def __init__(self, parent=None)

Re: What's the best way to minimize the need of run time checks?

2016-08-14 Thread MRAB
On 2016-08-14 15:29, Steven D'Aprano wrote: [snip] I don't know many untyped languages apart from machine code or maybe assembly. Perhaps Forth? (Maybe not -- some Forths include a separate floating point stack as well as the usual stack.) Hypertalk treated everything as strings. Tcl treats nearl

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread MRAB
On 2016-08-14 19:17, Atri Mahapatra wrote: I have a list of dictionaries which look like this: [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, 'Length': 40.0, 'Object': 'Object2'}.. so on till 10] I would like to find the first index in the list of dictionaries whose l

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread MRAB
On 2016-08-14 19:40, Atri Mahapatra wrote: On Monday, 15 August 2016 00:03:59 UTC+5:30, MRAB wrote: On 2016-08-14 19:17, Atri Mahapatra wrote: > I have a list of dictionaries which look like this: > [{'Width': 100, 'Length': 20.0, 'Object': 'Object1&#x

Re: What is the trick between these?

2016-08-15 Thread MRAB
On 2016-08-15 19:41, huey.y.ji...@gmail.com wrote: Hi All, I am trapped by these two funny things: class MyClass(upClass): def start(self): ***do_menu_here self.load_label_image() # ---> this works self.load_canvas_image() # ---> this does not work def load_

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread MRAB
On 2016-08-17 12:24, Jussi Piitulainen wrote: BartC writes: On 17/08/2016 07:39, Steven D'Aprano wrote: Rather than ask why Python uses `trueval if cond else falseval`, you should ask why C uses `cond ? trueval : falseval`. Is that documented anywhere? I'm not fond of C's a ? b : c but the p

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread MRAB
On 2016-08-17 18:19, Jussi Piitulainen wrote: MRAB writes: On 2016-08-17 12:24, Jussi Piitulainen wrote: BartC writes: On 17/08/2016 07:39, Steven D'Aprano wrote: Rather than ask why Python uses `trueval if cond else falseval`, you should ask why C uses `cond ? trueval : falseval`. Is

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread MRAB
On 2016-08-17 18:58, Marko Rauhamaa wrote: MRAB : C uses "->" for dereferencing a pointer to the member of a struct. What "->" is for C, "." is Python and Java. Python doesn't have C's ".". C has both stacked-allocated and heap-all

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread MRAB
On 2016-08-17 19:00, Grant Edwards wrote: On 2016-08-17, MRAB wrote: C uses "->" for dereferencing a pointer to the member of a struct. If "p" points to a struct (record), then "*p" is that struct, and if that struct has a member (field) "m", t

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread MRAB
On 2016-08-17 19:39, Random832 wrote: On Wed, Aug 17, 2016, at 14:27, Terry Reedy wrote: That particular syntax was not really considered. At least 10 versions using 'if', 'then', 'else', and other tokens were. They all had the problem of requiring a new keyword such as 'then' or some other in

Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread MRAB
On 2016-08-18 10:46, Jussi Piitulainen wrote: Marko Rauhamaa writes: Jussi Piitulainen wrote: That looks a bit funny if the "keyword" does not look like a word, but then programming languages do look funny, so why not: (c ? t : e) # ?-expression (c -> t, e) # ->-expression That sh

Re: Error in while loop code for packing items

2016-08-18 Thread MRAB
On 2016-08-18 14:10, GP wrote: On Thursday, August 18, 2016 at 5:59:43 PM UTC+5:30, Peter Otten wrote: GP wrote: [snip] However, when you really want to remove all items you instead assign a new empty list for item in items: print(item) items = [] Thanks Peter for the information. It

Re: Python Run Error

2016-08-19 Thread MRAB
On 2016-08-19 23:31, Lawrence D’Oliveiro wrote: On Saturday, August 20, 2016 at 10:01:08 AM UTC+12, Suzanna McGee wrote: “The program can’t start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.” Why not do what it says?

Re: Helloworld with Python C extension

2016-08-29 Thread MRAB
On 2016-08-29 18:30, Ganesh Pal wrote: Hello Team , I need you input on the below hello world program. I a m trying to add a python binding which will return the character for the given index . I am on Python 2.7 and linux Example : string ='helloworld' dda_hello(5) 'w' /* + * Hello

Re: Strange behaviour with numbers in exponential notation

2016-09-02 Thread MRAB
On 2016-09-02 20:47, Random832 wrote: On Fri, Sep 2, 2016, at 15:12, Christian Gollwitzer wrote: Tradition? All languages I know of treat a number with an exponent as floating point. Scheme does allow you to give integers (and rationals) in decimal and/or exponential notation with the "#e" pre

Re: Need some suggestions in grouping of items

2016-09-08 Thread MRAB
On 2016-09-08 21:50, GP wrote: I have a list of items: ShelvesToPack = [{'ShelfLength': 2278.0, 'ShelfWidth': 356.0, 'ShelfArea': 759152.0, 'ItemNames': 1}, {'ShelfLength': 1220.0, 'ShelfWidth': 610.0, 'ShelfArea': 372100.0, 'ItemNames': 2}, {'ShelfLength': 2310.0, 'ShelfWidth':

Re: mssql date format

2016-09-11 Thread MRAB
On 2016-09-12 01:37, sum abiut wrote: Hi, I am pulling data from an mssql server database and got a date in this format: 733010 please advise what of date is this and how to i convert it to a readable date? i use pyssql to connect to the database and pull data fro the database. Does the date "

Re: [Python-ideas] Inconsistencies

2016-09-11 Thread MRAB
On 2016-09-12 03:26, Chris Angelico wrote: On Mon, Sep 12, 2016 at 12:04 PM, Lawrence D’Oliveiro wrote: On Monday, September 12, 2016 at 1:11:39 PM UTC+12, Chris Angelico wrote: I have some _extremely_ strong views about absolutes (they come from the Creator of the Universe) ... By “Universe

Re: mssql date format

2016-09-12 Thread MRAB
On 2016-09-13 00:06, sum abiut wrote: Thanks for the response, i pulling data from an mssql database and i need to convert the date column. how to i covert and pass it to my template. i am using Django this is what i did conn=pymssql.connect(server,username,password,database) #cus=conn.cu

Re: Julian date to calendar date conversion

2016-09-12 Thread MRAB
On 2016-09-13 02:12, sum abiut wrote: Hi, how to convert julian date to a calander date Have a look at the jdcal module on PyPI: https://pypi.python.org/pypi/jdcal -- https://mail.python.org/mailman/listinfo/python-list

Re: Requests for webbrowser module

2016-09-14 Thread MRAB
On 2016-09-14 17:53, Jamie wrote: Hi, I am not sure if this is an intended consequence but when using the webbrowser module to open a new blank browser tab in chrome it opens it in a new browser window instead of using the current window. Providing any complete url provides different behaviour,

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-14 Thread MRAB
On 2016-09-14 18:43, Dale Marvin via Python-list wrote: On 9/14/16 12:20 AM, Steven D'Aprano wrote: On Wednesday 14 September 2016 16:54, Rustom Mody wrote: everything we know will be negated in 5-50-500 years I'm pretty sure that in 5, 50, 500 or even 5000 years, the sun will still rise in

Re: logging TypeError: not all arguments converted during string formatting

2016-09-15 Thread MRAB
On 2016-09-15 15:57, Daiyue Weng wrote: Hi, I am trying to record memory and CPU usages and load a logger from an external config file (logging.conf), [snip] import logging import psutil logging.config.fileConfig('logging.conf') hardware_log = logging.getLogger(HARDWARELOGNAME) free_mem_g

Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread MRAB
On 2016-09-16 20:14, Gary Herron wrote: On 09/16/2016 04:24 AM, meInvent bbird wrote: im = img.copy() cntcounter = 0 for cnt in contours: epsilon = 0.1*cv2.arcLength(cnt,True) approx = cv2.approxPolyDP(cnt,epsilon,True) #peri = cv2.arcLength(cnt, True) #ap

Re: is it possible to adjust convex hull to draw blue line instead of green line?

2016-09-16 Thread MRAB
On 2016-09-17 01:20, meInvent bbird wrote: i succeed to use code to draw green line, but green line not draw the large area, expect second uploaded picture, the blue line connect the bottom of red line graph [snip] Here's the code with the commented code and print statements removed and the i

Re: Where is the documentation for ','?

2016-09-16 Thread MRAB
On 2016-09-17 03:05, Peng Yu wrote: Hi, I'm wondering where is the documentation for ',' as in the following usage. x = 1 y = 2 x, y = y, x I tried help(','). But there are too many ',' in it and I don't see in which section ',' is documented. Could anybody let me know? Thanks. Search for 't

Re: list or dictionary

2016-09-21 Thread MRAB
On 2016-09-21 19:35, Ganesh Pal wrote: Thanks Steve for the clues , quickly tried out # Version 1 doesn't seen to work. for line in hostname: ... regex = r'(.*) is array with id {}'.format(devid) ... mo = re.search(regex, line) ... print line, regex, mo ... if mo is not None

Re: Obtain the raw line of text read by CSVDictReader when reporting errors?

2016-09-21 Thread MRAB
On 2016-09-21 21:28, Malcolm Greene wrote: Looking for ideas on how I can obtain the raw line of text read by a CSVDictReader. I've reviewed the CSV DictReader documentation and there are no public attributes that expose this type of data. My use case is reporting malformed lines detected when m

Re: Hidding Character as you type

2016-09-22 Thread MRAB
On 2016-09-22 17:16, Andrew Clark wrote: I'm looking for a way to either completely hide character as you type in command line or add * to each character as you for simple password obscurity. I've tried getpass.getpass() however the characters still show up on the screen as you type it. Ca

Re: Address boundary error when trying to use Image.putdata(array) from PIL

2016-09-24 Thread MRAB
On 2016-09-24 11:59, Tristan Trouwen wrote: Got a signal boundary error. Steps to reproduce: open python console Python 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. from PIL import Image im = Image.open('HKJ

Re: Stompy

2016-09-25 Thread MRAB
On 2016-09-25 18:46, Jason Friedman wrote: My goal is to send messages to an AMQ server using Python 3.3. I found Stompy and performed 2to3-3.3 before building. I am open to non-Stompy solutions. My code: from stompy.stomp import Stomp my_stomp = Stomp(AMQ_HOST, AMQ_PORT) my_stomp.connect(AMQ_

Re: Nested for loops and print statements

2016-09-26 Thread MRAB
On 2016-09-26 16:25, Cai Gengyang wrote: I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum for row in range(10): for column in range(10): print("*",end="") SyntaxError: inco

Re: xlsxwriter considering worksheet.write as tuple ???

2016-09-26 Thread MRAB
On 2016-09-26 23:03, M2 wrote: Hello The program is designed to collect different statistics from servers across the network and populate in excel sheet. Library : xlsxwriter.0.9.3 Below is the Snip of code being used #! /usr/bin/python import xlsxwriter import os; import subprocess; import sy

Re: xlsxwriter considering worksheet.write as tuple ???

2016-09-26 Thread MRAB
On 2016-09-27 01:34, Mohan Mohta wrote: On Monday, September 26, 2016 at 6:56:20 PM UTC-5, Nathan Ernst wrote: On Mon, Sep 26, 2016 at 6:00 PM, MRAB wrote: > On 2016-09-26 23:03, M2 wrote: > >> Hello >> The program is designed to collect different statistics from servers >

Re: How to make a copy of chained dicts effectively and nicely?

2016-09-27 Thread MRAB
On 2016-09-27 08:32, Jussi Piitulainen wrote: [snip] Is ChainMap really that bad? Otherwise the following would look somewhat nice: d = dict(ChainMap(d1, d2, d3).items()) Those come to mind. You can copy a dict just by passing it to 'dict': d = dict(d1) so I wondered if you can do the

Re: Case insensitive replacement?

2016-09-27 Thread MRAB
On 2016-09-27 17:56, Tim Chase wrote: I'd like to do a case-insensitive replacement in a string but want to do it pythonically. Ideally, the code would something like needle = "World" haystack = "Hello, world!" replacement = "THERE" result = haystack.replace(needle, replacement, ignore_

Re: Expression can be simplified on list

2016-09-29 Thread MRAB
On 2016-09-29 10:49, Steven D'Aprano wrote: On Thursday 29 September 2016 18:45, Jussi Piitulainen wrote: [snip] What do you say about things like iterators and generators? I'd say they are containers, but they count as true even when they are empty. No, they aren't containers, because they d

Re: Expression can be simplified on list

2016-09-29 Thread MRAB
On 2016-09-29 16:56, Steve D'Aprano wrote: On Thu, 29 Sep 2016 09:53 pm, MRAB wrote: What if an _exhausted_ iterator was falsey? The problem is that in general you can't tell if an iterator is exhausted until you attempt to advance it. So even if bool(iterator) returns True, t

Re: Expression can be simplified on list

2016-09-29 Thread MRAB
On 2016-09-29 09:14, Steven D'Aprano wrote: On Thursday 29 September 2016 16:47, Rustom Mody wrote: On Thursday, September 15, 2016 at 1:43:05 AM UTC+5:30, Terry Reedy wrote: [...] Python make no such nonsense claim. By default, Python objects are truthy. >>> bool(object()) True Because T

Re: inplace text filter - without writing file

2016-10-01 Thread MRAB
On 2016-10-02 01:21, Sayth Renshaw wrote: Hi I have a fileobject which was fine however now I want to delete a line from the file object before yielding. def return_files(file_list): for filename in sorted(file_list): When joining paths together, it's better to use 'os.path.join'.

Re: inplace text filter - without writing file

2016-10-02 Thread MRAB
On 2016-10-02 06:33, Sayth Renshaw wrote: On Sunday, 2 October 2016 16:19:14 UTC+11, Sayth Renshaw wrote: On Sunday, 2 October 2016 12:14:43 UTC+11, MRAB wrote: > On 2016-10-02 01:21, Sayth Renshaw wrote: > > Hi > > > > I have a fileobject which was fine however now I

Re: python (scipy) TypeError

2016-10-03 Thread MRAB
On 2016-10-03 17:14, chrischris201...@gmail.com wrote: hello i try to follow some tutorial but i have that error : Traceback (most recent call last): File "C:\Python27\test\test\earth.py", line 42, in slope_array = np.ones_like(data_array) * nodataval TypeError: unsupported operand type

Re: python (scipy) TypeError

2016-10-03 Thread MRAB
On 2016-10-03 17:48, chrischris201...@gmail.com wrote: Τη Δευτέρα, 3 Οκτωβρίου 2016 - 7:17:03 μ.μ. UTC+3, ο χρήστης chrischr...@gmail.com έγραψε: hello i try to follow some tutorial but i have that error : Traceback (most recent call last): File "C:\Python27\test\test\earth.py", line 42, i

Re: Python -Simplebool

2016-10-05 Thread MRAB
On 2016-10-05 16:01, priya@gmail.com wrote: Hi, I am new to Python and I am learning it. Need some help. I downloaded SimpleBool (https://github.com/lujunyan1118/SimpleBool) for simulating Boolean models. SimpleBool works in Python. I downloaded the Canopy and executed Boolmutation.py f

Re: I can't run python on my computer

2016-10-05 Thread MRAB
On 2016-10-05 15:19, Camille Benoit via Python-list wrote: Hi,it has been about a week since the last time I was able to use Python. Most of the time, the interpreter doesn't show up and when it does and I am trying to run a program it displayed the following message: "IDLE's subprocess didn't

Re: smtplib TimeoutError not catch

2016-10-12 Thread MRAB
On 2016-10-12 14:21, Joaquin Alzola wrote: Hi Guys Try to connect to the smtp via smtplib. The connection is down because the Firewall has not been open yet so the exception is something that should appear. Now I want to catch this timeout in case error happens in future. Here the exception t

Re: [RELEASE] Python 3.6.0b2 is now available

2016-10-13 Thread MRAB
On 2016-10-13 20:42, Irmen de Jong wrote: On 12-10-2016 12:56, Robin Becker wrote: I notice an extra space at the windows command prompt compared with 3.5, is that deliberate? C:\ux\XB33>\python35\python Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on

Re: [RELEASE] Python 3.6.0b2 is now available

2016-10-13 Thread MRAB
On 2016-10-13 22:45, Irmen de Jong wrote: On 13-10-2016 23:43, MRAB wrote: On 2016-10-13 20:42, Irmen de Jong wrote: On 12-10-2016 12:56, Robin Becker wrote: I notice an extra space at the windows command prompt compared with 3.5, is that deliberate? C:\ux\XB33>\python35\python Pyt

Re: trying to make a simple program help please :)

2016-10-14 Thread MRAB
On 2016-10-14 19:11, LongHairLuke wrote: Hi, l l am trying to make a simple guess program. This is my script: def main(): print ("Guess a letter between a and e") randomNumber = b userGuess = input("Your guess: ") if userGuess == randomNumber: print("You got it") else: pr

Re: Term frequency using scikit-learn's CountVectorizer

2016-10-16 Thread MRAB
On 2016-10-17 02:04, Abdul Abdul wrote: I have the following code snippet where I'm trying to list the term frequencies, where first_text and second_text are .tex documents: from sklearn.feature_extraction.text import CountVectorizer training_documents = (first_text, second_text) vectorizer = C

Re: Button Widget and Key Binding Problem

2016-10-18 Thread MRAB
On 2016-10-19 03:13, Wildman via Python-list wrote: I am working on a program with a GUI created with Tkinter. I want to enable key bindings for the button widgets. Below is some of the code to show how the window and button widget was created. The button calls a routine that will load an imag

Re: function call questions

2016-10-18 Thread MRAB
On 2016-10-19 03:15, chenyong20...@gmail.com wrote: Thanks Peter and Anssi for your kind help. Now I'm ok with the first question. But the second question still confused me. Why "it seems that after root = root.setdefault(ch,{}) tree['a'] and root are the same object" and follows tree['a']['b']?

Re: Internet Data Handling » mailbox

2016-10-21 Thread MRAB
On 2016-10-22 03:43, Adam Jensen wrote: The mailbox library documentation seems to be a little weak. In this example: https://docs.python.org/2.7/library/mailbox.html#examples import mailbox for message in mailbox.mbox('~/mbox'): subject = message['subject'] # Could possibly be None.

Re: multiprocess passing arguments double asterisks

2016-10-26 Thread MRAB
On 2016-10-26 21:44, pic8...@gmail.com wrote: On Monday, October 24, 2016 at 12:39:47 PM UTC-5, Thomas Nyberg wrote: On 10/24/2016 12:45 PM, pic8...@gmail.com wrote: > Thanks for the reply. > > The code snippet given by Peter is not very clear > > I would like to multiprocess a function which is

Re: comapring 2 sequences of DNA ouput the silent and non mutations

2016-10-29 Thread MRAB
On 2016-10-29 20:38, dishaachary...@gmail.com wrote: Code: A = 0 B= 0 i=0 j=0 # opening the files infile1 = open("CDSsrebf1.txt") infile2 = open("PROsrebf1.txt") infile3 = open("mutant.txt") print(" 1st line of WT SREBF1 (CDS):",infile1.readline()) print ("1st line of mutant protein of SREBF1: "

Re: Reading Fortran Ascii output using python

2016-10-31 Thread MRAB
On 2016-10-31 17:46, Heli wrote: On Monday, October 31, 2016 at 6:30:12 PM UTC+1, Irmen de Jong wrote: On 31-10-2016 18:20, Heli wrote: > Hi all, > > I am trying to read an ascii file written in Fortran90 using python. I am reading this file by opening the input file and then reading using: > >

Re: Need help with coding a function in Python

2016-10-31 Thread MRAB
On 2016-10-31 22:09, devers.meetthebadger.ja...@gmail.com wrote: http://imgur.com/a/rfGhK#iVLQKSW How do I code a function that returns a list of the first n elements of the sequence defined in the link? I have no idea! So far this is my best shot at it (the problem with it is that the n t

Re: Fwd: About Installation.

2016-11-06 Thread MRAB
On 2016-11-06 19:36, Avijit Paul wrote: I installed python-3.6.0b2-amd64 on my Windows PC. Which is running on 64-bit system of Windows 8.1. The installation was successful. After the installation, when I ran the program it showed the following error, as shows in the attachment. I need your kin

Re: Fwd: Error message

2016-11-10 Thread MRAB
On 2016-11-10 21:37, Keenan C wrote: To whom this may concern, I am continuously receiving this error after the installation of Python 3.5.2. The purpose of using this program is for a class I am currently enrolled in at a University. (I am running Windows 7 Home Premium 64-bit paired with an

Re: Python does not start

2016-11-12 Thread MRAB
On 2016-11-12 09:13, jelena.tav...@gmail.com wrote: I’m sending you the error message from command prompt C:\Users\Jelena>py.exe -3.5-32 -m idlelib Traceback (most recent call last): [snip] _tkinter.TclError: bad event type or keysym "Alt" It looks like someone else has had the same problem

Re: help on "from deen import *" vs. "import deen"

2016-11-14 Thread MRAB
On 2016-11-15 01:36, jf...@ms4.hinet.net wrote: Ned Batchelder at 2016/11/15 6:33:54AM wrote: > But I get a wrong answer this way: > >>> from deen import * > >>> tblm = tbli > >>> gpa(0x7d) > 125 # it's 0x7d, the tblm[2] is 0 > > Why? why! why:-( Here you are assigning a value to your own tblm

Re: Printing a generator returns "", need to print its values

2016-11-16 Thread MRAB
On 2016-11-16 20:01, vmaha...@centerpointmedia.com wrote: I am running Python2.7, wherein I am running the following price of code: y = m.predict(input_fn=lambda:input_fn(df_predict), as_iterable=True) print ('Predictions: {}'.format(str(y))) The output of the following is """ However, the des

Re: Access to the caller's globals, not your own

2016-11-17 Thread MRAB
On 2016-11-17 05:40, Dan Sommers wrote: On Thu, 17 Nov 2016 16:17:51 +1100, Steven D'Aprano wrote: ... factory functions are great. But I'm saying that as the writer of the library, not the user of the library. Can you imagine expecting users to do this? from math import trig sin = trig.buil

Re: how to control formatting of a namedtuple in a list

2016-11-17 Thread MRAB
On 2016-11-17 23:49, Boylan, Ross wrote: Thank you; I can confirm that overriding __repr__ makes the list display as I wanted. The decision to use repr inside the list seems very odd, given the context, namely formatting something for display or looking for a simple string representation. It

Re: Encountering fatal error x80070643 while installing Python

2016-11-18 Thread MRAB
On 2016-11-18 11:40, Irene Venditti wrote: Hi everybody, I've got a problem with the installation of Python. I am a translator and currently I'm translating a book on programming Minecraft with Python, from English to Dutch. My computer is a Windows 10 computer, 64-bits (Toshiba Qosmio all in

Re: Parsing a single-level JSON file

2016-11-18 Thread MRAB
On 2016-11-18 18:23, mike.rei...@gmail.com wrote: hi all, Im reading in a JSON file that looks like this [ { "name":"myField1", "searchable":true, "navigable":true, "custom":true, "clauseNames":[ "cf[10190]", "Log Details" ], "orde

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread MRAB
On 2016-11-23 02:50, Nathan Ernst wrote: I'm using Python 3.5.2, and the following code (when invoked) causes a PendingDeprecationWarning when used in a unit test: def identity(x): return x def adjacent_difference(seq, selector=identity): i = iter(seq) l = selector(next(i)) while True:

Re: Can I print 2 calendars side by side?

2016-11-23 Thread MRAB
On 2016-11-23 18:02, Dayton Jones wrote: I'd like to be able to display 2 calendars side by side, instead of stacked... is this possible? for instance: print(calendar.month(year_a,month)) print() print(calendar.month(year_b,month)) prints: June 1971 Mo Tu We Th Fr Sa Su 1

Re: Random number help

2016-11-23 Thread MRAB
On 2016-11-23 19:29, Chris Kaynor wrote: On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list wrote: I need a way of generating a random number but there is a catch: I don't want to include certain numbers, is this possible? random.randint(1,100) works as it will randomly pick numbe

Re: Python while loop

2016-11-29 Thread MRAB
On 2016-11-29 23:58, paul.garcia2...@gmail.com wrote: Write a program which prints the sum of numbers from 1 to 101 ( 1 and 101 are included) that are divisible by 5 (Use while loop) This is the code: x=0 count=0 while x<=100: if x%5==0: count=count+x x=x+1 print(count) Quest

Re: What meaning is "if k in [0, len(n_trials) - 1] else None"?

2016-12-03 Thread MRAB
On 2016-12-03 23:11, Robert wrote: On Saturday, December 3, 2016 at 6:09:02 PM UTC-5, Robert wrote: Hi, I am trying to understand the meaning of the below code snippet. Though I have a Python IDLE at computer, I can't get a way to know below line: if k in [0, len(n_trials) - 1] else None I fe

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-04 Thread MRAB
On 2016-12-04 22:52, Steve D'Aprano wrote: On Mon, 5 Dec 2016 07:26 am, DFS wrote: $python program.py column1=2174 and column2='R' Here is a simple script demonstrating the issue: # --- program.py --- import sys print "argv:", sys.argv print ' '.join(sys.argv[1:]) I haven't tested it on

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