[EMAIL PROTECTED] wrote:
> How do I check if a string contains (can be converted to) an int? I
> want to do one thing if I am parsing and integer, and another if not.
>
> /David
>
others already answered, this is just an idea
>>> def isNumber(n):
... import re
... if re.match("^[-+]?[0
Hello,
I am looking for simple solution to outb to parallel port.
The program should run on Linux. I hope someone here already
faced this problem. In C it would look like
iopl(3/*mode*/);
ioperm(0x378 /*PORT_BASE*/, 3 /*bytes*/, 1/*on*/);
outb(0xff /* < data */, 0x378 /*DATA_REG*/);
Any ideas we
hi,
[...]
>># pseudo code
>>i=2
>>lst=[i**=2 while i<1000]
>>
>>of course this could be easily rewritten into
>>i=2
>>lst=[]
>>while i<1000:
>> i**=2
>> lst.append(i)
>>
>
>
> Neither of these loops would terminate until memory is exhausted. Do you
> have a use case for a 'while' in a
D H wrote:
> [EMAIL PROTECTED] wrote:
>
>>> You can use i**=2 for i in range(1000) instead
>>
>>
>>
>> I don't think one can use assignment in list comprehension or generator
>> expression. The limitation is very much like lambda.
>>
>
> i**2
lst=[i**2 for i in range(1000)]
you will get a list
Hello NG,
I am wondering if there were proposals or previous disscussions in this
NG considering using 'while' in comprehension lists
# pseudo code
i=2
lst=[i**=2 while i<1000]
of course this could be easily rewritten into
i=2
lst=[]
while i<1000:
i**=2
lst.append(i)
usually
SPE - Stani's Python Editor wrote:
> I know that this code is nonsense, but why does this print 'Why?'
>
> a = 1
> if a >2:
> try:
> 5/0
> except:
> raise
> else:
> print 'why?'
>
because 1 is not greater than 2 I suppose :)
--
http://mail.python.org/mailman/listinf
dado wrote:
> I'm implementing a "self-tutorial" into my app,
> and wondering if there's a way of moving a mouse
> cursor on command? probably using sys,os modules?
sys doesn't mean [operating] system
it's completely Python related,
the intepreter itself
you can use it to see how many referenced d
[...]
>> >>> lst = [[1,4],[3,9],[2,5],[3,2]]
>> >>> lst
>>[[1, 4], [3, 9], [2, 5], [3, 2]]
>> >>>
>> >>>
>> >>> lst.sort(cmp = lambda x,y: cmp(x[1], y[1]))
>> >>> lst
>>[[3, 2], [1, 4], [2, 5], [3, 9]]
>> >>>
>>
>>works for Python 2.4
>>in earlier Pythons just let cmp = .. away
>>
>>Regards, Danie
Shi Mu wrote:
> I have a list like [[1,4],[3,9],[2,5],[3,2]]. How can I sort the list
> based on the second value in the item?
> That is,
> I want the list to be:
> [[3,2],[1,4],[2,5],[3,9]]
>>> lst = [[1,4],[3,9],[2,5],[3,2]]
>>> lst
[[1, 4], [3, 9], [2, 5], [3, 2]]
>>>
>>>
>>> lst.sort(cmp
Shi Mu wrote:
> I used the following method to remove duplicate items in a list and
> got confused by the error.
>
>
a
>
> [[1, 2], [1, 2], [2, 3]]
>
noDups=[ u for u in a if u not in locals()['_[1]'] ]
>
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: itera
purna chandra wrote:
> Hello,
>I have a simple question.Hoping not to take much of
> your valuable time...:-). I am trying to get the data
> from a string, and am wondering if I get
> http://groups.google.com/intl/en/googlegroups/tour/index.html
> from the array :
> array('c',
> '\x00=http://
[EMAIL PROTECTED] wrote:
> Hi, I am new in Python programming. Can anybody give me any idea about
> how to detect more than one date and time (like 11/11/2005 ,
> 10-12-2006, 12:30 etc) from a text file and keep them in a list.
well first we read the file
src = file("/your/file").read()
then we
yb wrote:
> Hi,
>
> Is there a python based tool to cut mp3 and wav file at a start and end
> time? I'm looking for a python script that can output a new wav or mp3
> file based on star and endpoint.
>
> Thank you
>
there is a wave module
>>> import wave
>>> dir(wave)
['Chunk', 'Error', 'WA
Steve already answeared to your question, regaring PHP script
if this would be python script, you could run it by import'ing it
#a.py
print "in a"
#b.py
import a# prints "in a"
print "in b"
and of course other solutions
import os
if os.fork()==0:
os.execv("
maybe you should look at subprocess module
I have one expamle, this is Linux though
>>> import subprocess as sp
>>> p1 = sp.Popen(["ls", "-l"], stdout = sp.PIPE)
>>> p2 = sp.Popen(["wc", "-c"], stdin = p1.stdout, stdout = sp.PIPE)
>>> print p2.stdout.read()
226
hth, Daniel
--
http://m
Paul DiRezze wrote:
> I'm spending the next two weeks off and I'm looking to take a crack at
> learning how to program in Python. Here's a list of the places I've
> bookmarked:
>
> http://www.python.org/doc/ and more specifically
> http://wiki.python.org/moin/
> http://wiki.python.org/moin/Begi
I just tried the same code at home and it worked fine
it has to do with windows .. some settings or whatever
(python 2.4.1 installed on both)
maybe someone have experienced the same problem
and had more luck in solving the puzzle
--
http://mail.python.org/mailman/listinfo/python-list
Hello
I wrote a simple module, which is also supposed to be used as standalone
program
after considering how to avoid multiple if's I came up with this idea
if __name__ == "__main__":
if len(sys.argv) not in (3,4):
print "usage: prog arg1 argv2 [-x]"
# etc ...
while develeoping
Rob Conner schrieb:
> seems like you are not running the correct wavePlayer. make sure you
> don't have 2 wavePlayer vars.
>
I am not sure I understand right
wavePlayer.py is a module I wrote myself and placed
to site-packages so there is no other wavePlayer module
I put a class wavePlayer into i
Hello Ng,
I was playing around with pymedia module
and I succeeded when I used complementation
instead of inheritance .. but then I was
forced to wrap simple methods of sound.Output
like pause/unpause/stop. It works, but
seems to me unnecessary .. and I would like
to grasp why the code below doesn
[...]
> Okay. Write a patch. Personally, I would prefer that it be a
> function in cmath rather than a method because then it could be made to
> work on integers and regular floats, too.
Ok, but what semantic should angle/arg have, say for 3 respectively
for 3.0?
the same as for arg(3+0j)?
--
[...]
> I am aware of the usage of argument to mean the angle in polar
> representation, but I don't like it. The word argument already has two
> other meanings, one in common English, the other in math/CS. The latter
> meaning is the inputs to a function, and that is how the word is used in
[...]
> Derive your own subclass of complex and define those methods.
I think something as basic as an angle/arg of complex number
definetly belongs to the interface, and it would not even require a
great effort to put it there
most complex formulas out there use Euler representation
it's a was
>>c = 1+1j
>>c.arg(angle_mode = cmath.GRAD) -> 45.0
>
>
> Is that right? The result looks more like Degrees...
maybe I confuse, in german one would say "45 Grad"
I took a freedom to translate it directly :)
well, my calculator shows a "D"
which most likely stands for Degree, I cannot tell
Hi Terry,
>>In my opinion it would also be nice to have the
>>possibility to write it as
>>c.abs()
>>it looks more OO
>
>
> Python is object based but not rigidly OO in syntax or looks. This
is an
> intentional design decision. Not being gratuitiously redundant is
another.
I agree, re
> I would also like to see some more functions to make
> calculations with complex number more convenient
> e.g.
> c = 27
c = 27+0j
--
http://mail.python.org/mailman/listinfo/python-list
Hello all,
I often have to deal with complex numbers
using python iteractive as calculator
I wonder why there are no methods like arg, abs
well one can use
c = 1+1j
abs(c)
In my opinion it would also be nice to have the
possibility to write it as
c.abs()
it looks more OO
unfortunately there is
Eric schrieb:
> I am reading a book on Python and ran across and exercise that I just
> can't seem to figure out. Its pretty simple, but I just can't get
> past a certain point.
>
> The task is to create a program that flips a coin 100 times and keeps
> track of the total of heads and tails which
> Am I just weird?
I feel the same way about where to use lambda's and where *not*
I come from C and C++ background and defining a function at the top
level (no nested functions) would always require good reasons
function name has to be remembered, to put it in other words it has to
be added in
I think in some contextes map is more readable than [f() for i in S]
because it's more verbatim
Removing lamdba would be reduce readability of Python, I think here
for examble of code like
class App:
def drawLines(self, event):
from random import r
Full Acknowledge
--
http://mail.python.org/mailman/listinfo/python-list
Jake wrote:
> in c and c++ there is a useful way to refresh an output line in printf
> and cout using \r meta command. So for example in the wget application
> the progress of the download is updated on the same output line of the
> screen. From an intital investigation python seems to lack this. I
Hi
> Trying to set up a timer function for my irc bot, which uses the python
> irclib.py.
>
> If I use time.sleep(20), it tends to freeze up the bot completely for 20
> secs. That's not what I want though! I want the program to wait 20 secs,
> then perform another function, but in the meantime be
33 matches
Mail list logo