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
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
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
Dan M ha scritto:
On Thu, 28 Oct 2010 15:05:56 -0500, Dan M wrote:
Ok, I didn't research enough before I posted this. I see now that this
*is* indeed a MIME message, and the '?Q' bit says that the next piece is
quoted-printable, and that the encoding is defined in RFC2047.
So the question th
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
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
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
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
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
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
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
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
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
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
...
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
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
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
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
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
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?
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):
"
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
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
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
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
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!
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
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
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)):
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
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
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
... 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
.:
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
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
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
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
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
>>> 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
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
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},
-
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:
>
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.
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"
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
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...
-
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 = ['
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
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
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
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
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_
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
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
"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:
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
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
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
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
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
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
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
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,
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
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
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
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
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
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
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
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
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
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
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
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
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?
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
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
how much is one half times one half?
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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 -->
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
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:
#
hi clp
what's the difference between:
while True:
input_line = sys.stdin.readline()
if input_line:
sys.stdout.write(input_line.upper())
else:
break
and:
while True:
try:
sys.stdout.write(sys.stdin.next().upper())
except StopIteration
Dr. Phillip M. Feldman wrote:
I'd like to be able to convert a float to a string representation in which
the number is rounded to a specified number of digits. If num2str is a
hypothetical function that does this, then num2str(pi,3) would be '3.142'
(not '3.141'). I've been told that there is n
MRAB wrote:
superpollo wrote:
...
how to reverse a string in python? must i usa a temp? like:
>>> s = "ciccio"
>>> l = list(s)
>>> l.reverse()
>>> s = "".join(l)
>>> s
'oiccic'
>>>
???
Use sl
Tim Rowe wrote:
2009/7/30 r :
Like your
first lay, your first programing language can leave an indelible mark
on you
That's true. FOCAL scarred me for life.
but i now realize Ruby has some good
things going for it.
Any language that gets any sort of real use has to have. For instance,
r wrote:
On Jul 30, 12:15 pm, Masklinn wrote:
[snip]
Furthermore Ruby has a pretty nice convention (sadly not used enough I
think) taken from Scheme where it's possible to postfix a method name
with "!" (note: the "!" is part of the name, there's no magic) to
indicate that this method mod
Masklinn wrote:
...
That's an interesting point, but not relevant at the end of the day:
`foo.length` and `length(foo)` have the same "practicality". On the
other hand Ruby can be praised for the coherence: everything's a method
period end of the story; while Python does have a dichotomy be
MRAB wrote:
Xavier Ho wrote:
superpollo wrote:
for (i, e) in enumerate(nomi):
print i, "-", e
Just to be random:
print '\n'.join(["%s - %s" % (i, e) for i, e in enumerate(nomi)])
This has one advantage: only print once. So it's sli
hi clp.
i want to get from here:
nomi = ["one", "two", "three"]
to here:
0 - one
1 - two
2 - three
i found two ways:
first way:
for i in range(len(nomi)):
print i, "-", nomi[i]
or second way:
for (i, e) in enumerate(nomi):
print i, "-", e
which one is "better"? is there a more py
David Lyon wrote:
pdftohtml on sourceforge may help...
also see: http://linuxcommand.org/man_pages/pdfimages1.html
bye
--
http://mail.python.org/mailman/listinfo/python-list
Piet van Oostrum wrote:
...
You have the string wrong.
oops yea.
But the correct one you get with:
In [67]: import struct
In [68]: number = 252509952
In [69]: struct.pack('>I', number)
Out[69]: '\x0f\x0c\xff\x00'
(Please note that this is big endian)
thanks a lot, but it does not work f
superpollo wrote:
Sebastian Bassi wrote:
On Fri, Jul 24, 2009 at 7:28 PM, superpollo wrote:
is there a pythonic and synthetic way (maybe some standard module) to
"pack"
an integer (maybe a *VERY* big one) into a string? like this:
What do you mean to pack? Maybe Pickle is wha
Sebastian Bassi wrote:
On Fri, Jul 24, 2009 at 7:28 PM, superpollo wrote:
is there a pythonic and synthetic way (maybe some standard module) to "pack"
an integer (maybe a *VERY* big one) into a string? like this:
What do you mean to pack? Maybe Pickle is what you want.
impo
is there a pythonic and synthetic way (maybe some standard module) to
"pack" an integer (maybe a *VERY* big one) into a string? like this:
>>> number = 252509952
>>> hex(number)
'0xf0cff00'
>>>
so i would like a string like '\xf0\xcf\xf0\x00'
i wrote some code to do it, so ugly i am ashame
1 - 100 of 135 matches
Mail list logo