> > Hi, I'm puzzled by the character encodings which I get when I use Python
> > with IDLE. The string '\xf6' represents a letter in the Swedish alphabet
> > when coded with utf8. On our computer with MacOSX this gets coded as
> > '\xc3\xb6' which is a string of length 2. I have configured IDLE
how to make a game tree for a tic tac toe game
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
As for other resources, I recently came across this:
http://farmdev.com/talks/unicode/
This was the first explanation that really made me understand the
difference between Unicode and utf-8 (and realize that I'd been using
the terms 'encode' and 'decode' backwards!). Anyway, just one more
r
On 09/07/2008, Paul McGuire <[EMAIL PROTECTED]> wrote:
> > def length(self):
> > dx,dy = self.p1 - self.p2
> > return (dx**2 + dy **2) ** 0.5
>
> How about:
>
> def length(self):
> return math.hypot( *(self.p1 - self.p2) )
>
> Compiled C code will be much faster than squaring and
> def length(self):
> dx,dy = self.p1 - self.p2
> return (dx**2 + dy **2) ** 0.5
How about:
def length(self):
return math.hypot( *(self.p1 - self.p2) )
Compiled C code will be much faster than squaring and square rooting.
-- Paul
___
T
On Tue, Jul 8, 2008 at 6:29 PM, Christopher Spears
<[EMAIL PROTECTED]> wrote:
> I have been reading everyone's comments on my line class. I have decided to
> implement some of the suggestions. Someone suggested that I create a
> Point.__cmp__ method. Here is what I have so far:
>
> def __cmp__
On 09/07/2008, bob gailer <[EMAIL PROTECTED]> wrote:
> or just [ x for x in LIST if x ]
or filter(None, LIST). But that's a bit obscure.
(fractionally faster, though, according to my brief experiment with timeit)
--
John.
___
Tutor maillist - Tuto
On Tue, Jul 8, 2008 at 6:35 PM, Don Jennings <[EMAIL PROTECTED]> wrote:
> def __unicode__(self):
> l=[self.first_name, self.last_name, self.email, self.phone]
> res=[]
>
> for x in l:
> if x != '':
> res.append(x)
>
> return ';'.join(
On Tue, Jul 8, 2008 at 5:19 PM, Robert Johansson
<[EMAIL PROTECTED]> wrote:
> Hi, I'm puzzled by the character encodings which I get when I use Python
> with IDLE. The string '\xf6' represents a letter in the Swedish alphabet
> when coded with utf8. On our computer with MacOSX this gets coded as
>
("Duh! Code would be good," says newbie to himself.)
Here's an example from django which I am using, but I asked on this list
since it seems more related to python than the web framework:
class Contact(models.Model):
first_name = models.CharField(max_length=30, blank=True)
last_name = mod
Hi, I'm puzzled by the character encodings which I get when I use Python
with IDLE. The string '\xf6' represents a letter in the Swedish alphabet
when coded with utf8. On our computer with MacOSX this gets coded as
'\xc3\xb6' which is a string of length 2. I have configured IDLE to encode
utf8 but
On 09/07/2008, Kelie <[EMAIL PROTECTED]> wrote:
> I think comtypes or pywin32 do take care of some conversion between Python
> types and VB types. But they don't work with AutoCAD.
Hi Kelie,
This is a short excerpt from _Python Programming on Win32_:
"""In many cases, PythonCOM can translate be
Alan Gauld btinternet.com> writes:
> So if you pass in two Python lists containing:
>
> DataType = [1001,1070]
> Data = ["Test_Application", 600]
>
> Does it work?
>
> If not what error do you get? (The full text please)
>
Thanks Alan. This is the error I got:
Traceback (most recent call las
On Tue, Jul 8, 2008 at 3:29 PM, Christopher Spears <[EMAIL PROTECTED]>
wrote:
> I have been reading everyone's comments on my line class. I have decided
> to implement some of the suggestions. Someone suggested that I create a
> Point.__cmp__ method. Here is what I have so far:
>
> def __cmp__(
I have been reading everyone's comments on my line class. I have decided to
implement some of the suggestions. Someone suggested that I create a
Point.__cmp__ method. Here is what I have so far:
def __cmp__(self, other):
if self.x == other.x and self.y == other.y:
return 0
Monika Jisswel wrote:
list comprehention : [ x for x in LIST if x != '' ]
or just [ x for x in LIST if x ]
--
Bob Gailer
919-636-4239 Chapel Hill, NC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"Kelie" <[EMAIL PROTECTED]> wrote
I'm trying to translate the following VB code into Python and not
sure how to
create an array of variants.
An array of variants in Python is a list.
But I'm not sure why you think you need one?
VB Code:
Sub SetXdata()
Dim lineObj As AcadLine
Set line
Hmm. I don't understand the LSP to make any requirements on the
constructors. It says that instances of a subclass should be
substitutable for instances of the base class, it doesn't say anthing
how the instances are created.
Constructors as a separate language entity is an idea born of C++,
Jav
list comprehention : [ x for x in LIST if x != '' ]
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Andre Engels gmail.com> writes:
>
> So what does the code of line.SetXData(dataType, dataValue) look like?
> >From that code you should be able to discern what argument type is
> wanted.
>
Thanks Andre. I don't know how the correct code should look like in Python. In
VB, I've posted the code in
"Christopher Spears" <[EMAIL PROTECTED]> wrote
class Point(object):
def __init__(self, x=0.0,y=0.0):
self.x = float(x)
self.y = float(y)
def __repr__(self):
coord = (self.x,self.y)
return coord
You could add a couple of methods here to get deltaX and
deltaY values Or ev
On Tue, Jul 8, 2008 at 9:14 AM, Don Jennings <[EMAIL PROTECTED]> wrote:
> Hi, folks.
>
> From within a class, I want to return a string with data from non-empty
> variables in a class.
>
> I could create a list of all the variables and then iterate over them,
> dropping the ones which are empty, th
"Faheem" <[EMAIL PROTECTED]> wrote
If anyone is interested I found this while googling
answers= ['ask'.'tell','repeat','sell']
def unzip(answers):
unzipped = "".join(answers) # if all items are strings
unzipped = ", ".join(map(str, answers))
unzipped = " ".join(str(v) for v in answers i
>
> > def __init__(self,p1,p2):
> > self.p1 = p1
> > self.p2 = p2
> >
> > And since a line should not have zero length (although you might argue
> > with that!) you could also check if
> > p1==p2
>
> In this case he should define Point.__cmp__() so the comparison is by
value rather than iden
Hi, folks.
>From within a class, I want to return a string with data from non-empty
variables in a class.
I could create a list of all the variables and then iterate over them,
dropping the ones which are empty, then join() and return them; however, I
am guessing there is another way to get that
Hansen, Mike wrote:
[mailto:[EMAIL PROTECTED] On Behalf Of Nathan Farrar
Sent: Saturday, July 05, 2008 12:24 PM
To: Python Tutor
Subject: [Tutor] Exploring the Standard Library
I'd like to spend some time exploring the standard library.
I'm running python on Ubuntu. How would I find the locat
>Subject: Re: [Tutor] New to pythong
>Hello everybody:
>
>I am new to this mailing list, and it said that i could the simplest of
questions. So i was wondering if anyone could be so kind as to e-mail me
a project idea or something to go out an learn to do in python. I don't
know any languages, b
> [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Farrar
> Sent: Saturday, July 05, 2008 12:24 PM
> To: Python Tutor
> Subject: [Tutor] Exploring the Standard Library
>
> I'd like to spend some time exploring the standard library.
> I'm running python on Ubuntu. How would I find the location
> o
On Sun, Jul 6, 2008 at 5:09 AM, Lie Ryan <[EMAIL PROTECTED]> wrote:
> The string implicit string concatenation exist for things like verbose
> re (regular expression):
>
> import re
> re.compile(
> '<' # Start opening tag
> '\s*' # Arbitrary whitespace
> '(.*?)' # tagname
> '\s*' # Arbitr
Comment : I never did any VB so I am not sure if I understand you.
supposing your data comes like this :
python code :
Data = ( ('A', 1), ('B', 2), ('C', 3), ('D', 4) )
> #you can create a list of the items like this :
>
> List_Letters = [ x[0] for x in Data]
> List_Numbers = [ x[1] for x in Dat
> Message: 5
> Date: Fri, 04 Jul 2008 00:29:03 +0800
> From: Dong Li <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Question about string
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain
>
>
> > Date: Thu, 3 Jul 2008 10:18:23 +0100
> > From: "Alan Gauld" <[EMAIL PRO
On Tue, Jul 8, 2008 at 4:01 AM, Alan Gauld <[EMAIL PROTECTED]> wrote:
> def __init__(self,p1,p2):
> self.p1 = p1
> self.p2 = p2
>
> And since a line should not have zero length (although
> you might argue with that!) you could also check if
> p1==p2
In this case he should define Point.__cmp__
On Tue, Jul 8, 2008 at 12:52 AM, Christopher Spears
<[EMAIL PROTECTED]> wrote:
> For problem 13-6 out of Core Python Programming, I created a line class that
> consists of two points. The line class has the following methods: __repr__,
> length, and slope. Here is the code:
>def __repr__(s
On Tue, Jul 8, 2008 at 11:00 AM, Kelie <[EMAIL PROTECTED]> wrote:
> John,
>
> Thanks for your reply. I'm aware of list, tuple, sets, etc. and have tried
> them,
> which results in an error: Invalid argument type in SetXData method. My
> understanding is that I do need an array here. Just don't kno
John,
Thanks for your reply. I'm aware of list, tuple, sets, etc. and have tried them,
which results in an error: Invalid argument type in SetXData method. My
understanding is that I do need an array here. Just don't know the correct way
of doing it.
__
"Christopher Spears" <[EMAIL PROTECTED]> wrote
class Point(object):
def __init__(self, x=0.0,y=0.0):
class Line(object):
def __init__(self, p1, p2):
self.p1 = Point(x1,y1)
self.p2 = Point(x2,y2)
This is wrong I suspect.
You are passing two point objects into the constructor b
Hey all,
If anyone is interested I found this while googling
answers= ['ask'.'tell','repeat','sell']
def unzip(answers):
unzipped = "".join(answers) # if all items are strings
unzipped = ", ".join(map(str, answers))
unzipped = " ".join(str(v) for v in answers if v > 0)
return unzipped
37 matches
Mail list logo