Re: how to sort a list of tuples with custom function

2017-08-02 Thread Peter Otten
Glenn Linderman wrote: > On 8/1/2017 2:10 PM, Piet van Oostrum wrote: >> Ho Yeung Lee writes: >> >>> def isneighborlocation(lo1, lo2): >>> if abs(lo1[0] - lo2[0]) < 7 and abs(lo1[1] - lo2[1]) < 7: >>> return 1 >>> elif abs(lo1[0] - lo2[0]) == 1 and lo1[1] == lo2[1]: >>>

Re: Basic python understanding

2017-07-26 Thread Peter Otten
monica.sn...@gmail.com wrote: > Hi I am in need some understanding on how to become more knowledgeable > while interviewing a candidate that requires Python and other (see below) > experience for a position with Mass Mutual as Developer, Systems Design > Engineer, Web Engineer Director, Web Engin

Re: Regular expression

2017-07-26 Thread Peter Otten
Kunal Jamdade wrote: > There is a filename say:- 'first-324-True-rms-kjhg-Meterc639.html' . > > I want to extract the last 4 characters. I tried different regex. but i am > not getting it right. > > Can anyone suggest me how should i proceed.? You don't need a regular expression: >>> import os

Re: Reading a random element from a set

2017-07-26 Thread Peter Otten
ast wrote: > Hello > > random.choice on a set doesn't work because sets are > not indexable > > so I found nothing better than taking an element and > puting it back > > a = {5, 7, 8, 3, 0, 8, 1, 15, 16, 34, 765443} > elt = a.pop() > a.add(elt) > > any better idea, in a single instruction ? >

Re: how to group by function if one of the group has relationship with another one in the group?

2017-07-25 Thread Peter Otten
Ho Yeung Lee wrote: > from itertools import groupby > > testing1 = [(1,1),(2,3),(2,4),(3,5),(3,6),(4,6)] > def isneighborlocation(lo1, lo2): > if abs(lo1[0] - lo2[0]) == 1 or lo1[1] == lo2[1]: > return 1 > elif abs(lo1[1] - lo2[1]) == 1 or lo1[0] == lo2[0]: > return 1 >

Re: Script to replace contents inside the files

2017-07-24 Thread Peter Otten
Kunal Jamdade wrote: > I have thousands of html files inside a folder. I want to replace the > filename present inside another files. Say for ex:- fileName :- > 'abcd1234.html' is found inside another file say file2.html. Then I want > to remove the last 4 digits of the fileName i.e,. 'abcd1234.ht

Re: Compare files excel

2017-07-23 Thread Peter Otten
Smith wrote: > On 22/07/2017 22:21, Albert-Jan Roskam wrote: >> df1['difference'] = (df1 == df2).all(axis=1) > > below here there is the mistake : > > In [17]: diff = df1['difference'] = (df1 == df2).all(axis=1) > --- > Val

Downloading a file with Python 2

2017-07-22 Thread Peter Otten
Rahul Sircar wrote: > I wrote my code for downloading a file 'Metasploitable' using urllib2.But > it seems to have entered infinite loop.Because the screen is blank.It just > hangs there. It "hangs", i. e. doesn't give any feedback while the data is retrieved. > Please have a look at my code. >

Re: Not cathing nested StopIteration

