Op maandag 9 april 2012 22:51:48 UTC+2 schreef Roy Smith het volgende:
In article
1a558398-3984-4b20-8d67-a0807871b...@v1g2000yqm.googlegroups.com,
aapeetnootjes ilyacool...@gmail.com wrote:
I'm trying out the pygame tutorial at
http://www.pygame.org/docs/tut/intro/intro.html
If I
I'm trying out the pygame tutorial at
http://www.pygame.org/docs/tut/intro/intro.html
If I try out the code I'm facing an error:
./game.py: line 4: syntax error at unexpected symbol 'size'
./game.py: line 4: `size = width, height = 320, 240'
can anyone here tell me what's going wrong?
thanks
On 09/04/2012 21:20, aapeetnootjes wrote:
I'm trying out the pygame tutorial at
http://www.pygame.org/docs/tut/intro/intro.html
If I try out the code I'm facing an error:
./game.py: line 4: syntax error at unexpected symbol 'size'
./game.py: line 4: `size = width, height = 320, 240'
can
In article
1a558398-3984-4b20-8d67-a0807871b...@v1g2000yqm.googlegroups.com,
aapeetnootjes ilyacool...@gmail.com wrote:
I'm trying out the pygame tutorial at
http://www.pygame.org/docs/tut/intro/intro.html
If I try out the code I'm facing an error:
./game.py: line 4: syntax error at
mixolydian mixolydian@postersRUS wrote:
I want to get into Python progamming for both local database applications and
dynamic web pages. Maybe some QD scripts.
There is a ton of excellent language books.
I have downloaded and installed 2.7.2 and got it working by pasting samples
into IDLE, and
On Tue, 03 Jan 2012 17:13:17 -0600, mixolydian wrote:
I want to get into Python progamming for both local database
applications and dynamic web pages. Maybe some QD scripts.
I am new to Python too, and recently completed my first real cross-
platform GUI application with local/remote database
Ben Finney ben+pyt...@benfinney.id.au writes:
* Cross-platform, so that you're not denied the use of any popular
workstation OS.
For my purposes, either { GNU Screen + Bash + Emacs } or { GNU Screen +
Bash + Vim } are good choices satisfying all the above criteria. There
may be other good
I want to get into Python progamming for both local database applications and
dynamic web pages. Maybe some QD scripts.
There is a ton of excellent language books.
I have downloaded and installed 2.7.2 and got it working by pasting samples
into IDLE, and uploading to my web server and doing
mixolydian mixolydian@postersRUS writes:
I want to get into Python progamming for both local database
applications and dynamic web pages. Maybe some QD scripts.
Welcome to the Python community. You have found a good general-purpose
programming language, and I hope you find the right help for
On Tue, 03 Jan 2012 17:13:17 -0600, mixolydian wrote:
I would like some advice on:
1. IDEs
Avoid them. Everything you need can be used with two applications:
- a programmer's text editor;
- a decent terminal (console) application.
A decent text editor will allow you to have multiple files
those included modules would have to get compiled with the rest of the
code for it to work, right?
Bruce
-Original Message-
From: Chris Angelico
Sent: Saturday, July 09, 2011 10:10 PM
To: python-list@python.org
Subject: Re: Newbie help - Programming the Semantic Web with Python
On Sun, Jul
This didn't seem to work either. I was getting errors the number of
arguments expected being two, when I changed to
def add (self, args):
I seem to remember that if I removed the parentheses around sub, pred, obj,
it worked. I thought that was how it worked. What is strange is that this
is
don't know if I should look for
Python applications, or if I'll have more luck looking for Python Libraries.
Thanks,
Bruce
-Original Message-
From: Andrew Berg
Sent: Saturday, July 09, 2011 10:44 PM
To: comp.lang.python
Subject: Re: Newbie help - Programming the Semantic Web with Python
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160
On 2011.07.10 02:28 PM, Bruce Whealton wrote:
If you know of any good resources for finding python applications on
the web, this might be a good way to learn. I don't know if I
should look for Python applications, or if I'll have more luck
Hello,
So, I got this book on Programming the Semantic Web about the same
time I started learning Python. The code seems to be developed for python 2.7
and not 3, I believe. The code is here:
http://semprog.com/content/the-book/
I tried to run simpletriple.py from inside eclipse
On Sun, Jul 10, 2011 at 11:32 AM, Bruce Whealton br...@whealton.info wrote:
problem with is this line:
def add(self, (sub, pred, obj)):
I think the problem is with the parentheses before the sub. I removed those
and that seemed to fix that error or make it go away. I don’t remember how I
On 2011.07.09 08:32 PM, Bruce Whealton wrote:
Hello,
So, I got this book on Programming the Semantic Web about
the same time I started learning Python. The code seems to be
developed for python 2.7 and not 3, I believe.
If you're going to learn Python 3, I suggest learning from a
I have a class of let's say empty bottle which can have a mix of two
items. I want to create let's say 30 of these objects which will have
names based on the 2 attributes (apple juice, beer, grape juice, beer,
etc) that I provide from a list. All the objects are a mix of (1 of
three alcohols) and
You could put them in a dictionary with the key being the name, instead of a
list.
Shawn
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jan 4, 2010 at 1:32 PM, Shawn Milochik sh...@milochik.com wrote:
You could put them in a dictionary with the key being the name, instead of a
list.
To illustrate that for the OP:
name2drink = {}
for booze in liquors:
for juice in juices:
name = juice + +booze # or however
2010-01-04, 22:54:41 Chris Rebert c...@rebertia.com wrote:
name2drink = {}
for booze in liquors:
for juice in juices:
name = juice + +booze # or however you're naming them
drink = Bottle(booze, juice)
name2drink[name] = drink
@Nav: ...and if you really desire to
On Jan 4, 4:54 pm, Chris Rebert c...@rebertia.com wrote:
On Mon, Jan 4, 2010 at 1:32 PM, Shawn Milochik sh...@milochik.com wrote:
You could put them in a dictionary with the key being the name, instead of
a list.
To illustrate that for the OP:
name2drink = {}
for booze in liquors:
On Jan 4, 2010, at 5:59 PM, Nav wrote:
On Jan 4, 4:54 pm, Chris Rebert c...@rebertia.com wrote:
On Mon, Jan 4, 2010 at 1:32 PM, Shawn Milochik sh...@milochik.com wrote:
You could put them in a dictionary with the key being the name, instead of
a list.
To illustrate that for the OP:
Nav wrote:
On Jan 4, 4:54 pm, Chris Rebert c...@rebertia.com wrote:
On Mon, Jan 4, 2010 at 1:32 PM, Shawn Milochik sh...@milochik.com wrote:
You could put them in a dictionary with the key being the name, instead of
a list.
To illustrate that for the OP:
name2drink = {}
for booze in
Thanks Jan,
You read my mind. That is exactly what I needed.
Thanks for showing the product function from itertools as well. It
seems easier to grasp than the nested loops, I had been using.
I noticed chopin.edu.pl. Are you a musician?
Nav
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 5, 9:33 am, Nav navjotmu...@gmail.com wrote:
what are the risks of globalnamespace use
You're unnecessarily tying your code to the implementation.
and what are the benefits?
Absolutely none that using a dictionary doesn't also give you.
--
Okay, let me ask another question:
When we create instances of objects by doing
x = className ()
are we using globalnamespace?
if yes then:
if using globalnamespace is bad then why does every book or tutorial
about python classes give the above style of assignment as an
example?
Second why
Thanks for pointing it out Steve. The blog post doesn't explain it
very well. I understand the risk of exec or eval(input). but what are
the risks of globalnamespace use and what are the benefits?
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 04 Jan 2010 19:12:53 -0800, Nav wrote:
Okay, let me ask another question:
When we create instances of objects by doing
x = className()
are we using globalnamespace?
That depends on whether you are doing x = className() inside a function
(or class), or in the top level of the
On Jan 5, 1:12 pm, Nav navjotmu...@gmail.com wrote:
When we create instances of objects by doing
x = className ()
are we using globalnamespace?
Well, you're using a namespace, which namespaces its in would depend
on the scope in which that assignment occurred. And there's not really
a global
(You top-posted. It's polite on most newsgroups, and specifically on
this one to add your comments *following* the quoted earlier text)
Nav wrote:
Okay, let me ask another question:
When we create instances of objects by doing
x = className ()
are we using globalnamespace?
If that line
if yes then:
if using globalnamespace is bad then why does every book or tutorial
about python classes give the above style of assignment as an
example?
That's a basic assignment example. It's not a direct manipulation of
globals(), like the solution given by Jan, which you seem to feel is
On Mon, 04 Jan 2010 21:27:12 -0800, Nav wrote:
@ Steven
No, you're confused -- the problem isn't with using the global
namespace.
The problem is that you don't know what names you want to use ahead of
time.
Actually I know what the names would be and how I want to use them.
You
Hi All,
I am new to Python, and have a very specific task to accomplish. I
have a command line shell script that takes two arguments:
create_graphs.sh -v --sta=STANAME
where STANAME is a string 4 characters long.
create_graphs creates a series of graphs using Matlab (among other 3rd
Try replacing:
cmd = [ ls /path/to/file/+staname+_info.pf ]
with:
cmd = [ “ls”, “/path/to/file/+staname+_info.pf ]
Basically, the first is the conceptual equivalent of executing the
following in BASH:
‘ls /path/to/file/FOO_info.pf’
The second is this:
‘ls’ ‘/path/to/file/FOO_info.pf’
The
Thanks Matt - that worked.
Kind regards,
- Rob
On Jun 16, 2009, at 12:47 PM, Matt wrote:
Try replacing:
cmd = [ ls /path/to/file/+staname+_info.pf ]
with:
cmd = [ “ls”, “/path/to/file/+staname+_info.pf ]
Basically, the first is the conceptual equivalent of executing the
following in
Matt hellzfury+pyt...@gmail.com (M) wrote:
M Try replacing:
M cmd = [ ls /path/to/file/+staname+_info.pf ]
M with:
M cmd = [ “ls”, “/path/to/file/+staname+_info.pf ]
In addition I would like to remark that -- if the only thing you want to
do is to start up a new command with
On Tue, 16 Jun 2009 23:20:05 +0200
Piet van Oostrum p...@cs.uu.nl wrote:
Matt hellzfury+pyt...@gmail.com (M) wrote:
M Try replacing:
M cmd = [ ls /path/to/file/+staname+_info.pf ]
M with:
M cmd = [ “ls”, “/path/to/file/+staname+_info.pf ]
In addition I would like to remark that
Hi,
I am new to python. I have been having trouble using the MysqlDB. I
get an error pointing from the line
cursor.execute(UPDATE article SET title = %s, text = %s WHERE id =
%u, (self.title, self.text, self.id))
Here is the error:
line 56, in save
cursor.execute(UPDATE article SET title
On Jun 8, 1:43 pm, Iain Adams [EMAIL PROTECTED] wrote:
Hi,
I am new to python. I have been having trouble using the MysqlDB. I
get an error pointing from the line
cursor.execute(UPDATE article SET title = %s, text = %s WHERE id =
%u, (self.title, self.text, self.id))
Here is the error:
On Jun 8, 11:43 am, Iain Adams [EMAIL PROTECTED] wrote:
Hi,
I am new to python. I have been having trouble using the MysqlDB. I
get an error pointing from the line
cursor.execute(UPDATE article SET title = %s, text = %s WHERE id =
%u, (self.title, self.text, self.id))
Here is the error:
Hi,
I'm new to this having previously done some programming in Game Maker.
In Game Maker there was a function (Alarm) that lets you run a block of code
run every x seconds without freezing up the whole program waiting for it.
Is there an equavalant for this built in Python beacuse I can't find it?
On Feb 28, 11:22 pm, Grant Edwards [EMAIL PROTECTED] wrote:
On 2008-02-29, Gabriel Genellina [EMAIL PROTECTED] wrote:
En Fri, 29 Feb 2008 00:20:26 -0200, [EMAIL PROTECTED] escribió:
Hi everyone. I'm fairly new to Python, and even more new to socket
programming. I think I've wrapped my
On 2008-02-29, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
You claim to be writing a telnet server, yet I don't see any
code that actually implements the telnet protocol. Different
telnet clients default to different modes, so if you want them
in a certain mode, you have to put them in the
On Feb 29, 9:42 am, Grant Edwards [EMAIL PROTECTED] wrote:
On 2008-02-29, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
You claim to be writing a telnet server, yet I don't see any
code that actually implements the telnet protocol. Different
telnet clients default to different modes, so if
Hi everyone. I'm fairly new to Python, and even more new to socket
programming. I think I've wrapped my head around sockets, and with
that I want to create a Telnet-based chat server, the idea being
people connect to the telnet servers with their clients and they all
communicate. I've got the code
Hello,
Hi everyone. I'm fairly new to Python, and even more new to socket
programming. I think I've wrapped my head around sockets, and with
that I want to create a Telnet-based chat server, the idea being
people connect to the telnet servers with their clients and they all
communicate.
IMO
En Fri, 29 Feb 2008 00:20:26 -0200, [EMAIL PROTECTED] escribió:
Hi everyone. I'm fairly new to Python, and even more new to socket
programming. I think I've wrapped my head around sockets, and with
that I want to create a Telnet-based chat server, the idea being
people connect to the telnet
On 2008-02-29, Gabriel Genellina [EMAIL PROTECTED] wrote:
En Fri, 29 Feb 2008 00:20:26 -0200, [EMAIL PROTECTED] escribió:
Hi everyone. I'm fairly new to Python, and even more new to socket
programming. I think I've wrapped my head around sockets, and with
that I want to create a Telnet-based
Hi I am trying to get a piece of code to work based on an exercise in
a book. Any help appreciated. Can someone please explain what is going
on here.
I am trying to read from a text file a list of cards with the
following format and sort firstly by suit and then by rank
h 1
d 2
c 5
s 9
h2
d3
On 26 May 2007 00:23:32 -0700, mark [EMAIL PROTECTED] wrote:
Hi I am trying to get a piece of code to work based on an exercise in
a book. Any help appreciated. Can someone please explain what is going
on here.
I am trying to read from a text file a list of cards with the
following format
The problem is that in your function t is a string (one of the cards
in the list called cards) and strings don't have the ability to use
the append method. But lists do. Therefore t.append is wrong but
cards.append works fine. (Append means take the list you have and
add what is in the
The following code only returns the last row(22) added to the
machines dictionary.
presumably I need some additional syntax to add rows to the dictionary
rather than overwrite.
What do I need to add?
machinekey = 11
machines = { machinekey:[1,0,0,0,0,0,0,0,0,0,0,0,0] }
machinekey =
On Mon, Apr 16, 2007 at 06:43:37AM -0700, loial wrote:
The following code only returns the last row(22) added to the
machines dictionary.
presumably I need some additional syntax to add rows to the dictionary
rather than overwrite.
What do I need to add?
machinekey = 11
machines[machinekey] = [0,1,0,0,0,0,0,0,0,0,0,0,0]
is what I needed...thanks
On 16 Apr, 15:07, Christoph Haas [EMAIL PROTECTED] wrote:
On Mon, Apr 16, 2007 at 06:43:37AM -0700, loial wrote:
The following code only returns the last row(22) added to the
machines dictionary.
presumably
I am new to python and am converting an awk script to python
I need to store some data in an array/table of some form
keyvalue1, value1, value2, value3
keyvalue2, value1,value2, value3
keyvalue3, value1,value2,value3
etc
I will later need to sort in keyvalue order and also need to be able
to
do something like this
{keyvalue1:[ value1, value2, value3],keyvalue2:[value1,value2,
value3],keyvalue3,:[value1,value2,value3]}
On 12 Apr 2007 00:58:54 -0700, loial [EMAIL PROTECTED] wrote:
I am new to python and am converting an awk script to python
I need to store some data in an
use dir with list nested
for example:
{key1 : [value1, value2, value3], key2 : [value1, value2, vlaue4]}
loial [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I am new to python and am converting an awk script to python
I need to store some data in an array/table of some form
loial:
I am new to python and am converting an awk script to python
It seems there are many people trying to convert awk code to
Python :-)
I need to store some data in an array/table of some form
keyvalue1, value1, value2, value3
keyvalue2, value1,value2, value3
keyvalue3,
loial a écrit :
I am new to python and am converting an awk script to python
I need to store some data in an array/table of some form
keyvalue1, value1, value2, value3
keyvalue2, value1,value2, value3
keyvalue3, value1,value2,value3
etc
data = dict(
keyvalue1=[value11, value12,
loial wrote:
I am new to python and am converting an awk script to python
I need to store some data in an array/table of some form
keyvalue1, value1, value2, value3
keyvalue2, value1,value2, value3
keyvalue3, value1,value2,value3
etc
I will later need to sort in keyvalue order and also
OK, thanks for the replies
One other thing...I need to update the values since they are basically
totals that I am accumulating.
How do I update a specific value for a specific key?
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 12, 3:31 am, loial [EMAIL PROTECTED] wrote:
OK, thanks for the replies
One other thing...I need to update the values since they are basically
totals that I am accumulating.
How do I update a specific value for a specific key?
mydict[keyvalue1]
returns the value, which in this case
On Apr 12, 3:50 am, 7stud [EMAIL PROTECTED] wrote:
On Apr 12, 3:31 am, loial [EMAIL PROTECTED] wrote:
lst = mydict[keyvalue1]
lst[0] = 4
list.append(red)
Rather the last line there should read:
lst.append(red)
--
http://mail.python.org/mailman/listinfo/python-list
Since you are a beginner and since RCCILA (Runnable, Commented Code Is
Least Ambiguous) I'm proving this example code to help you get used to
manipulating data with python. This should give you an idea of how to
juggle a bit. After you learn how to do this you likely still will not
be
Hey all,
Can someone help me reduce this code? It sure seems
like there ought to be a way to loop this or combine
things so that there is only 1 or 3 lines to this
instead of 6. I've been scratching my head over this
for a while though I can't come up with anything.
Just as a note, I need
Lance Hoffmeyer [EMAIL PROTECTED] writes:
T2B = even_odd_round(float(str(T2B)))
VS = even_odd_round(float(str(VS)))
SS = even_odd_round(float(str(SS)))
sh.Cells(21,lastcol+1).Value = float(str(T2B))/100
sh.Cells(22,lastcol+1).Value = float(str(VS))/100
sh.Cells(23,lastcol+1).Value =
Lance Hoffmeyer [EMAIL PROTECTED] writes:
def even_odd_round(num):
if(round(num,2) + .5 == int(round(num,2)) + 1):
if num .5:
if(int(num) % 2):
num = round(num,2) + .1 #an odd number
else:
In article [EMAIL PROTECTED],
Paul Rubin http://[EMAIL PROTECTED] wrote:
Lance Hoffmeyer [EMAIL PROTECTED] writes:
def even_odd_round(num):
if(round(num,2) + .5 == int(round(num,2)) + 1):
if num .5:
if(int(num) % 2):
num =
thanks , i got it
--
http://mail.python.org/mailman/listinfo/python-list
hi...
i m now updating an sql file
old file contains lines
insert into mobilebill values ('Apr 01, 03', 'OUT', '91804103253', 34,
3.2);
insert into mobilebill values ('Apr 01, 03', 'OUT', '91806392475', 84,
5.2);
insert into mobilebill values ('Apr 01, 03', 'OUT', '918317048193', 76,
7.6);
i
techie2go wrote:
i m now updating an sql file
=
but the output is just
2003-01-04
and not
insert into mobilebill values ('2003-01-04', 'OUT', '91804103253', 34,
3.2);
help me in this regard, what did i do wrong...
You can find out yourself if you throw in some print
Hi Listers,
I have a requirement to test for a data type could someone tell me if this
is possible in python?
Basically I have a ZPT in Zope that users can select checkboxes in a form
which pass arguments for a python function, however if there is only one
checkbox selected it is passed as a
Jonathan Bowlas wrote:
Hi Listers,
I have a requirement to test for a data type could someone tell me if this
is possible in python?
Basically I have a ZPT in Zope that users can select checkboxes in a form
which pass arguments for a python function, however if there is only one
checkbox
Jonathan Bowlas wrote:
Hi Listers,
I have a requirement to test for a data type could someone tell me if this
is possible in python?
Basically I have a ZPT in Zope that users can select checkboxes in a form
which pass arguments for a python function, however if there is only one
checkbox
Thanks for everyones help, much appreciated, Ill check
out the isinstance function.
Jon
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dennis
Benzinger
Sent: 31 July 2006 10:20
To: python-list@python.org
Subject: Re: Newbie help - test
This is my function:
selecteddeptcodes = context.REQUEST.DEPTCODE
currentstatus = context.REQUEST.STATUS
if currentstatus == 'pending':
for dptcd in selecteddeptcodes:
context.changetolive(DEPTCODE=dptcd)
if currentstatus == 'old':
for dptcd in selecteddeptcodes:
Jonathan Bowlas wrote:
Hi Listers,
I have a requirement to test for a data type could someone tell me if this
is possible in python?
Basically I have a ZPT in Zope that users can select checkboxes in a form
which pass arguments for a python function, however if there is only one
checkbox
John Machin wrote:
Jonathan Bowlas wrote:
Hi Listers,
I have a requirement to test for a data type could someone tell me if this
is possible in python?
Basically I have a ZPT in Zope that users can select checkboxes in a form
which pass arguments for a python function, however if there is
Dennis Benzinger wrote:
Jonathan Bowlas wrote:
Hi Listers,
I have a requirement to test for a data type could someone tell me if
this
is possible in python?
Basically I have a ZPT in Zope that users can select checkboxes in a form
which pass arguments for a python function, however if
Rob Wolfe wrote:
This is my function:
selecteddeptcodes = context.REQUEST.DEPTCODE
currentstatus = context.REQUEST.STATUS
if currentstatus == 'pending':
for dptcd in selecteddeptcodes:
context.changetolive(DEPTCODE=dptcd)
if currentstatus == 'old':
for dptcd in selecteddeptcodes:
rh0dium wrote:
Hi all,
Can someone help me out. I am trying to determing for each run whether
or not the test should pass or fail but I can't seem to access the
results ..
Alternatively can someone suggest a better structure ( and a lesson as
to the reasoning ) that would be great too!!
Hi all,
Can someone help me out. I am trying to determing for each run whether
or not the test should pass or fail but I can't seem to access the
results ..
Alternatively can someone suggest a better structure ( and a lesson as
to the reasoning ) that would be great too!!
cells={}
rh0dium wrote:
Hi all,
Can someone help me out. I am trying to determing for each run whether
or not the test should pass or fail but I can't seem to access the
results ..
Alternatively can someone suggest a better structure ( and a lesson as
to the reasoning ) that would be great too!!
Can someone help me out. I am trying to determing for each run whether
or not the test should pass or fail but I can't seem to access the
results ..
Alternatively can someone suggest a better structure ( and a lesson as
to the reasoning ) that would be great too!!
Flat is better than
rh0dium wrote:
Hi all,
Can someone help me out. I am trying to determing for each run whether
or not the test should pass or fail but I can't seem to access the
results ..
Alternatively can someone suggest a better structure ( and a lesson as
to the reasoning ) that would be great too!!
rh0dium a écrit :
Hi all,
Can someone help me out. I am trying to determing for each run whether
or not the test should pass or fail but I can't seem to access the
results ..
(snip)
cells={}
cells[NOR3X1]= {
'run' : [ 'lvs', 'drc' ],
Hi,
I'm quite new to Python and I'm in need of help!
I need to open an audio file, divide it into frame-based intervals and
for each of those interval I have to analyze the sound level.
audioop.rms() should do the trick, but I can't find a way to convert a
frame interval (taken via
3. Any good ebooks or links to start with. (according to the web this is
the
best place to start.)
If you get the point of wantig to buy a book, I can recommend Python Visual
Quickstart Guide by Chris Fhris Fehily as a very good text for beginners. I
has helped me a lot.
--
Hi All,
im new to python i just have a few questions and was wondering if
you could help me??
1. what programming langaugue does python use? or which is most popular?
2. Does anyone know where i could get hold of practice code
3. Any good ebooks or links to start with. (according to
Stephen [EMAIL PROTECTED] wrote:
Hi All,
im new to python i just have a few questions and was wondering if
you could help me??
1. what programming langaugue does python use? or which is most popular?
Python _is_ a programming language, so your question is not clear. If
you're
Stephen wrote:
Hi All,
im new to python i just have a few questions and was wondering if
you could help me??
1. what programming langaugue does python use? or which is most popular?
2. Does anyone know where i could get hold of practice code
3. Any good ebooks or links to
Alex Martelli wrote:
Stephen [EMAIL PROTECTED] wrote:
Hi All,
im new to python i just have a few questions and was wondering if
you could help me??
1. what programming langaugue does python use? or which is most popular?
Python _is_ a programming language, so your question
On 1 Dec 2005 05:45:54 -0800, Niels L Ellegaard [EMAIL PROTECTED] wrote:
I just started learning python and I have been wondering. Is there a
short pythonic way to find the element, x, of a list, mylist, that
maximizes an expression f(x).
In other words I am looking for a short version of the
[EMAIL PROTECTED] wrote:
Thanks. In that case, would it be easier to understand(beside the
original iterative loop) if I use reduce and lambda ?
You could try putting them side by side and seeing which is easiest for
someone to understand:
reduce(lambda (mv,mx), (v,x): mv v and (mv,mx) or
[EMAIL PROTECTED] wrote:
...
As while DSU is a very smart way to guard the max compare thing, it is
still being introduced as a way that is not related to the original
problem, i.e. I just want to compare f(x)
And that's why in 2.5 you'll just code max(mylist, key=f) to express
this intent
I just started learning python and I have been wondering. Is there a
short pythonic way to find the element, x, of a list, mylist, that
maximizes an expression f(x).
In other words I am looking for a short version of the following:
pair=[mylist[0],f(mylist[0])]
for x in mylist[1:]:
if f(x)
If the elements of mylist can be compared (es. not complex values),
then this can be a solution for you:
from math import sin as f
mylist = [float(2*i)/10 for i in xrange(10)]
pairs = [(f(x), x) for x in mylist]
ymax = max(pairs)[1]
print pairs, \n
print ymax
You can also try this, for Py2.4:
Niels L Ellegaard wrote:
I just started learning python and I have been wondering. Is there a
short pythonic way to find the element, x, of a list, mylist, that
maximizes an expression f(x).
In other words I am looking for a short version of the following:
pair=[mylist[0],f(mylist[0])]
wrote:
In other words I am looking for a short version of the following:
pair=[mylist[0],f(mylist[0])]
for x in mylist[1:]:
if f(x) pair[1]:
pair=[x,f(x)]
this is already very short, what else you want? May be this :
max(((f(x), x) for x in mylist))
That is first
1 - 100 of 159 matches
Mail list logo