Re: Help with map python 2

2015-01-04 Thread Sayth Renshaw
Thank you for those solutions so varied. Am going to have a party with them to see what works best for me. Strange is there a way too use lousy comprehension without returning just the matching odd values? Sayth On Mon, 5 Jan 2015 5:06 AM Dan Stromberg wrote: > I'm partial to: > > #!/usr/local

lxml objectify - attribute elements to list.

2015-02-08 Thread Sayth Renshaw
Hi How can I actually access the values of an element with lxml objectify? for example if I had this element in my xml file. I can see all the attributes using this. In [86]: for child in root.getchildren(): print(child.attrib) : {} {'RequestCode': '', 'RequestId': '0'} {} {}

Re: lxml objectify - attribute elements to list.

2015-02-08 Thread Sayth Renshaw
Awesome, thanks so much for the help. Sayth -- https://mail.python.org/mailman/listinfo/python-list

Re: SQLAlchemy - web framework ?

2014-05-12 Thread Sayth Renshaw
I am saying 'do it myself' in that with flask that provide a small base and then all functionality is added by me directly, with the assistance of community modules. Compared to Django whose developers have created an integrated set of defaults with more functionality standard, which is good if yo

beautifulSoup 4.1

2015-03-19 Thread Sayth Renshaw
HI Probably very easy question. If I have a section of html. App Approaching D/N Did nothing DGO Didn't go on DRO Didn't run on H/In Hung in H/Out Hung out I can easily get the class values out. In [69]: soup.find_all("td", class_="abbreviation") Out[69]: [App, D/N, DGO, DRO, H/In, H/Ou

Re: beautifulSoup 4.1

2015-03-20 Thread Sayth Renshaw
On Friday, 20 March 2015 15:20:41 UTC+11, Sayth Renshaw wrote: > HI > > Probably very easy question. > > If I have a section of html. > > > App > Approaching > D/N > Did nothing > DGO > Didn't go on > DRO > Didn't run on > H/In >

Is it normal to cry when given XML?

2015-05-05 Thread Sayth Renshaw
Hi Just checking if the reaction to cry when given XML is normal. I thought maybe I am approaching it all wrong, using lxml largely or some xquery to club it into submission. See the usual goal is just to take the entire XML and push it into a database. or in future experiment with Mongo or

Re: Is it normal to cry when given XML?

2015-05-05 Thread Sayth Renshaw
Adam I am glad to hear it in someways because it's something I have never heard it. For a person relatively new to XML most articles and tutorials demonstrate getting it out to a more "manageable" format. I had been using xbase to inspect the data and query but really ask I want to do was push

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

2015-05-12 Thread Sayth Renshaw
why can't I filter a list based on an itertools condition using dropwhile? This is the docs and the example. https://docs.python.org/3/library/itertools.html#itertools.dropwhile def less_than_10(x): return x < 10 itertools.takewhile(less_than_10, itertools.count()) => 0, 1, 2, 3, 4, 5, 6,

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

2015-05-13 Thread Sayth Renshaw
Thank You for the explanations. I found this counter implementation is really cool and easily adaptable to more solutions. Thanks > Alternatively collections.Counter() supports an arbitrary number of bins... > > >>> import collections > >>> freq = collections.Counter(t[1] for t in stats) > >>>

refer to xpath attributes generally

2015-05-28 Thread Sayth Renshaw
Is there a way to specify to all attributes in xpath? Instead of directly Eg //element/@attr So that you could effectively loop and filter if an element had more than one Attribute? So items = tree.xpath(@all_attrs) >From lxml import etree Tree = etree.Xpath(//root) For k, v in items: C

Re: refer to xpath attributes generally

2015-05-28 Thread Sayth Renshaw
On Friday, 29 May 2015 09:21:01 UTC+10, Sayth Renshaw wrote: > Is there a way to specify to all attributes in xpath? Instead of directly Eg > //element/@attr > > So that you could effectively loop and filter if an element had more than one > Attribute? > > So items =

Should iPython Notebook replace Idle

2015-07-03 Thread Sayth Renshaw
In future releases of Python should ipython Notebooks replace idle as the default tool for new users to learn python? This would as I see it have many benefits? 1. A nicer more usual web interface for new users. 2. Would allow the python documentation and tutorials to be distributed as ipython

Re: Should iPython Notebook replace Idle

2015-07-04 Thread Sayth Renshaw
On Sunday, 5 July 2015 05:16:04 UTC+10, Sturla Molden wrote: > Jason Swails wrote: > > > Everything gets swallowed into Python. I can't imagine this ever happening. > > IPython's successor Jupyter is also an REPL environment for Julia and R, > and many other languages will also be supported (e

Can't call file from another - well correctly

2015-07-04 Thread Sayth Renshaw
I was playing with odo(blaze http://blaze.pydata.org/en/latest/) and wanted to use it with a current script I have been using on the command line. So my 2 scripts are below, I will explain here hopefully to keep question clearer what I have done. Script 2 works for me from the command line as p

Re: Can't call file from another - well correctly

2015-07-04 Thread Sayth Renshaw
On Sunday, 5 July 2015 10:23:17 UTC+10, Sayth Renshaw wrote: > I was playing with odo(blaze http://blaze.pydata.org/en/latest/) and wanted > to use it with a current script I have been using on the command line. > > So my 2 scripts are below, I will explain here hopefully to k

Is there an archive of the gohlke python binaries on windows

2015-11-07 Thread Sayth Renshaw
Just wondering if there is an archive mirror for these binaries available. i was looking for lxml 3.4.1 and the current version is the latest on the page at 3.4.4 being on windows I cannot build it. http://www.lfd.uci.edu/~gohlke/pythonlibs/ Thanks Sayth -- https://mail.python.org/mailman/lis

Re: Is there an archive of the gohlke python binaries on windows

2015-11-08 Thread Sayth Renshaw
On Sunday, 8 November 2015 20:44:02 UTC+11, Chris Warrick wrote: > On 8 November 2015 at 06:55, Sayth Renshaw wrote: > > Just wondering if there is an archive mirror for these binaries available. > > i was looking for lxml 3.4.1 and the current version is the latest on the &g

Re: Is there an archive of the gohlke python binaries on windows

2015-11-08 Thread Sayth Renshaw
On Sunday, 8 November 2015 21:30:59 UTC+11, Laura Creighton wrote: > In a message of Sat, 07 Nov 2015 21:55:32 -0800, Sayth Renshaw writes: > >Just wondering if there is an archive mirror for these binaries available. i > >was looking for lxml 3.4.1 and the current version is th

Python version of Ruby devkit - Advice On library compilation

2015-11-08 Thread Sayth Renshaw
Hi I was wondering if there is a reason that we on windows with python do not have a version of Ruby devkit for python. Is it just for historical reason of life before pip became the package manager and released with python? I can't find the actual post in SO it came off this discussion http

Re: Python version of Ruby devkit - Advice On library compilation

2015-11-08 Thread Sayth Renshaw
This is an exert DevKit Overview The DevKit is a toolkit that makes it easy to build and use native C/C++ extensions such as RDiscount and RedCloth for Ruby on Windows. Because on Windows with python libraries like lxml will fail with a vcvarsall error based on different c++ compilers. Sayth

How to flatten only one sub list of list of lists

2017-02-28 Thread Sayth Renshaw
How can I flatten just a specific sublist of each list in a list of lists? So if I had this data [ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0 $277790.00']], ['46295', 'Dark Eyes', '5', '59', '83', ['6', '4', '1', '0 $105625.00']], ['46295', 'Machinegun Jubs', '6', '53',

Re: How to flatten only one sub list of list of lists

2017-03-01 Thread Sayth Renshaw
> Replace the slice row[index:index+1] with row[index], either by building a > new list or in place: > > >>> def show(data): > ...for item in data: print(item) > ... > >>> def flatten_one(rows, index): > ... return [r[:index] + r[index] + r[index+1:] for r in rows] > ... > >>> def fla

Better way to do this dict comprehesion

2017-03-07 Thread Sayth Renshaw
Hi I have got this dictionary comprehension and it works but how can I do it better? from collections import Counter def find_it(seq): counts = dict(Counter(seq)) a = [(k, v) for k,v in counts.items() if v % 3 == 0] return a[0][0] test_seq = [20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-

Re: Better way to do this dict comprehesion

2017-03-07 Thread Sayth Renshaw
> > But the given problem states there will always only be one number appearing > > an odd number of times given that is there a neater way to get the answer? > > Take a step back for a moment. Are you trying to find something that > appears an odd number of times, or a number of times that coun

Re: Better way to do this dict comprehesion

2017-03-08 Thread Sayth Renshaw
Peter I really like this The complete code: >>> from collections import Counter >>> def find_it(seq): ... [result] = [k for k, v in Counter(seq).items() if v % 3 == 0] ... return result ... >>> test_seq = [20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5] >>> find_it(test_seq) But what ma

Create a list of dates for same day of week in a year

2017-06-27 Thread Sayth Renshaw
Afternoon Is there an obvious method I am missing in creating a list of dates? I want to get a list of each Saturday and each Wednesday for the year 2017. It seems and maybe this is where I am wrong but doesn't the datetime library already know the dates if yes is there an easy way to query it?

Re: Create a list of dates for same day of week in a year

2017-06-27 Thread Sayth Renshaw
> > Is there an obvious method I am missing in creating a list of dates? I want > > to get a list of each Saturday and each Wednesday for the year 2017. > > > > It seems and maybe this is where I am wrong but doesn't the datetime > > library already know the dates if yes is there an easy way to

Re: Create a list of dates for same day of week in a year

2017-06-28 Thread Sayth Renshaw
> > Thoughts or examples? > > > dateutil.rrule is what you may use e.g. > > > In [38]: from dateutil import rrule > > In [39]: from datetime import date

Generator - Provide parameters to url - requests

2017-07-04 Thread Sayth Renshaw
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 list of dates for the first 210 days of this ye

Re: Generator - Provide parameters to url - requests

2017-07-05 Thread Sayth Renshaw
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) Reading your code this sounds to simple :-). def dates(first, numdays): # generate datetime objects for extra clarity # note ther

Test 0 and false since false is 0

2017-07-06 Thread Sayth Renshaw
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,0,0,0,0,0,0,0,0,0,0] However if I f

Re: Test 0 and false since false is 0

2017-07-06 Thread Sayth Renshaw
On Friday, 7 July 2017 12:46:51 UTC+10, Rick Johnson wrote: > On Thursday, July 6, 2017 at 9:29:29 PM UTC-5, 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 > &g

Re: Test 0 and false since false is 0

2017-07-08 Thread Sayth Renshaw
> Another option is to test for type(value) == int: > > >>> before = ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0, > {},0,0,9] > >>> wanted = ["a","b",None,"c","d",1,False,1,3,[],1,9, > {},9,0,0,0,0,0,0,0,0,0,0] > >>> after = sorted(before, key=lambda x: x == 0 and type(x) == int) > >

Why is my class undefined?

2017-08-16 Thread Sayth Renshaw
Morning I haven't ventured into classes much before. When trying to follow some examples and create my own classes in a jupyter notebook I receive an error that the class is undefined. So I created for practise a frog class class frog(object): def __init__(self, ftype, word):

Re: Why is my class undefined?

2017-08-16 Thread Sayth Renshaw
On Thursday, 17 August 2017 09:03:59 UTC+10, Ian wrote: wrote: > > Morning > > > > I haven't ventured into classes much before. When trying to follow some > > examples and create my own classes in a jupyter notebook I receive an error > > that the class is undefined. > > > > So I created for pr

<    1   2   3