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
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).
> >
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
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).
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
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
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
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
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
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
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
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
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:
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
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
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
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
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'
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
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
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
,
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
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
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
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
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
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
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
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]
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
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
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
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
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
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?
&
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
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
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
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
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
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
201 - 241 of 241 matches
Mail list logo