pygame: output to file?

2012-04-16 Thread superpollo
HI. is there a way to convert the graphical output of a pygame application to a mpeg file or better an animated gif? i mean, not using an external capture program... bye -- http://mail.python.org/mailman/listinfo/python-list

Re: pygame: output to file?

2012-04-16 Thread superpollo
alex23 ha scritto: On Apr 16, 7:34 pm, superpollo wrote: is there a way to convert the graphical output of a pygame application to a mpeg file or better an animated gif? i mean, not using an external capture program... There is, but it's probably not going to be as performant as

Re: pygame: output to file?

2012-04-16 Thread superpollo
superpollo ha scritto: alex23 ha scritto: On Apr 16, 7:34 pm, superpollo wrote: is there a way to convert the graphical output of a pygame application to a mpeg file or better an animated gif? i mean, not using an external capture program... There is, but it's probably not going to

simple cgi program

2010-01-17 Thread superpollo
hi clp. i would like to submit the following code for review. it is a simple common gateway interface program, which uses the least possible libraries for the sake of mechanism undertanding. the third option in the firts conditional is for commandline testing. bye. code follows as: #

Re: simple cgi program

2010-01-17 Thread superpollo
D'Arcy J.M. Cain ha scritto: On Sun, 17 Jan 2010 15:15:12 +0100 superpollo wrote: hi clp. i would like to submit the following code for review. it is a simple common gateway interface program, which uses the least possible libraries for the sake of mechanism undertanding. Why not jus

Re: substitution

2010-01-18 Thread superpollo
superpollo ha scritto: hi. what is the most pythonic way to substitute substrings? eg: i want to apply: foo --> bar baz --> quux quuux --> foo so that: fooxxxbazyyyquuux --> barxxxquuxyyyfoo bye i explain better: say the subs are: quuux --> foo foo --> bar baz -->

substitution

2010-01-18 Thread superpollo
hi. what is the most pythonic way to substitute substrings? eg: i want to apply: foo --> bar baz --> quux quuux --> foo so that: fooxxxbazyyyquuux --> barxxxquuxyyyfoo bye -- http://mail.python.org/mailman/listinfo/python-list

Re: substitution

2010-01-18 Thread superpollo
it looked simpler when i posted, but i realize that the problem is non trivial. thanks to everybody. i guess that the algorithm would be easier if it was known in advance that the string to substitute must have some specific property, say: 1) they all must start with "XYZ" 2) they all have t

not and is not problem

2010-01-18 Thread superpollo
hi: #!/usr/bin/env python data = "seq=123" name , value = data.split("=") print name print value if not name == "seq": print "DOES NOT PRINT OF COURSE..." if name is not "seq": print "WTF! WHY DOES IT PRINT?" help please. bye -- http://mail.python.org/mailman/listinfo/python-list

Re: What is a list compression in Python?

2010-01-18 Thread superpollo
Kit ha scritto: Hello Everyone, I am not sure if I have posted this question in a correct board. Can anyone please teach me: What is a list compression in Python? Would you mind give me some list compression examples? Thanks & really appreciate that. Kit i think that's compreHENsion... htt

Re: [ANN] Data Plotting Library DISLIN 10.0

