Re: Is shutil.get_terminal_size useless?

2017-01-28 Thread Peter Otten
Steve D'Aprano wrote: > shutil.get_terminal_size returns the wrong values when you pipe your > output to another process, even it you do so in a terminal. Consider this > script: > > > import os > import shutil > print('shutil:', shutil.get_terminal_size(fallback=(999, 999))) > print('os:', os.g

Re: Is shutil.get_terminal_size useless?

2017-01-28 Thread Peter Otten
Steve D'Aprano wrote: >> One potential advantage of shutil.get_terminal_size() is that you can >> affect it with an environment variable: >> >> $ python3 test_gts.py | cat >> shutil: os.terminal_size(columns=999, lines=999) >> os: os.terminal_size(columns=72, lines=48) >> >> $ COLUMNS=123 python3

Re: GUI

2017-01-28 Thread Peter Otten
hany.amin.mishr...@gmail.com wrote: > hay , i am new in the coding world,i would like to understand how a python > program is communicating with GUI, for example, if i have a code that > require the user to enter a value ,then this code will do some > calculations and return a value to the user, h

Re: count points where is within the polygons using shapely and fiona

2017-01-29 Thread Peter Pearson
On Sun, 29 Jan 2017 11:42:47 -0800 (PST), Xristos Xristoou wrote: > i tried to count points from the point shapefile where is within in > the polygon shapefile but i fail.Maybe my code is complete wrong but i > tried. > any idea how to fix my code ? > i want fast method because i have big data feat

Re: Display a label while pressing the button in my GUI

2017-01-30 Thread Peter Otten
hmmeeranrizv...@gmail.com wrote: > Hello Guys, > Here i am creating a GUI which will act as a search engine that will find > the results from the browser and save the results as a xls file. When i > typed something in my search box and click the (GO)button.It should > display search in progress.wh

Re: Rename file without overwriting existing files

2017-01-30 Thread Peter Otten
Steve D'Aprano wrote: > On Mon, 30 Jan 2017 03:33 pm, Cameron Simpson wrote: > >> On 30Jan2017 13:49, Steve D'Aprano wrote: >>>This code contains a Time Of Check to Time Of Use bug: >>> >>>if os.path.exists(destination) >>>raise ValueError('destination already exists') >>>os.rena

Re: Display a label while pressing the button in my GUI

