blank lines representation in python

2006-05-02 Thread micklee74
hi what is the correct way to represent blank lines in python (while iterating a file) without regexp? I know one way is to use re.search((line,r'^$') to grab a blank line, but i wanna try not to use regexp... is it 1) if line == ''": dosomething() (this also means EOF right? ) 2) if line is None:

string.find first before location

2006-05-02 Thread Gary Wessle
Hi I have a string like this text = "abc abc and Here and there" I want to grab the first "abc" before "Here" import string string.find(text, "Here") # I am having a problem with the next step. thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: string.find first before location

2006-05-02 Thread Ravi Teja
text[:text.find('Here')].rfind('abc') -- http://mail.python.org/mailman/listinfo/python-list

Re: blank lines representation in python

2006-05-02 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > what is the correct way to represent blank lines in python (while > iterating a file) without regexp? I know one way is to use > re.search((line,r'^$') to grab a blank line, but i wanna try not to use > regexp... > is it > 1) if line == ''": dosomething() (this also mea

Re: strip newlines and blanks

2006-05-02 Thread Peter Otten
[EMAIL PROTECTED] wrote: Mick, you should be a bit more patient. Allow for some time for an answer to arrive. Minor edits of your question don't warrant a repost. > i have a file test.dat eg > > abcdefgh > ijklmn > <-newline > opqrs > tuvwxyz > > > I wish to print the contents of

Re: string.find first before location

2006-05-02 Thread Peter Otten
Gary Wessle wrote: > I have a string like this > > text = "abc abc and Here and there" > I want to grab the first "abc" before "Here" > > import string > string.find(text, "Here") # > > I am having a problem with the next step. These days str methods are preferred over the string module's fun

Re: strip newlines and blanks

2006-05-02 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > i have a file test.dat eg > > abcdefgh > ijklmn > <-newline > opqrs > tuvwxyz > > > I wish to print the contents of the file such that it appears: > abcdefgh > ijklmn > opqrs > tuvwxyz > > here is what i did: > f = open("test.dat") > while 1: > line

Re: Using elementtree: replacing nodes

2006-05-02 Thread Fredrik Lundh
André wrote: > I've started using elementtree and don't understand how to use it to > manipulate and replace nodes. I know how to do this using a simple, > but inefficient parser I wrote, but I'd rather learn to use a better > tool - especially as it is to be added to the standard library. > Now

Re: strip newlines and blanks

2006-05-02 Thread micklee74
thanks..and sorry, i am using the web version of google groups and didn't find an option i can edit my post, so i just removed it.. thanks again for the reply.. -- http://mail.python.org/mailman/listinfo/python-list

Re: stripping blanks

