l it has enough.
So your opener returns as soon as the request is sent, and read() blocks
if it doesn't have enough data to handle your request.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
l it has enough.
So your opener returns as soon as the request is sent, and read() blocks
if it doesn't have enough data to handle your request.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 2010-04-17 at 00:37 +1000, Lie Ryan wrote:
> On 04/16/10 23:41, J wrote:
> > So, what I'm curious about, is there a list comprehension or other
> > means to reduce that to a single line?
>
> from itertools import chain
> def printout(*info):
> print '\n'.join(map(str, chain(*info)))
>
On Fri, 2010-04-16 at 09:50 -0700, Dave W. wrote:
> >>> old_print = __builtins__.print
> >>> __builtins__.print = printhook
> >>> yield
> >>> __builtins__.print = old_print
> >
> >> I'm pretty sure this is semantically equivalent to my original
> >> code, but I gave it a try anyway.
You need to know what your input data actually looks like, and the best
thing for that is a little bit of formatting. I bet you can figure out
the problem yourself, once you see the structure of your data more
clearly. I've reformatted the JSON for you to help out.
On Fri, 2010-04-23 at 07:20
our columns can have spaces within them, or are separated in other
ways, you'll need something else.
Cheers,
Cliff
On Mon, 2010-04-26 at 14:50 +, mannu jha wrote:
> Dear all,
>
> I am new in python, can anyone help me that how can I select two
> column out of 6 column from
That's kind of a nifty idea. However, python is currently under a
syntax moratorium. No syntax changes will be accepted for at least 24
months starting from the release date of Python 3.1. See more details
here: http://www.python.org/dev/peps/pep-3003/
Cheers,
Cliff
On Fri, 2010-04-30
On Fri, 2010-05-07 at 15:36 -0400, William R. Wing wrote:
>
> Maybe I should have been more explicit. The first line in the Python
> file is:
>
>
> #!/usr/bin/env Python (alternatively #!/usr/bin/Python - same results
> either way).
>
python should be lowercased when referring to the name of
On Fri, 2010-05-07 at 15:36 -0400, William R. Wing wrote:
>
> Maybe I should have been more explicit. The first line in the Python
> file is:
>
>
> #!/usr/bin/env Python (alternatively #!/usr/bin/Python - same results
> either way).
>
python should be lowercased when referring to the name of
on of your `def
test_T1(self):` line is off by one column, relative to pass, and by
three columns relative to the other methods.
Cheers,
Cliff
On Mon, 2010-05-10 at 13:38 +0100, John Maclean wrote:
> hi,
>
> can some one explain why the __first__ test is not being run?
>
> #
Don't use regular expressions for that.
s = '0x340x5A0x9B0xBA'
return '0x' + ''.join(s.split('0x'))
On Tue, 2010-05-18 at 06:48 -0700, Back9 wrote:
> Hi,
>
> I have a string like this:
> 0x340x5A0x9B0xBA
> I want to extract 0x from the string but the first one.
>
> How I can use re for this cas
in s)
However, if you need an arbitrary number of zeros preserved, you're out
of luck. They are semantically meaningless in python. (Is semantically
meaningless redundant?)
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
+1
Options are options, arguments are arguments. An optional argument is
not an option. It is an argument that can be left out.
On Wed, 2010-06-02 at 12:42 +0200, Antoine Pitrou wrote:
> On Wed, 2 Jun 2010 01:49:18 -0700 (PDT)
> Michele Simionato wrote:
> >
> > Notice that optparse is bas
On Thu, 2010-06-17 at 16:36 +, Deadly Dirk wrote:
> I cannot get right the super() function:
> Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22)
> [GCC 4.4.1] on linux2
> Type "copyright", "credits" or "license()" for more information.
> No Subprocess
> >>> class P:
> def __init_
; But I think this is an obvious enough extension to the __getitem__ protocol
> that I for one would vote +1 on it being added to Python sequence objects
> (lists, tuples, strings).
>
I'd be +0. It won't change my life, but it seems like a decent idea.
>
> --
> Steven
>
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
ple from doing a 'from package import *'. However, example code
should always include relevant imports.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 2009-06-22 at 14:57 +0200, Jean-Michel Pichavant wrote:
> J. Cliff Dyer wrote:
> > On Wed, 2009-06-17 at 14:13 +0200, Jean-Michel Pichavant wrote:
> >
> >> On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote:
> >>
> >>>> What&
Have you looked at the JSON module?
On Mon, 2009-06-22 at 21:17 +0800, Jim Qiu wrote:
> Hi all,
>
> I have a object list list this:
>
> from bots.botsconfig import *
> from D96Arecords import recorddefs
> from edifactsyntax3 import syntax
>
> structure=[
> {ID:'UNH',MIN:1,MAX:1,LEVEL:[
> {I
trace which will help you (or us) debug the problem. If
you don't show us this information, we can't tell you what's going
wrong. It will tell you (in ways that are crystal clear once you have a
bit of practice reading them) exactly what went wrong.
Can you show your code, as well as the complete error message you are
receiving?
My suggestions here, are essentially a paraphrasing of Eric Raymond's
essay, "How to Ask Smart Questions." It is freely available on the web,
and easily found via google. I recommend reading that, in order to get
the most mileage out this news group.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
were just defs. I changed the short defs
> into sub-classes out of desperation, since I don't understand why the
> main script is not recognizing functions that are in the same file.
>
> First is the shell input/output, then "ParseWork.py", the entire text
&g
On Mon, 2009-06-22 at 22:52 +, Peter Billam wrote:
> I wonder on what grounds PEP8
> says "The preferred place to break around a binary operator is
> *after* the operator" ?
> Perhaps it's just the "continutation marker" rationale?
>
> Regards, Peter
>
> --
> Peter Billam www.pjb.com
On Wed, 2009-06-24 at 09:17 -0700, Bryan wrote:
> Given a class:
>
> class Foo(object):
> pass
>
> How can I get the name "Foo" without having an instance of the class?
>
> str(Foo) gives me more than just the name Foo. "__main__.Account"
> Foo.__class__.__name__ gives me "type"
>
> I don
, I'm just getting my feet wet, and I'll try not to ask too many
> silly questions!
>
> First impressions are: (1) Python seems both elegant and practical;
> and (2) Beazley seems a pleasantly unfussy introduction for someone
> with at least a little programming exper
On Tue, 2009-06-30 at 13:24 -0700, Beni Cherniavsky wrote:
> On Jun 24, 11:40 pm, "J. Cliff Dyer" wrote:
> > Also note that you can iterate over a file several times:
> >
> > f = open('foo.txt')
> > for line in f:
> > print line[0] # print
On Wed, 2009-07-01 at 17:19 +1200, Lawrence D'Oliveiro wrote:
> In message , J. Cliff
> Dyer wrote:
>
> > If the lines got separated, a leading + could disappear into its line
> > without any errors showing up. A trailing + would raise a syntax error.
>
> Unle
Bearophile wins! (This only times the loop itself. It doesn't check
for __len__)
summer:5
0:00:00.51
bearophile:5
0:00:00.09
summer:50
0:00:00.30
bearophile:50
0:00:00.13
summer:500
0:00:00.77
bearophile:500
0:00:00.53
summer:5000
0:00:00.000575
bearophile:5000
0:00:00.00
On Thu, 2009-07-09 at 18:10 +, Steven D'Aprano wrote:
> If programming is symbol manipulation, then you should remember that
> the
> user interface is also symbol manipulation, and it is a MUCH harder
> problem than databases, sorting, searching, and all the other
> problems
> you learn abou
pening more
clearly. And it protects you if another caller (even one internal to
the class) calls it with a different set of assumptions.
At minimum, I think there's a heavy burden on an author to justify the
use of AssertionErrors rather than other kinds of Exceptions.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2009-07-10 at 11:57 -0500, Robert Kern wrote:
> On 2009-07-10 11:50, J. Cliff Dyer wrote:
> > On Fri, 2009-07-10 at 02:57 +, Steven D'Aprano wrote:
> >> On Fri, 10 Jul 2009 03:28:04 +0100, Nobody wrote:
> >>
> >>> On Thu, 09 Jul
On Thu, 2009-07-09 at 13:53 +, Friðrik Már Jónsson wrote:
> Look at:
>
>len = len(text)
>
> You're overriding `len` (a built-in method), with an integer
> (`len(text)`). You then call:
>
>for i in range(len(fields)):
>
> But `len` is no longer a callable, but merely an integer.
>
def __init__(self, color):
self.color = color
class Sign(object):
def __init__(self, inscription):
self.inscription = str(housenumber)
(Something like that)
Cheers,
Cliff
> Well, so far, so good. Now, what I'd like to achive is that the text of
> the "sign"
plit()
>>>
>>> if data[1] not in thingies:
>>> # group data by data[1]
>>> thingies[data[1]] = {}
>>>
>>> thingies[data[1]][data[3]] = data[5]
Step two, extract the data from the list:
>>> for key, data in thingies.items():
>>> print key,
>>> for entry in data
>>> print '%s = %s' % (entry, data[entry]),
This should do what you want, minus some formatting issues.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
rity, a.k.a. don't you have something better to do?
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 2009-07-20 at 12:26 -0700, Phillip B Oldham wrote:
> On Jul 20, 6:08 pm, Duncan Booth wrote:
> > The main reason why you need both lists and tuples is that because a tuple
> > of immutable objects is itself immutable you can use it as a dictionary
> > key.
>
> Really? That sounds interest
, but it is not. You are proposing changing the parsing
rules, which completely changes the scope of what is possible and what
isn't with python syntax. All to solve a problem that, so far, hasn't
been proven to exist in anything other than a speculative way.
You're trying to turn an ocean liner around because you left your
sunscreen on the dock.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
Learn the pythonic workaround of using
None in your parameters whenever you want a default empty list, and
don't let it bother you too much. Overall, python is a remarkably well
designed language. This is one of the relatively rare warts that crept
in because it enables a broader cleanliness of design.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
u want your class to be able to do,
and what the API will be for performing each of those functions. Then
you should be able to begin implementing it, or at least come up with
some more specific questions.
> Thank you very much,
> Krishna
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 2009-08-19 at 15:56 +0200, Bruno Desthuilliers wrote:
> Terry Reedy a écrit :
> > Robert Dailey wrote:
> >
> >> I'm using Python 2.6. And using the legacy syntax in the lambda does
> >> not work either. I want to avoid using a def if possible. Thanks.
> >
> > In Python, writing
> >
> > n
tion as I think, and explain a
clean, elegant implementation for this, many of my concerns would be
alleviated, and I would change my -1 to a -0.
Cheers,
Cliff
On Mon, 2009-08-24 at 00:01 +1000, Ben Finney wrote:
> garabik-news-2005...@kassiopeia.juls.savba.sk writes:
> > Why not
sum totals of nums"""
# ???
list_of_numbers = [1, 24, 34, 28, 4, 1]
cumulative_sum = summifier(list_of_numbers)
assert(cumulative_sum == [1, 25, 59, 87, 91, 92])
If you can come up with the summifier function, you're all set. I gotta
say, though, this smells like homework.
301 - 340 of 340 matches
Mail list logo