On Mon, 2009-01-26 at 09:52 -0800, Paul McGuire wrote:
> On Jan 26, 10:54 am, "J. Cliff Dyer" wrote:
> > On Fri, 2009-01-23 at 20:25 -0800, Paul McGuire wrote:
> > > Want to change the type/behavior of an object from class A to class
> > > B? H
On Mon, 2009-01-26 at 12:37 -0800, Paul McGuire wrote:
> On Jan 26, 2:06 pm, "J. Cliff Dyer" wrote:
> >
> > Thanks. That makes sense. But your example creates a new instance of
> > the new class each time, rather than changing the class of a persistent
> >
On Fri, 2009-01-23 at 19:31 -0500, Benjamin Kaplan wrote:
>
>
> On Fri, Jan 23, 2009 at 7:28 PM, Gary Herron
> wrote:
> Steven D'Aprano wrote:
> > On Fri, 23 Jan 2009 14:58:34 -0500, Gerald Britton wrote:
> >
> >
> >> Hi -- Some time ago I ran across a co
r which quote character is being used, and require
those characters to be escaped, and not the other (but then does "te
\'st" render as r"te'st" or r"te\'st"?) and only close the string when
the appropriate quote is found.
Not an impossible task, but certainly more complex than the current
parsing requirements for JSON.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
does :))
x = Beep
Does that assign the name x to the Beep object or does it assign the
result of a Beep call to x?
There's no virtue in making ridiculously simple things even simpler if
it makes the interesting things impossible.
def tone_sequence(sound):
sequence = DialTone.follo
On Tue, 2009-02-03 at 08:33 -0700, Joe Strout wrote:
> J. Cliff Dyer wrote:
>
> > But what if your language allows functions to be used as first class
> > objects? (Mine does :))
> >
> > x = Beep
> >
> > Does that assign the name x to the Beep ob
nary with 2.5 if you do install it yourself. Instead, install
it to python2.5, and set the shebang line (#!) on your scripts to point
to /usr/local/bin/python2.5 (or wherever you install it).
Cheers,
Cliff
On Mon, 2009-02-16 at 07:28 -0800, Germán Gutiérrez wrote:
> Hi,
>
> I ne
On Mon, 2009-02-16 at 00:28 -0500, Nicolas Dandrimont wrote:
> * pyt...@bdurham.com [2009-02-16 00:17:37 -0500]:
>
> > I need to test strings to determine if one of a list of chars is
> > in the string. A simple example would be to test strings to
> > determine if they have a vowel (aeiouAEIOU)
ow wxpython works in this regard.
So:
s = u"Matični broj" # instead of "Matični broj"
text = wx.StaticText(self, -1, s,(0,100))
# or if that doesn't work try this:
#text = wx.StaticText(self, -1, s.encode('utf-8'), (0,100))
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 2009-02-17 at 06:15 -0800, 一首诗 wrote:
> Thanks for your reply.
>
> With sqlalchemy, an mapped must living in a session, you have no way
> to disconnect it with its session.
>
> For example :
>
> #-
> user = session.query(User).first()
> session.expung
n
> the Python source I would start for implementing such an idea?
>
> Thanks
>
> Ken
For the reasons already stated, I think it's probably a bad idea to
enforce this at compile time. I think it's a great idea to make sure
that this information is present in all your code, but unless you want
to see useless stubs, the correct time to enforce this is at commit
time. Don't accept any improperly documented patches.
Syntax is not enough to ensure what you want to ensure. The semantics
have to be right as well.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 2008-11-29 at 13:31 -0800, Lie wrote:
> pdb and logging is too much for beginners, which most likely does not
> yet understand the workings of the debugger and logger (and pdb's many
> quirks). Don't forget that we're all beginners once. Python's learning
> curve shouldn't raise with time,
as just a thought.
>
> Ken
>
>
>
> On Tue, Dec 2, 2008 at 3:03 AM, J. Cliff Dyer <[EMAIL PROTECTED]>
> wrote:
>
>
> On Sun, 2008-11-30 at 16:27 -0800, [EMAIL PROTECTED]
> wrote:
> > I've been thinking abo
ith the four line conditional import are
all you need for each import, and best of all, it's completely hidden
from your users, until they want to migrate to python 2.6, and then all
they have to do is change all references to Foo.as to point to
Foo.as_type. But by observing step 1 above, th
file("/dev/tty0")
nonstdout.write("\a")
nonstdout.flush()
(same permissions caveats apply)
On the other hand, the OP was looking for a cross-platform solution. I
don't think Windows has a /dev/tty0, but I don't work on windows, so I
can't help with cross platform issues.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
m, encode them to your favorite encoding. Better yet, use
codecs.open(file, encoding='utf-16') in place of open(file), pass an
encoding argument, and be done with it.
When you create strings in your code, always use u'stuff' rather than
'stuff' and ur'stu\f
On Thu, 2008-12-11 at 13:44 -0600, Kirk Strauser wrote:
> At 2008-12-11T17:24:44Z, rdmur...@bitdance.com writes:
>
> > >>> ' ab c \r\n'.rstrip('\r\n')
> > ' ab c '
> > >>> ' ab c \n'.rstrip('\r\n')
> > ' ab c '
> > >>> ' ab c '.rstrip('\r\n')
> > ' ab c '
>
>
*I* know about the precedence rule, but a newbie or a tired programmer
> might not. He might want to reverse the truth value of argument b but
> instead has just reversed the whole expression. Probably in a slightly
> convoluted code like this:
>
> if a is not(b and c):
>...
>
A newbie might make that mistake, but a tired programmer would be
testing for equality rather than identity in that case, and if she
weren't, she'd have to fix her code in the morning anyway.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
if you can.
>
> - Hendrik
>
It's a good thing *its* got that heat-sink sieve-
its -> it has
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 2008-12-17 at 06:28 -0800, aka wrote:
> Hi John, thanks.
> You're right, I didn't past the method header because I thought it
> didn't matter when the input filename is hardcoded.
> The try/except isn't very helpful indeed so I commented it out.
> You're right I wrongly referred to the Uni
On Thu, 2008-12-18 at 11:52 -0800, eric wrote:
> On Dec 18, 8:37 pm, collin.da...@gmail.com wrote:
> > I am trying to write a simple application to factor polynomials. I
> > wrote (simple) raw_input lines to collect the a, b, and c values from
> > the user, but I dont know how to implement the qua
object
chooses to recursively call __str__ on its elements, it is free to do
so, but since that causes ambiguity (as many people have pointed out),
python has (wisely) chosen to use repr instead. If I wanted to
implement a list-like class that doesn't show it's elements at all when
printed, but instead shows its length, I am free to do so.
For example:
>>> hl = HiddenList(1,2,3)
>>> hl
>>> hl[1]
2
(Implementation of HiddenList left as an exercise for the reader.)
If you want to implement a list-like object that returns the str of its
elements, go right ahead, or implement a function that digs into
containers and creates its own list representation for them. But that's
not how python works by default, nor should it be, for reasons already
explained by others.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 2009-01-05 at 11:49 -0800, TechieInsights wrote:
> Ok I have read all of the tutorials and documents I could find. I am
> running Python 2.6 on windows. The problem I am having with packages
> is that they don't show up!
>
> Simple example of what isn't working...
> Structure-
>
> pyte
On Tue, 2009-01-06 at 10:36 -0700, Joe Strout wrote:
> I've actually been rather frustrated by Python lately.
OFF TOPIC!!!
Please try to stay within the subject presented by the subject header.
The subject in question is "python is great," not "python is
frustrating."
Speaking of which, python
On Tue, 2009-01-06 at 12:34 -0800, akineko wrote:
> Hello everyone,
>
> I'm creating a class which is subclassed from list (Bulit-in type).
>
> It works great.
> However, I'm having a hard time finding a way to set a new value to
> the object (within the class).
> There are methods that alter a
eld(Field):
def __new__(cls, a):
return object.__new__(cls, a)
Is there a cleaner way to do this? The main problem is that
Field.__new__ gets in the way of properly constructing the subclasses
once I've used it to select the proper subclass in the first place.
Cheers,
Cliff
--
Oook,
J. Cliff Dyer
Carolina Digital Library and Archives
UNC Chapel Hill
--
http://mail.python.org/mailman/listinfo/python-list
Thanks for the solutions everyone! I'm not sure which I'll end up
using, but I think I've got a better grasp of the problem now.
Cool stuff.
Cheers,
Cliff
On Thu, 2009-01-08 at 06:52 -0800, Paul McGuire wrote:
> On Jan 7, 12:00 pm, Paul McGuire wrote:
> > On Jan 7,
On Fri, 2009-01-09 at 13:13 -0500, Steve Holden wrote:
> Aivar Annamaa wrote:
> >> As was recently pointed out in a nearly identical thread, the -3
> >> switch only points out problems that the 2to3 converter tool can't
> >> automatically fix. Changing print to print() on the other hand is
> >> ea
On Tue, 2008-10-21 at 09:34 -0400, Philip Semanchuk wrote:
> On Oct 21, 2008, at 9:05 AM, Amie wrote:
>
> > Hi,
> >
> > what does is the meaning of this error: int object is unsubscriptable.
> > This is the code that I have written that seems to give me that:
> >
> > def render_sideMenu(self, ctx
tring.split(substr))
location_lines = [replace_by_location(x, 'CHANGED', 15, 22) for x in lines]
match_lines = [replace_by_match(x, '199', 'CHANGED') for x in lines]
print location_lines
print match_lines
Cheers,
Cliff
> #My Current Code
>
> #
> ... self._count += 1
> ... return " ".join("spam" for _ in xrange(self._count))
> ...
> ... __call__ = spam
> ...
Interesting. I hadn't thought of making __call__ a synonym for an
existing method. I think I like that, but I'm not quite sure. There's
something that nags at me about having two ways to do the same thing,
but I like giving the method a more descriptive name than __call__.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
._count = counter_start
... def __call__(self):
... self._count += 1
... return ("spam " * self._count).rstrip()
...
>>> foo = Foo()
>>> foo()
'spam'
>>> foo()
'spam spam'
>>>
Essentially, this has the same behavior as the other two. But it looks
cleaner, and you don't have to worry about coupling separate functions,
or refering to a function by name within itself (because you have self
to work with). But the "object" semantics are essentially the same, and
state is just as legitimately preserved on a function object as a Foo
object.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 2008-11-17 at 14:52 +, Darren Mansell wrote:
> Hi.
>
> I'm relatively new to python so please be gentle :)
>
> I'm trying to write a £ symbol to an MS SQL server using pymsssql . This
> works but when selecting the data back (e.g. using SQL management
> studio) the £ symbol is repla
lude æ.
So what you are seeing is best thought of as two garbage characters, one
of which happens (by coincidence only) to be the same as your original
character. If you decode the bytes returned properly (as UTF-8), you
will get the bytes you put in, for all characters.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 2009-02-25 at 15:54 -0500, Shawn Milochik wrote:
> On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch wrote:
>
> > Not really. The point about properties is that you *can* make attribute
> > access trigger getter or setter code.
> >
> > But not that you do unless there is an actual reason
ror
@GET
def foo(x):
return "Got", x
@POST
def foo(x)
return "Posted to", x
This is definitely not functional code, but might get you in the right
direction on __getattribute__. __getattr__ might also work for you. I
haven't worked too much
hat is by changing the __class__
attribute on c.
class A(object):
x = 4
def __init__(self):
self.y = 5
class B(object):
x = u'cow'
def __init__(self):
self.y = u'goat'
>>> c = A()
>>> c.x
4
>>> c.y
5
>>> c.__class__ = B
>>> # Note that neither c nor x were changed in the last step
... c.x # Class attribute found on B now
u'cow'
>>> c.y # Instance attribute: already initialized from A.__init__
5
>>> c.__init__() # Reinitialize c, now using B.__init__
>>> c.y # Re-initialized instance attribute
u'goat'
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 2009-03-18 at 08:18 -0700, Adam wrote:
> On Mar 18, 10:33 am, "J. Cliff Dyer" wrote:
> > You might be interested in redefining __getattribute__(self, attr) on
> > your class. This could operate in conjunction with the hash tables
> > (dictionaries)
gt; from StringIO import StringIO
to
>>> from cStringIO import StringIO
3) Functions as first-class variables (which could connect to a
discussion of decorators or of dictionaries as dispatch tables).
4) List comprehensions
5) Generators using yield
6) Also very handy is the interactive inte
ode26.html
Something like the following might work:
print eval(line, {'tableTop': tableTop})
Cheers,
Cliff
On Tue, 2009-04-07 at 08:38 -0400, Victor Subervi wrote:
>
> I have excluded the code where I call the separate text files for
> printing normal text. They work. It's m
On Wed, 2009-04-08 at 01:57 +0100, Rhodri James wrote:
> On Tue, 07 Apr 2009 12:46:18 +0100, J. Clifford Dyer
> wrote:
>
> > On Mon, 2009-04-06 at 23:41 +0100, Rhodri James wrote:
> >> On Mon, 06 Apr 2009 23:12:14 +0100, Anish Chapagain
> >> wrote:
> >>
> >> > Hi,
> >> > I was trying to extrac
"copyright", "credits" or "license" for more information.
>>> import cPickle as p
>>> class Foo(object):
... a = lambda self, x: x+1
>>> foo.a(1)
2
>>> type(foo.a)
>>> p.dumps(foo)
'ccopy_reg\n_reconstructor\np1\n(c__main__\nFoo\np2\nc__builtin__
\nobject\np3\nNtRp4\n.'
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 2009-04-16 at 14:11 -0700, John Fabiani wrote:
> Daniel Fetchinson wrote:
>
> > Hi folks, I've come across many times the claim that 'joins are bad'
> > for large databases because they don't scale
>
> IMO that's bull...
OK. That makes four legs so far
> --
> http://mail.python.org
ble, when the loop calls
iterable.__iter__(), it gets a fresh iterator, so it can loop over the
file again.
The important thing is that when you call x.__iter__() (which you do
when entering a loop), you get a fresh iterator that won't just call
StopIteration right away.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
native, but lo and
behold, they are the same, at least in the cases I was trying to account
for.
' a b c '.split() == ' a b c '.strip().split() == 'a b c'.split()
Thanks for pointing this out.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
back up is
an exercise for the reader.
def general_xrange(start, stop, step=1):
target = stop * step
if start * step > target:
raise ValueError
i = start
while i * step < target:
yield i
i += step
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
hidden breakage. But if you have one of
those in your data structure, why are you trying to flatten it anyway?
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 2009-05-05 at 12:15 -0400, J Kenneth King wrote:
> Emile van Sebille writes:
>
> > On 5/1/2009 7:31 AM J Kenneth King said...
> >> Chris Rebert writes:
> >>> b = []
> >>> for pair in a:
> >>> for item in pair:
> >>> b.append(item)
> >>
> >> This is much more clear than a nest
On Fri, 2009-05-08 at 07:53 -0700, anuraguni...@yahoo.com wrote:
> #how can I print a list of object which may return unicode
> representation?
> # -*- coding: utf-8 -*-
>
> class A(object):
>
> def __unicode__(self):
> return u"©au"
>
> __str__ = __repr__ = __unicode__
>
Your
On Fri, 2009-05-08 at 17:19 +0200, Pascal Chambon wrote:
> PS : Am I the only one having most of answers rejected by the
> antispam
> system of python-list ? That's humiliating :p
>
I've had several messages not make it through.
:(
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 2009-05-13 at 09:40 -0700, Mohan Parthasarathy wrote:
> Hi,
>
> I am new to Python. I tried searching this but could not find an
> answer. In the interactive shell, I write a new function and I want to
> be able to see all the code that I wrote at a later time. Just typing
> the function n
order. But they are
processed in the order they appeared in the list. If you want to
process the elements of the list in alphabetical order, you have to sort
the list itself:
>>> for x in sorted(['hat', 'socks', 'shirt', 'pants']):
... print x
hat
pants
shirt
socks
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
> y = Y()
>>> for c in y:
... print c
...
1
2
3
>>> for c in y:
... if c < 3:
... print c
...
1
2
>>> for c in y:
... print c
...
1
2
3
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
when using python 2.6 with old-style division. Probably because python
doesn't have to check the types of its arguments before deciding to do
integer division.
>>> a = timeit.Timer("(200 * 100.)/5")
>>> b = timeit.Timer("(200 * 100)/5")
>>> c = timeit.Timer("(200 * 100)//5")
>>> d = timeit.Timer("(200 * 100.0)//5")
>>> for each in a, b, c, d:
... each.timeit()
...
2.3681092262268066
2.417525053024292
0.81031703948974609
0.81548619270324707
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
alue
print serialc_bin.sum()
Any one of these seems like a better idea to me than trying to pollute
your local namespace with an unknown number of variables. You have a
collection of objects. It makes sense to store them in one of python's
collection types, or create an object of your own to store them.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2009-05-22 at 10:54 -0700, Jan wrote:
> On May 22, 9:46 am, "J. Cliff Dyer" wrote:
>
> > You don't need a reset method. There is no hard and fast rule that
> > __iter__ must return the object itself. It just needs to return an
> > iterator.
n, I usually don't agree much with both what you say and how you
> say it, but I must admit that this one is, well... just brillant !-)
>
> (IOW: rofl, keyboard, and +1 QOTW)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Agreed. Best. Synonym. EVAR.
self.movies = movies
> return self
>
>
> ?
No. __init__ should not return anything (rather, it should return None,
but it'll do that on its own without you telling it to return anything).
The problem is that you are trying to create an object with __init__,
but that is not what it does. It *initializes* objects that already
exist. when you call a class, it creates a new instance using
__new__(), and then initializes it using __init__(). So if you were
really inclined to muck around. You could do something like
cust1 = Customer.__new__(Customer)
cust1.__init__('12', ['1','435', '2332'])
But that would just be silly. What you really want is this:
cust1 = Customer('12', ['1','435', '2332'])
which does the same thing. Don't explicitly call under-under variables
unless you really have to.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2008-05-16 at 06:04 -0700, globalrev wrote:
> On 16 Maj, 13:54, Peter Otten <[EMAIL PROTECTED]> wrote:
> > Christian Heimes wrote:
> > > globalrev schrieb:
> > >> cust1 = customer.__init__('12',['1','435','2332'])
> >
> > > cust1 = customer('12',['1','435','2332'])
> >
> > ... and before th
27;t using str.replace. You were using unicode.replace. Slight
difference, but important.) If you do the replace on a plain string, it
doesn't have to convert anything, so you don't get a UnicodeDecodeError.
>>> x = x.encode('latin1')
>>> x
'\xad'
>>> # Note the lack of a u before the ' above.
>>> x.replace('\xad','-')
'-'
>>>
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
re are occasional packages where it is common practice to
import *. Tkinter might be one of those. I don't have any experience
with it. But don't make a habit of it. :)
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 2008-05-22 at 15:06 -0400, Dan Upton wrote:
> Who wants to verify that that's correct to that many digits? ;)
Verified.
I checked it against the million digits on piday.org, by putting each
into a string, stripping out spaces and newlines, and doing:
>>> piday[:len(clpy)] == clpy
False
>
On Wed, 2008-05-28 at 09:31 -0400, Alok Kumar wrote:
> I am getting following error when tried as you suggested.
>
> self.event = [] #Create an empty list, bind to the name "event" under
> the "self" namespace
>self.event.append(Event()) #Create an event object and
> append to the e
sleet
slush
And in some contexts (http://www.abc-of-snowboarding.com/snowtypes.asp)
crud
crust
rime
graupel
hail
That's 14. Inuits are unimaginative punks. ;)
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
Take a look at django's built in pagination features:
http://www.djangoproject.com/documentation/generic_views/
http://www.djangoproject.com/documentation/pagination/
Also, take a look at the django specific mailing list.
[EMAIL PROTECTED]
Cheers,
Cliff
On Fri, 2008-05-30 at 12:59 +000
1 secs
> test('file-2.txt') took 398.349623132 secs
Sounds like a good strategy would be to find the smallest chunk of the
file that matches can't cross, and iterate your search on units of those
chunks. For example, if none of your regexes cross line boundaries,
search each line of the file individually. That may help turn around
the speed degradation you're seeing.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
atements in question are:
if name is not None:
and
if name:
The difference?
name=''
if name is not None:
print "name is not None."
if name:
print "name is."
Give it a whirl.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
adecimal" % a
'1e is hexadecimal'
py>>> "0x%x is hex prepended with 0x" % a
'0x1e is hex prepended with 0x'
>>> "0%o is octal prepended with 0" % a
'036 is octal prepended with 0'
You are making your life more complicated than you need to.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
It is published. On comp.lang.python. Google groups has it, so google
(search) will find it.
Cheers,
Cliff
On Tue, 2008-04-15 at 17:04 +0200, Victor Subervi wrote:
> Gabriel;
>
> That's really nice code you wrote. I will rewrite my app accordingly,
> after I catch a breathe
Linux (or any Open Source
> > product), they shouldn't be used either (since I'm not paying for
> > them).
> >
> I'm not saying people shouldn't use Google Groups. I'm saying that
> Google can "justify" providing customer "supp
new messages to different folders by matching
various criteria.
In Evolution this is as easy as right clicking on a message from the
list in your inbox, select "Create Rule From Message > Filter on Mailing
List", and then choose a folder to redirect to.
Reading by thread instead of by
to open newfile in any piece of software of your choosing.
It's no longer a well-formed jpeg, so it won't work. That's exactly
what you're asking the browser to do.
I guess this isn't really python related, so my apologies for that.
Cheers,
Cliff
--
Oook,
J. Cliff Dyer
Carolina Digital Library and Archives
UNC Chapel Hill
--
http://mail.python.org/mailman/listinfo/python-list
; > ...
> >
> Thank you, you saved me from making that point. It doesn't even seem
> like there's a need for each header to reference the same value (though
> in this case they will, precisely because there is only one None object).
>
> regards
> Steve
Another possibility is to assign to a dict using a loop, if typing None
over and over again is so onerous.
options = ['cache_control',
'connection',
'date',
'pragma']
params = {}
for option in options:
params[option] = None
And of course you could substitute your choice of appropriate __dict__
for params, if you want to access the options as free-standing objects.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
will always work on Python 2.5. If you're
worried about wild code, bundle it with its own interpreter when you
distribute it. It'll survive.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
the "%s"es that you don't need, because you already
parameterized that query. Your dbapi interface will provide appropriate
quoting for whatever type of data you pass it.
Cheers,
Cliff
On Fri, 2008-04-18 at 10:13 -0500, Victor Subervi wrote:
> Hi;
> If I grab an image
ro.py/go?FREETEXT=crack+open
>
I was with you on this issue right up until that last paragraph. You
want it, but only if its free. That's ridiculous. Every thing a
computer does requires processor cycles.
Do you really mean to tell me that string interpolation has been a major
bottleneck
with
> this after defining bg as a list of the four colours:
>
> print '' % bg[z % 4], d
>
> I tried that just for fun. It gave a bg of ´f´. Again, how are you
> incorporating d?
If you add that print line to end of your original code, then you'll get
the z%4-th element of bg, which would be one character, because bg is a
string, but if you "define bg as a list of the four colours" first, as
instructed, you'll get sensible results:
bg = ['#ff', '#b2b2b2', '#33FF66', '#00']
for z in (0,1,2,3,4,5,6,7,8,9):
print (' TIA,
> Victor
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 2008-04-29 at 15:39 -0400, D'Arcy J.M. Cain wrote:
> On Tue, 29 Apr 2008 15:03:23 -0400
> "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote:
> > Or, if you aren't sure how many colors you'll be using, try the more
> > robust:
> >
&g
x27;re
trying to catch, it's better to leave off the try/except block,
*especially* during development. Stack traces are full of good
information.
Second, you never initialize w, which causes the following problem.
$ python
Python 2.3.4 (#1, Nov 20 2007, 15:18:15)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> w += 1
Traceback (most recent call last):
File "", line 1, in ?
NameError: name 'w' is not defined
>>>
Third, double-spacing your code makes it difficult to read. Take out
blank lines, unless they add contextual hints which improve readability.
Post working code, and I'll answer your actual question.
Cheers,
Cliff
>
--
Oook,
J. Cliff Dyer
Carolina Digital Library and Archives
UNC Chapel Hill
--
http://mail.python.org/mailman/listinfo/python-list
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object):
... def Hello(sel):
... print "hi"
...
>>> f = Foo()
>>> f.Hel
'\\uabcd'
>>> u'\uabcd'
u'\uabcd'
>>> u'\ufoo'
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position
0-4: end of string in escape sequence
>>> '\xfoo'
ValueError: invalid \x escape
>>
On Mon, 2008-05-05 at 10:08 -0700, [EMAIL PROTECTED] wrote:
> At some point, code goes "on" and "off" the processor, which knowledge
> I do owe to spending money. Thus, if the group news is a localcy
> (other dimension of currency), that's bounce check the house dollar.
> What do [second person pl
--
Oook,
J. Cliff Dyer
Carolina Digital Library and Archives
UNC Chapel Hill
--- Begin Message ---
On Wed, 2008-05-07 at 21:19 +0200, Daniel Marcel Eichler wrote:
> Am Dienstag 06 Mai 2008 16:07:01 schrieb Mike Driscoll:
>
> > If so, then it looks like an Interface is a generi
On Thu, 2008-05-08 at 14:53 +0200, Aspersieman wrote:
> Hi
>
> I have a python script that parses email headers to extract information
> from them. I need to get the _last_ messageid in the 'References' field
> (http://cr.yp.to/immhf/thread.html) to create a threaded view of these
> emails (the
On Thu, 2008-05-08 at 05:56 -0700, [EMAIL PROTECTED] wrote:
> Hello,
> is it possibble listening on TCP port by python and how? I am trying
> chilkat but poorly :(.
>
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
>
You just asked this exact same question yesterday, and got
On Thu, 2008-05-08 at 13:25 -0400, J. Cliff Dyer wrote:
> On Thu, 2008-05-08 at 19:11 +0200, Daniel Marcel Eichler wrote:
> > Am Donnerstag 08 Mai 2008 13:02:52 schrieb J. Clifford Dyer:
> >
> > > > I didn't said that interfaces are a kind of duck-typing. In fact i
;The new improved thing"
You rebind the name system.thing, but the object it was originally bound
to is unaffected. Strings are immutable, so you couldn't change that
object if you tried. thing is still bound to the original object.
Another feature of this behavior is as follows:
>&
On Thu, 2008-05-08 at 10:33 -0500, Victor Subervi wrote:
> Okay, trying this again with everything working and no ValueError or
> any other errors, here we go:
>
> Load this code. Unless you use a similar login() script, you will want
> to edit your own values into the user, passwd, db and host:
>
heers,
Cliff
On Fri, 2008-05-09 at 13:51 +, Alan Isaac wrote:
> A question related to the observer pattern...
>
> Suppose I have a variant: there are stocks, mutual funds, and investors. Let
> us say that funds are observers for multiple stocks, and investors are
> observer
z.strip().endswith('z') and
remove_first(w))
attach_list(q, r)
reject(x)
A colon on the correct line would help readability quite a bit.
Yeah, I know I made it pretty ugly to begin with, and there are ways to
improve it without the colon, but still, just because it could be
removed doesn't necessarily mean it should.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
ere are other options available, but those are
straightforward to use, and well designed.
Good luck with your site.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
behavior as the OP's original solution. The
OP's solution retrieves the first matching value only. Mine gets one
arbitrary matching value, determined by the algorithm used for
constructing the search dict (not specified in my solution). What the
OP actually said was that he can
to be numbers between 0 and
15, you can just do:
if ''.join(map(hex, a)) in ''.join(map(hex, b)):
return True
Hmm... actually, with the '0x' prefix that hex() puts on numbers, I
think this works for arbitrary integers.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
un on 8084, you can
do the following
import socket
port = {
'www.example.com': 80,
'dev.example.com': 8084,
}[socket.gethostname()]
It's a handy idiom.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 2008-09-18 at 07:57 -0500, Tim Chase wrote:
> > Code: Select all
> > for i in range(len(IN)): #scan all elements of the list IN
> > for j in range(len(IN)):
> > if i <> j:
> > if IN[i].coordinates[0] == IN[j].coordinates[0]:
> >if IN[i].coordinates[1]
On Fri, 2008-10-03 at 09:15 -0500, Grant Edwards wrote:
> On 2008-10-03, greg <[EMAIL PROTECTED]> wrote:
> > Lawrence D'Oliveiro wrote:
> >> In message <[EMAIL PROTECTED]>, Steven D'Aprano
> >> wrote:
> >>
> >> > (2) Even when the source is available, it is sometimes a legal trap to
> >> > read i
practice. You leave yourself vulnerable not only
to attacks, but to simple absent-mindedness as well. Using parameters
in your execute statement will handle all necessary quoting for you,
which eliminates the possibility of a bad query sneaking in. For more
information, as I mentioned, look up SQL injection. Also, read this:
http://xkcd.com/327/
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 2010-02-10 at 13:18 -0800, Stephen Hansen wrote:
>
> The original code:
>
>
> s = f.readline()
> if 'mystring' in s: print 'foundit'
> if 'mystring' not in s: print 'not found'
> if 'mystring' in s:
> print 'processing'
>
>
> ... will only work on Python 2.x, as print is being used
The problem is that the class of platform.__builtins__ is a dict, not a
string containing the text "".
Try replacing line 16 with this:
self.assertEqual(type(platform.__builtins__), dict)
Cheers,
Cliff
On Tue, 2010-04-13 at 15:01 +0100, John Maclean wrote:
> I normally u
nvalid syntax
Admittedly, this is a trivial benefit. If you're using a literal, you
already know what type you're dealing with.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
201 - 300 of 340 matches
Mail list logo