2010-01-19 Thread superpollo
Helmut Michels ha scritto: Dear Pytnon users, I am pleased to announce version 10.0 of the data plotting software DISLIN. why dont you make it free software (i mean. GPL'ed) bye -- http://mail.python.org/mailman/listinfo/python-list

off topic but please forgive me me and answer

2010-04-01 Thread superpollo
how much is one half times one half? -- http://mail.python.org/mailman/listinfo/python-list

Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo
Patrick Maupin ha scritto: On Apr 2, 2:41 pm, Andreas Waldenburger wrote: While everyone else is mocking you: Can you please elaborate on why you want to know and what kind of problem you're trying to solve with this? Also, don't you think you should have picked a maths forum for this kind of

Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo
Steve Holden ha scritto: superpollo wrote: Patrick Maupin ha scritto: On Apr 2, 2:41 pm, Andreas Waldenburger wrote: While everyone else is mocking you: Can you please elaborate on why you want to know and what kind of problem you're trying to solve with this? Also, don't you

Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo
Mensanator ha scritto: On Apr 3, 8:00 am, superpollo wrote: Patrick Maupin ha scritto: On Apr 2, 2:41 pm, Andreas Waldenburger wrote: While everyone else is mocking you: Can you please elaborate on why you want to know and what kind of problem you're trying to solve with this?

Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo
Patrick Maupin ha scritto: On Apr 3, 8:00 am, superpollo wrote: sorry if I misunderstood. no no you understood prfectly *but* the thing is i am a regular in an italian language math ng which is haunted by a crackpot who insists that 1/2 * 1/2 cannot be 1/4, "because multiplication

Re: off topic but please forgive me me and answer

2010-04-04 Thread superpollo
rantingrick ha scritto: On Apr 1, 3:44 pm, superpollo wrote: how much is one half times one half? This is amazing, how can such an off topic post based completely on lunacy exist so long here? 54 posts and counting. I think i had this very argument in grade school. We have SD'A, Tim

Re: pythonrag

2010-04-05 Thread superpollo
Jason Friedman ha scritto: I saw this posted in the July issue but did not see any follow-up there: $ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. a = 500 b = 500 a == b True a is b False

Re: Recommend Commercial graphing library

2010-04-06 Thread superpollo
Grant Edwards ha scritto: On 2010-04-06, Grant Edwards wrote: On 2010-04-06, Jean-Michel Pichavant wrote: Pablo Recio Quijano wrote: Why must be commercial, when there is open and free alternatives? Like GNU Plot. Gnuplot is ugly. I'm using it because I don't care if it's ugly but it clearl

Re: Python script error when using print

2010-04-06 Thread superpollo
Robbie ha scritto: Hi all, So, I'm trying to use Python with an apache2 server to create some web pages. The web server is configured and seems to work correctly, but only with a certain type of script. For instance, this script works fine #!/usr/bin/env python def index(): s = "Hello Wor

Re: Teaching Programming

2010-05-04 Thread superpollo
Samuel Williams ha scritto: I personally like indentation. I just wonder whether it is an issue that some people will dislike. i think there is an issue if you -- say -- produce python code, from within another programming environment, to be executed on the fly, at least in some instances. t

Re: Teaching Programming

2010-05-04 Thread superpollo
Stefan Behnel ha scritto: superpollo, 04.05.2010 12:28: i think there is an issue if you -- say -- produce python code, from within another programming environment, to be executed on the fly, at least in some instances. there might be problems if for example you generate code from a one-line

Re: Teaching Programming

2010-05-04 Thread superpollo
Stefan Behnel ha scritto: superpollo, 04.05.2010 13:23: Stefan Behnel ha scritto: the main reason why this problem doesn't hurt much in Python is that Python is a dynamic language that can get you extremely far without generating code. It's simply not necessary in most cases, so pe

Re: Teaching Programming

2010-05-04 Thread superpollo
Martin P. Hellwig ha scritto: On 05/04/10 11:28, superpollo wrote: Samuel Williams ha scritto: I personally like indentation. I just wonder whether it is an issue that some people will dislike. there might be problems if for example you generate code from a one-line template. Well a one

Re: Teaching Programming

2010-05-04 Thread superpollo
James Mills ha scritto: On Tue, May 4, 2010 at 9:56 PM, superpollo wrote: of course! *but* if i must generate on-the-fly python code that defines a function i am back again to the problem: One-liner: $ python Python 2.6.5 (r265:79063, Apr 27 2010, 18:26:49) [GCC 4.4.1 (CRUX)] on linux2 Type

Re: Teaching Programming

2010-05-04 Thread superpollo
Stefan Behnel ha scritto: superpollo, 04.05.2010 13:56: Stefan Behnel ha scritto: The question is: why do you have to generate the above code in the first place? Isn't a function enough that does the above? of course! *but* if i must generate on-the-fly python code that defines a fun

Re: Teaching Programming

2010-05-04 Thread superpollo
Stefan Behnel ha scritto: superpollo, 04.05.2010 14:46: my template system wants the input to generate the code to stay on a single line ( don't ask :-( ) I hope you don't mind if I still ask. What are you generating and for what templating system? ok, since you asked for i

Re: Teaching Programming

2010-05-04 Thread superpollo
superpollo ha scritto: Stefan Behnel ha scritto: superpollo, 04.05.2010 14:46: my template system wants the input to generate the code to stay on a single line ( don't ask :-( ) I hope you don't mind if I still ask. What are you generating and for what templating system? ok,

Re: Teaching Programming

2010-05-04 Thread superpollo
James Mills ha scritto: On Tue, May 4, 2010 at 9:56 PM, superpollo wrote: of course! *but* if i must generate on-the-fly python code that defines a function i am back again to the problem: One-liner: $ python Python 2.6.5 (r265:79063, Apr 27 2010, 18:26:49) [GCC 4.4.1 (CRUX)] on linux2 Type

Re: Teaching Programming

2010-05-04 Thread superpollo
superpollo ha scritto: James Mills ha scritto: On Tue, May 4, 2010 at 9:56 PM, superpollo wrote: of course! *but* if i must generate on-the-fly python code that defines a function i am back again to the problem: One-liner: $ python Python 2.6.5 (r265:79063, Apr 27 2010, 18:26:49) [GCC

Re: Teaching Programming

2010-05-04 Thread superpollo
superpollo ha scritto: superpollo ha scritto: James Mills ha scritto: On Tue, May 4, 2010 at 9:56 PM, superpollo wrote: of course! *but* if i must generate on-the-fly python code that defines a function i am back again to the problem: One-liner: $ python Python 2.6.5 (r265:79063, Apr 27

Re: Teaching Programming

2010-05-05 Thread superpollo
Martin P. Hellwig ha scritto: On 05/04/10 12:59, superpollo wrote: Martin P. Hellwig ha scritto: For the corner cases (I can think of a couple) it is good to know you can use ';' most of the time. most but not always as i noted (think about loops or function definition) Well

Re: Kindly show me a better way to do it

2010-05-08 Thread superpollo
Oltmans ha scritto: Hi, I've a list that looks like following a = [ [1,2,3,4], [5,6,7,8] ] Currently, I'm iterating through it like for i in [k for k in a]: for a in i: i think you used te a identifier for two meanings... print a but I was wondering if there is a s

Re: Kindly show me a better way to do it

2010-05-08 Thread superpollo
superpollo ha scritto: Oltmans ha scritto: Hi, I've a list that looks like following a = [ [1,2,3,4], [5,6,7,8] ] Currently, I'm iterating through it like for i in [k for k in a]: for a in i: i think you used te a identifier for two meanings... print a but I was wo

Re: Kindly show me a better way to do it

2010-05-08 Thread superpollo
Oltmans ha scritto: On May 9, 1:53 am, superpollo wrote: add = lambda a,b: a+b for i in reduce(add,a): print i This is very neat. Thank you. Sounds like magic to me. Can you please explain how does that work? Many thanks again. here: http://tinyurl.com/3xp and here: http

solve a newspaper quiz

2010-05-09 Thread superpollo
"if a b c are digits, solve ab:c=a*c+b" solved in one minute with no thought: for a in range(10): for b in range(10): for c in range(10): try: if (10.*a+b)/c==a*c+b: print "%i%i:%i=%i*%i+%i" % (a,b,c,a,c,b) except:

Re: Extract all words that begin with x

2010-05-10 Thread superpollo
Jimbo ha scritto: Hello I am trying to find if there is a string OR list function that will search a list of strings for all the strings that start with 'a' & return a new list containing all the strings that started with 'a'. I have had a search of Python site & I could not find what I am look

Re: Extract all words that begin with x

2010-05-10 Thread superpollo
superpollo ha scritto: Jimbo ha scritto: Hello I am trying to find if there is a string OR list function that will search a list of strings for all the strings that start with 'a' & return a new list containing all the strings that started with 'a'. I have had a s

Re: Extract all words that begin with x

2010-05-11 Thread superpollo
Aahz ha scritto: In article , Terry Reedy wrote: On 5/10/2010 5:35 AM, James Mills wrote: On Mon, May 10, 2010 at 6:50 PM, Xavier Ho wrote: Have I missed something, or wouldn't this work just as well: list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas'] [word for word in list_of_

Re: Slice last char from string without raising exception on empty string (Re: Extract all words that begin with x)

2010-05-11 Thread superpollo
pyt...@bdurham.com ha scritto: Terry, ... word[0:1] does the same thing. All Python programmers should learn to use slicing to extract a char from a string that might be empty. Is there an equivalent way to slice the last char from a string (similar to an .endswith) that doesn't raise an ex

Re: Iterating over dict and removing some elements

2010-05-11 Thread superpollo
Ulrich Eckhardt ha scritto: Hi! I wrote a simple loop like this: d = {} ... for k in d: if some_condition(d[k]): d.pop(k) If I run this, Python complains that the dictionary size changed during iteration. I understand that the iterator relies on the internal structure not

Re: Iterating over dict and removing some elements

2010-05-11 Thread superpollo
superpollo ha scritto: Ulrich Eckhardt ha scritto: Hi! I wrote a simple loop like this: d = {} ... for k in d: if some_condition(d[k]): d.pop(k) If I run this, Python complains that the dictionary size changed during iteration. I understand that the iterator relies on

Re: Slice last char from string without raising exception on empty string (Re: Extract all words that begin with x)

2010-05-11 Thread superpollo
James Mills ha scritto: On Wed, May 12, 2010 at 2:01 AM, wrote: word[len(word)-1:] This works just as well: word[-1:] d'uh. ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Extract all words that begin with x

2010-05-12 Thread superpollo
Stefan Behnel ha scritto: superpollo, 11.05.2010 17:03: Aahz ha scritto: In article , Terry Reedy wrote: On 5/10/2010 5:35 AM, James Mills wrote: On Mon, May 10, 2010 at 6:50 PM, Xavier Ho wrote: Have I missed something, or wouldn't this work just as well: list_of_strings = ['

Re: Data store solution need help

2010-05-14 Thread superpollo
Haulyn Jason ha scritto: Hi, all: I am a Java programmer, now I am working on a Python program. At the moment, I need to store some data from user's input, no database, no xml, no txt(we can not make users open the data file by vim or other text editor). security thru obscurity? mmmhhh... -

Re: Human word reader

2010-05-15 Thread superpollo
timo verbeek ha scritto: I'm planning to create a human word program A human inputs a string "Give me the weather for London please." Then I will strip the string. "weather for london" Then I get the useful information. what:"weather" where:"london" After that I use the info. I need help with ge

Re: Human word reader

2010-05-15 Thread superpollo
superpollo ha scritto: timo verbeek ha scritto: I'm planning to create a human word program A human inputs a string "Give me the weather for London please." Then I will strip the string. "weather for london" Then I get the useful information. what:"weather"

Re: parsing XML

2010-05-15 Thread superpollo
kak...@gmail.com ha scritto: Hi to all, let's say we have the following Xml 17.1 6.4 15.5 7.8 How can i get the players name, age and height? DOM or SAX and how Thanks Antonis another minimal xml.etree.ElementTree solution: >>> print document 17.1 6.

Re: parsing XML

2010-05-15 Thread superpollo
superpollo ha scritto: kak...@gmail.com ha scritto: Hi to all, let's say we have the following Xml 17.1 6.4 15.5 7.8 How can i get the players name, age and height? DOM or SAX and how Thanks Antonis another minimal xml.etree.ElementTree solution: >

Re: Updating values in a dictionary

2010-05-16 Thread superpollo
Thomas ha scritto: Greetings I am having a darn awful time trying to update a matrix: row = dict([(x,0) for x in range(3)]) matrix = dict([(x,row) for x in range(-3,4,1)]) matrix[2][1] += 1 matrix[-1][2] += 1 """ Got: a 1 in all col 1 and 2 {-3: {0: 0, 1: 1, 2: 1}, -2: {0: 0, 1: 1, 2: 1}, -

Re: reading XML file using python

2010-05-17 Thread superpollo
Simon Brunning ha scritto: On 17 May 2010 09:34:51 UTC+1, shanti bhushan wrote: Hi , i am new to python.i want to read the XML file using python it ,by using DOm or SAX any of them. I want to read the http://www.google.com(any hyper text) from XML and print that. please give me the sample progr

recall function definition from shell

2010-05-18 Thread superpollo
>>> def myfun(): ... return "WOW" ... >>> myfun() 'WOW' >>> now, i would like to "list" the funcion definition, something like this: >>> myfun.somethinglikethis() def myfun(): return "WOW" >>> is there something like this around? bye -- http://mail.python.org/mailman/listinfo/python-li

Re: recall function definition from shell

2010-05-18 Thread superpollo
Patrick Maupin ha scritto: On May 18, 12:31 pm, superpollo wrote: >>> def myfun(): ... return "WOW" ... >>> myfun() 'WOW' >>> now, i would like to "list" the funcion definition, something like this: >>> myfun.something

Re: recall function definition from shell

2010-05-18 Thread superpollo
Patrick Maupin ha scritto: On May 18, 1:41 pm, superpollo wrote: Patrick Maupin ha scritto: On May 18, 12:31 pm, superpollo wrote: >>> def myfun(): ... return "WOW" ... >>> myfun() 'WOW' now, i would like to "list&q

Re: recall function definition from shell

2010-05-18 Thread superpollo
Peter Otten ha scritto: superpollo wrote: Patrick Maupin ha scritto: On May 18, 1:41 pm, superpollo wrote: Patrick Maupin ha scritto: On May 18, 12:31 pm, superpollo wrote: >>> def myfun(): ... return "WOW" ... >>> myfun() 'WOW' now, i would

Re: remove elements incrementally from a list

2010-05-19 Thread superpollo
Javier Montoya ha scritto: Dear all, I've a list of float numbers and I would like to delete incrementally a set of elements in a given range of indexes, sth. like: for j in range(beginIndex, endIndex+1): print ("remove [%d] => val: %g" % (j, myList[j])) del myList[j] However, since I'm

ipython question

2010-05-19 Thread superpollo
In [39]: def f(): : return 42 : In [40]: %psource f No source found for f In [41]: i expected to see the source... -- http://mail.python.org/mailman/listinfo/python-list

function that counts...

2010-05-19 Thread superpollo
... how many positive integers less than n have digits that sum up to m: In [197]: def prttn(m, n): tot = 0 for i in range(n): s = str(i) sum = 0 for j in range(len(s)): sum += int(s[j]) if sum == m: tot += 1 return tot .:

Re: ipython question

2010-05-19 Thread superpollo
Robert Kern ha scritto: On 5/19/10 12:11 PM, superpollo wrote: In [39]: def f(): : return 42 : In [40]: %psource f No source found for f In [41]: i expected to see the source... You will want to ask IPython questions on the IPython mailing list: http://mail.scipy.org/mailman

Re: ipython question

2010-05-19 Thread superpollo
superpollo ha scritto: Robert Kern ha scritto: On 5/19/10 12:11 PM, superpollo wrote: In [39]: def f(): : return 42 : In [40]: %psource f No source found for f In [41]: i expected to see the source... You will want to ask IPython questions on the IPython mailing list: http

Re: function that counts...

2010-05-19 Thread superpollo
Jerry Hill ha scritto: On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: ... any suggestion for pythonizin' it? This is how I would do it: def prttn(m, n): """How many positive integers les

Re: function that counts...

2010-05-19 Thread superpollo
René 'Necoro' Neumann ha scritto: Am 19.05.2010 21:58, schrieb superpollo: ... how many positive integers less than n have digits that sum up to m: In [197]: def prttn(m, n): tot = 0 for i in range(n): s = str(i) sum = 0 for j in range(len(s)):

Re: function that counts...

2010-05-19 Thread superpollo
Jerry Hill ha scritto: On Wed, May 19, 2010 at 4:25 PM, superpollo wrote: Jerry Hill ha scritto: sumofdigits = sum(int(char) for char in str(testval)) this line gives me this: TypeError: 'int' object is not callable is it some new feature in >2.5 ? No, sum() has b

Re: function that counts...

2010-05-19 Thread superpollo
Mark Dickinson ha scritto: On May 19, 9:30 pm, superpollo wrote: René 'Necoro' Neumann ha scritto: An idea would be: def prttn(m, n): ...return sum(1 for x in range(n) if sum(map(int, str(x))) == m) TypeError: 'int' object is not callable on 2.5.4 The

Re: function that counts...

2010-05-20 Thread superpollo
Steven D'Aprano ha scritto: On Wed, 19 May 2010 22:58:22 +0200, superpollo wrote: In [266]: del(sum) del is a statement, not a function, so the brackets are pointless. This is like writing: x = (1) instead of x = 1 `del sum` is all you need. sorry about that, thanks a lot!

Re: function that counts...

2010-05-20 Thread superpollo
Steven D'Aprano ha scritto: On Wed, 19 May 2010 21:58:04 +0200, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: In [197]: def prttn(m, n): Does the name "prttn" mean anything? I'm afraid I keep reading it as a mispelling of &q

Re: function that counts...

2010-05-20 Thread superpollo
Richard Thomas ha scritto: For this kind of problem you should avoid all that stringification. I find it best to deal with sequences of digits of a fixed length and go from there. For example: def count1(m, n, cache={}): """Number of digit sequences of length `n` summing to `m`.""" if n

Re: function that counts...

2010-05-20 Thread superpollo
Peter Pearson ha scritto: On Wed, 19 May 2010 21:58:04 +0200, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: If it's important for the function to execute quickly for large n, you might get a useful speedup by testing only every ninth in

Re: function that counts...

2010-05-20 Thread superpollo
Grant Edwards ha scritto: On 2010-05-20, superpollo wrote: Steven D'Aprano ha scritto: On Wed, 19 May 2010 21:58:04 +0200, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: In [197]: def prttn(m, n): Does the name "prttn" mean anythin

Re: function that counts...

2010-05-24 Thread superpollo
Jean-Michel Pichavant ha scritto: Jerry Hill wrote: On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: ... any suggestion for pythonizin' it? This is how I would do it: def prttn(m, n): "

Re: function that counts...

2010-05-25 Thread superpollo
Jean-Michel Pichavant ha scritto: superpollo wrote: Jean-Michel Pichavant ha scritto: Jerry Hill wrote: On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: ... any suggestion for pythonizin' it?

Re: Creating a single list

2010-05-29 Thread superpollo
Astley Le Jasper ha scritto: This is probably a really silly question but, given the example code at the bottom, how would I get a single list? What I currently get is: ('id', 20, 'integer') ('companyname', 50, 'text') [('focus', 30, 'text'), ('fiesta', 30, 'text'), ('mondeo', 30, 'text'), ('pu

Re: Reading file bit by bit

2010-06-07 Thread superpollo
Ulrich Eckhardt ha scritto: Peter Otten wrote: Ulrich Eckhardt wrote: Says Python: bin(192) '0x1100' Hmm, if that's what /your/ Python says, here's mine to counter: bin(192) '0_totally_faked_binary_0011' Argh! Of course one of my Pythons says '0b1100' and not what I mistype

Re: GUIs - A Modest Proposal

2010-06-11 Thread superpollo
Andreas Waldenburger ha scritto: On Thu, 10 Jun 2010 23:00:37 -0700 (PDT) rantingrick wrote: On Jun 11, 12:17 am, ant wrote: I like the points about backwards compatibility. Presumably that reason alone is enough to keep Tkinter in the standard library for a long while. I don't see why that

Re: a +b ?

2010-06-11 Thread superpollo
yanhua ha scritto: hi,all?? it's a simple question: input two integers A and B in a line,output A+B? this is my program: s = input() this does not work t = s.split() a = int(t[0]) b = int(t[1]) print(a+b) but i think it's too complex,can anybody tell to slove it with less code. >>> import

Re: a +b ?

2010-06-11 Thread superpollo
Simon Brunning ha scritto: 2010/6/11 yanhua : hi,all! it's a simple question: input two integers A and B in a line,output A+B? print sum(int(i) for i in raw_input("Please enter some integers: ").split()) LOL -- http://mail.python.org/mailman/listinfo/python-list

pythonize this!

2010-06-15 Thread superpollo
goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) my solution: >>> s = 0 >>> for i in range(1, 2011): ... s += i**2 ... if not (i+1)%5: ... s -= 2*i**2 ...

Re: pythonize this!

2010-06-15 Thread superpollo
Ulrich Eckhardt ha scritto: superpollo wrote: ... s += i**2 ... if not (i+1)%5: ... s -= 2*i**2 ... if not i%5: ... s -= 2*i**2 if not (i % 5) in [1, 2]: s += i**2 else: s -= i**2 Untested code. does not work: >>> s = 0 >>> for

Re: pythonize this!

2010-06-15 Thread superpollo
Peter Otten ha scritto: superpollo wrote: goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) from itertools import cycle, izip sum(sign*i*i for sign, i in izip(cycle([1]*3

Re: pythonize this!

2010-06-15 Thread superpollo
superpollo ha scritto: Peter Otten ha scritto: superpollo wrote: goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) from itertools import cycle, izip sum(sign*i*i for sign

Re: GUIs - A Modest Proposal

2010-06-15 Thread superpollo
lkcl ha scritto: ... That sounds too good to be true. yup, it does. how can one person, a free software developer, have come up with something like "The Holy Grail" of software development, right? when all the money in the world, from ibm, adobe, microsoft, google, nokia and so on _hasn't_ m

Re: pythonize this!

2010-06-15 Thread superpollo
Stefan Behnel ha scritto: superpollo, 15.06.2010 14:55: Peter Otten ha scritto: superpollo wrote: goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) from itertools import

Re: pythonize this!

2010-06-15 Thread superpollo
Paul Rubin ha scritto: superpollo writes: goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) print sum([-1,1,1,1,-1][i%5]*i**2 for i in xrange(1,2011)) beautiful. thx

python source code -> win/dos executable (on linux)

2010-06-25 Thread superpollo
hi. suppose i work in a linux environment, but i would like to ship a win/dos executable file from time to time, just for test purposes (my "testers" are windows users and don't want to go through the hassle of installing python on their win boxes). what is the best way to do that? (the appli

Re: python source code -> win/dos executable (on linux)

2010-06-28 Thread superpollo
Lawrence D'Oliveiro ha scritto: In message <4c24c152$0$31381$4fafb...@reader1.news.tin.it>, superpollo wrote: suppose i work in a linux environment, but i would like to ship a win/dos executable file from time to time, just for test purposes (my "testers" are windows us

Re: automate minesweeper with python

2010-07-02 Thread superpollo
Ethan Furman ha scritto: Terry Reedy wrote: On 7/1/2010 6:42 PM, Emile van Sebille wrote: On 7/1/2010 2:52 PM Jay said... pywinauto looks to be almost perfect. All I need now is to read the numbers uncovered when a minesweeper square is clicked on, or that I just hit a mine. ... or, you c

timer

2009-06-29 Thread superpollo
hi folks. the follwing shoud print 'stuff' for 3 seconds and then stop. why it does not work? (prints stuff forever) 1 #!/usr/bin/python 2 3 import threading 4 import sys 5 6 t = threading.Timer(3.0, sys.exit) 7 t.start() 8 while True: 9

Re: timer

2009-06-30 Thread superpollo
Paul Moore wrote: 2009/6/29 MRAB : superpollo wrote: hi folks. the follwing shoud print 'stuff' for 3 seconds and then stop. why it does not work? (prints stuff forever) 1 #!/usr/bin/python 2 3 import threading 4 import sys 5 6 t = threading.Timer(3.0

Re: timer

2009-06-30 Thread superpollo
Paul Moore wrote: 2009/6/29 MRAB : superpollo wrote: hi folks. the follwing shoud print 'stuff' for 3 seconds and then stop. why it does not work? (prints stuff forever) 1 #!/usr/bin/python 2 3 import threading 4 import sys 5 6 t = threading.Timer(3.0

Re: timer

2009-06-30 Thread superpollo
Paul Moore wrote: 2009/6/30 superpollo : Paul Moore wrote: For a non-toy example, you'd probably create an Event object, use your timer to set the event, and your while loop would do while event.is_set(), so the problem wouldn't arise. thank u paul. if u dont mind, would you give

Re: timer

2009-06-30 Thread superpollo
Paul Moore wrote: 2009/6/30 superpollo : Paul Moore wrote: For a non-toy example, you'd probably create an Event object, use your timer to set the event, and your while loop would do while event.is_set(), so the problem wouldn't arise. thank u paul. if u dont mind, would you give

Re: timer

2009-06-30 Thread superpollo
i would like to thank each and everyone for help given, and aplologise for my inaccuracy. thanks 10**3! superchicken -- http://mail.python.org/mailman/listinfo/python-list

stringio+tarfile

2009-07-02 Thread superpollo
why the following does not work? can you help me correct (if possible)? 1 import tarfile 2 import StringIO 3 sf1 = StringIO.StringIO("one\n") 4 sf2 = StringIO.StringIO("two\n") 5 tf = StringIO.StringIO() 6 tar = tarfile.open(tf , "w") 7 for name in [sf1 ,

Re: stringio+tarfile

2009-07-03 Thread superpollo
First problem I see is all those numbers before the lines. That's not valid python. Assuming that was a transcription error not so. i intentionally add linenumbers to facilitare reference to the code, but if it is a nuisance i will not include them anymore. thanks -- http://mail.python.org

Re: stringio+tarfile

2009-07-03 Thread superpollo
thanks to the guys who bothered to answer me even using their chrystal ball ;-) i'll try to be more specific. yes: i want to create a tar file in memory, and add some content from a memory buffer... my platform: $ uname -a Linux fisso 2.4.24 #1 Thu Feb 12 19:49:02 CET 2004 i686 GNU/Linux $ py

Re: stringio+tarfile

2009-07-03 Thread superpollo
Peter Otten wrote: gettarinfo() expects a real file, not a file-like object. You have to create your TarInfo manually. ok... which attributes are mandatory, and which optional? I recommend that you have a look into the tarfile module's source code. i will try... but: $ cat /usr/lib/pyt

Re: stringio+tarfile (or better... zipfile)

2009-07-03 Thread superpollo
following the excellent suggestions received, i tried to adapt the problem to zipfile, and i wrote this: $ cat zip001.py import sys import zipfile import StringIO nb1 = "first.txt", StringIO.StringIO("one one\n") nb2 = "second.txt", StringIO.StringIO("two\n") zb = StringIO.StringIO() zip = zip

older pythons

2009-07-09 Thread superpollo
hi everybody. i have a certain set of old python scripts and data used by said scripts which were written using python 2.3 in particular i used some features which were later modified or deprecated by the language newer versions (e.g.: cmp(), print as keyword, and such...) for reasons i fi

Re: older pythons

2009-07-09 Thread superpollo
Adrian Dziubek wrote: The recommended Debian way is update-alternatives. I find it a bit unintuitive, so I have to read through the documentation every time I use it, but it should be able link a chosen version of python to /usr/ bin/python. I don't know if it's set up by default, I have only one

Re: older pythons

2009-07-09 Thread superpollo
Lie Ryan wrote: AFAIK, no major linux distributions have officially ported to python 3.x. http://packages.debian.org/experimental/python3.1 thanks for help -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >