On Jul 17, 2005, at 20:18, Bill Campbell wrote:
Is there any significant performance difference between the
tests, ``key in dictionary'' and ``dictionary.has_key(key)''?
I would prefer using the ``key in'' because it's a bit easier to
type, and can also be used with lists in addition to diction
On Jul 14, 2005, at 12:26, Negroup - wrote:
"To read a file's contents, call f.read(size), which reads some
quantity of data and returns it as a string. size is an optional
numeric argument. When size is omitted or negative, the entire
contents of the file will be read and returned; it's your p
On Jul 12, 2005, at 18:44, Gooch, John wrote:
I have a Python script that stores the results of the processing
that it
does in a
database, but it has to have an alternate way of storing its data in a
database-friendly way (XML)in case the database is not available
( connected
down, data st
On Jul 9, 2005, at 11:17, Don Parris wrote:
get_Name(prt_Name)
# Calling get_Name with prt_Name as the argument produces this:
C:\Python24>python scripts\learning.py
f
At least it found the function. That's little shy of a miracle for
me. :) However, I would like to see 'foo' printed out,
On Jul 2, 2005, at 01:43, Brian van den Broek wrote:
This sounds, to the untutored, rather like magic. (It reminds me of a
line from the German mathematician and philosopher, Gottlob Frege,
who, in a book on the foundations of arithmetic, characterized an
opposing position as akin to "trying to
On Jun 23, 2005, at 01:04, Alan G wrote:
Curses comes as standard on linux...
They also do on Windows. Just listen to any user when the bloody
thing crashes. (sorry, couldn't resist :p )
More seriously, I seem to recall that on the contrary, the
Windows Python distribution do
On Jun 17, 2005, at 11:58, János Juhász wrote:
>
> Dear Guys,
>
> I have a 2D array:
>
[['1', '2 ', '3'], ['longer ', 'longer', 'sort']]
>
>
> How can I get what is the max(len(item)) for the columns ?
> I would like to get a list with the max_col_width values.
>
> I hope t
On Jun 14, 2005, at 23:17, Pujo Aji wrote:
> I just use Ctrl+C Ctrl+C to run the code.
> The code wait for 3 second and show all i all together.
>
> I can't feel every second pass.
>
> pujo
Try running your script from a terminal (outside of emacs, that
is).
-- Max
maxnoel_fr at yahoo do
On Jun 14, 2005, at 22:56, Pujo Aji wrote:
> Hello,
>
> I tried this code in emacs.
> for i in range(3):
> time.sleep(1)
> print i
>
> It shows the result but total result not second per second.
>
> Any one experiance this problem
>
> pujo
Works for me... How do you run it? Do you use a
On Jun 12, 2005, at 00:42, Simon Gerber wrote:
> Any hints? I looked up the python reference manual, but couldn't find
> any way to force print statements to draw. Should I be looking into
> threads, perhaps?
I/O in Python is buffered -- that is, it uses RAM whenever
possible to delay the
On Jun 9, 2005, at 07:45, Kevin Reeder wrote:
> I'm having trouble with this code which is meant to run a time
> comparison between two similar functions. The first module is
> makezeros.py
>
> def lots_of_appends():
> zeros = []
> for i in range(1):
> zeros.append(0)
>
> def one_
On Jun 7, 2005, at 20:42, Bernard Lebel wrote:
> repr( myFunc )
>
> Wich returns
>
> ''
>
>
> Okay then I run
>
> s = repr( myFunc() )
> print s
>
> Wich returns
>
> 'None'
That's perfectly normal. Your last assignment calls the
function, then assigns to s the representation of the functi
On Jun 6, 2005, at 05:27, Bill Campbell wrote:
> I don't do Windows so can't say what it does (knowing Microsoft, it
> may
> vary between Windows versions, patch levels, and the phase of the
> moon :-).
>
> Bill
Well, Windows doesn't even do ifconfig. The (more-or-less)
equivalent com
On Jun 2, 2005, at 23:39, Terry Carroll wrote:
> The palette mode ("P") uses a colour palette to define the actual
> colour for each pixel.
>
>
>
> Not sure what that means, exactly, but it looks like im.palette
> will get
> the palette of a a P-mode image, and im.putpalette will change
(meh, forgot to click "reply-all" again)
Begin forwarded message:
> From: Max Noel <[EMAIL PROTECTED]>
> Date: May 24, 2005 23:01:39 BDT
> To: "D. Hartley" <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] xml
>
>
>
> On May 24, 2005, at 22
On May 24, 2005, at 02:49, Joseph Quigley wrote:
> ... to play a .wav music file. I tried w.play() but got an error that
> module has no attribute 'play'.
> What do I use to get it to play?
> Thanks,
The wave module is meant to read, write and manipulate
(transform, filter, whatever) WAV
On May 24, 2005, at 14:22, Mike Hansen wrote:
> Excel has some nice database-like queries itself. Take a look at
> Advanced Filter
> in Help. You can essentially query a worksheet and even send the
> results to a
> different worksheet. I'd imagine that once you got the query
> working, you
On May 22, 2005, at 21:07, Jonas Melian wrote:
> for line in fileinput.input(glob.glob(os.path.join
> (dir_locales, "*_[A-Z][A-Z]"))):
> if re.search("locale for", line):
> print line
If you're only looking for the occurrence of a string and not a
regex pattern, you do
On May 19, 2005, at 23:05, Terry Carroll wrote:
> Thanks to you both. I think I may need to step up my "development
> environment" beyond emacs and a command line.
Actually, if you're having problems with debugging your problem,
what you should step up is your approach to debugging/testi
On May 19, 2005, at 23:28, Jonas Melian wrote:
> I want get the kernel serie, so 2.x only (2.6 or 2.4)
>
> info_kernel = platform.release() # get the kernel version
> info_kernel = '.'.join(info_kernel.split('.',2)[:2])
>
> is there any way of get it in one line only?
Based on your code, th
On May 19, 2005, at 22:46, Chelan Farsight wrote:
> Thanks!
> You were right about the double underscore, however, I am still
> getting the error on line 7...hrmm
> any other ideas?
>
In your original code, the space between if and __main__ is also
missing. This may be the source of the e
On May 19, 2005, at 22:18, Chelan Farsight wrote:
> I am using the online book Dive Into Python.
> I ran the first program given and have run into an error on line 7 at
> the colon. Now I imagine that there is probably a corrections page at
> the site, but I am interested in knowing why it won't
On May 19, 2005, at 20:49, William O'Higgins wrote:
> I am trying to discover the syntax for call on a dictionary of
> lists by
> key and index.
>
> The data structure looks like this:
>
> dol = {'key1':['li1','li2','li3'],'key2':['li1','li2','li3'],\
> 'key3':['li1'li2,'li3','']}
>
> The keys
On May 17, 2005, at 22:00, Smith, Jeff wrote:
> Is there a more Pythonic way to get the Perl equivalent of
> $#var
> other than
> len(var) - 1
AFAIK, len(var) - 1 is the only way. Note, however, that the
last element of a list (or of any ordered sequence) can be obtained
with th
On May 17, 2005, at 08:52, Olli Rajala wrote:
> Okay,
> I have a string table (don't recall the right word used in Python
> right now)
It's called a list, or an array.
> and would like to remove every 'cell' that contains a
> string '_thumb.jpg'. There are 1-> digits before the string if t
On May 16, 2005, at 18:30, Jonas Melian wrote:
> To knowing if a directory isn't empty, I use:
>
> dir_example = "/usr/foo/"
>
> if glob.glob(os.path.join(dir_example, "*")):
> ...
>
>
> But, as it has to expand all files, i'm supposed that it's a little
> slow
> to simply knowing if a dire
On May 15, 2005, at 06:54, Terry Carroll wrote:
> if (a == b &
> a == c &
> a == d &
> a == e &
> a == f &
> a == g):
> do stuff
>
Well, you can already try this:
if a == b == c == d == e == f == g:
do stuff
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"
On May 14, 2005, at 20:09, Aaron Elbaz wrote:
> The idea is to print out a multiplication table on the command line
> with numbers lining up in the ones column. I want to eventually
> emulate programs like top with their spacing. But this code is mostly
> for my amusement. How would you make this
On May 14, 2005, at 01:30, William O'Higgins wrote:
> if sys.argv[1]:
> do stuff
> else:
> do different stuff
>
> If I have arguments, the "different stuff" happens beautifully, thank
> you very much. If I don't have arguments I get this:
>
> if sys.argv[1]:
> IndexError: list index out
On May 13, 2005, at 21:03, Alberto Troiano wrote:
os.system("fec=cam`date +%Y%m%d%H%M%S`.jpg")
> 0
>
os.system("echo $fec")
> 0
>
os.system("mv hola.txt grabacion/$fec")
> 0
>
> Then I check for the file and turns out that it moved hola.txt to
> grabacion
> with th
On May 13, 2005, at 20:36, [EMAIL PROTECTED] wrote:
> Hi,
>
> i am a Biology student taking some early steps with programming. I'm
> currently trying to write a Python script to do some simple
> processing of a
> gene sequence file.
Welcome aboard!
> A line in the file looks like:
> SCER
On May 13, 2005, at 01:30, Jacob S. wrote:
> Okay, I've tried pickling, marshal, marshalling, serialization, and
> amazingly pi because I noticed that pickle was under the section 3.14
> however, none of this worked, so, I hate to ask again but, could
> you go one
> step farther?
>
> Thanx,
> J
On May 12, 2005, at 03:00, [EMAIL PROTECTED] wrote:
> As was pointed out, I'm not American. I guess the problem stems
> from an
> American cultural assumption, though, in that Americans (I think)
> developed the
> ASCII character set without any thought for other languages.
At that tim
On May 12, 2005, at 02:42, Tony Meyer wrote:
>>
>> From the email address, chances are that this was a New Zealand
>> cultural
>>
> assumption. Ah, the French, lumping all English speakers under the
> American
> banner .
Touché. :D
-- Max
( What makes it even more unforgivable is that
On May 12, 2005, at 02:22, D. Hartley wrote:
> Max - yep, and the hint was "BUSY" (... BZ...)...
>
> Unfortunately that hint doesnt lead me anywhere (except to bz2, which
> involves compression, and didnt seem very likely).
>
> I went through and removed all the \x## 's that represented
> 'unprin
On May 12, 2005, at 01:50, [EMAIL PROTECTED] wrote:
chr(130)
> '\x82'
>
> If you look at http://asciitable.com/, you will see that ascii
> chracter 130 is
> an e with a tick on its head. This is not something you can find
> on your
> keyboard, so python can't/won't display it.
>
On May 11, 2005, at 07:23, Liam Clarke wrote:
> Ack, banner.p eh?
>
> Can anyone explain the significance of the numbers? Are they columns?
>
> Regards,
>
>
> Liam Clarke
As I said, read about Run-Length Encoding.
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A
On May 10, 2005, at 01:18, D. Hartley wrote:
> I admitted that my grasp of classes (and "constructors") is a bit
> fuzzy. I did get this particular class to work, and got the first half
> of the problem done. However, now i'm working in another class,
> zipinfo. It says:
>
> Instances of the Zip
On May 9, 2005, at 17:57, Joseph Quigley wrote:
> Why do I get the error:
>NameError: global name 'main' is not defined
>
> when switching between the two module twice (ie: type: jargon
> type:back()
> type:jargontype:back() )?
>
> Thanks
> JQ
>
Namespaces. Each module has
On May 8, 2005, at 03:02, Bernard Lebel wrote:
> Hello,
>
> I just started using list comprehensions (loving them!)
>
> I know you can add an if statement, but can you put in there an else?
> I could not find an example of this.
>
Apparently, no. I just tried:
>>> b = [i for i in range(10
On May 7, 2005, at 20:50, D. Hartley wrote:
> Ok, I hate to ask another question about this riddle. But I have
> looked and looked and looked.
>
> Where can I find more information on 'banner'? Everywhere I look it
> starts telling me about banner ads and so on, and that is not what I
> want!
>
On May 7, 2005, at 15:06, Max Noel wrote:
> Try the following code:
>
>
>
> for i in neverEndingTest():
> print i
>
Sorry, i meant "for in in neverEndingStatus()" (not
neverEndingTest()), where neverEndingStatus is the function I gave as
an e
On May 7, 2005, at 13:17, John Carmona wrote:
> Hi to everybody reading this thread, can anybody point me to the
> URL where I can find these challenges. Many thanks
>
> JC
>
http://www.pythonchallenge.com/
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathe
On May 7, 2005, at 13:22, John Clark wrote:
> (Either that, or I am not following what you mean when you say:
>
>
>> As for how to access it, use a for loop (for i in
>> neverEndingStatus()). xrange, for example, is a generator function.
>>
>
> Can you please provide an example of how my Tes
On May 7, 2005, at 12:28, John Clark wrote:
> My question - the creation of the global variable x seems kludged -
> when I
> first started with this I thought I was going to be coding
> something like
> sys.stderr.write('\b'+neverEndingStatus()) but that just returns
> '\' each
> time and I
On May 6, 2005, at 22:32, D. Hartley wrote:
> Maybe that's my problem. I dont know how to save this particular file
> onto my computer first. I can't 'reach' it from the url. It's not
> like a picture I can right click on and save image, or something. My
> first thought was i needed to use th
On May 6, 2005, at 22:20, D. Hartley wrote:
> Yes, I realized my original guess was wrong. I think I found the
> target file but now none of the module commands I'm used to will do
> anything useful on it. I'm just getting "file not found" errors and
> the like. There's something in the big pictu
On May 6, 2005, at 21:57, Tim Peters wrote:
> What do you have against PIL ?
Nothing in particular, just no idea how to use it.
> simple ways has been part of the fun for me. I don't know how you
> solved level 7,
Hint: it's a stupid and inelegant method involving a certain
progra
On May 6, 2005, at 21:40, D. Hartley wrote:
> I figured out what module you're supposed to use for 5, and the thing
> that kills me is it's a module I've actually *used* too! But I don't
> know what to . man this is hard to say without using a spoiler. I
> dont know what particular thing to a
On May 6, 2005, at 21:06, Alberto Troiano wrote:
> Hey
>
> I'm stucked in number 5
> It says pronounce it and there is nothing else not in page nor in
> the source
> code
> What can I do??
Well... Go ahead and pronounce it (the title of the page, that
is)... Sounds awfully close to a ce
On May 6, 2005, at 01:33, D. Hartley wrote:
> They do seem to be useful! But with all those special characters, it
> certainly doesnt make for an easy read. I think I'm making some
> progress - I got it to make me a list of all the
> {uppercaseuppercaseuppercaselowercaseuppercaseuppercaseupperca
On May 6, 2005, at 01:10, D. Hartley wrote:
> Anyone have a gentle hint, or pointer to another 'beginner' tutorial
> to regular expressions?
>
> Thanks! I dont want to get stuck here in the riddles!
>
> ~Denise
I learned most of what I know about regular expressions while I
was learning P
On May 5, 2005, at 19:39, D. Hartley wrote:
> Ok, now, I'm sure this sounds like a very dumb question. But I
> clicked on riddle 1, and I don't know how this thing works - "about"
> didnt give a lot of extra info. Am I trying to duplicate something on
> my screen that looks like the picture on
On May 5, 2005, at 16:37, Allen John Schmidt, Jr. wrote:
> Ok, I have had enough. I have looked all through the python docs and I
> cannot find it. How do you insert an entry into a dictionary?
>
The way you think it's done:
>>> a = {'foo': 1, 'bar': 2}
>>> a
{'foo': 1, 'bar': 2}
>>> a[
On May 5, 2005, at 00:53, [EMAIL PROTECTED] wrote:
> As seen on python-announce (via Dr Dobbs):
>
> http://www.pythonchallenge.com/
>
> Good fun!
>
Very interesting indeed! I'm stuck on number 7, though -- looks
like it requires the use of PIL, which I've never used before.
-- Max
maxnoe
On May 4, 2005, at 16:35, Joseph Quigley wrote:
> For those who use Psyco:
> Is it any good? I'm searching for instructions on how to use
> it, should I
> stop?
I hear it's quite good at what it does. Note, however, that it
only works on x86 computers (i.e. IBM PC compatibles).
On May 3, 2005, at 20:52, Danny Yoo wrote:
> ##
>cron(8) examines cron entries once every minute.
>
>The time and date fields are:
>
> field allowed values
> - --
> minute 0-59
>
On May 3, 2005, at 08:57, Danny Yoo wrote:
> I believe that cron has a resolution of a minute, so now it doesn't
> sound
> that cron is so viable. But how about writing a program that just
> continues to run as a "daemon" service in the background? A simple
> example is something like:
>
On Apr 30, 2005, at 19:50, Alan Gauld wrote:
If my student has plagiarised - I need to know.
Could you ask him(?) to explain some of the more "interesting"
features?
Maybe how he came up with the variable names? It is possible that
he/she has come up with it themselves since its not really a great
On Apr 30, 2005, at 09:49, Diana Hawksworth wrote:
Hello list!
I have started teaching Python to a group of High School students. I
set them the "Guess the Number" game as a GUI as an assignment. One of
the students has passed in some script that is foreign to any tutorial
work we have done.
Begin forwarded message:
From: Joseph Quigley <[EMAIL PROTECTED]>
Date: April 29, 2005 17:16:22 BST
To: Max Noel <[EMAIL PROTECTED]>
Subject: Re: [Tutor] cPickle (Joseph Q.)
I tried that and it doesn't work!
I type the name and it just sits there!
Here's the code:
# v
On Apr 29, 2005, at 04:48, Joseph Quigley wrote:
Hi all,
How could I have the user name his file? I learned that I type
file_name = "foo.bar"
How could I make it that the use could name it "hello.hi"?
Thanks,
Joe
Well, all you have to do is have the user input a string, and use this
st
On Apr 28, 2005, at 23:06, Alberto Troiano wrote:
I tried:
import os
os.system("ps --user root")
and I get
0
as a return
How can I get the PID and bind the command above with a variable?? I
mean
varusername="root"
os.system("ps --user varusername")
works???
So in essence, what you're trying t
On Apr 27, 2005, at 22:35, Alberto Troiano wrote:
I'm gonna give you an example:
The program will check for new users and to check record time every 10
seconds. But first the program will have to finish the checking
process that started before so it won't be 10 seconds right?
Unless I have one pr
On Apr 26, 2005, at 22:01, Alan Gauld wrote:
I had found the first thread you linked. I see what you mean about
the
cure -- my general belief is that *I* am unlikely to have problems
for which meta-classes are really the best solution :-)
Once you get used to them meta-classes are very useful. In
On Apr 27, 2005, at 01:36, D. Hartley wrote:
I haven't programmed in C (python is my first language!), but I *have*
done something like this before, only with the print command:
def displaybalance():
for score, name in mylist:
slip = 30 - len(name)
slip_amt = slip*" "
pr
[Forwarding to the list. Please use "Reply to all", not "Reply", if you
want your reply to a message to go to the list]
Begin forwarded message:
From: "D. Hartley" <[EMAIL PROTECTED]>
Date: April 27, 2005 01:36:26 BST
To: Max Noel <[EMAIL PROTECTED]>
On Apr 26, 2005, at 23:57, D. Hartley wrote:
But in any case, font/text will only take strings - i cant pass in a
list, or an index to an item in a list (which is, in this case, a
tuple), and since the items in the list will be changed and updated
obviously i cant just type in the items as strings
On Apr 25, 2005, at 17:03, André Roberge wrote:
I'm writing a program "interpreter" which has two windows: a program
editing window and a program output window.
The interpreter can either step through the program automatically, at
a slow pace, or step through the program one instruction at a tim
On Apr 24, 2005, at 18:04, Gavin Bauer wrote:
I've decided it would be cool to make a flashcard program. You would
start by entering all of the cards and their answers, then it would
ask you them in random order, with ones you get right coming up less
often, and ones you consistantly get wrong comi
On Apr 23, 2005, at 15:44, John Carmona wrote:
Thanks Kent, it is working now. Is this what you meant in your reply?
Because if I set up the main code at the end of the script I was still
getting an error message.
Also, what do I need to use if for example I want my code to rerun
once I have co
On Apr 22, 2005, at 21:09, Prasad Kotipalli wrote:
Hello evryone
I am a newbie to python. I have a makefile which i can compile in
UNIX/LINUX, But i
I am planning to write a python script which actually does what my
MAKEFILE does.
Then what you want is SCons (http://www.scons.org/). Haven't h
On Apr 22, 2005, at 11:41, Chris Smith wrote:
Do you have a suggestion as to what can I give a module so it has
enough information to execute a function that resides in __main__?
Here is a visual of what is going on:
--__main__
def y1():
pass
import foo
foo.run(string_from_main) #what shou
On Apr 21, 2005, at 00:19, D. Hartley wrote:
Max -
I thought it might be a version issue as well, thanks. Also, good
luck on your paper! 50 pages, whoo! Haven't done that since grad
school, my condolences man.
~Denise :)
Thanks... I'm almost done now, only a few more pages and all that will
be l
On Apr 20, 2005, at 23:57, Alberto Troiano wrote:
Hi
The thing is this
I get an error that says sort() has no arguments
Th error is in the sentence
high_score.sort(reverse=TRUE)
If you put just sort() it will work but the list will show from low to
high and we don't want that 'cause if you make a
On Apr 20, 2005, at 16:52, Alberto Troiano wrote:
Hey
Didn't work
I try the python2.3 setup.py build
I couldn't print the exact error because it's a lot of pages that says
mostly the same
the final error says
error: mysql ended exit with status 1
I run the other command python2.3 setup.py install
On Apr 20, 2005, at 00:04, Joseph Quigley wrote:
My point is for practice and knowledge. Sure, I have Setup 2 Go (the
paid version) and Install Creator (not paid)
Then again, how many free installers are there for linux?
emerge and apt-get come to mind. rpm is inferior (no dependency
resolution)
On Apr 20, 2005, at 01:29, Danny Yoo wrote:
Is there a convention for obfuscating database passwords?
Hi David,
Most people run passwords through some sort of hashing function. That
is,
databases almost never contain passwords in the clear, but instead
store
the hashes of those passwords.
For
On Apr 19, 2005, at 21:22, Tim Johnson wrote:
Hello Pythonmeisters:
Is it possible to dynamically compose a module name
for import?
Pointers to documentation or other discussions would
be sufficient at this time.
thanks
Ah, metaprogramming. I must admit I can't think of a way. Or rather, I
did t
On Apr 19, 2005, at 19:57, Alberto Troiano wrote:
Thanks Danny
I will try to do that and let you know how it went
But one question thou, does it matter the location where I gunzip the
distutil
If so where should I put it???
NOTE: It's just to be sure that I'm understanding righ
On Apr 19, 2005, at 13:49, Alberto Troiano wrote:
Hi
I have another problem. It seems that I manage to solve a problem and
run into another
The problem is that now I can't install MySQLdb (MySQL database module
for Python 2.3.4)
I try to ./configure and it prints a lot of crap and then says mys
On Apr 18, 2005, at 23:18, D. Hartley wrote:
Another quick question. I tried to send a file to my friend to test
it out, and it gave her the following sound-related error:
Cannot load sound: data\explode2.wav
Traceback (most recent call last):
File "D:\Python24\play w paused screen residue.py",
On Apr 18, 2005, at 19:59, Smith, Jeff wrote:
Is there a Python equivalent to the Perl
require 5.6.0
Which enforces a minimum interpreter version?
As far as I know, no. But:
>>> import sys
>>> sys.version_info
(2, 3, 0, 'final', 0)
>>> (2, 4, 0) > sys.version_info
True
>>> (2, 2, 0) > sys.versi
On Apr 18, 2005, at 16:55, Olli Rajala wrote:
Michael,
does it help if you change the second line into:
# -*- coding: iso-8859-15 -*-
?
I *think* that is the correct syntax (at least it works for me).
Thanks, it doesn't give the error message anymore. But non-ascii
letters still don't go well from
On Apr 17, 2005, at 17:29, Joseph Quigley wrote:
So what do you use the
def bar(x, y):
return x + y
bar(4, 5)
functions for? (I just need a simple example)
Whenever you have something that you may want to do more than once
and/or in more than one place in your program. Here's a small exam
On Apr 17, 2005, at 16:51, Sean Perry wrote:
R. Alan Monroe wrote:
Just curious. Googling for 'python "dis module" convert "another
language" ' only got two hits. So maybe no one is trying it? I was
just daydreaming about a native python compiler, and wondered how
feasible it would be.
There is alr
On Apr 15, 2005, at 21:30, D. Hartley wrote:
Unless you can explain what "lambda x:
x[1]" does, in preschool-speak ;)
That's an anonymous function, also known as a lambda function. Let's
take an example:
>>> a = range(10)
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> map(lambda x: 2*x, a)
[0, 2, 4, 6
On Apr 15, 2005, at 03:32, [EMAIL PROTECTED] wrote:
Interestingly, the key argument is the solution to this problem:
arr = zip(range(10), range(10,0,-1))
arr
[(0, 10), (1, 9), (2, 8), (3, 7), (4, 6), (5, 5), (6, 4), (7, 3), (8,
2), (9, 1)]
arr.sort(key=lambda x: x[1])
arr
[(9, 1), (8, 2), (7, 3),
On Apr 15, 2005, at 01:33, D. Hartley wrote:
This is what I have so far:
high_scorelist = [(1000,"Denise"), (945,"Denise"), (883,"Denise"),
(823,"Grant"), (779,"Aaron"), (702,"Pete"),
(555,"Tom"), (443,"Tom"), (442,"Robin"), (404,"Pete")]
userscore = (441,"Joe")
de
On Apr 14, 2005, at 21:06, [EMAIL PROTECTED] wrote:
I've seen a couple of nice tutorials on recursion, and a lot of awful
ones. The latter always trot out the fibonacci and factorial examples
for some reason. And that's about it! The good ones showed me how to
trace through recursive calls and g
On Apr 14, 2005, at 14:14, Ben Markwell wrote:
Could somebody explain to me why the code I used to complete this
exercise doesn't work.
And how do you send an integer to len?
Well, I think you've successfully completed that exercise. len()
doesn't work on integers because integers don't have a
On Apr 14, 2005, at 12:58, Orri Ganel wrote:
a = Node(1)
b = Node(a)
12932600 12932600
1
id(b)
12960632
Any ideas on why this happens, or suggestions as to how to implement
the behavior I'm looking for (in which b and a would refer to the same
object, have the same id, etc.), would be greatly appre
On Apr 12, 2005, at 23:22, Danny Yoo wrote:
There was an interesting article by Phillip Eby about what conventions
work and don't work when one makes a jump from Java to Python:
http://dirtsimple.org/2004/12/python-is-not-java.html
A very interesting read. Thanks for the link, Danny!
-- Max
On Apr 9, 2005, at 21:50, Kent Johnson wrote:
I think you have to return a value when len(t) <= 1. You don't return
anything which means you return None which can't be added to a list.
Kent
Yup. Here's a quicksort I did, adapting an example from the Wikipedia
article on Haskell:
def qsort(toSo
On Apr 9, 2005, at 10:36, Danny Yoo wrote:
-- Forwarded message --
Date: Fri, 8 Apr 2005 22:03:58 EDT
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: newb problem running the translator
I will try to make this quick. I am a newb to python, and
programming at
that, but i
On Apr 4, 2005, at 16:04, Vines, John (Civ, ARL/CISD) wrote:
Hello. I have a question regarding strings. How do I format a string
to be a specific length?
For example I need 'string1' to be 72 characters long.
Thanks for your time,
John
You can use the string methods ljust, rjust and zfill:
On Apr 2, 2005, at 12:12, Liam Clarke wrote:
Hi,
Out of curiosity, is it possible to create a dictionary like this -
foo = {'a':1, 'b':2, 'c':foo['a']}
I know that as above doesn't work, but was just wondering if it's
possible, and if it's a
Bad Thing?
Regards,
Liam Clarke
It doesn't work because
On Apr 1, 2005, at 09:59, Alan Gauld wrote:
Since the data are obviously related (since you need to keep them
linked),
I'd be inclined to merge the lists into a list of tuples
merged = [(a,b,c,d) for a in l1 for b in l2 for c in l3 for d in l4]
Then you can sort 'merged' and it should just work
On Apr 1, 2005, at 00:14, Mike Hall wrote:
On Mar 31, 2005, at 12:21 AM, Max Noel wrote:
It's been too long since I used Python on MacOSX, but IIRC you can't
just run a Python GUI program from the shell. Or something like
that...you should ask this one on the python-mac SIG mailing
On Mar 31, 2005, at 23:07, Alan Gauld wrote:
And if Sun ever get round to finishing their JVM on a chip
we'll have a chip that is both OO and procedural!
At that point it would be a JRM, then, wouldn't it? :D
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic c
1 - 100 of 215 matches
Mail list logo