2017-07-21 Thread Peter Otten
Antoon Pardon wrote: > This is python 3.4 on a debian box > > In the code below, line 36 raises a StopIteration, I would have > thought that this exception would be caught by line 39 but instead > I get a traceback. > > Did I miss something or is this a bug? Your code structure is try: rai

Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Peter Otten
Ganesh Pal wrote: > On Tue, Jul 18, 2017 at 11:02 PM, Dan Strohl wrote: > >> >> Like this: >> >> Def test_this(self): >> For i in range(10): >> with self.subTest('test number %s) % i): >> self.assertTrue(I <= 5) >> >> With the subTest() method, if anything within that sub

Re: Is this PEP viable?

2017-07-17 Thread Peter Otten
Evan Adler wrote: > I would like to submit the following proposal. In the logging module, I > would like handlers (like file handlers and stream handlers) to have a > field for exc_info printing. This way, a call to logger.exception() will > write the stack trace to the handlers with this flag set

Re: Difference in behavior of GenericMeta between 3.6.0 and 3.6.1

2017-07-16 Thread Peter Otten
Oren Ben-Kiki wrote: > TL;DR: We need improved documentation of the way meta-classes behave for > generic classes, and possibly reconsider the way "__setattr__" and > "__getattribute__" behave for such classes. The typing module is marked as "provisional", so you probably have to live with the i

Re: Connecting Google News

2017-07-16 Thread Peter Otten
Javier Bezos wrote: > Google News used to fail with the high level functions provided by httplib > and the like. However, I found this piece of code somewhere: > > def gopen(): >http = httplib.HTTPSConnection('news.google.com') >http.request("GET","/news?ned=es_MX" , When yo

Re: is @ operator popular now?

2017-07-15 Thread Peter Otten
Chris Angelico wrote: > On Sat, Jul 15, 2017 at 11:05 PM, Peter Otten <__pete...@web.de> wrote: >> Matt Wheeler wrote: >> >>>> as the title says. has @ been used in projects? >> >> numpy, probably? >> >>> Strictly speaking, @ is not

Re: is @ operator popular now?

2017-07-15 Thread Peter Otten
Matt Wheeler wrote: >> as the title says. has @ been used in projects? numpy, probably? > Strictly speaking, @ is not an operator. In other words it's not popular, not even widely known. Compare: $ python3.4 -c '__pete...@web.de' File "", line 1 __pete...@web.de ^ SyntaxErr

Re: python 3.5 raiaing an error when import the class Manager in this module sayning name Manager is not define

2017-07-12 Thread Peter Otten
WoFy The 95s wrote: > On Wednesday, 12 July 2017 18:57:11 UTC+5:30, Peter Otten wrote: >> WoFy The 95s wrote: >> >> > i tried from idle interpreter >> > >> > from person import Manager >> > >> > >> > >> >&g

Re: python 3.5 raiaing an error when import the class Manager in this module sayning name Manager is not define

2017-07-12 Thread Peter Otten
WoFy The 95s wrote: > i tried from idle interpreter > > from person import Manager > > > from person import Manager > Traceback (most recent call last): > File "", line 1, in > from person import Manager > ImportError: cannot import name 'Manager' Enter import person person.__file__

Re: Can anybody help me retrieve how to retrieve output from this Python code below!

2017-07-11 Thread Peter Otten
ksatish@gmail.com wrote: [snip code] Wasn't there any documentation to go with that script? That's the preferable method to use software written by someone else ;) Anyway -- First you have to undo what was probably changed by yourself: $ diff -u json2csv_orig.py json2csv.py --- json2csv_o

Re: Write this accumuator in a functional style

2017-07-11 Thread Peter Otten
Steven D'Aprano wrote: > I have a colleague who is allergic to mutating data structures. Yeah, I > know, he needs to just HTFU but I thought I'd humour him. > > Suppose I have an iterator that yields named tuples: > > Parrot(colour='blue', species='Norwegian', status='tired and shagged out') >

Re: Test 0 and false since false is 0

2017-07-07 Thread Peter Otten
Nathan Ernst wrote: > On Fri, Jul 7, 2017 at 2:04 AM, Peter Otten <__pete...@web.de> wrote: >> >>> sorted([0.0, 0, False, [], "x"], key=lambda x: x == 0 and type(x) == >> int) >> [0.0, False, [], 'x', 0] > You'd be better off us

Re: Test 0 and false since false is 0

2017-07-07 Thread Peter Otten
Sayth Renshaw wrote: > I was trying to solve a problem and cannot determine how to filter 0's but > not false. > > Given a list like this > ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9] > > I want to be able to return this list > ["a","b",None,"c","d",1,False,1,3,[],1,9,{},9

Re: Python threading and sharing variables

2017-07-05 Thread Peter Otten
Chris Angelico wrote: > You can be confident that a single assignment will happen atomically. > Even if "self.cnt = i" requires multiple instructions to perform For name binding cnt = i maybe, but self.cnt = i can execute arbitrary Python code (think __setattr__()). With threads I'd rather p

Re: Generator - Provide parameters to url - requests

2017-07-05 Thread Peter Otten
Sayth Renshaw wrote: > Thanks. > > I left "base" out as i was trying to remove as much uneeded code from > example as possible. I had defined it as > > base = datetime.datetime(2017,1,1) You actually did provide that line in your post. > Reading your code this sounds to simple :-). > > def da

Re: memory leak with re.match