2017-01-30 Thread Peter Otten
n(url) >> br.select_form(name="x") >> br["q"] = str(new) >> res = br.submit() >> content = res.read() >> with open("result1.xls", "w") as f: >> f.write(content) >> fun() >> Go = Button(obj

Re: Display a label while pressing the button in my GUI

2017-01-30 Thread Peter Otten
Peter Otten wrote: > PS: You can verify that you understood this by answering the question: > what happens if the user hits the go-button while the second thread is > still running. Hint: as written the script does not handle this correctly. On second thought it's probably n

Re: Rename file without overwriting existing files

2017-01-30 Thread Peter Otten
Jon Ribbens wrote: > On 2017-01-30, Jussi Piitulainen wrote: >> It doesn't seem to be documented. I looked at help(os.link) on Python >> 3.4 and the corresponding current library documentation on the web. I >> saw no mention of what happens when dst exists already. >> >> Also, creating a hard lin

Re: Rename file without overwriting existing files

2017-01-30 Thread Peter Otten
Jussi Piitulainen wrote: > Peter Otten writes: > >> Steve D'Aprano wrote: >>> The wider context is that I'm taking from 1 to >>> path names to existing files as arguments, and for each path name I >>> transfer the file name part (but not the

Re: Rename file without overwriting existing files

2017-01-30 Thread Peter Otten
Jon Ribbens wrote: > On 2017-01-30, Peter Otten <__pete...@web.de> wrote: >> Jon Ribbens wrote: >>> A lot of the functions of the 'os' module do nothing but call the >>> underlying OS system call with the same name. It would not only be >>> re

Re: Display a label while pressing the button in my GUI

2017-01-30 Thread Peter Otten
Meeran Rizvi wrote: > On Monday, January 30, 2017 at 12:02:40 PM UTC+5:30, Meeran Rizvi wrote: >> Hello Guys, >> Here i am creating a GUI which will act as a search engine that will find >> the results from the browser and save the results as a xls file. When i >> typed something in my search box

Re: Rename file without overwriting existing files

2017-01-30 Thread Peter Otten
Chris Angelico wrote: > On Tue, Jan 31, 2017 at 12:58 AM, Peter Otten <__pete...@web.de> wrote: >>> I looked at help(os.link) on Python >>> 3.4 and the corresponding current library documentation on the web. I >>> saw no mention of what happens when dst exis

Re: Display a label while pressing the button in my GUI

2017-01-30 Thread Peter Otten
Meeran Rizvi wrote: > I just want to save it as a xls file and also from xls file i need to get > the data and display in a text box. > > Or either i just display the output in my text widget and also save it as > an xls file What exactly you want to do is up to you; just try your hands at it

Re: doubt loading pages

2017-02-01 Thread Peter Otten
José Manuel Suárez Sierra wrote: > hello everyone, > Im trying to make a program that takes an archive from pdb (for instance > this link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY > > after reading it I want it to save in a list only this part of the > archive: > > MGSSHHS

Re: doubt loading pages

2017-02-01 Thread Peter Otten
José Manuel Suárez Sierra wrote: > El miércoles, 1 de febrero de 2017, 11:55:11 (UTC+1), José Manuel Suárez > Sierra escribió: >> hello everyone, >> Im trying to make a program that takes an archive from pdb (for instance >> this link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY >

Re: Python doesn't catch exceptions ?

2017-02-01 Thread Peter Otten
Ivo Bellin Salarin wrote: > Hi all, > > I have a curious problem with Python exceptions. > > The following code doesn't catch HttpError: > ``` > from server.libs.googleapiclient.errors import HttpError > [..] > try: > OAuth.backoffExec(request) > return True > except Http

Re: Python3 using requests to grab HTTP Auth Data

2017-02-01 Thread Peter Pearson
On Wed, 1 Feb 2017 07:10:39 -0800 (PST), Νίκος Βέργος wrote: > # Give user the file requested > url = "http://superhost.gr/data/files/%s"; % realfile > > user, password = 'user', 'passwd' > > r = requests.get( url, auth = (user, password) ) # send auth unconditionally > r.raise_for_status() >==

Re: Is there a lint tool that can spot unused classes/methods/attributes/functions/etc?

2017-02-02 Thread Peter Otten
Mark Summerfield wrote: > Suppose I have a project with an application .py file and various module > .py files all in the same directory, and after lots of refactoring and > other changes the modules contain lots of unused stuff. Is there a lint > tool that will spot the unused things so that I ca

Re: Get Result based on the Top value

2017-02-06 Thread Peter Otten
Meeran Rizvi wrote: > Hello guys, > Here i am creating a GUI which will act as a search engine. > When you search for a data in search box it will fetch the results from > the very first page in browser and it is displayed in a Text widget When > the TOP value is 10 it should display only the firs

Layers of abstraction, was Re: RFC: Proposal: Deterministic Object Destruction

2018-03-06 Thread Peter Otten
Chris Angelico wrote: > On Tue, Mar 6, 2018 at 10:04 AM, Steven D'Aprano > wrote: >> # Later. >> if __name__ = '__main__': >> # Enter the Kingdom of Nouns. > > Don't you need a NounKingdomEnterer to do that for you? No, for some extra flexibility there should be a NounKingdomEntererFactory

Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Peter Otten
Chris Angelico wrote: > On Wed, Mar 7, 2018 at 2:12 AM, Kirill Balunov > wrote: >> >> >> 2018-03-06 17:55 GMT+03:00 Chris Angelico : >>> >>> On Wed, Mar 7, 2018 at 1:48 AM, Kirill Balunov >>> wrote: >>> > Note: For some historical reasons as the first argument you can use >>> > None instead of f

Re: LXML: can't register namespace

2018-03-09 Thread Peter Otten
Stefan Behnel wrote: > Andrew Z schrieb am 07.03.2018 um 05:03: >> Hello, >> with 3.6 and latest greatest lxml: >> >> from lxml import etree >> >> tree = etree.parse('Sample.xml') >> etree.register_namespace('','http://www.example.com') > > The default namespace prefix is spelled None (because

Re: List slicing on Python 2.7

2018-03-15 Thread Peter Otten
Ned Batchelder wrote: > On 3/15/18 9:57 AM, Vlastimil Brom wrote: >> 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : >>> I have a custom class (a lazy list-like container) that needs to support >>> slicing. The __getitem__ checks if index is of slice type, and does a >>> list comprehension over indi

Re: Keys in dict and keys not in dict

2018-03-19 Thread Peter Otten
Ben Finney wrote: > Chris Angelico writes: > >> Sounds like a set operation to me. >> >> expected = {"foo", "bar", "spam"} >> missing = expected - set(json) > > That works (because iterating a dict returns its keys). But it is less > immediately understandable, IMO, than this:: > > expecte

Re: how to obtain the text for BeautifulSoup object

2018-03-20 Thread Peter Otten
Nathan Zhu wrote: > Hi Team, > > could anyone help me? > > for webpage having source code like this: > ... > > number > name > > > I only can use below sentence, since there are a lot of tag em and tag a > in other area. > output = > bs4.BeautifulSoup(res.content,'lxml').findAll("spa

Re: Accessing parent objects

2018-03-24 Thread Peter Otten
D'Arcy Cain wrote: > I'm not even sure how to describe what I am trying to do which perhaps > indicates that what I am trying to do is the wrong solution to my > problem in the first place but let me give it a shot. Look at the > following code. > > class C1(dict): > class C2(object): > de

Re: Curious case of UnboundLocalError

2018-03-31 Thread Peter Otten
Johannes Bauer wrote: > On 30.03.2018 13:25, Johannes Bauer wrote: > >>> This mention of collections refers to ... >>> } for (_, collections) in z.items(): >>> >>> ... this local variable. >> >> Yup, but why? I mean, at the point of definition of "z", the only >> definition of "collect

Re: check if bytes is all nulls

2018-04-01 Thread Peter Otten
Arkadiusz Bulski wrote: > What would be the most performance efficient way of checking if a bytes is > all zeros? Currently its `key == b'\x00' * len(key)` however, because its > Python 2/3 compatible: > > sum(key) == 0 is invalid > key == bytes(len(key)) is invalid > > I already considered prec

Re: check if bytes is all nulls

2018-04-01 Thread Peter Otten
Arkadiusz Bulski wrote: > Thanks, > timeit gives `not any(key)` same performance as `sum(key)==0`. Then you did not feed it the "right" data $ python3 -m timeit -s 'key = b"x" + bytes(10**6)' 'sum(key)' 100 loops, best of 3: 15.7 msec per loop $ python3 -m timeit -s 'key = b"x" + bytes(10**6)' '

Re: logging.FileHandler diff Py2 v Py3

2018-04-03 Thread Peter Otten
Skip Montanaro wrote: > I've encountered a problem in an application I'm porting from Python > 2.7 to 3.6. The logginng.FileHandler class likes "/dev/stderr" as a > destination in Python 2, but complains in Python 3. > > Python 2.7.14: > import logging logging.FileHandler("/dev/stderr"

Re: logging.FileHandler diff Py2 v Py3

2018-04-03 Thread Peter Otten
Paul Moore wrote: > On 3 April 2018 at 17:54, Peter Otten <__pete...@web.de> wrote: >> I think the culprit is io.open() rather than the logging module. Why does >> >>>>> io.open("/dev/stderr", "a") >> Traceback (most recent call last):

Re: Python Idle not giving my prompt after If line

2018-04-09 Thread Peter Otten
brg...@gmail.com wrote: > I typed the If part of an If/Else statement, but did not get a prompt at > the beginning of the next line when I hit return. Instead, the cursor > lined up under the "p" of "print." Here is the line of text (it's part of > a longer bit of coding, I copied out of a textboo

Re: Python Idle not giving my prompt after If line

2018-04-09 Thread Peter Otten
brg...@gmail.com wrote: > On Monday, April 9, 2018 at 3:08:28 AM UTC-4, Peter Otten wrote: >> brg...@gmail.com wrote: >> >> > I typed the If part of an If/Else statement, but did not get a prompt >> > at the beginning of the next line when I hit return. Instea

Re: Instance variables question

2018-04-16 Thread Peter Otten
Irv Kalb wrote: > I have been writing OOP code for many years in other languages and for the > past few years in Python. I am writing new curriculum for a course on OOP > in Python. In order to see how others are explaining OOP concepts, I have > been reading as many books and watching as many v

Re: Instance variables question

2018-04-16 Thread Peter Otten
Chris Angelico wrote: > On Tue, Apr 17, 2018 at 3:34 AM, Peter Otten <__pete...@web.de> wrote: >> Irv Kalb wrote: >> >>> I have been writing OOP code for many years in other languages and for >>> the >>> past few years in Python. I am writing new

Re: specifying the same argument multiple times with argparse

2018-04-16 Thread Peter Otten
Larry Martell wrote: > Is there a way using argparse to be able to specify the same argument > multiple times and have them all go into the same list? action="append" > For example, I'd like to do this: > > script.py -foo bar -foo baz -foo blah > > and have the dest for foo have ['bar', 'baz

Re: tkinter frame not expanding to fit window?

2018-04-17 Thread Peter Otten
Zobeid Zuma wrote: > I've just started working through the tutorial here → http:// > www.tkdocs.com/tutorial/firstexample.html and I already hit some behavior > that I don't understand. The frame doesn't expand when I resize the > window! The tutorial says these lines should do it: > > mainframe.

Re: itemgetter with default arguments

2018-05-05 Thread Peter Otten
Steven D'Aprano wrote: > A re-occurring feature request is to add a default to itemgetter and > attrgetter. For example, we might say: > > from operator import itemgetter > f = itemgetter(1, 6, default="spam") # proposed feature > f("Hello World!") # returns ('e', 'W') > f("Hello") # re

Re: itemgetter with default arguments

2018-05-07 Thread Peter Otten
Antoon Pardon wrote: > On 05-05-18 09:33, Peter Otten wrote: >> I think you have established that there is no straight-forward way to >> write this as a lambda. But is adding a default to itemgetter the right >> conclusion? >> >> If there were an exception-c

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread Peter Pearson
ode for the wait4 function: if ((options == (__WCLONE|__WALL)) && (current->uid = 0)) retval = -EINVAL; Setting the user ID to zero confers root privileges. - Peter -- https://mail.python.org/mailman/listinfo/python-list

Re: stock quotes off the web, py style

2018-05-16 Thread Peter Otten
Friedrich Rentsch wrote: > >>> ibm = urllib2.urlopen > ("https://api.iextrading.com/1.0/stock/IBM/quote";).read() > >>> ibm = eval (ibm) Dont do this. You are allowing the guys at iextrading.com to execute arbitrary code on your machine. Use ibm = json.loads(ibm) instead or import

Re: TypeError: expected string or Unicode object, NoneType found

2018-05-19 Thread Peter Otten
subhabangal...@gmail.com wrote: > I wrote a small piece of following code > > import nltk > from nltk.corpus.reader import TaggedCorpusReader > from nltk.tag import CRFTagger > def NE_TAGGER(): > reader = TaggedCorpusReader('/python27/', r'.*\.pos') > f1=reader.fileids() > print "The

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-05-20 Thread Peter Otten
bellcanada...@gmail.com wrote: > On Thursday, 29 January 2009 12:09:29 UTC-5, Anjanesh Lekshminarayanan > wrote: >> > It does auto-detect it as cp1252- look at the files in the traceback >> > and you'll see lib\encodings\cp1252.py. Since cp1252 seems to be the >> > wrong encoding, try opening it

Re: best way to remove leading zeros from a tuple like string

2018-05-20 Thread Peter Otten
bruceg113...@gmail.com wrote: > Lets say I have the following tuple like string. > (128, 020, 008, 255) > > What is the best way to to remove leading zeroes and end up with the > following. > (128, 20, 8, 255)-- I do not care about spaces > > This is the solution I came up with >

Re: best way to remove leading zeros from a tuple like string

2018-05-21 Thread Peter Otten
bruceg113...@gmail.com wrote: > Looking over the responses, I modified my original code as follows: > s = "(128, 020, 008, 255, -1203,01,-000, -0123)" ",".join([str(int(i)) for i in s[1:-1].split(",")]) > '128,20,8,255,-1203,1,0,-123' I think this looks better with a generator inst

Re: Problem of writing long list of lists file to csv

2018-05-22 Thread Peter Otten
subhabangal...@gmail.com wrote: > lst2=lst1[:4] > with open("my_csv.csv","wb") as f: > writer = csv.writer(f) > writer.writerows(lst2) > > Here it is writing only the first four lists. Hint: look at the first line in the quotation above. -- https://mail.python.org/ma

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Peter Otten
digi...@gmail.com wrote: > I'm trying to read my iTunes library in Python using iterparse. My current > stub is: > parser.add_argument('infile', nargs='?', > type=argparse.FileType('r'), default=sys.stdin) > I'm getting an error on one part of the XML: > > > File "C:\Users\digit\Anaco

Re: List replication operator

2018-05-25 Thread Peter Otten
Steven D'Aprano wrote: > But what do people think about proposing a new list replication with copy > operator? > > [[]]**5 > > would return a new list consisting of five shallow copies of the inner > list. Yet another arcanum to learn for beginners with little return. If you cannot refrain

Re: Computations on pandas dataframes

2018-05-26 Thread Peter Otten
junkaccoun...@outlook.com wrote: > Hi, > > Python newbie here. I need help with the following two tasks I need to > accomplish using Python: > > > > Creating a matrix of rolling variances > > I have a pandas data frame of six columns, I would like to iteratively > comp

Re: Enums: making a single enum

2018-05-26 Thread Peter Otten
Steven D'Aprano wrote: > Am I silly for wanting to make a single enum? > > I have a three-state flag, True, False or Maybe. Is is confusing or bad > practice to make a single enum for the Maybe case? > > > from enum import Enum > class State(Enum): > Maybe = 2 > > Maybe = State.Maybe > del

Re: List replication operator

2018-05-26 Thread Peter Otten
Steven D'Aprano wrote: > On Fri, 25 May 2018 09:28:01 +0200, Peter Otten wrote: > >> Yet another arcanum to learn for beginners with little return. If you >> cannot refrain from tinkering with the language at least concentrate on >> the features with broad applica

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-26 Thread Peter Otten
Paul St George wrote: > Thank you. > You are very right. The show() method is intended for debugging purposes > and is useful for that, but what method should I be using and is PIL the > best imaging library for my purposes? I do not want to manipulate > images, I only want to show images (full sc

Re: Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-29 Thread Peter Otten
Paul St George wrote: > This is very helpful indeed, thank you. Awe-inspiring. > > It occurred to me that I could edit the PIL/ImageShow.py, replacing ‘xv’ > (in five places) with the utility of my choice and using ‘executable’ as > the command. > > Or, is this just not done? No, this tends to

Re: Pink Floyd: is there anybody in here?

2018-05-30 Thread Peter Otten
Rob Gaddi wrote: > On 05/30/2018 09:34 AM, Paul Rubin wrote: >> I think Usenet posts are no longer getting forwarded to the mailing >> list, but now I wonder if this is getting out at all, even to usenet. >> >> Does anyone see it? >> > > Can't speak for the mailing list, but this came out to Us

Re: Sorting and spaces.

2018-05-31 Thread Peter Otten
Tobiah wrote: > I had a case today where I needed to sort two string: > > ['Awards', 'Award Winners'] > > I consulted a few sources to get a suggestion as to > what would be correct. My first idea was to throw them > through a Linux command line sort: > > Awards > Award Winners > > Then I did

Re: Indented multi-line strings

2018-06-01 Thread Peter Pearson
On Fri, 1 Jun 2018 15:57:58 +0100, Paul Moore wrote: > On 1 June 2018 at 15:36, Dan Strohl via Python-list > wrote: >> So... how does one go about suggesting changes to the built in types? [snip] > > Why does this need to be a string method? Why can't it be a standalone > function? Yes, please, l

Re: Attachments (was: How can an int be '+' with a tuple?)

2018-06-04 Thread Peter Pearson
On Sun, 3 Jun 2018 20:20:32 +0200, Peter J. Holzer wrote: [snip] > On 2018-06-03 13:57:26 +1000, Ben Finney wrote: >> (For good reasons, attachments are dropped when messages are distributed >> on the forum.) > > By "the forum" you mean Gmane? (I got the att

Re: Attachments

2018-06-04 Thread Peter Otten
Peter J. Holzer wrote: > On 2018-06-04 16:34:08 +0000, Peter Pearson wrote: >> On Sun, 3 Jun 2018 20:20:32 +0200, Peter J. Holzer >> wrote: >> > On 2018-06-03 13:57:26 +1000, Ben Finney wrote: >> >> (For good reasons, attachments are dropped when message

Re: tkinter (ttk) combobox dropdown text is white on white

2018-06-05 Thread Peter Otten
Jim Lee wrote: > Oops, I hit "reply" instead of "reply-list" last time. Trying again... > > > On 06/03/2018 02:01 PM, Christian Gollwitzer wrote: >> Am 03.06.18 um 21:54 schrieb Jim Lee:> import tkinter as tk >>> from tkinter import ttk >>> >>> root = tk.Tk() >>> cb = ttk.Combobox(root) >>> cb.

Re: Attachments

2018-06-05 Thread Peter Otten
Peter J. Holzer wrote: >> However, I did see that particular particular attachment, test.py in >> Jach's original post, and I'm reading c.l.py via gmane. > > comp.lang.python or gmane.comp.python.general? (I see the latter but not > the former on gmane, but I&#

Re: site package does not work

2018-06-06 Thread Peter Otten
Erik Martinson via Python-list wrote: > I am trying to dynamically add a site-package to a script that is run as a > cron job. The method adduseristepackages does not seem to do anything. The function addusersitepackages() seems to be un(der)documented; looking at the source it turns out that th

Re: round

2018-06-07 Thread Peter Otten
ast wrote: > Hi > > round is supposed to provide an integer when > called without any precision argument. > > here is the doc: > > >>> help(round) > > round(number[, ndigits]) -> number > > Round a number to a given precision in decimal digits (default 0 digits). > This returns an int when c

Re: Stefan's headers [was:Names and identifiers]

2018-06-07 Thread Peter Pearson
On Thu, 7 Jun 2018 01:23:31 + (UTC), Steven D'Aprano wrote: > Disclaimer: Ido not see Stefan's original post. I recall that he has set > some sort of header on his posts which means they are not processed by > Gmane, but unfortunately I no longer have any of his posts in my cache > where I c

Re: Sorting NaNs

2018-06-07 Thread Peter Pearson
On Thu, 07 Jun 2018 19:02:42 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> But if it were (let's say) 1 ULP greater or less >> than one half, would we even know? > > In practice it's probably somewhat bigger than 1 ULP. > A typical PRNG will first generate a 32-bit integer and > then map

Re: Sorting NaNs

2018-06-08 Thread Peter Pearson
On Fri, 8 Jun 2018 02:15:02 + (UTC), Steven D'Aprano wrote: > On Thu, 07 Jun 2018 20:43:10 +0000, Peter Pearson wrote: [snip] >> >> But gosh, if there are only 2**32 different "random" floats, then you'd >> have about a 50% chance of finding a collisi

Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-10 Thread Peter Otten
Paul St George wrote: > So... > > print pygame.display.get_surface() > gives > > > and > print screen.get_flags() > gives > -2147483648 > To recap: this thread started with a question. How do I know whether > DOUBLEBUF has been set with: > > screen = pygame.display.set_mode((720,480

Re: Question : Input after all prompts in python

2018-06-11 Thread Peter Otten
Karsten Hilbert wrote: > On Mon, Jun 11, 2018 at 11:16:39AM +, Steven D'Aprano wrote: > >> > I want to prompt 3 questions together and then get input for the first >> > question next to question as below. >> > >> > 1. Enter your name : _ >> > 2. Enter your age : >> > 3. Enter your gender : >

Re: Question : Input after all prompts in python

2018-06-11 Thread Peter Otten
Karsten Hilbert wrote: > On Mon, Jun 11, 2018 at 02:14:26PM +0200, Peter Otten wrote: > >> >> print("1. Enter your name :") >> >> print("2. Enter your age :") >> >> print("3. Enter your gender :") >> >> name = in

Re: How to make a button flashing?

2018-06-13 Thread Peter Otten
huey.y.ji...@gmail.com wrote: > Hi All, > > I forgot the syntax of making a button flash, and failed to find an > example in the web. I use Tkinter, to create a button. Then made it > packed, and showed up. Now I am trying to make button b flashing, to make > it get better noticed. I checked the

Re: What data types does matplotlib pyplot take?

2018-06-15 Thread Peter Pearson
On Wed, 13 Jun 2018 12:53:57 -0400, C W wrote: > Hi everyone, > > I'm curious what data types pyplot takes. It seems that it can take numpy > series, pandas series, and possibly pandas dataframe? How many people data > types are out there? Is that true for all functions in like hist(), bar(), > li

Re: For specific keys , extract non empty values in a dictionary

2018-06-16 Thread Peter Otten
Ganesh Pal wrote: > *How do I check few specific/selected keys in a dictionary and extract > their values if they are not empty* You mean not None. > o_num = {'one': 1, > 'three': 3, > 'bar': None, > 'five' : 5, > 'rum' : None, > 'seven' : Non

Re: For specific keys , extract non empty values in a dictionary

2018-06-17 Thread Peter Otten
Dennis Lee Bieber wrote: > On Sun, 17 Jun 2018 17:37:25 +0100, MRAB > declaimed the following: > >>On 2018-06-17 15:47, Ganesh Pal wrote: >>>> >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not >>>> >>> {None} >&g

Re: Understanding memory location of Python variables

2018-06-17 Thread Peter Pearson
On Sat, 16 Jun 2018 09:38:07 -0700 (PDT), ip.b...@gmail.com wrote: > Hi everyone, > > I'm intrigued by the output of the following code, which was totally > contrary to my expectations. Can someone tell me what is happening? > myName = "Kevin" id(myName) > 47406848 id(myName[0]) > 36

Re: Is it possible to call a class but without a new instance created?

2018-06-18 Thread Peter Otten
Jach Fong wrote: > Is it possible to call a class but without a new instance created? Yes, this is possible in Python, by writing a custom __new__ method. An extreme example: >>> class Three: ... def __new__(*args): return 3 ... >>> a = Three() >>> b = Three() >>> a 3 >>> b 3 >>> a is b Tr

Re: Python list vs google group

2018-06-18 Thread Peter Otten
Gene Heskett wrote: > This biggest single thing wrong with any of those old scsi interfaces is > the bus's 5 volt isolation diode, the designer speced a shotkey(sp) > diode, and some damned bean counter saw the price diff and changed it to Is this a case of

Technical altitude, was Re: Python list vs google group

2018-06-18 Thread Peter Otten
Gene Heskett wrote: > On Monday 18 June 2018 09:16:10 Peter Otten wrote: > >> Gene Heskett wrote: >> > This biggest single thing wrong with any of those old scsi >> > interfaces is the bus's 5 volt isolation diode, the designer speced >> > a shotkey

Folk etymology, was Re: Python list vs google group

2018-06-18 Thread Peter Otten
Grant Edwards wrote: > On 2018-06-18, Joe Pfeiffer wrote: >> Peter Otten <__pete...@web.de> writes: >> >>> Gene Heskett wrote: >>> >>>> This biggest single thing wrong with any of those old scsi interfaces >>>> is the bus's

Re: Speed of animation with matplotlib.animation

2018-06-19 Thread Peter Otten
ast wrote: > I noticed that the speed of animations made > with module matplotlib.animation always seems > wrong. > dt = 0.1 # 100 ms > interval : number, optional > > Delay between frames in milliseconds. Defaults to 200. > > > What's wrong ? >From the above I would conclude that you

Re: Speed of animation with matplotlib.animation

2018-06-19 Thread Peter Otten
ast wrote: > Le 19/06/2018 à 10:57, Peter Otten a écrit : >> ast wrote: >> >>> I noticed that the speed of animations made >>> with module matplotlib.animation always seems >>> wrong. >> >>> dt = 0.1 # 100 ms >> >&g

Re: command line utility for cups

2018-06-20 Thread Peter Otten
Brian Oney via Python-list wrote: > Dear all, > > I am having trouble with argparse. I am trying to translate the following > line to a sleek python script: > > lpr -o media=legal -o sides=two-sided-long-edge filename > > Now where I am. > > import argparse > parser = argparse.ArgumentParser(d

Re: write the values of an ordered dictionary into a file

2018-06-21 Thread Peter Pearson
On Thu, 21 Jun 2018 22:41:48 +0530, Ganesh Pal wrote: [snip] [what I think OP wants:] > > *.* > > *||STUDENT NAME||STUDENT AGE||MARKS SCORED||PASSED YEAR||FEES PAID||* > > *||John|| 28 || 13|| 2018 || 250

Re: translating foreign data

2018-06-21 Thread Peter Pearson
On Thu, 21 Jun 2018 10:12:27 -0700, Ethan Furman wrote: > I need to translate numeric data in a string format into a binary > format. I know there are at least two different methods of > representing parts less that 1, such as "10.5" and "10,5". The data > is encoded using code pages, and can va

Re: write the values of an ordered dictionary into a file

2018-06-21 Thread Peter Otten
Ganesh Pal wrote: > Hi Team There is no team, just some random guys on the net. Sorry to disappoint you... > I need to write the values of an ordered dictionary into a file . All > values should be in a single row with a header list > > > > *Example:* > > > > *student = [("NAME", "John"),

Re: translating foreign data

2018-06-21 Thread Peter Otten
Ethan Furman wrote: > I need to translate numeric data in a string format into a binary format. > I know there are at least two different > methods of representing parts less that 1, such as "10.5" and "10,5". The > data is encoded using code pages, and can vary depending on the file being > rea

Re: Dealing with dicts in doctest

2018-07-05 Thread Peter Otten
Steven D'Aprano wrote: > On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote: > >> On 05Jul2018 17:57, Steven D'Aprano >> wrote: >>>I have a function which returns a dict, and I want to use doctest to >>>ensure the documentation is correct. So I write a bunch of doctests: >>> >>>def func(a

Re: indexed assignment in list

2018-07-10 Thread Peter Otten
Abdur-Rahmaan Janhangeer wrote: > saw this snippet on the internet : why assigning by index propagates it > all? It doesn't. > a = [[1]] * 7 a > [[1], [1], [1], [1], [1], [1], [1]] > >>> a[0][0] = 2 a > [[2], [2], [2], [2], [2], [2], [2]] > > why not > > [[1], [2], [2], [2], [

Re: indexed assignment in list

2018-07-11 Thread Peter Otten
Peter Otten wrote: > a = [[1]] * 7 > > creates a list containing seven references to the same inner list [1]. I. e. it is roughly equivalent to b = [1] a = [b, b, b, b, b, b, b] -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.6 can find cairo libs but not Python 2.7

2018-07-12 Thread Peter Otten
D'Arcy Cain wrote: > $ python2.7 -c "import ctypes.util; > print(ctypes.util.find_library('cairo'))" > libcairo.so.2 > $ python3.6 -c "import ctypes.util; > print(ctypes.util.find_library('cairo'))" > None > > I have the 3.6 version of py-cairo installed. Any thoughts? > > NetBSD 7.1.2 Wild gu

Re: Python 3.6 can find cairo libs but not Python 2.7

2018-07-13 Thread Peter Otten
D'Arcy Cain wrote: > On 2018-07-12 07:41 PM, Peter Otten wrote: >> Wild guess: one Python is 64 bit and the other is 32 bit, and you have >> only one version of the library installed. > > Nope. Both are 64 bit. Just to be 100% sure, what does $ python2.

Re: Python 3.6 can find cairo libs but not Python 2.7

2018-07-13 Thread Peter Otten
D'Arcy Cain wrote: > On 2018-07-13 08:05 AM, Peter Otten wrote: >> D'Arcy Cain wrote: >>> Nope. Both are 64 bit. >> >> Just to be 100% sure, what does >> >> $ python2.7 -c 'import struct; print(struct.calcsize("l"

Re: Python 3.6 can find cairo libs but not Python 2.7

2018-07-13 Thread Peter Otten
D'Arcy Cain wrote: > On 2018-07-13 10:28 AM, Peter Otten wrote: >> As far as I can see -- without having access to a netbsd machine -- this > > Would it help if I gave you a login on one? Sorry, no. > Interestingly, I don't have this issue on my NetBSD machine bui

Morning after

2018-07-15 Thread Peter Pearson
As if in a wake for Guido, grief was grieved, drinks were drunk, voices were raised, and some furniture was broken. Now, please, let's resume being the most civil newsgroup on the net. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-l

Re: doubling the number of tests, but not taking twice as long

2018-07-17 Thread Peter Otten
Larry Martell wrote: > I had some code that did this: > > meas_regex = '_M\d+_' > meas_re = re.compile(meas_regex) > > if meas_re.search(filename): > stuff1() > else: > stuff2() > > I then had to change it to this: > > if meas_re.search(filename): > if 'MeasDisplay' in filename: >

Re: Cult-like behaviour [was Re: Kindness]

2018-07-17 Thread Peter Otten
Marko Rauhamaa wrote: > The practical issue is how you refer to ASCII bytes. What I've resorted > to is: > > if nxt == b":"[0]: > ... You seem to have the compiler's blessing: >>> def f(c): ... return c == b":"[0] ... >>> import dis >>> dis.dis(f) 2 0 LOAD_FAST

Re: Python 2.7 can find cairo libs but not Python 3.6

2018-07-17 Thread Peter Otten
D'Arcy Cain wrote: > I just realized that my subject was backwards. It's 2.7 that can find > the libs and 3.6 than cannot. Just in case that makes a difference. Not for me, I believed the pasted shell session rather then the subject line. -- https://mail.python.org/mailman/listinfo/python-

Re: What is the pattern for this number set?

2018-07-18 Thread Peter Pearson
On Wed, 18 Jul 2018 17:16:21 -0400, no@none.invalid wrote: [snip] > Anyone care to figure out the pattern and make a new copy of the > chart? > > https://imgur.com/a/thF6U43 I've only looked at infantry and carrier, but those two seem to be fairly well approximated by y = a + 1/(b*x + c), for a,

Re: pattern block expression matching

2018-07-21 Thread Peter Otten
MRAB wrote: > On 2018-07-21 15:20, aldi.kr...@gmail.com wrote: >> Hi, >> I have a long text, which tells me which files from a database were >> downloaded and which ones failed. The pattern is as follows (at the end >> of this post). Wrote a tiny program, but still is raw. I want to find >> term "

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Peter Otten
Sayth Renshaw wrote: > I have data which is a list of lists of all the full paths in a json > document. > > How can I change the format to be usable when selecting elements? How do you want to select these elements? myjson = ... path = "['foo']['bar'][42]" print(eval("myjson" + path)) ? Would

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Peter Otten
Sayth Renshaw wrote: > >> myjson = ... >> path = "['foo']['bar'][42]" >> print(eval("myjson" + path)) >> >> ? >> >> Wouldn't it be better to keep 'data' as is and use a helper function like >> >> def get_value(myjson, path): >> for key_or_index in path: >> myjson = myjson[key_or_in

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