2006-05-02 Thread seeker
[EMAIL PROTECTED] wrote: > hi > i have a file test.dat eg > > abcdefgh > ijklmn > <-newline > opqrs > tuvwxyz > <---newline > > I wish to print the contents of the file such that it appears: > abcdefgh > ijklmn > opqrs > tuvwxyz > > here is what i did: > f = open("test.dat

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
Steve Holden wrote: > Objects don't actually "pass references to themselves". The interpreter > adds the bound instance as the first argument to a call on a bound method. Sure, if you want to get technical For that matter, objects don't actually call their methods either -- the interpreter looks

Re: set partitioning

2006-05-02 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > For the list [1,2,3,4], I'm looking for the following for k = 2: > > [[1,2], [3,4]] > [[1,3], [2,4]] > [[1,4], [2,3]] That's not what you asked for the first time. You said you wanted "m non-empty, disjoint subsets", but the subsets above are clearly not all disjoint;

Re: returning none when it should be returning a list?

2006-05-02 Thread Christos Georgiou
On 1 May 2006 07:19:48 -0700, rumours say that [EMAIL PROTECTED] might have written: >I'm not sure what "falls off the end" of the function means, i searched >online, it seems to mean that the function has reached the end >prematurely and returned a default identifier to signal success or >not.. C

Re: Can Python kill a child process that keeps on running?

2006-05-02 Thread Edward Elliott
Serge Orlov wrote: > I. Myself wrote: >> Suppose it is supposed to run for one minute, but it just keeps going >> and going. Does Python have any way to kill it? > > On linux it's pretty easy to do, just setup alarm signal. On windows > it's not so trivial to the point you cannot do it using pyth

Re: stripping blanks

2006-05-02 Thread seeker
[EMAIL PROTECTED] wrote: > hi > i have a file test.dat eg > > abcdefgh > ijklmn > <-newline > opqrs > tuvwxyz > <---newline > > I wish to print the contents of the file such that it appears: > abcdefgh > ijklmn > opqrs > tuvwxyz > > here is what i did: > f = open("test.dat

Re: Non-web-based templating system

2006-05-02 Thread Fuzzyman
[EMAIL PROTECTED] wrote: > Hi, > > I'm creating a small application in Python that uses lists and > dictionaries to create a rudimentary database. I'd like to create some > "fill-in-the-blanks" reports from this data, ideally by taking an RTF > or plaintext file as a template and replacing placeho

Re: returning none when it should be returning a list?

2006-05-02 Thread Iain King
John Machin wrote: > > # Doh! Looks like recursion not necessary. Google 'eliminate tail > recursion' :-) > I did, and found this: http://www.biglist.com/lists/dssslist/archives/199907/msg00389.html which explains that the Scheme compiler optimises (obvious) tail recursion into iterative code. I

Re: resume picking items from a previous list

2006-05-02 Thread Christos Georgiou
On 30 Apr 2006 05:33:39 -0700, rumours say that "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> might have written: > >kpp9c wrote: >> For a time i pick from my songs, but i only play a few of the songs in >> that list... now my wife, Jessica Alba, comes home, and i start playing >> from Jessica's list o

Re: Can Python kill a child process that keeps on running?

2006-05-02 Thread Serge Orlov
Edward Elliott wrote: > Serge Orlov wrote: > > I. Myself wrote: > >> Suppose it is supposed to run for one minute, but it just keeps going > >> and going. Does Python have any way to kill it? > > > > On linux it's pretty easy to do, just setup alarm signal. On windows > > it's not so trivial to th

Re: Using elementtree: replacing nodes

2006-05-02 Thread André
Fredrik Lundh wrote: > André wrote: > > > I've started using elementtree and don't understand how to use it to > > manipulate and replace nodes. [snip] It was mostly the following step which I couldn`t figure out... > # 2) mutate the pre element > pre.clear() > pre.tag = "form" >

Re: returning none when it should be returning a list?

2006-05-02 Thread Christos Georgiou
On 2 May 2006 03:03:45 -0700, rumours say that "Iain King" <[EMAIL PROTECTED]> might have written: >John Machin wrote: >> >> # Doh! Looks like recursion not necessary. Google 'eliminate tail >> recursion' :-) > >I did, and found this: >http://www.biglist.com/lists/dssslist/archives/199907/msg003

Re: strip newlines and blanks

2006-05-02 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > thanks..and sorry, i am using the web version of google groups and > didn't find an option i can edit my post It's usenet, you can't edit posts. > so i just removed it.. Which doesn't work at all. Stupid thing they allow you to try and delete something o

Re: Non-web-based templating system

2006-05-02 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > I'm creating a small application in Python that uses lists and > dictionaries to create a rudimentary database. I'd like to create > some "fill-in-the-blanks" reports from this data, ideally by taking > an RTF or plaintext file as a template and replacing pl

Re: string.find first before location

2006-05-02 Thread Gary Wessle
Peter Otten <[EMAIL PROTECTED]> writes: > Gary Wessle wrote: > > > I have a string like this > > > > text = "abc abc and Here and there" > > I want to grab the first "abc" before "Here" > > > > import string > > string.find(text, "Here") # > > > > I am having a problem with the next step. >

Re: stripping

2006-05-02 Thread Tim Williams
On 1 May 2006 23:20:56 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:hii have a file test.dat egabcdefghijklmn <-newline opqrstuvwxyz  <---newlineI wish to print the contents of the file such that it appears:abcdefghijklmnopqrstuvwxyzhere is what i did:f = open("test.dat")

Re: stripping

2006-05-02 Thread Tim Williams
On 02/05/06, Tim Williams <[EMAIL PROTECTED]> wrote: On 1 May 2006 23:20:56 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:hii have a file test.dat eg f = open("test.dat") while 1: line = f.readline().rstrip("\n") if line: print line is simpler and easier to re

Re: string.find first before location

2006-05-02 Thread Peter Otten
Gary Wessle wrote: >> These days str methods are preferred over the string module's functions. >> >> >>> text = "abc abc and Here and there" >> >>> here_pos = text.find("Here") >> >>> text.rfind("abc", 0, here_pos) >> 4 >> >> Peter > > and what about when python 3.0 is released and those deprec

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread bruno at modulix
Edward Elliott wrote: > Holger wrote: > >>oops, that was kinda embarrassing. > > > It's really not. You got a completely unhelpful error message saying you > passed 2 args when you only passed one explicitly. The fact the b is also > an argument to b.addfile(f) is totally nonobvious until you

Re: set partitioning

2006-05-02 Thread Boris Borcic
[EMAIL PROTECTED] wrote: > For the list [1,2,3,4], I'm looking for the following for k = 2: > > [[1,2], [3,4]] > [[1,3], [2,4]] > [[1,4], [2,3]] > > for k = 3: > > [[1,2,3], [4]] > [[1,2,4], [3]] > [[1,3,4], [2]] > [[2,3,4], [1]] > def pickk(k,N,m=0) : if k==1 : return ((n,) for

Re: strip newlines and blanks

2006-05-02 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hi > i have a file test.dat eg > > abcdefgh > ijklmn > <-newline > opqrs > tuvwxyz > > > I wish to print the contents of the file such that it appears: > abcdefgh > ijklmn > opqrs > tuvwxyz > > here is what i did: > f = open("test.dat") > while 1: >

pyqt v3.* and v4.*

2006-05-02 Thread Skink
Hi, Is it possible to have both versions of pyqt (in my case 3.14.1 and 4.0)? Version 3 is built using sip 4.2.1, version 4 is built using sip 4.4.3 When I run pyqt 4.0 (but with installed sip 4.2.1) I get: from PyQt4 import QtCore, QtGui TypeError: invalid argument to sipBadCatcherResult() Wh

Strange result with math.atan2()

2006-05-02 Thread Vedran Furač
I think that this results must be the same: In [3]: math.atan2(-0.0,-1) Out[3]: -3.1415926535897931 In [4]: math.atan2(-0,-1) Out[4]: 3.1415926535897931 In [5]: -0 == -0.0 Out[5]: True This is python 2.4.4c0 on Debian GNU/Linux. Regards, Vedran Furač -- http://mail.python.org/mailman/lis

--version?

2006-05-02 Thread Paul Watson
Is there any chance that Python would support the --version command line parameter? It seems that many open source programs use this switch to report their version number. -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython, wxcombobox opening

2006-05-02 Thread Philippe Martin
Hi, >From the wxPython list: > Hi, > > Which event must I catch to be called when the user clicks on the combo > "button" to make the drop down list to appear ? No, there isn't a specific event for the opening of the drop-down box. Regards, Philippe Philippe Martin wrote: > Hi, > > I

Re: pyqt v3.* and v4.*

2006-05-02 Thread Phil Thompson
On Tuesday 02 May 2006 1:01 pm, Skink wrote: > Hi, > > Is it possible to have both versions of pyqt (in my case 3.14.1 and 4.0)? Yes - but not that version of PyQt3. > Version 3 is built using sip 4.2.1, version 4 is built using sip 4.4.3 > > When I run pyqt 4.0 (but with installed sip 4.2.1) I g

Re: string.find first before location

2006-05-02 Thread Serge Orlov
Peter Otten wrote: > Gary Wessle wrote: > > >> These days str methods are preferred over the string module's functions. > >> > >> >>> text = "abc abc and Here and there" > >> >>> here_pos = text.find("Here") > >> >>> text.rfind("abc", 0, here_pos) > >> 4 > >> > >> Peter > > > > and what about when

Re: --version?

2006-05-02 Thread Adonis
Paul Watson wrote: > Is there any chance that Python would support the --version command line > parameter? It seems that many open source programs use this switch to > report their version number. try at a command prompt: python -V Hope this helps. Adonis -- http://mail.python.org/mailman/

Re: string.find first before location

2006-05-02 Thread Peter Otten
Serge Orlov wrote: > Peter Otten wrote: >> Gary Wessle wrote: >> >> >> These days str methods are preferred over the string module's >> >> functions. >> >> >> >> >>> text = "abc abc and Here and there" >> >> >>> here_pos = text.find("Here") >> >> >>> text.rfind("abc", 0, here_pos) >> >> 4 >> >> >>

Re: pyqt v3.* and v4.*

2006-05-02 Thread Skink
Phil Thompson wrote: > > > Install the latest versions of PyQt3 and SIP. Thanks Phil! v4.0 & v3.16 work with sip 4.4.3 ;) skink -- http://mail.python.org/mailman/listinfo/python-list

Re: --version?

2006-05-02 Thread Paul Watson
Adonis wrote: > Paul Watson wrote: > >> Is there any chance that Python would support the --version command >> line parameter? It seems that many open source programs use this >> switch to report their version number. > > > > try at a command prompt: > python -V > > Hope this helps. > > A

Re: Strange result with math.atan2()

2006-05-02 Thread Peter Otten
Vedran Fura? wrote: > I think that this results must be the same: > > In [3]: math.atan2(-0.0,-1) > Out[3]: -3.1415926535897931 > > In [4]: math.atan2(-0,-1) > Out[4]: 3.1415926535897931 > > In [5]: -0 == -0.0 > Out[5]: True Glimpsing at the hardware formats: >>> struct.pack("d", 0.0) '\x00\x

produce xml documents with python, and display it with xsl in a internet browser

2006-05-02 Thread wyattroerb
Hi, like a lot of other newbies in xml i suffer from the various ways you can take for xml data processing in python. Here are my two major problems: Problem number one: A application written in python remote controls (demands actions) a HIL (Hardware in the loop) test stand and evaluate its actio

py2app, pythoncard build problems

2006-05-02 Thread loren . davie
Hi, I'm attempting to build a small app that uses pythoncard for a gui layer. The intention is to use py2app to construct an .app bundle for the Mac. I'm running OS 10.4 on an Intel MacBook Pro. I'm using the default installed Python 2.3 The .app bundle appears to build, but when I start up it

Re: Strange result with math.atan2()

2006-05-02 Thread Ben Caradoc-Davies
Vedran Furač wrote: > I think that this results must be the same: > In [3]: math.atan2(-0.0,-1) > Out[3]: -3.1415926535897931 > In [4]: math.atan2(-0,-1) > Out[4]: 3.1415926535897931 -0 is converted to 0, then to 0.0 for calculation, losing the sign. You might as well write 0.0 instead of -0 The

Re: --version?

2006-05-02 Thread gry
I agree. The "--version" option has become quite a de-facto standard in the linux world. In my sys-admin role, I can blithely run initiate_global_thermonuclear_war --version to find what version we have, even if I don't know what it does... python --version would be a very helpful addition.

Pamie and Python - new browser focus

2006-05-02 Thread saltima
Hi all, I'm trying to automate my web browser testing by using Pamie and Python. Everything is going great except for when a new window opens up. (on the previous page, I click next, and a new window is opened up) The focus it seems is never transferred. I suspect this because the control is no

Re: set partitioning

2006-05-02 Thread Boris Borcic
I wrote: > > def pickk(k,N,m=0) : > if k==1 : > return ((n,) for n in range(m,N)) > else : > return ((n,)+more for more in pickk(k-1,N,m+1) > for n in range(m,more[0])) > > def partitionN(k,N) : > subsets = [frozenset(S) for S in pickk(k,N)]

Re: py2app, pythoncard build problems

2006-05-02 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Hi, > > I'm attempting to build a small app that uses pythoncard for a gui > layer. The intention is to use py2app to construct an .app bundle for > the Mac. I'm running OS 10.4 on an Intel MacBook Pro. I'm using the > default installed Python 2.3 > > The .app bundle

Re: Strange result with math.atan2()

2006-05-02 Thread Vedran Furač
Ben Caradoc-Davies wrote: > Vedran Furač wrote: >> I think that this results must be the same: >> In [3]: math.atan2(-0.0,-1) >> Out[3]: -3.1415926535897931 >> In [4]: math.atan2(-0,-1) >> Out[4]: 3.1415926535897931 > > -0 is converted to 0, then to 0.0 for calculation, losing the sign. You > mig

Re: --version?

2006-05-02 Thread Fredrik Lundh
Paul Watson wrote: > I am well aware of -V. Could --version be supported as well? http://www.python.org/dev/ http://sourceforge.net/tracker/?group_id=5470&atid=355470 -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange result with math.atan2()

2006-05-02 Thread Serge Orlov
Vedran Furac wrote: > Ben Caradoc-Davies wrote: > > Vedran Furac wrote: > >> I think that this results must be the same: > >> In [3]: math.atan2(-0.0,-1) > >> Out[3]: -3.1415926535897931 > >> In [4]: math.atan2(-0,-1) > >> Out[4]: 3.1415926535897931 > > > > -0 is converted to 0, then to 0.0 for cal

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-02 Thread Ben Sizer
[EMAIL PROTECTED] wrote: > To begin with I'd like to apologize that I am not very experienced > Python programmer so please forgive me if the following text does not > make any sense. > > I have been missing constants in Python language. There are some > workarounds available, for example the const

ConfigParser and multiple option names

2006-05-02 Thread Florian Lindner
Hello, since ConfigParser does not seem to support multiple times the same option name, like: dir="/home/florian" dir="/home/john" dir="/home/whoever" (only the last one is read in) I wonder what the best way to work around this. I think the best solution would be to use a seperation character:

Re: wxPython, wxcombobox opening

2006-05-02 Thread Rony Steelandt
That is what I was afraid for Thanks for answering, Rony > Hi, > > From the wxPython list: > >> Hi, >> >> Which event must I catch to be called when the user clicks on the combo >> "button" to make the drop down list to appear ? > > No, there isn't a specific event for the opening of the

Re: Strange result with math.atan2()

2006-05-02 Thread Vedran Furač
Serge Orlov wrote: >> So, you can convert -0 to 0, but you must multiply the result with sign of >> y, which is '-' (minus). > > But you miss the fact that 0 is an *integer*, not a float, and -0 > doesn't exist. Yes, you are right, I completely missed that 0 is integer in python, and I need a fl

Re: stripping blanks

2006-05-02 Thread Fulvio
Alle 17:06, martedì 02 maggio 2006, seeker ha scritto: >      printLine = line.rstrip("\n") I think that nobody considered if the text has (\r) or (\r\n) or (\n) at the end of the line(s). -- http://mail.python.org/mailman/listinfo/python-list

Re: stripping blanks

2006-05-02 Thread Duncan Booth
Fulvio wrote: > Alle 17:06, martedì 02 maggio 2006, seeker ha scritto: >>      printLine = line.rstrip("\n") > > I think that nobody considered if the text has (\r) or (\r\n) or (\n) > at the end of the line(s). > You think wrongly. The suggested code opens the file in text mode so the line end

Re: bug in modulus?

2006-05-02 Thread Andrew Koenig
"Christophe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] a écrit : > Floating point numbers just don't have the required precision to represent > 2.0 - 1e-050. For your specific problem, if you really want the result to > be < 2.0, the the best you can do is

Re: stripping blanks

2006-05-02 Thread Fredrik Lundh
Fulvio wrote: > > printLine = line.rstrip("\n") > > I think that nobody considered if the text has (\r) or (\r\n) or (\n) at the > end of the line(s). if it's opened in text mode (the default), and is a text file, it will always have "\n" at the end of the line. -- http://mail.python.org/ma

Re: bug in modulus?

2006-05-02 Thread Andrew Koenig
"Andrew Koenig" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I disagree. For any two floating-point numbers a and b, with b != 0, it > is always possible to represent the exact value of a mod b as a > floating-point number--at least on every floating-point system I have ever

Re: ConfigParser and multiple option names

2006-05-02 Thread Alexis Roda
Florian Lindner escribió: > I think the best solution would be to use a seperation character: > > dir="/home/florian, /home/john, home/whoever" RCS uses , in filenames > What do you think? Any better ideas? A bit ugly, but probably safer and simpler than adding arbitrary separators: [section]

Python and Windows new Powershell

2006-05-02 Thread BartlebyScrivener
The Windows Powershell is available, fka Monad. Any special Python tricks? Just breezing through the manual, they seemed to have borrowed from any language they wanted in making a new scripting language. http://tinyurl.com/l9ghj rd -- http://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser and multiple option names

2006-05-02 Thread Florian Lindner
Alexis Roda wrote: > Florian Lindner escribió: >> I think the best solution would be to use a seperation character: >> >> dir="/home/florian, /home/john, home/whoever" > > RCS uses , in filenames A kommata (,) is a valid character in path names. Ok, you can use quotes. >> What do you think? An

Re: ConfigParser and multiple option names

2006-05-02 Thread Larry Bates
Florian Lindner wrote: > Hello, > since ConfigParser does not seem to support multiple times the same option > name, like: > > dir="/home/florian" > dir="/home/john" > dir="/home/whoever" > > (only the last one is read in) > > I wonder what the best way to work around this. > > I think the best

milliseconds are not stored in the timestamp KInterbasDB + Firebird

2006-05-02 Thread Petr Jakes
I am trying to insert "timestamp" to the Firebird database using standard library datetime module example given in the "KInterbasDB Usage Guide" http://tinyurl.com/mplo4 , section "Example Programs DATE/TIME/TIMESTAMP" Even timestamp has the correct format before inserting to the database (2006-26

RFC 822 continuations

2006-05-02 Thread Florian Lindner
Hello, http://docs.python.org/lib/module-ConfigParser.html writes: "with continuations in the style of RFC 822; " what is meant with these continuations? Thanks, Florian -- http://mail.python.org/mailman/listinfo/python-list

simultaneous assignment

2006-05-02 Thread John Salerno
Is there a way to assign multiple variables to the same value, but so that an identity test still evaluates to False? e.g.: >>> w = x = y = z = False >>> w False >>> x False >>> w == x True >>> w is x True # not sure if this is harmful The first line above is the only way I know to

Re: Can Python kill a child process that keeps on running?

2006-05-02 Thread I. Myself
Steve Holden wrote: > I. Myself wrote: >> Serge Orlov wrote: >> >>> I. Myself wrote: >>> >>> Suppose we spawn a child process with Popen. I'm thinking of an executable file, like a compiled C program. Suppose it is supposed to run for one minute, but it just keeps going and g

Re: RFC 822 continuations

2006-05-02 Thread Larry Bates
Florian Lindner wrote: > Hello, > http://docs.python.org/lib/module-ConfigParser.html writes: > > "with continuations in the style of RFC 822; " > > what is meant with these continuations? > > Thanks, > > Florian >From ConfigParser source code: Continuations are represented by an embedded new

xml-rpc and 64-bit ints?

2006-05-02 Thread Mark Harrison
I've got an API that deals with 64 bit int values. Is there any way of handling this smoothly? Right now I'm casting the values into and out of strings for the API. If not, are there any nice alternatives to XML-RPC that support this? Many TIA! Mark -- Mark Harrison Pixar Animation Studios --

Re: simultaneous assignment

2006-05-02 Thread Diez B. Roggisch
John Salerno wrote: > Is there a way to assign multiple variables to the same value, but so > that an identity test still evaluates to False? > > e.g.: > > >>> w = x = y = z = False > >>> w > False > >>> x > False > >>> w == x > True > >>> w is x > True # not sure if this is harmful

Re: simultaneous assignment

2006-05-02 Thread Boris Borcic
John Salerno wrote: > Is there a way to assign multiple variables to the same value, but so > that an identity test still evaluates to False? > > e.g.: > > >>> w = x = y = z = False > >>> w > False > >>> x > False > >>> w == x > True > >>> w is x > True # not sure if this is harmful

Re: simultaneous assignment

2006-05-02 Thread John Salerno
Boris Borcic wrote: > >>> w == x > False > >>> w is x > True > >>> That's the opposite of what I want to happen. -- http://mail.python.org/mailman/listinfo/python-list

Re: simultaneous assignment

2006-05-02 Thread John Salerno
Diez B. Roggisch wrote: > I can't imagine what you're actually after here, but assuming that you > really need this Hard to explain because I'm still trying to figure out how to do it myself. I'm trying to solve a little puzzle using Python, even though I'm sure it's not necessary. Basically W,

Re: simultaneous assignment

2006-05-02 Thread Diez B. Roggisch
John Salerno wrote: > Diez B. Roggisch wrote: > >> I can't imagine what you're actually after here, but assuming that you >> really need this > > Hard to explain because I'm still trying to figure out how to do it > myself. I'm trying to solve a little puzzle using Python, even though > I'm sure

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
bruno at modulix wrote: >> that 1) b is an object not a module*, and 2) objects pass references to >> themselves as the first argument to their methods. > > Nope. It's the MethodType object (a descriptor) that wraps the function > that do the job. The object itself is totally unaware of this. It'

Re: bug in modulus?

2006-05-02 Thread Tim Peters
[Andrew Koenig, on the counter intuitive -1e-050 % 2.0 == 2.0 example] >> I disagree. For any two floating-point numbers a and b, with b != 0, it >> is always possible to represent the exact value of a mod b as a >> floating-point number--at least on every floating-point system I have ever >> enco

Re: simultaneous assignment

2006-05-02 Thread John Salerno
Diez B. Roggisch wrote: > Then use a Proposition-class that holds the actual value. > >> Another thing I'm trying to do is write a function that tests to see if >> a list contains exactly one true item, and the rest are false (obviously >> this would have to be a list of boolean values, I guess)

Re: [Python-3000] bug in modulus?

2006-05-02 Thread Guido van Rossum
This is way above my head. :-) The only requirement *I* would like to see is that for floats that exactly represent ints (or longs for that matter) the result ought of x%y ought to have the same value as the same operation on the corresponding ints (except if the result can't be represented exactl

Re: simultaneous assignment

2006-05-02 Thread David Isaac
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there a way to assign multiple variables to the same value, but so > that an identity test still evaluates to False? Make sure the value is not a singleton. Assign them one at a time. >>> w=1000 >>> x=1000 >>> w==x Tr

Re: simultaneous assignment

2006-05-02 Thread Diez B. Roggisch
> Hmm, classes still scare me a little, but I should consider this. The > only thing is, it is not known in advance if the propositions are true > or false, you have to figure that out yourself based on the combination > of the statements given. I don't know if this changes the idea behind > your P

Re: simultaneous assignment

2006-05-02 Thread bruno at modulix
John Salerno wrote: > Is there a way to assign multiple variables to the same value, > but so > that an identity test still evaluates to False? re-phrase it according to how Python works, and you'll get the answer: "Is there a way to bind multiple names to the same object, but so the identity of

Re: simultaneous assignment

2006-05-02 Thread bruno at modulix
John Salerno wrote: > Boris Borcic wrote: > >> >>> w == x >> False >> >>> w is x >> True >> >>> > > > That's the opposite of what I want to happen. And that wouldn't be really helpful anyway !-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) fo

Polling from keyboard

2006-05-02 Thread [EMAIL PROTECTED]
I am trying to find a way to poll the keyboard. In my searching, I have found that Windows users are given the msvcrt module. Is there an equivilant for Unix systems? I am writing a p2p chat application, and would like to ideally approach user input in a manner similar to the way I am using poll

Re: using ftplib

2006-05-02 Thread Dave Hughes
Steve Holden wrote: > John Salerno wrote: > [...] > > > > So if I already have files on the server and I want to change file > > permissions, do I need to mess with TYPE A/TYPE I commands, or are > > those strictly for when you transfer files? Because I just did a > > quick test of changing fil

Re: Polling from keyboard

2006-05-02 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > I am trying to find a way to poll the keyboard. In my searching, I > have found that Windows users are given the msvcrt module. Is there an > equivilant for Unix systems? > > I am writing a p2p chat application, and would like to ideally approach > user input in a man

Re: using ftplib

2006-05-02 Thread John Salerno
Dave Hughes wrote: > As far as I recall your speculation is indeed correct: a TYPE command > is only necessary before a transfer (it's only used to transform data > passing over the secondary data connection). I'm reasonably certain you > don't need *anything* before a SITE command (like SITE CHMO

Re: simultaneous assignment

2006-05-02 Thread John Salerno
bruno at modulix wrote: > Now if I may ask: what is your actual problem ? Ok, since you're so curious. :) Here's a scan of the page from the puzzle book: http://johnjsalerno.com/spies.png Basically I'm reading this book to give me little things to try out in Python. There's no guarantee that t

Re: unable to resize mmap object

2006-05-02 Thread Fabiano Sidler
On Sunday 30 April 2006 21:06, Serge Orlov wrote: > Fabiano Sidler wrote: >> Now, when I try to resize mm to 10 byte >> --- snip --- >> mm.resize(10) >> --- snap --- >> I get an EnvironmentError:[Errno 22] Invalid argument. > > Just a guess: try a new size argument that is multiple of page size. N

Re: SGML parsing tags and leeping track

2006-05-02 Thread hapaboy2059
could i make a global variable and keep track of each tag count? Also how would i make a list or dictionary of tags that is found? how can i handle any tag that is given? -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread bruno at modulix
Edward Elliott wrote: > bruno at modulix wrote: > >>>that 1) b is an object not a module*, and 2) objects pass references to >>>themselves as the first argument to their methods. >> >>Nope. It's the MethodType object (a descriptor) that wraps the function >>that do the job. The object itself is to

Re: simultaneous assignment

2006-05-02 Thread Steve R. Hastings
On Tue, 02 May 2006 17:15:05 +, John Salerno wrote: > Basically W, X, Y and Z are propositions > that are either true or false, and the puzzle lists a few statements > such as "Exactly one of X, Y and Z is true", and I'm trying to work out > a little algorithm that might test for this kind o

Re: simultaneous assignment

2006-05-02 Thread John Salerno
Steve R. Hastings wrote: > Anyway, the major point I want you to take away from all this: it doesn't > matter whether the "is" test succeeds or fails, if all you care about is > the *value* of a variable. Python reuses object references to save > memory, because this doesn't affect expressions th

Re: Multi-Monitor Support

2006-05-02 Thread Jesse Hager
Mark rainess wrote: > Hello, > > > Does Python or wxPython include any support for multiple monitors. In my > application multiple monitors are located at a distance. It is not > convenient to move a window from the main monitor to one of the others. > I want to have the option to open an an appl

Wake on LAN and Shutdown for Windows and Linux

2006-05-02 Thread diffuser78
I am using 8 computers on a small network. I have one Main computer which should be able to remotely start other computers. I used Wake on LAN to start them all. My Main computer is Linux. Other 4 are Windows and 3 are Linux. How can I shutdown Windows box from my Main (Linux) ? Also, How can I

Re: simultaneous assignment

2006-05-02 Thread Grant Edwards
On 2006-05-02, John Salerno <[EMAIL PROTECTED]> wrote: > Yeah, after trying some crazy things, I just wrote it this way: > > def truth_test(seq): > truth = 0 > for item in seq: > if item: > truth += 1 > if truth == 1: > return True > else: >

Re: stripping

2006-05-02 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > while 1: > line = f.readline().rstrip("\n") > if line == '': > break > #if not re.findall(r'^$',line): > print line you want continue, not break there. but that gives you an infinite loop, so you need a new exit condition

Re: stripping

2006-05-02 Thread Jesse Hager
[EMAIL PROTECTED] wrote: > hi > i have a file test.dat eg > > abcdefgh > ijklmn > <-newline > opqrs > tuvwxyz > <---newline > > > I wish to print the contents of the file such that it appears: > abcdefgh > ijklmn > opqrs > tuvwxyz > > here is what i did: > f = open("test.

Re: simultaneous assignment

2006-05-02 Thread John Salerno
Grant Edwards wrote: > Python knows how to count. :) > > def countFalse(seq): > return len([v for v in seq if not v]) > > def countTrue(seq): > return len([v for v in seq if v]) > > def truth_test(seq): > return countTrue(seq) == 1 Gosh, so much to learn! Of course, I already know

Re: simultaneous assignment

2006-05-02 Thread Boris Borcic
Steve R. Hastings wrote: > So, don't test to see if something is equal to True or False: > > if 0 == False: > pass # never executed; False and 0 do not directly compare of course they do - ie isinstance(False,int) is True and False == 0 > > > You *could* do this, but I don't really recom

  1   2   3   >