Re: Eleganz way to get rid of \n

2008-09-01 Thread josh logan
On Sep 1, 9:25 am, Hans Müller <[EMAIL PROTECTED]> wrote: > Hello, > > I'm quite often using this construct: > > for l in open("file", "r"): >         do something > > here, l contains the \n or \r\n on windows at the end. > I get rid of it this way: > > for l in open("file", "r"): >         while

Re: SAXReaderNotAvailble: No parsers found

2008-09-01 Thread josh logan
On Aug 30, 8:59 pm, josh logan <[EMAIL PROTECTED]> wrote: > > Vincent Yau <[EMAIL PROTECTED]> writes: > > > I am trying to use Python SAX API to parse XML files.  I do see expat.py > > > somewhere underneath my Python 2.1.1 installation (on Solaris). > >

Re: Eleganz way to get rid of \n

2008-09-01 Thread josh logan
On Sep 1, 9:41 am, Wojtek Walczak <[EMAIL PROTECTED]> wrote: > On Mon, 01 Sep 2008 15:25:03 +0200, Hans Müller wrote: > > I'm quite often using this construct: > > > for l in open("file", "r"): > >    do something > > Has someone a better solution ? > > The most general would be to use rstrip() wit

Re: String/Number Conversion

2008-09-06 Thread josh logan
On Sep 6, 5:04 pm, Andreas Hofmann <[EMAIL PROTECTED]> wrote: > Hello Folks! > > I've got a little problem here, which which really creeps me out at the > moment. > I've got some strings, which only contain numbers plus eventually one > character as si-postfix (k for kilo, m for mega, g for giga).

Question about sorted in Python 3.0rc1

2008-09-21 Thread josh logan
Hello, I have 2 questions. Say I have this class: class Player(object): def __init__(self, fname, lname, score): self.score = score self.fname = fname self.lname = lname def __cmp__(self, other): return (-cmp(self.score, other.score) or cmp

Re: Question about sorted in Python 3.0rc1

2008-09-22 Thread josh logan
On Sep 22, 3:41 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On 22 Sep, 04:05, josh logan <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > I have 2 questions. Say I have this class: > > > class Player(object): > >     def __init__(self

Re: Question about sorted in Python 3.0rc1

2008-09-22 Thread josh logan
On Sep 22, 7:32 am, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > josh logan  <[EMAIL PROTECTED]> wrote: > > >sorted(P) # throws TypeError: unorderable types Player() < Player() > > >The sorted function works when I define __lt__. > >I must be misreading

Re: Question about sorted in Python 3.0rc1

2008-09-22 Thread josh logan
On Sep 22, 9:29 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > josh logan <[EMAIL PROTECTED]> writes: > > sorted(P) # throws TypeError: unorderable types Player() < Player() > > > The sorted function works when I define __lt__. > > I must be misreading th

Re: assert type([]) == type(())

2010-01-02 Thread Josh Holland
t;In loop body" You won't see anything printed. OTOH, look at this one: for x in [[]]: # a list containing an empty list assert type(x) == type(()) That will raise the AssertionError as expected. -- Josh "dutchie" Holland http://joshh.co.uk http://twitter.com/jshholl

Re: Compiling Python 2.7a2 on AIX6.1 (also pycrypto)

2010-01-13 Thread Josh Volchko
On Jan 13, 6:13 am, knipknap wrote: > Hi, > > I have just successfully compiled Python 2.7a2 on AIX6.1, using the > IBM XL compiler (no gcc). I am documenting this here in case somebody > needs it: > > ### > First, I installed the following dependencies: > > 1. readline-6.1; > 2. tcl8.4.19/uni

Re: Wrap a function

2010-01-28 Thread Josh Holland
On 2010-01-28, Joan Miller wrote: > I've to call to many functions with the format: > >>>> run("cmd") Check the docs on os.system(). -- Josh "dutchie" Holland http://www.joshh.co.uk/ http://twitter.com/jshholland http://identi.ca/jshholland -- htt

Re: Great example of a python module/package following up to date conventions.

2010-01-28 Thread Josh Holland
On 2010-01-28, Big Stu wrote: > I'm hoping someone on here can point me to an example of a python > package that is a great example of how to put it all together. I'm > hoping for example code that demonstrates: Surely most of the Standard Library should satisfy all your requ

Re: Great example of a python module/package following up to date conventions.

2010-01-28 Thread Josh Holland
On 2010-01-28, exar...@twistedmatrix.com wrote: > Have you actually looked at any of the standard library? Not recently or in depth, no. I would have thought that it would be of high quality. I must have been mistaken. -- Josh "dutchie" Holland http://www.joshh.co.uk/ http:

MediaWiki to RTF/Word/PDF

2010-02-17 Thread Josh English
ndows here. Has anyone heard of a module that parses wiki markup and transforms it? Or am I looking at XSLT? Josh -- http://mail.python.org/mailman/listinfo/python-list

Dynamic Class Creation

2010-03-15 Thread Josh English
s and have it run? I have had a few solutions work where I had a class with three methods (get_code, get_tier, get_mail) but they all return the same value, not the individual values. Josh English -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime string conversion error

2010-03-16 Thread Josh English
teError: 'module' object has no attribute 'day_abbr' err... what? Is this an old weirdness I don't remember from the 2.5 series? I can select dates in the calendar, but nothing dismisses it but the close box. Josh English Incredibly Confused -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic Class Creation

2010-03-16 Thread Josh English
a bit of a bear. In short, I have to figure out the whole object interface to the XML and how I want that to work. Thanks for the suggestion. It is undeniably clever. Josh -- http://mail.python.org/mailman/listinfo/python-list

Multiple instances and wrong parental links

2011-01-01 Thread Josh English
p.__name__= checker.title() return Wrap if __name__ == '__main__': Dude = MakeWrapper('Dude') print Dude d1 = Dude('Josh') print d1, d1.stuff # creating the second instance changes the behavior of the subclass d2 = Dude('Ben'

Re: Multiple instances and wrong parental links

2011-01-02 Thread Josh English
returns. (yeah, it's complicated). This is the same project I asked about at https://groups.google.com/d/topic/comp.lang.python/K9PinAbuCJk/discussion. That's why this simple sample looks so incredibly complicated. I'm coding on the far edge of my learning curve. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple instances and wrong parental links

2011-01-02 Thread Josh English
always goes back to the original XML element (an elementree.Element object in this case.) Insanely complicated and just beyond my comprehension, I fear. I haven't found an easier way to wrap an object around these XML validators of mine. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Which coding style is better? public API or private method inside class definition

2011-01-04 Thread Josh English
r to change one thing once instead of one thing twice. In general, I try to code in a way that will reduce the number of places I'll have to change or refactor. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem inserting an element where I want it using lxml

2011-01-04 Thread Josh English
, new_child) new_child.text=str(text) return new_child I don't think you need to count the instances of the bingo node (unless you want to prevent too many from being added in). Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem inserting an element where I want it using lxml

2011-01-04 Thread Josh English
Oh, and I usually use a separate function to indent my xml for readability when I need to actually look at the xml. It's easier than trying to change the element in situ and make it look nice. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Python use growing fast

2011-01-11 Thread Josh Benner
his article ... http://neopythonic.blogspot.com/2009/11/python-in-scientific-world.html ... the answer is python. Josh Benner -- http://mail.python.org/mailman/listinfo/python-list

Re: Remove whitespaces and line breaks in a XML file

2011-02-07 Thread Josh English
I found the code posted at http://infix.se/2007/02/06/gentlemen-indent-your-xml quite helpful in turning my xml into human-readable structures. It works best for XML-Data. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: frequency of values in a field

2011-02-08 Thread Josh English
sure what you want get_last_two_digits to look like from your post, or how you would get the long_list, which is just an iterator through your records. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: frequency of values in a field

2011-02-09 Thread Josh English
mports whatsoever," the code would look like: counts = {} for thing in long_list: key = make_key(thing) if key in counts: counts[key] += 1 else: counts[key] = 1 But using a few imports is cleaner and just as easy to troubleshoot. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: frequency of values in a field

2011-02-09 Thread Josh English
is a list with the records you want, or an iterator that goes through the records. The get_key function does whatever you need it to do to get the key by which you are counting. Andreas offers a nice pythonic solution in this thread. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Josh Benner
On Fri, Feb 11, 2011 at 1:51 PM, Dan Stromberg wrote: > On Fri, Feb 11, 2011 at 1:43 PM, André Roberge > wrote: > > On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: > >> Hi, > >> > >> I'm looking for a pythonic way to translate this short Ruby code : > >> t=[6,7,8,6,7,9,8,4,3,6,7]

Re: Python Line Intersection

2010-04-09 Thread Josh English
On Apr 9, 8:36 am, Emile van Sebille wrote: > On 4/9/2010 8:04 AM Peyman Askari said... > > > Hello > > > This is partly Python related, although it might end up being more math > > related. > > > I am using PyGTK (GUI builder for Python) and I need to find the > > intersection point for two lin

Namespace problem?

2010-07-01 Thread Josh English
I have a script that generates a report from a bunch of data I've been collecting for the past year. I ran the script, successfully, for several weeks on test runs and creating more detailed reports. Today (back from vacation) and the script doesn't work. It's giving me a name error. I'm running

Re: Namespace problem?

2010-07-01 Thread Josh English
On Jul 1, 2:50 pm, Matt McCredie wrote: > > That doesn't give me enough information to help you with the issue. In general > you need to provide enough code to reproduce the failure, not some modified > version that doesn't fail. My guess is that the "if True" is actually > something > else, and

Re: Namespace problem?

2010-07-02 Thread Josh English
he clue. I added one parameter to one function elsewhere and the thing seems to be working again. Thanks for the help. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: pyxser-1.5r --- Python Object to XML serializer/deserializer

2010-08-26 Thread Josh English
It looks nice, but it's a shame it doesn't work on Windows. This could solve a lot of the problems I'm running into in my own attempt to build a python Class implementation of an XML Validation object. -- http://mail.python.org/mailman/listinfo/python-list

Re: pyxser-1.5r --- Python Object to XML serializer/deserializer

2010-08-28 Thread Josh English
On Aug 26, 10:02 pm, Stefan Behnel wrote: > Josh English, 27.08.2010 01:30: > > > solve a lot of the problems I'm running into in my own attempt to > > build a python Class implementation of an XML Validation object. > > How would object serialisation help here? &

Re: Tag parsing in python

2010-08-28 Thread Josh English
ds qualifying the other keywords so on.. > So I would like to know the python way of doing this. Is there any > library already existing for making my work easier. ? > > ~ > Agnibhu Have you looked at pyparsing? (http://pyparsing.wikispaces.com/) It may be possible to use that library to do this. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: palindrome iteration

2010-08-28 Thread Josh English
rsed") print "is_palindrome_reversed", min(t.repeat()) The results: is_palindrome_recursive 6.32680866827 is_palindrome_slice 1.23618350114 is_palindrome_list 4.60104846653 is_palindrome_reversed 5.99355296513 The slice method is uglier, I have to admit, but it's the fastest of these four on my machine. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: palindrome iteration

2010-08-29 Thread Josh English
I have no idea. That's a lower level of programming than I'm used to dealing with. Josh (I also only tried the one value. Had I tried with other strings that would fail the test, some functions may have performed better.) On Aug 29, 2:19 am, Matteo Landi wrote: > Well, I tried

HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
Hello, I wanted to use python to scrub an html file for score data, but I'm having trouble. I'm using HTMLParser, and the parsing seems to fizzle out around line 192 or so. None of the event functions are being called anymore (handle_starttag, handle_endtag, etc.) and I don't understand why, becau

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
On Oct 24, 4:36 pm, josh logan wrote: > Hello, > > I wanted to use python to scrub an html file for score data, but I'm > having trouble. > I'm using HTMLParser, and the parsing seems to fizzle out around line > 192 or so. None of the event functions are being calle

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
On Oct 24, 4:38 pm, josh logan wrote: > On Oct 24, 4:36 pm, josh logan wrote: > > > > > > > Hello, > > > I wanted to use python to scrub an html file for score data, but I'm > > having trouble. > > I'm using HTMLParser, and the parsing see

<    1   2   3