2017-07-05 Thread Peter Otten
Mayling ge wrote: > Sorry. The code here is just to describe the issue and is just pseudo > code, That is the problem with your post. It's too vague for us to make sense of it. Can you provide a minimal example that shows what you think is a "memory leak"? Then we can either help you avo

Re: Generator - Provide parameters to url - requests

2017-07-05 Thread Peter Otten
Sayth Renshaw wrote: > Hi > > I am struggling to figure out how I can create a generator to provide > values to my url. My url needs to insert the year month and day in the url > not as params to the url. > > > import json > import requests > import datetime > > # using this I can create a lis

Re: Problem getting unittest tests for existing project working

2017-07-03 Thread Peter Otten
Aaron Gray wrote: > I am trying to get distorm3's unittests working but to no avail. > > I am not really a Python programmer so was hoping someone in the know > maybe able to fix this for me. Normally it doesn't work that way... > > Here's a GitHub issue I have created for the bug :- > > h

Re: how to make this situation return this result?

2017-07-01 Thread Peter Otten
;> unique_items set([frozenset([0]), frozenset([1, 2]), frozenset([0, 2]), frozenset([1]), frozenset([2]), frozenset([0, 1])]) > On Saturday, July 1, 2017 at 7:00:17 PM UTC+8, Peter Otten wrote: >> Ho Yeung Lee wrote: >> >> > finally i searched dict.values()[index] solved th

Re: how to make this situation return this result?

2017-07-01 Thread Peter Otten
Ho Yeung Lee wrote: > finally i searched dict.values()[index] solved this That doesn't look like a good solution to anything -- including "this", whatever it may be ;) If you make an effort to better explain your problem in plain english rather than with code examples you are likely tho get be

Re: how to make this situation return this result?

2017-07-01 Thread Peter Otten
Ho Yeung Lee wrote: > expect result as this first case > > ii = 0 > jj = 0 > for ii in range(0,3): > for jj in range(0,3): > if ii < jj: > print (ii, jj) > > > but below is different > as sometimes the situation is not range(0,3), but it a a list of tuple > > = 0

Re: how to add new tuple as key in dictionary?

2017-06-30 Thread Peter Otten
Ho Yeung Lee wrote: > I find that list can not be key in dictionary > then find tuple can be as key > > but when I add new tuple as key , got error in python 2.7 > > groupkey = {(0,0): []} > groupkey[tuple([0,3])] = groupkey[tuple([0,3])] + [[0,1]] First try to understand that you get the same

Re: Teaching the "range" function in Python 3

2017-06-29 Thread Peter Otten
Gregory Ewing wrote: > Don't start with range(). Start with lists, and introduce the for > loop as a way to iterate over lists. Leave range() until much later. > You should be able to go a *long* way without it -- it's quite > rare to need to iterate over a range of ints in idiomatic Python > code

Re: Development testing without reinstalling egg constantly?

2017-06-29 Thread Peter Otten
Grant Edwards wrote: > The projects 'main.py' can't be run directly from the command line, > since it contains code like this: > >from . import config >from . import __version__ >__name__ = 'muttdown' > >[ stuff that does real work ] Stupid question: isn't the following >

Re: argparse epilog call function?

2017-06-27 Thread Peter Otten
Didymus wrote: > Greetings, > > I might be barking up the wrong tree, but was wondering if there's a way > to have the argpasre epilog call a function. for example: > > epilog=Examples() > > Where Examples is: > > def Examples(): > text = """Lots of examples""" > print(text.format()) >

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
it shows as a string and not bytes in the debugger was > throwing me for a loop, in my log section I was trying to determine if > it was unicode decode it...if not don't do anything which wasn't working > > http://rodperson.com/graphics/uc/log_section.png > > >

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
Steve D'Aprano wrote: > On Sun, 25 Jun 2017 04:57 pm, Peter Otten wrote: >> if everything worked correctly? Though I don't understand why the OP >> doesn't see >> >> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac' >>

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
Steve D'Aprano wrote: > On Sun, 25 Jun 2017 07:17 am, Peter Otten wrote: > >> Then I'd fix the name manually... > > The file name isn't broken. > > > What's broken is parts of the OP's code which assumes that non-ASCII file > names are b

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Peter Otten
Rod Person wrote: > On Sat, 24 Jun 2017 21:28:45 +0200 > Peter Otten <__pete...@web.de> wrote: > >> Rod Person wrote: >> >> > Hi, >> > >> > I'm working on a program that will walk a file system and clean the >> > id3 tags of m

