Jojo Mwebaze jojo.mweb...@gmail.com 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
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
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
Thanks to everyone, nice ideas!
cheers
On Wed, Mar 3, 2010 at 10:02 AM, Christian Witts cwi...@compuscan.co.zawrote:
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
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
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 lie.1...@gmail.com 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
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
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 i can
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 anothernetfel...@gmail.com
byte_string = unicode_string.encode('utf-8')
If you use unicode
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
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 (عمـ نوفل ـاد) emadnaw...@gmail.com
On Wed,
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
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
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?
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
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 ken...@tds.net 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 da...@ieee.org
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
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:
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.
--- On Wed, 3/3/10, Sander Sweers sander.swe...@gmail.com wrote:
From: Sander Sweers sander.swe...@gmail.com
Subject: Re: [Tutor] Bowing out
To: Kent Johnson ken...@tds.net
Cc: Tutor@python.org
Date: Wednesday, March 3, 2010, 11:06 AM
On 3 March 2010 14:17, Kent Johnson ken...@tds.net wrote:
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 fo...@yahoo.com 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) gm...@gringer.orgwrote:
I've managed to drum up some code to obtain a list
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 = ublabla
This is unicode, ok. Unicode UTF-8?
Thankyou
2010/3/3 Giorgio anothernetfel...@gmail.com
Ok.
So, how do you encode .py files? UTF-8?
2010/3/3 Dave Angel da...@ieee.org
Giorgio wrote:
Depends on your python version. If you use python
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?
John
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
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)
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
(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.
kevin parks k...@mac.com 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:
Giorgio, 03.03.2010 18:28:
string = ublabla
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
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 pyshell#2, line 1, in module
s.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode
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 stefan...@behnel.de
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 yielding
(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 da...@ieee.org
I personally use Komodo to edit my python source files, and tell it to
use UTF8 encoding. Then I add
On 3 March 2010 20:44, Giorgio anothernetfel...@gmail.com wrote:
s = ciao è ciao
print s
ciao è ciao
s.encode('utf-8')
Traceback (most recent call last):
File pyshell#2, line 1, in module
s.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 5:
On Wed, Mar 3, 2010 at 6:43 PM, Jan Jansen knack...@googlemail.com 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
On Wed, Mar 3, 2010 at 11:51 AM, Robert webtour...@gmail.com 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
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 sander.swe...@gmail.com 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
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, you
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 library
On Thu, 4 Mar 2010 05:18:40 am Alan Gauld wrote:
Steven D'Aprano st...@pearwood.info 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
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
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 well the
Steven D'Aprano st...@pearwood.info 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
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
--- On Wed, 3/3/10, Wayne Watson sierra_mtnv...@sbcglobal.net wrote:
From: Wayne Watson sierra_mtnv...@sbcglobal.net
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
On Wed, 3 Mar 2010 16:32:01 +0100
Giorgio anothernetfel...@gmail.com 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
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:
On Wed, 3 Mar 2010 20:44:51 +0100
Giorgio anothernetfel...@gmail.com 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
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
62 matches
Mail list logo