Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
___
Tutor maillis
Hi,
i am looking for more informations about encoding in python:
i've read that Amazon SimpleDB accepts every string encoded in UTF-8. How
can I encode a string? And, what's the default string encoding in python?
the other question is about mysql DB: if i have a mysql field latin1 and
extract hi
"Jojo Mwebaze" wrote
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Assuming you actually mean that you don;t want to include
any item
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
--
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
--
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
Are there any constraints on x an
Giorgio, 03.03.2010 09:36:
i am looking for more informations about encoding in python:
i've read that Amazon SimpleDB accepts every string encoded in UTF-8. How
can I encode a string?
byte_string = unicode_string.encode('utf-8')
If you use unicode strings throughout your application, you w
Thanks to everyone, nice ideas!
cheers
On Wed, Mar 3, 2010 at 10:02 AM, Christian Witts wrote:
> Jojo Mwebaze wrote:
>
>> Hi There,
>>
>> i would like to implement the following in lists
>>
>> assuming
>>
>> x = 3
>> y = 4
>> z = None
>>
>> i want to create a dynamic list such that
>>
>> mylist
Dave Angel wrote:
Jojo Mwebaze wrote:
Hi There,
i would like to implement the following in lists
assuming
x = 3
y = 4
z = None
i want to create a dynamic list such that
mylist = [ x , y, z ] , if z in not None
if z is None then
mylist = [x,y]
Anyhelp!
cheers
Jojo
Are there any
On Wed, 3 Mar 2010 07:46:39 pm Alan Gauld wrote:
> mylist = [irtem for item in aList where item != None]
Comparisons with None almost always should be one of:
item is None
item is not None
The reason is that "item is None" is ONLY ever true if the item actually
is the singleton object None (ac
Hello,
This is follow up on a question I had about algorithms. In the thread it
was suggested I make my own sorting algorithm.
Here are my results.
#!/usr/bin/python
def sort_(list_):
for item1 in list_:
pos1 = list_.index(item1)
pos2 = pos1 + 1
try:
item2
On Wed, 03 Mar 2010 02:38:57 +1100
Lie Ryan wrote:
> On 03/02/2010 04:13 AM, Wayne Watson wrote:
> > See Subject. 40K here, but other Python lists allow for larger (total)
> > sizes.
>
> I don't know, I've never realized it; that's an indication that the 40K
> limit is reasonable, at least to me
Giorgio wrote:
i am looking for more informations about encoding in python:
i've read that Amazon SimpleDB accepts every string encoded in UTF-8.
How can I encode a string? And, what's the default string encoding in
python?
I think the safest way is to use unicode strings in your application
>
>
>> byte_string = unicode_string.encode('utf-8')
>
> If you use unicode strings throughout your application, you will be happy
> with the above. Note that this is an advice, not a condition.
Mmm ok. So all strings in the app are unicode by default?
Do you know if there is a function/method
Oh, sorry, let me update my last post:
if i have a string, let's say:
s = "hi giorgio";
and want to store it in a latin1 db, i need to convert it to latin1 before
storing, right?
2010/3/3 Giorgio
>
>>> byte_string = unicode_string.encode('utf-8')
>>
>> If you use unicode strings throughout y
Hi all,
After six years of tutor posts my interest and energy have waned and
I'm ready to move on to something new. I'm planning to stop reading
and contributing to the list. I have handed over list moderation
duties to Alan Gauld and Wesley Chun.
Thanks to everyone who contributes questions and
Mmm ok. So all strings in the app are unicode by default?
Depends on your python version. If you use python 2.x, you have to use a
u before the string:
s = u'Hallo World'
Do you know if there is a function/method i can use to check encoding of
a string?
AFAIK such a function doesn't exis
Dang!
I wish you were not going. But really, I have to say a HUGE thank you
to you for all the fine teaching you have done on this list. I learned
so much from reading your posts. Thanks for all the time and effort
(and code) you put into this! I wish you were staying. Hats off to
you. Wi
Kent
We salute you. Thanks for everything you did for the community.
~l0nwlf
On Wed, Mar 3, 2010 at 7:09 PM, kevin parks wrote:
> Dang!
>
> I wish you were not going. But really, I have to say a HUGE thank you to
> you for all the fine teaching you have done on this list. I learned so much
> f
Giorgio, 03.03.2010 14:09:
byte_string = unicode_string.encode('utf-8')
If you use unicode strings throughout your application, you will be happy
with the above. Note that this is an advice, not a condition.
Mmm ok. So all strings in the app are unicode by default?
Do you know if there is
On Wed, Mar 3, 2010 at 9:17 AM, Shashwat Anand wrote:
> Kent
>
> We salute you. Thanks for everything you did for the community.
>
> ~l0nwlf
>
>
> On Wed, Mar 3, 2010 at 7:09 PM, kevin parks wrote:
>
>> Dang!
>>
>> I wish you were not going. But really, I have to say a HUGE thank you to
>> you fo
>
>
>> Depends on your python version. If you use python 2.x, you have to use a
> u before the string:
>
> s = u'Hallo World'
Ok. So, let's go back to my first question:
s = u'Hallo World' is unicode in python 2.x -> ok
s = 'Hallo World' how is encoded?
>> I think the encoding of the db doesn
Kent,
Thanks for all of the work you've done over the years to help make this
one of the best/most useful lists around. Enjoy the new challenges ahead!
It was great to finally meet you at PyCon!
Cheers,
Vern
Kent Johnson wrote:
Hi all,
After six years of tutor posts my interest and energy
>
> Date: Wed, 3 Mar 2010 08:17:45 -0500
> From: Kent Johnson
> To: Tutor@python.org
> Subject: [Tutor] Bowing out
> Message-ID:
><1c2a2c591003030517r66cf067fgf2f5a052a4a08...@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi all,
>
> After six years of tutor posts my i
I can only add my personal thanks, and echo the sentiments of others.
I'm certainly glad the archives exist, and that those inheriting
responsibility are certainly well qualified.
So long and thanks for all the fish!
-Wayne
2010/3/3 Emad Nawfal (عمـ نوفل ـاد)
>
>
> On Wed, Mar 3, 2010 at 9:17
> After six years of tutor posts my interest and energy have waned and
> I'm ready to move on to something new. I'm planning to stop reading
> and contributing to the list. I have handed over list moderation
> duties to Alan Gauld and Wesley Chun.
>
> Thanks to everyone who contributes questions an
Hi Kent,
Thank you!
--
Regards,
PhilK
'work as if you lived in the early days of a better nation'
- alasdair gray
smime.p7s
Description: S/MIME Cryptographic Signature
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription
Giorgio, 03.03.2010 15:50:
Depends on your python version. If you use python 2.x, you have to use a
u before the string:
s = u'Hallo World'
Ok. So, let's go back to my first question:
s = u'Hallo World' is unicode in python 2.x -> ok
Correct.
s = 'Hallo World' how is encoded?
Depend
Giorgio wrote:
Depends on your python version. If you use python 2.x, you have to
use a u before the string:
s = u'Hallo World'
Ok. So, let's go back to my first question:
s = u'Hallo World' is unicode in python 2.x -> ok
s = 'Hallo World' how is encoded?
I am not 100% sure,
Kent Johnson wrote:
Hi all,
After six years of tutor posts my interest and energy have waned and
I'm ready to move on to something new. I'm planning to stop reading
and contributing to the list. I have handed over list moderation
duties to Alan Gauld and Wesley Chun.
Thanks to everyone who cont
Uff, encoding is a very painful thing in programming.
Ok so now comes last "layer" of the encoding: the webserver.
I now know how to handle encoding in a python app and in interactions with
the db, but the last step is sending the content to the webserver.
How should i encode pages? The encoding
C.T. Matsumoto wrote:
Hello,
This is follow up on a question I had about algorithms. In the thread
it was suggested I make my own sorting algorithm.
Here are my results.
#!/usr/bin/python
def sort_(list_):
for item1 in list_:
pos1 = list_.index(item1)
pos2 = pos1 + 1
Giorgio wrote:
Depends on your python version. If you use python 2.x, you have to use a
u before the string:
s = u'Hallo World'
Ok. So, let's go back to my first question:
s = u'Hallo World' is unicode in python 2.x -> ok
s = 'Hallo World' how is encoded?
Since it's a
On 3 March 2010 14:17, Kent Johnson wrote:
> After six years of tutor posts my interest and energy have waned and
> I'm ready to move on to something new.
Let me join the other people and thank you for your contribution to
this list. Good luck with something new :-)
Greets
Sander
___
Ok.
So, how do you encode .py files? UTF-8?
2010/3/3 Dave Angel
> Giorgio wrote:
>
>>
>>>
Depends on your python version. If you use python 2.x, you have to use
a
>>> u before the string:
>>>
>>> s = u'Hallo World'
>>>
>>>
>>
>>
>> Ok. So, let's go back to my first question
Hi Kent,
Thank you very much for sharing your knowledge. Much appreciated!
Cheers!!
Albert-Jan
~~
In the face of ambiguity, refuse the temptation to guess.
~~~
Nope ya can't do it Kent, we wont have it !
Looks like a good time to start a patitiion to get you a salary or
something to keep you on :)
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/
On 3/2/2010 2:54 PM David Eccles (gringer) said...
I've managed to drum up some code to obtain a list containing joined diagonal
elements of a matrix (I'm making a word finder generator), but am wondering if
there's any better way to do this:
This works. Lots of other ways would work too. Wha
> -Original Message-
> From: tutor-bounces+mike.hansen=atmel@python.org
> [mailto:tutor-bounces+mike.hansen=atmel@python.org] On
> Behalf Of Kent Johnson
> Sent: Wednesday, March 03, 2010 6:18 AM
> To: Tutor@python.org
> Subject: [Tutor] Bowing out
>
> Hi all,
>
> After six year
I'm new to Python, so I thought as a first project I'd create a basic script
building wizard to help with my understanding of the flow, and for basic
practice. The following is a outline of what I would initially like to
accomplish.
I've begun creating small functions, and very lightly worded
so you're "done" with Python ? :)
> On 3 March 2010 14:17, Kent Johnson wrote:
>> After six years of tutor posts my interest and energy have waned and
>> I'm ready to move on to something new.
___
Tutor maillist - Tutor@python.org
To unsubscribe or c
--- On Wed, 3/3/10, Sander Sweers wrote:
From: Sander Sweers
Subject: Re: [Tutor] Bowing out
To: "Kent Johnson"
Cc: Tutor@python.org
Date: Wednesday, March 3, 2010, 11:06 AM
On 3 March 2010 14:17, Kent Johnson wrote:
> After six years of tutor posts my interest and energy have waned and
> I
Thank you for all your hard work! I learned a ton from your tutorials.
Good luck on your future endeavors.
On Wed, Mar 3, 2010 at 10:18 AM, Albert-Jan Roskam wrote:
> Hi Kent,
>
> Thank you very much for sharing your knowledge. Much appreciated!
>
> Cheers!!
> Albert-Jan
>
> ~~~
I am not really sure of a better way but if your looking for a way to make
your code cleaner or more efficient
you can try Numpy - http://numpy.scipy.org/
On Tue, Mar 2, 2010 at 4:54 PM, David Eccles (gringer) wrote:
> I've managed to drum up some code to obtain a list containing joined
> diagon
Hello,
Can someone tell me the difference between unittests assertEqual and
assertEquals?
Cheers,
T
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Ops, i have another update:
string = u"blabla"
This is unicode, ok. Unicode UTF-8?
Thankyou
2010/3/3 Giorgio
> Ok.
>
> So, how do you encode .py files? UTF-8?
>
> 2010/3/3 Dave Angel
>
> Giorgio wrote:
>>
>>>
> Depends on your python version. If you use python 2.x, you have to use
Hi,
I just read a few pages of tutorial on list comprehenion and generator
expression. From what I gather the difference is "[ ]" and "( )" at the
ends, better memory usage and the something the tutorial labeled as "lazy
evaluation". So a generator 'yields'. But what is it yielding too?
J
http://www.sorting-algorithms.com/
It is a fantastic website that explains each kind of sort and how it works.
They also show you visuals how the sorts work and how fast they go based on
the amount of data.
Depending on the amount/kind of data I would choose a sorting algorithm that
fits your nee
Dave Angel wrote:
C.T. Matsumoto wrote:
Hello,
This is follow up on a question I had about algorithms. In the thread
it was suggested I make my own sorting algorithm.
Here are my results.
#!/usr/bin/python
def sort_(list_):
for item1 in list_:
pos1 = list_.index(item1)
pos
>> After six years of tutor posts my interest and energy have waned and
>> I'm ready to move on to something new.
Another new Python student that received understanding from your style
and knowledge, great teacher. I hope you will post some more tutorials
on Kents Korner when you find the time and
Hi there,
I wonder what's the best way to wrap given function calls (in this case
ctype function calls but more generally built-in functions and those kinds).
I have a huge c library and almost all functions return an error code. The
library also contains a function, that returns the corresponding
(You forgot to do a Reply-All, so your message went to just me, rather
than to me and the list )
C.T. Matsumoto wrote:
Dave Angel wrote:
C.T. Matsumoto wrote:
Hello,
This is follow up on a question I had about algorithms. In the
thread it was suggested I make my own sorting algorithm.
He
"Steven D'Aprano" wrote
Comparisons with None almost always should be one of:
item is None
item is not None
Yes, but the reason I changed it (I originally had "is not") is that != is
a more general test for illustrating the use of 'if' within a LC which
seemed to be the real issue within the
"kevin parks" wrote
Wish Danny Yoo was still here too.
Technically he is, but just keeps very, very quiet! :-)
Alan G.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinf
Giorgio, 03.03.2010 18:28:
string = u"blabla"
This is unicode, ok. Unicode UTF-8?
No, not UTF-8. Unicode.
You may want to read this:
http://www.amk.ca/python/howto/unicode
Stefan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change su
Thanks for helping out. I enjoyed readying your posts. Good luck on
your future endeavors.
Ken
Kent Johnson wrote:
Hi all,
After six years of tutor posts my interest and energy have waned and
I'm ready to move on to something new. I'm planning to stop reading
and contributing to the list. I
Please let me post the third update O_o. You can forgot other 2, i'll put
them into this email.
---
>>> s = "ciao è ciao"
>>> print s
ciao è ciao
>>> s.encode('utf-8')
Traceback (most recent call last):
File "", line 1, in
s.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode by
I'm sorry, it's utf8_unicode_ci that's confusing me.
So, "UTF-8 is one of the most commonly used encodings. UTF stands for
"Unicode Transformation Format"" UTF8 is, we can say, a type of "unicode",
right? And what about utf8_unicode_ci in mysql?
Giorgio
2010/3/3 Stefan Behnel
> Giorgio, 03.03.
John wrote:
Hi,
I just read a few pages of tutorial on list comprehenion and generator
expression. From what I gather the difference is "[ ]" and "( )" at the
ends, better memory usage and the something the tutorial labeled as "lazy
evaluation". So a generator 'yields'. But what is it yiel
(Don't top-post. Put your response below whatever you're responding to,
or at the bottom.)
Giorgio wrote:
Ok.
So, how do you encode .py files? UTF-8?
2010/3/3 Dave Angel
I personally use Komodo to edit my python source files, and tell it to
use UTF8 encoding. Then I add a encoding lin
On 3 March 2010 20:44, Giorgio wrote:
s = "ciao è ciao"
print s
> ciao è ciao
s.encode('utf-8')
> Traceback (most recent call last):
> File "", line 1, in
> s.encode('utf-8')
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 5:
> ordinal not in range(128)
On Wed, Mar 3, 2010 at 6:43 PM, Jan Jansen wrote:
> Hi there,
>
> I wonder what's the best way to wrap given function calls (in this case
> ctype function calls but more generally built-in functions and those kinds).
> I have a huge c library and almost all functions return an error code. The
> li
On Wed, Mar 3, 2010 at 11:51 AM, Robert wrote:
> so you're "done" with Python ? :)
No, I hope not! I still love Python, but my enthusiasm for beginners
questions has pretty much gone away. I'm looking for a place where I
can contribute code rather than answers, possibly with the Mercurial
project
On Thu, 4 Mar 2010 04:27:23 am C.T. Matsumoto wrote:
> Hello,
>
> Can someone tell me the difference between unittests assertEqual and
> assertEquals?
assertEqual, assertEquals and failUnless are three spellings for the
same thing. There is no difference.
--
Steven D'Aprano
__
On 3 March 2010 22:41, Sander Sweers wrote:
> It is confusing but once understand how it works it makes sense.
I remembered Kent explained it very clear in [1].
Greets
Sander
[1] http://mail.python.org/pipermail/tutor/2009-May/068920.html
___
Tutor ma
On Thu, 4 Mar 2010 04:34:09 am Glen Zangirolami wrote:
> http://www.sorting-algorithms.com/
>
> It is a fantastic website that explains each kind of sort and how it
> works. They also show you visuals how the sorts work and how fast
> they go based on the amount of data.
For actual practical work,
On Thu, 4 Mar 2010 04:43:28 am Jan Jansen wrote:
> Hi there,
>
> I wonder what's the best way to wrap given function calls (in this
> case ctype function calls but more generally built-in functions and
> those kinds). I have a huge c library and almost all functions return
> an error code. The libr
On Thu, 4 Mar 2010 05:18:40 am Alan Gauld wrote:
> "Steven D'Aprano" wrote
>
> > Comparisons with None almost always should be one of:
> >
> > item is None
> > item is not None
>
> Yes, but the reason I changed it (I originally had "is not") is that
> != is a more general test for illustrating the
Hello Alan, Steven,
I was narrow minded about this topic and did not see the benefits of
these multiple Python
implementations. You opened my eyes.
Regards
Karim
Steven D'Aprano wrote:
On Tue, 2 Mar 2010 11:25:44 am Andreas Kostyrka wrote:
Furthermore I do not think that most of the "c
Hello Steven,
Is there a big difference to write your first functions as below because
I am not familiar with yield keyword?
def skip_blanks(lines):
"""Remove leading and trailing whitespace, ignore blank lines."""
return [line.strip() in lines if line.strip()]
I tried to write as wel
"Steven D'Aprano" wrote
List comps can include *any* comparison:
[x+1 for x in data if (3*x+2)**2 > 100*x or x < -5]
Sure, but the wording suggested (maybe wrongly) that the OP
was a real beginner and so the concept of an expression
was likely to be foreign. Sticking with equalty or inequa
First a little preamble before my questions.
Most of my work in Python has required modifying a program that uses
modules that were imported by the original program. I've made some use
of modules on a command line like math, and have used the idea of a
qualifier. On occasion, I've used exampl
--- On Wed, 3/3/10, Wayne Watson wrote:
From: Wayne Watson
Subject: [Tutor] Understanding (Complex) Modules
To: tutor@python.org
Date: Wednesday, March 3, 2010, 8:24 PM
First a little preamble before my questions.
Most of my work in Python has required modifying a program that uses modules
On Wed, 3 Mar 2010 16:32:01 +0100
Giorgio wrote:
> Uff, encoding is a very painful thing in programming.
For sure, but it's true for any kind of data, not only text :-) Think at music
or images *formats*. The issue is a bit obscured for text but the use of the
mysterious, _cryptic_ (!), word "
Steven D'Aprano wrote:
On Thu, 4 Mar 2010 04:27:23 am C.T. Matsumoto wrote:
Hello,
Can someone tell me the difference between unittests assertEqual and
assertEquals?
assertEqual, assertEquals and failUnless are three spellings for the
same thing. There is no difference.
Thank
Kent Johnson wrote:
Hi all,
After six years of tutor posts my interest and energy have waned and
I'm ready to move on to something new. I'm planning to stop reading
and contributing to the list. I have handed over list moderation
duties to Alan Gauld and Wesley Chun.
Thanks to everyone who cont
Denis,
That was a great explanation!! I'm not the OP, but your explanation
really clicked with me.
Regards,
Malcolm
For sure, but it's true for any kind of data, not only text :-) Think at
music or images *formats*. The issue is a bit obscured for text but the
use of the mysterious, _cryptic_ (
Hi Kent,
Your posts and web pages really helped me during my early days with
python.
Wishing you great success in your new endeavors!!!
Cheers,
Malcolm
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.p
On Wed, 3 Mar 2010 20:44:51 +0100
Giorgio wrote:
> Please let me post the third update O_o. You can forgot other 2, i'll put
> them into this email.
>
> ---
> >>> s = "ciao è ciao"
> >>> print s
> ciao è ciao
> >>> s.encode('utf-8')
>
> Traceback (most recent call last):
> File "", line 1, in
Hello,
In python like in most languages, I guess, objects (at least composite ones --
I don't know about ints, for instance -- someone knows?) are internally
represented as associative arrays. Python associative arrays are dicts, which
in turn are implemented as hash tables. Correct?
Does this
80 matches
Mail list logo