Re: os.walk the apostrophe and unicode

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

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-23 Thread Peter Otten
Dennis Lee Bieber wrote: > On Fri, 23 Jun 2017 09:49:06 +0300, Jussi Piitulainen > declaimed the following: > >>I just like those character translation methods, and I didn't like it >>when you first took the time to call a simple regex "line noise" and >>then proceeded to post something that loo

Re: Best way to ensure user calls methods in correct order?

2017-06-22 Thread Peter Otten
Thomas Nyberg wrote: > I have a situation in which I want a user to call methods in a certain > order and to force the re-calling of methods "down-stream" if upstream > methods are called again. An example of this sort of thing would be a > pipeline where calling methods again invalidates the resu

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-16 Thread Peter Otten
Andre Müller wrote: > # to impress your friends you can do > for chunk in itertools.zip_longest(*[iter(s)]*4): > chunked_str = ''.join(c for c in chunk if c) # generator expression > inside join with condition > print(chunked_str) This can be simplified with a fillvalue >>> s = "abracad

Re: [gettext] How to change language at run-time

2017-06-15 Thread Peter Otten
pozz wrote: > Il 15/06/2017 15:22, Peter Otten ha scritto: >> pozz wrote: >> >>> I know I can load multiple gettext.translation: >>> >>> it = gettext.translation('test', localedir="locale", >>> languages=["it&qu

Re: sqlite in 2.7 on redhat 6

2017-06-15 Thread Peter Otten
Larry Martell wrote: > Sorry I mistyped - it wasn't pip it was yum. OK, I'm out then. Looks like what works for Debian derivatives is not easily transferable to Redhead... -- https://mail.python.org/mailman/listinfo/python-list

Re: sqlite in 2.7 on redhat 6

2017-06-15 Thread Peter Otten
Larry Martell wrote: >> On linux the system sqlite3 is used. > > I tried building and installing sqlite from source and that did not > solve the problem. You misunderstood: the problem is not sqlite3 it's that python needs sqlite3's header files. >> Is that a Python version that you compiled y

Re: sqlite in 2.7 on redhat 6

2017-06-15 Thread Peter Otten
Larry Martell wrote: > On Thu, Jun 15, 2017 at 8:56 AM, Mark Summerfield via Python-list > wrote: >> On Thursday, June 15, 2017 at 1:47:00 PM UTC+1, larry@gmail.com >> wrote: >>> I am trying to use sqlite >>> >>> $ python2.7 >>> Python 2.7.10 (default, Feb 22 2016, 12:13:36) >>> [GCC 4.4.7 20

Re: [gettext] How to change language at run-time

2017-06-15 Thread Peter Otten
pozz wrote: > I know I can load multiple gettext.translation: > >it = gettext.translation('test', localedir="locale", languages=["it"]) >es = gettext.translation('test', localedir="locale", languages=["es"]) > > and install one translation at run-time when I want at a later time > (when

Re: sqlite3 is non-transactional??

2017-06-15 Thread Peter Otten
Michele Simionato wrote: > I know that CREATE queries are non-transactional in sqlite, as documented, > but I finding something really strange in INSERT queries. > > Consider this example: > > $ cat example.py > import os > import shutil > import sqlite3 > > script0 = '''\ > CREATE TABLE test (

Re: API Help

2017-06-14 Thread Peter Otten
Bradley Cooper wrote: > Yes it is not json, I did try that with no luck. What exactly did you try and how did it fail? -- https://mail.python.org/mailman/listinfo/python-list

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Peter Otten
Malcolm Greene wrote: > Wondering if there's a standard lib version of something like > enumerate() that takes a max count value? > Use case: When you want to enumerate through an iterable, but want to > limit the number of iterations without introducing if-condition-break > blocks in code. > Some

Re: Test String Contents

2017-06-13 Thread Peter Otten
Peter Otten wrote: > Matt wrote: > >> What is easiest way to determine if a string ONLY contains a-z upper >> or lowercase. I also want to allow the "-" and "_" symbols. No >> spaces or anything else. > > If you don't know regular ex

Re: Test String Contents

2017-06-13 Thread Peter Otten
Matt wrote: > What is easiest way to determine if a string ONLY contains a-z upper > or lowercase. I also want to allow the "-" and "_" symbols. No > spaces or anything else. If you don't know regular expressions here's a method where not much can go wrong: >>> import string >>> acceptable =

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

2017-06-13 Thread Peter Otten
Grant Edwards wrote: > On 2017-06-13, Peter Otten <__pete...@web.de> wrote: > >>> def edges(items): # where items is a non-empty iterator >>> first = next(items) >>> last = functools.reduce(sekond, items, first) >>> return [first, las

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

2017-06-13 Thread Peter Otten
Jussi Piitulainen wrote: > Peter Otten writes: > > ... > >> def edges(items): >> first = last = next(items) >> for last in items: >> pass >> return [first, last] > > ... > >> However, this is infested with for loops.

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

2017-06-13 Thread Peter Otten
Jussi Piitulainen wrote: > breamore...@gmail.com writes: > >> On Monday, June 12, 2017 at 7:33:03 PM UTC+1, José Manuel Suárez Sierra >> wrote: >>> Hello, >>> I am stuck with a (perhaps) easy problem, I hope someone can help me: >>> >>> My problem is: >>> I have a list of lists like this one: >>

Re: Unhelpful error message

2017-06-06 Thread Peter Otten
Stephen Tucker wrote: > Hi, > > I have just been thrown through an unecessary loop because of an unhelpful > error message. > > I am running Python 2.7.10 on a Windows 10 machine. > > I incorporate sample output from IDLE: > > ~~~ > print float ("123.456") > 123.4

Re: Finding the name of an object's source file

2017-06-06 Thread Peter Otten
Friedrich Rentsch wrote: > Hi all, > > Developing a project, I have portions that work and should be assembled > into a final program. Some parts don't interconnect when they should, > because of my lack of rigor in managing versions. So in order to get on, > I should next tidy up the mess and th

Re: Namedtuple problem #32.11.d

2017-06-06 Thread Peter Otten
Deborah Swanson wrote: > [{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='') Lovely column names ;) > Because, I can't say > > r = r._replace(getattr(r, column) = data) When r is mutable, i. e. *not* a namedtuple, you can write setattr(r, column, data) This assumes column is the column

Re: Is An Element of a Sequence an Object?

2017-06-05 Thread Peter Otten
Thomas Jollans wrote: > What I thought was going on was that single-character strings return > self on [0], as they do on full-length slices. > c = 'δ' c[0] is c > False c[:] is c > True c[0:1] is c > True > > I wonder why they don't do this... Perhaps noone has found a

Re: Is An Element of a Sequence an Object?

2017-06-05 Thread Peter Otten
Jussi Piitulainen wrote: > Peter Otten writes: >> However, this is an implementation detail: >> >>>>> def is_cached(c): >> ... return c[0] is c[0][0] >> ... > > I think this works the same, and looks more dramatic to me: > > ...

Re: Is An Element of a Sequence an Object?

2017-06-04 Thread Peter Otten
Thomas Jollans wrote: > On 04/06/17 09:52, Rustom Mody wrote: >> On Sunday, June 4, 2017 at 12:45:23 AM UTC+5:30, Jon Forrest wrote: >>> I'm learning about Python. A book I'm reading about it >>> says "... a string in Python is a sequence. A sequence is an ordered >>> collection of objects". This

Re: Is An Element of a Sequence an Object?

2017-06-03 Thread Peter Otten
Steven D'Aprano wrote: > On Sun, 04 Jun 2017 02:15:33 +, Grant Edwards wrote: > >> On 2017-06-03, Thomas Jollans wrote: >>> On 03/06/17 21:10, Jon Forrest wrote: >>> I'm learning about Python. A book I'm reading about it says "... a string in Python is a sequence. A sequence is an

Re: how to convert json to csv with python?

2017-06-03 Thread Peter Otten
Ho Yeung Lee wrote: > after edit the file, > > Traceback (most recent call last): > File "json2csv.py", line 148, in > loader.load(args.json_file) > File "json2csv.py", line 53, in load > self.process_each(json.load(json_file)) > File "C:\Python27\lib\json\__init__.py", line 291, i

Re: Order a matrix by columns with priority

2017-05-31 Thread Peter Otten
1024m...@gmail.com wrote: > i have the following matrix: > catch = [['fc', 2, 12, 2], > ['abcd', 1, 2, 0], > ['ab', 1, 0, 0], > ['cf', 1, 13, 0], > ['fc', 1, 14, 0], > ['f', 1, 11, 0]] > > and i want this matrix to be ordered by the third columns firstly, when > the values of the third colum

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

2017-05-31 Thread Peter Otten
Jon Ribbens wrote: > On 2017-05-31, Peter Otten <__pete...@web.de> wrote: >> Jon Ribbens wrote: >>> You would do: >>> >>> cur.execute("SELECT ...") >>> for row1 in cur.fetchall(): >>>

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

2017-05-31 Thread Peter Otten
Jon Ribbens wrote: > On 2017-05-31, Skip Montanaro wrote: >> I'm kind of stuck with the database API I have. ("Love the child you >> have, not the one you wish you had?") Given that I have the choice to >> execute those three statements to bound a transaction, is there any >> reason not to use th

Re: zeep, infinite recursion

2017-05-31 Thread Peter Otten
Nagy László Zsolt wrote: > > >> It was easier than I thought. It seems that zeep has a problem >> processing a basic WS-Security STS (Security Token Service, plain >> username+password authentication) document. I have changed the endpoint >> URL to example.com. Total size 11K compressed. I hope

Re: Pandas dataframe, how to find a very specific max values?

2017-05-30 Thread Peter Otten
zljubi...@gmail.com wrote: > I have a dataframe: > > > df = pd.DataFrame({ >'x': [3,4,5,8,10,11,12,13,15,16,18,21,24,25], >'a': [10,9,16,4,21,5,3,17,11,5,21,19,3,9] > }) > > df > Out[30]: > a x > 0 10 3 > 19 4 > 2 16 5 > 34 8 > 4 21 10 > 55 11 > 63

Re: Circular iteration on tuple starting from a specific index

2017-05-30 Thread Peter Otten
Beppe wrote: > hi all > > I've a tuple, something like > > x = ("A","B","C","D","E","F","G","H",) > > I would want to iterate on all tuple's elements > starting from a specific index > with the difference that I would want to restart from the beginning when I > reach the end of the tupla > >

Re: The argparse docs don't say who's responsible for closing FileType objects

2017-05-29 Thread Peter Otten
Bob Kline wrote: > The subject line pretty much says it all. Should the programmer close the > file? If the programmer does that, and the user has asked that the file > object be hooked up to standard in (or standard out) what will happen? If > the programmer doesn't close it, does it get closed c

Re: repeat until keypressed

2017-05-29 Thread Peter Otten
Poul Riis wrote: > In good old pascal there was this one-liner command: > repeat until keypressed > > Apparently there is no built-in analogue for that in python. I have > explored several different possibilities (pyglet, keyboard, curses, ginput > (from matplotlib) and others) but not managed to

Re: zeep, infinite recursion

2017-05-29 Thread Peter Otten
Nagy László Zsolt wrote: > Running this command: > > python3.6 -m zeep exmaple.wsdl This example is no more, we heave ceased to see it, it's gone to meet its maker... this is an ex-ex-ample. > line 259, in signature > from zeep.xsd import ComplexType > RecursionError: maximum recursion dep

Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Peter Otten
Tim Williams wrote: > I've spent too much time trying to track this down. I'll just hard-code my > filename in my INI file. Maybe I'll get back to it, but I need to move on. The only alternative I see would be to build your own InterpolationEngine which understands some kind of escaping so that

Re: Check for regular expression in a list

2017-05-26 Thread Peter Otten
Jussi Piitulainen wrote: > Surely that should be: > > if not 'firefox' in (i.name() for i in process_iter()): > > And that again should be: > > if any((i.name() == 'firefox') for i in process_iter()): The previous one certainly looks better than this, particularly if you move the `not

Re: using configobj string interpolation and logging.config.dictConfig

2017-05-25 Thread Peter Otten
Tim Williams wrote: > On Wednesday, May 24, 2017 at 5:47:37 PM UTC-4, Peter Otten wrote: >> Tim Williams wrote: >> >> > Just as a followup, if I use 'unrepr=True' in my ConfigObj, I don't >> > have to convert the strings. >> >> I

Re: dictConfig: logging.StreamHandler object is not iterable.

2017-05-24 Thread Peter Otten
Tim Williams wrote: > Just as a followup, if I use 'unrepr=True' in my ConfigObj, I don't have > to convert the strings. I'd keep it simple and would use JSON... -- https://mail.python.org/mailman/listinfo/python-list

Re: dictConfig: logging.StreamHandler object is not iterable.

2017-05-24 Thread Peter Otten
Tim Williams wrote: > (Apologies for using Google Groups to post) > > I'm trying to use dictConfig to configure logging. I keep running into the > error that the logging.StreamHandler object is not iterable. > > I'm using Python 3.4.3 on a Windows 7 box. > > C:\Python34\python.exe 3.4.3 (v3.4.3

Re: Concatenating files in order

2017-05-24 Thread Peter Otten
bartc wrote: > On 24/05/2017 16:41, Peter Otten wrote: >> Dennis Lee Bieber wrote: >> >>> On Tue, 23 May 2017 21:42:45 +0100, bartc declaimed the >>> following: >>> >>>> Is it necessary to sort them? If XXX is known, then presumably th

Re: Concatenating files in order

2017-05-24 Thread Peter Otten
Dennis Lee Bieber wrote: > On Tue, 23 May 2017 21:42:45 +0100, bartc declaimed the > following: > >>Is it necessary to sort them? If XXX is known, then presumably the first >>file will be called XXX_chunk_0, the next XXX_chunk_1 and so on. >> > > XXX_chunk_1 > XXX_chunk_10 > XXX_chunk_2 This i

Re: Passing yield as a function argument...

2017-05-23 Thread Peter Otten
Christopher Reimer wrote: > Greetings, > > I have two functions that I generalized to be nearly identical except > for one line. One function has a yield statement, the other function > appends to a queue. > > If I rewrite the one line to be a function passed in as an argument -- > i.e., func(da

Re: I need help with making my claculator

2017-05-21 Thread Peter Otten
woo...@gmail.com wrote: > First, you have to have a Tk instance before you do anything else. Take a > look at this example, and then expand upon it to create the calculator > http://python-textbok.readthedocs.io/en/1.0/Introduction_to_GUI_Programming.html While I agree that creating a Tk instan

Re: Python subprocess error win 10

2017-05-19 Thread Peter Otten
Havalda Andrew wrote: [Please answer to the list rather than in private mail. Thank you.] > Yes, the message is exactly like that. I can't really use the command > line, so could you please tell me how should I start it from there with > the -n option? I'm sorry I cannot give you any details as

Re: Python subprocess error win 10

2017-05-19 Thread Peter Otten
Havalda Andrew wrote: > Dear Python team, > > I have encountered a problem with Python 3.6 version, when I open IDLE it > sais: "Subprocess startup error". I attached a photo of it. This is a text-only list, so we will not be able to see any pictures. > And after I > click "Ok" it closes. I ca

Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Peter Otten
Edward Ned Harvey (python) wrote: > I think it's great that for built-in types such as int and str, backward > compatibility of type hinting annotations is baked into python 3.0 to 3.4. > In fact, I *thought* python 3.0 to 3.4 would *ignore* annotations, but it > doesn't... > > I'm struggling to

Re: python-enum34

2017-05-19 Thread Peter Otten
Gene Heskett wrote: > On Friday 19 May 2017 09:32:00 Ethan Furman wrote: > >> On 05/19/2017 04:49 AM, Gene Heskett wrote: >> > I have a need for the subjects function but installed on wheezy. >> > But it is not in the repo's. >> > >> > Is there a solution that doesn't break wheezy? >> >> It's a p

Re: Referring to a module by a string without using eval()

2017-05-17 Thread Peter Otten
jeanbigbo...@gmail.com wrote: > I am trying to write some recursive code to explore the methods, classes, > functions, builtins, etc. of a package all the way down the hierarchy. > > 1) Preliminaries > In [2]: def explore_pkg(pkg): >...: return dir(pkg) >...: > > In [3]: import numpy

Re: Out of memory while reading excel file

2017-05-12 Thread Peter Otten
Pavol Lisy wrote: > On 5/11/17, Peter Otten <__pete...@web.de> wrote: >> Mahmood Naderan via Python-list wrote: >>> between two lines there is a new empty line. In other word, the first >>> line is the first row of excel file. The second line is empty ("\n&

Re: Out of memory while reading excel file

2017-05-11 Thread Peter Otten
Mahmood Naderan via Python-list wrote: > Excuse me, I changed > > csv.writer(outstream) > > to > > csv.writer(outstream, delimiter =' ') > > > It puts space between cells and omits "" around some content. If your data doesn't contain any spaces that's fine. Otherwise you need a way to dist

Re: Out of memory while reading excel file

2017-05-11 Thread Peter Otten
Mahmood Naderan via Python-list wrote: > I wrote this: > > a = np.zeros((p.max_row, p.max_column), dtype=object) > for y, row in enumerate(p.rows): > for cell in row: > print (cell.value) > a[y] = cell.value In the line above you overwrite the row in the numpy array

Re: Out of memory while reading excel file

2017-05-10 Thread Peter Otten
Mahmood Naderan via Python-list wrote: >>a = numpy.zeros((ws.max_row, ws.max_column), dtype=float) >>for y, row in enumerate(ws.rows): >> a[y] = [cell.value for cell in row] > > > > Peter, > > As I used this code, it gave me an error that cannot convert string to > float for the first cell.

Re: Out of memory while reading excel file

2017-05-10 Thread Peter Otten
Mahmood Naderan via Python-list wrote: > Well actually cells are treated as strings and not integer or float > numbers. May I ask why you are using numpy when you are dealing with strings? If you provide a few details about what you are trying to achieve someone may be able to suggest a workabl

Re: Out of memory while reading excel file

2017-05-10 Thread Peter Otten
Mahmood Naderan via Python-list wrote: > Thanks for your reply. The openpyxl part (reading the workbook) works > fine. I printed some debug information and found that when it reaches the > np.array, after some 10 seconds, the memory usage goes high. > > > So, I think numpy is unable to manage th

Re: Out of memory while reading excel file

2017-05-10 Thread Peter Otten
Mahmood Naderan via Python-list wrote: > Hello, > > The following code which uses openpyxl and numpy, fails to read large > Excel (xlsx) files. The file si 20Mb which contains 100K rows and 50 > columns. > > > > W = load_workbook(fname, read_only = True) > > p = W.worksheets[0] > > a=[] > >

Re: Elegant way to merge dicts without overwriting keys?

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

Re: Array column separations for beginners

2017-05-01 Thread Peter Otten
katarin.b...@gmail.com wrote: > Hi again, > > I am trying to subtract the minimum value from all numbers (in one array). > I am using this: > > > (array[:,1] -= np.min(array[:,1]) but I alsways have syntaxerror:invalid > syntax. Do I need some import for this -=? or its something else? THanks

Re: Not understanding itertools.dropwhile()

2017-04-30 Thread Peter Otten
Jason Friedman wrote: > def test_to_start(s): > return "2" in s > > for line in itertools.dropwhile(test_to_start, data.splitlines()): > print(line) It's really all in the names: it could either be for line in dropwhile(test_to_drop, items): ... or for line in dropwhilenot(test_to

Re: "Edit with IDLE" doesn't work any more ?

2017-04-28 Thread Peter Otten
Stefan Ram wrote: > Peter Otten <__pete...@web.de> writes: >>one of the modules in Python's standard library IDLE will try to run with >>your module rather than the one it actually needs. Common candidates are >>code.py or string.py, but there are many mo

Re: "Edit with IDLE" doesn't work any more ?

2017-04-28 Thread Peter Otten
Yip, Kin wrote: > I'm relatively new with Python3 in Windows 7. I'm using now Python 3.6.1. > > Suddenly right-clicking on a .py file and choose "Edit with IDLE" just > doesn't work. > > I've tried to do : > > "c:\program files\python36\pythonw.exe" -m idlelibmypythoncodes.py > > > th

Re: Array column separations for beginners

2017-04-26 Thread Peter Otten
katarin.b...@gmail.com wrote: > Hi, > 1. I would like to ask how can I adjust array.csv like this: > ,,,-00.00014640, 0.08000, > ,,,-00.00014620, 0.0, > ,,,-00.00014600, 0.0, > ,,,-00.00014580, 0.0, > > so I can have in first column -00.00014640 and in seco

Re: Trying to run a program within a python script on multiple output files creating by the same script

2017-04-24 Thread Peter Otten
Unaiza Batool wrote: > i'm confused here as the script gives an error saying simple_to_fasta and > fasta_to_mafft are not defined. You have to write this functions yourself (I gave one example) and make sure that they are defined before the 'for barcode' loop. > How do I combine the part of in

Re: Trying to run a program within a python script on multiple output files creating by the same script

2017-04-24 Thread Peter Otten
ubat...@ufl.edu wrote: > I'm writing a script that takes two command line options, a file > containing barcodes and a file containing sequences. I've managed to > create output files for each barcode with the matching and corresponding > sequences in it. > > For the next part of my script, I'm tr

<    2   3   4   5   6   7   8   9   10   11   >