Re: write a .txt file

2010-07-12 Thread Jia Hu
Hi: Do you mean the following code? #!/usr/bin/python # OS: Ubuntu import subprocess fileName = open ('final.txt', 'a') fileName.write ('%s %s %s \n' % (12,25,9)) fileName.flush() # add fileName.close() # add desLrr = subprocess.Popen('ls -a >> final.txt', shell=True) # change to "ls -a" fi

Re: Lua is faster than Fortran???

2010-07-12 Thread Stefan Behnel
sturlamolden, 04.07.2010 05:30: I was just looking at Debian's benchmarks. It seems LuaJIT is now (on median) beating Intel Fortran! C (gcc) is running the benchmarks faster by less than a factor of two. Consider that Lua is a dynamically typed scripting language very similar to Python. LuaJIT

Re: Check if a command is valid

2010-07-12 Thread Tim Roberts
Kenny Meyer wrote: > >I have to figure out if a string is callable on a Linux system. I'm >actually doing this: >... >Never mind the code, because this is not the original. >The side effect of subprocess.call() is that it *actually* executes >it, but I just need the return code. What are better wa

Re: Errno 9] Bad file descriptor

2010-07-12 Thread Tim Roberts
joblack wrote: > >I get sometimes a > >Errno 9 Bad file descriptor > >the code is too long to show it here but what are the circumstances >this could happen? A web search showed nothing. > >I have especially the feeling Python 2.6 has some problems with >Unicode ... and might not find the file. Is

Re: write a .txt file

2010-07-12 Thread Cameron Simpson
On 12Jul2010 21:28, Jia Hu wrote: | I have a problem about how to generate a specific.txt file. I use the | following code: | | #!/usr/bin/python | # OS: Ubuntu | import subprocess | fileName = open ('final.txt', 'a') | fileName.write ('%s %s %s \n' % (12,25,9)) String still in Python's buffer,

Re: Debugging a segmentation fault

2010-07-12 Thread dierkerdm...@mail.com
On 8 Jul., 19:32, Christian Heimes wrote: > Which third party products with C extensions do you use? Have you > updated your database adapter and NumPy yet? I'm using sqlalchemy, scipy and numpy. I will try to update these and see if that helps. Dierk -- http://mail.python.org/mailman/listinf

Re: write a .txt file

2010-07-12 Thread Jia Hu
If I change "'echo "hello">> final.txt" to "ls -a >> final.txt" and add fileName.close() before subprocess. The result is still like: 12 25 9 85 25 12 # list of files . How can I put the list before the number list 85 25 12? Thank you. On Tue, Jul 13, 2010 at 12:47 AM, Jia Hu wrote:

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Michael Torrie
On 07/12/2010 06:36 PM, Paul Rubin wrote: > I'd personally prefer > > if not bool(myValue): > > which would call the myValue's __bool__ method if it chose to implement > one. Explicit is better than implicit. That's just ugly. Probably a more explicit way would be to have an is_true() and

if you choose this bag you will ged a loptop

2010-07-12 Thread sivaji
http;//www.123maza.com/elaxa/domain-hosting -- http://mail.python.org/mailman/listinfo/python-list

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Michael Torrie
On 07/12/2010 06:18 PM, Steven D'Aprano wrote: > Early versions of BASIC used -1 as true and 0 as false. They did this for good reason. BASIC had no logical operators. AND, OR, and NOT were all actually bitwise operators. By making the True value -1, the bitwise operations yielded the result on

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 20:58:39 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> What Python does instead is to accept *any* object in a context where >> other languages (such as Pascal) would insist on a boolean. > > I'm aware of what Python does, just saying I can sympathize with the > senti

Re: any issues with long running python apps?

2010-07-12 Thread CM
> >      Yesterday, I was running a CNC plasma cutter that's controlled > > by Windows XP.  This is a machine that moves around a plasma torch that > > cuts thick steel plate.  A "New Java update is available" window > > popped up while I was working.  Not good. > > Hi, it looks like you're attem

Re: Python 3 grammar, function parameters

2010-07-12 Thread Chris Rebert
On Mon, Jul 12, 2010 at 3:32 PM, Junkman wrote: > Greetings to Python users, > > I'm trying to parse Python code using the grammar supplied with the > documentation set, and have a question on the grammar for function > parameters: > > funcdef: 'def' NAME parameters ['->' test] ':' suite > paramet

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Paul Rubin
Steven D'Aprano writes: > What Python does instead is to accept *any* object in a context where > other languages (such as Pascal) would insist on a boolean. I'm aware of what Python does, just saying I can sympathize with the sentiment that explicit conversions would make more sense. I wouldn'

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 20:22:39 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Writing the explicit tests: >> if bool(myInt): >> or even: >> if myInt <> 0: >> >> are firmly in the same category. The only difference is that it is more >> familiar and therefore comfortable to those who are use

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 17:36:38 -0700, Paul Rubin wrote: >> I would argue against that. Why do you, the coder, care about the >> specific details of treating ints in a boolean context? The int type >> itself knows, leave the decision to it. > > There is a horrible (IMO) thing that Perl, Lua, and Jav

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Ian Kelly
On Mon, Jul 12, 2010 at 9:16 PM, Steven D'Aprano wrote: > You've seen -1 being used as false? Where? Are you still talking about > Python builtins or language semantics? Some of our database tables at work use 1 for true, -1 for false, and 0 for neither. Don't look at me, I didn't design it. Wh

Re: Check if a command is valid

2010-07-12 Thread Chris Rebert
On Mon, Jul 12, 2010 at 6:29 PM, Kenny Meyer wrote: > Hello, > > I have to figure out if a string is callable on a Linux system. I'm "callable" seems vague. Is a command string with invalid arguments but a valid executable "callable"? If no, then there's no general way to test "callability" witho

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Paul Rubin
Steven D'Aprano writes: > Writing the explicit tests: > if bool(myInt): > or even: > if myInt <> 0: > > are firmly in the same category. The only difference is that it is more > familiar and therefore comfortable to those who are used to languages > that don't have Python's truth-testing rules.

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 19:28:28 -0600, Ian Kelly wrote: > On Mon, Jul 12, 2010 at 6:18 PM, Steven D'Aprano > wrote: >>> I prefere to explicitly write what I want to test: >>> >>> if myInt <> 0: >> >> I would argue against that. Why do you, the coder, care about the >> specific details of treating in

Must We Worship

2010-07-12 Thread nais-saudi
Must We Worship Whom Must We Worship The submission of man to His Creator is the essence of Islam. The name “Islam” is chosen by God (Allah) and not by man. It is the same unifying Message revealed to all the Prophets and Messengers by Allah and which they spread amongst their respective nations.

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Chris Kaynor
On Mon, Jul 12, 2010 at 7:14 PM, Paul Rubin wrote: > Ian Kelly writes: > > I don't think it's any more egregious than automatic conversions of > > mixed-type expressions, such as 3 + 4.5. > > That could also be explicit: float(3) + 4.5, or 3 + int(4.5). > > > If you don't want your ints automati

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Cameron Simpson
On 12Jul2010 17:36, Paul Rubin wrote: | Steven D'Aprano writes: | > This is why virtually all low-level languages treat 0 as a false ... | | OK, but is Python a low-level language, Not particularly, but true/false and Boolean login are low level ideas. If it works well in a low level language (

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Paul Rubin
Ian Kelly writes: > I don't think it's any more egregious than automatic conversions of > mixed-type expressions, such as 3 + 4.5. That could also be explicit: float(3) + 4.5, or 3 + int(4.5). > If you don't want your ints automatically converted to floats on > division, then use the integer d

Re: write a .txt file

2010-07-12 Thread MRAB
Jia Hu wrote: Hello: I have a problem about how to generate a specific.txt file. I use the following code: #!/usr/bin/python # OS: Ubuntu import subprocess fileName = open ('final.txt', 'a') fileName.write ('%s %s %s \n' % (12,25,9)) desLrr = subprocess.Popen('echo "hello" >> final.txt ', s

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Ian Kelly
On Mon, Jul 12, 2010 at 6:36 PM, Paul Rubin wrote: > There is a horrible (IMO) thing that Perl, Lua, and Javascript all do, > which is automatically convert strings to numbers, so "12"+3 = 15. > Python has the good sense to throw a type error if you attempt such an > addition, but it goes and conv

Re: any issues with long running python apps?

2010-07-12 Thread Stephen Hansen
On 7/12/10 10:16 AM, John Nagle wrote: >Yesterday, I was running a CNC plasma cutter that's controlled > by Windows XP. This is a machine that moves around a plasma torch that > cuts thick steel plate. A "New Java update is available" window > popped up while I was working. Not good. That's

Check if a command is valid

2010-07-12 Thread Kenny Meyer
Hello, I have to figure out if a string is callable on a Linux system. I'm actually doing this: def is_valid_command(command): retcode = 100 # initialize if command: retcode = subprocess.call(command, shell=True) if retcode is 0: print "Valid co

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Ian Kelly
On Mon, Jul 12, 2010 at 6:18 PM, Steven D'Aprano wrote: >> I prefere to explicitly write what I want to test: >> >> if myInt <> 0: > > I would argue against that. Why do you, the coder, care about the > specific details of treating ints in a boolean context? The int type > itself knows, leave the

write a .txt file

2010-07-12 Thread Jia Hu
Hello: I have a problem about how to generate a specific.txt file. I use the following code: #!/usr/bin/python # OS: Ubuntu import subprocess fileName = open ('final.txt', 'a') fileName.write ('%s %s %s \n' % (12,25,9)) desLrr = subprocess.Popen('echo "hello" >> final.txt ', shell=True) fileName

Re: how to delete "\n"

2010-07-12 Thread Benjamin Kaplan
On Mon, Jul 12, 2010 at 2:33 PM, Jia Hu wrote: > Thank you. It works now. > >  if I use 'print' to print the whole list, 'print' will add newline > at the end of the list but not each item in the list.  right? > > For the code: > for line in fileName: >     line = line.rstrip('\n') > I think this

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Paul Rubin
Steven D'Aprano writes: > This is why virtually all low-level languages treat 0 as a false ... OK, but is Python a low-level language, and if not, why are low-level languages appropriate examples to follow? >> if myInt <> 0: > > I would argue against that. Why do you, the coder, care about the

Re: Easy questions from a python beginner

2010-07-12 Thread Rami Chowdhury
On Jul 12, 2010, at 15:55 , Alf P. Steinbach /Usenet wrote: > * Rami Chowdhury, on 13.07.2010 00:14: >> Perhaps I'm misunderstanding, but ... >> >> On Jul 12, 2010, at 13:57 , Alf P. Steinbach /Usenet wrote: >>> >>> Existence of a variable means, among other things, that >>> >>> * You can use

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 12:34:46 +0200, Jean-Michel Pichavant wrote: > Well, actually some people might think otherwise. While I disagree with > the OP flaming style, one could argue that muting an integer into a > boolean makes no sense (I'm one of them). You can still do it, but there > is no "right

Re: Easy questions from a python beginner

2010-07-12 Thread Alf P. Steinbach /Usenet
* Steven D'Aprano, on 13.07.2010 01:34: On Mon, 12 Jul 2010 20:28:49 +0200, Alf P. Steinbach /Usenet wrote: As I see it it doesn't matter whether the implementation is CPython call frame slots or that mechanism called something else or a different mechanism called the same or a different mechan

Re: Easy questions from a python beginner

2010-07-12 Thread Alf P. Steinbach /Usenet
* Steven D'Aprano, on 13.07.2010 01:50: On Mon, 12 Jul 2010 22:57:10 +0200, Alf P. Steinbach /Usenet wrote: Existence of a variable means, among other things, that * You can use the value, with guaranteed effect (either unassigned exception or you get a proper value): in particul

Re: Easy questions from a python beginner

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 22:57:10 +0200, Alf P. Steinbach /Usenet wrote: > Existence of a variable means, among other things, that > >* You can use the value, with guaranteed effect (either unassigned >exception > or you get a proper value): in particular, you won't be accessing a >

Re: Help choosing license for new projects

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 17:00:22 -0500, Jake b wrote: > I'm starting a new python code project. What license do you suggest? I > am searching, but I'm not finding a simple comparison of licenses. So I > don't know which to use. Maybe MIT or Apache or LGPL or BSD? http://www.dwheeler.com/essays/gpl-co

Re: multitask http server (single-process multi-connection HTTP server)

2010-07-12 Thread lkcl
On Jul 12, 9:52 pm, Gelonida wrote: > Hi lkcl, > > Do you have any documentation or overview for your project? git clone git://pyjs.org/git/multitaskhttpd.git i only started it today, but yes, there's a README. the primary reason it's being developed is because GNUmed are looking to create a

Re: Easy questions from a python beginner

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 20:28:49 +0200, Alf P. Steinbach /Usenet wrote: > As I see it it doesn't matter whether the implementation is CPython call > frame slots or that mechanism called something else or a different > mechanism called the same or a different mechanism called something > different; wha

Re: Help choosing license for new projects

2010-07-12 Thread Ben Finney
Jake b writes: > I want: > 1] Pretty much let anyone use it. Users do not have to include source > code, as long as I get credit. (which I think normallly is a textfile > with project url + name?) The simplest effective license that requires nothing more that attribution is “under the terms of t

Re: multitask http server (single-process multi-connection HTTP server)

2010-07-12 Thread Luke Kenneth Casson Leighton
On Mon, Jul 12, 2010 at 10:13 PM, geremy condra wrote: > On Mon, Jul 12, 2010 at 4:59 PM, lkcl wrote: >> for several reasons, i'm doing a cooperative multi-tasking HTTP >> server: >>  git clone git://pyjs.org/git/multitaskhttpd.git >> >> there probably exist perfectly good web frameworks that are

Re: Help choosing license for new projects

2010-07-12 Thread geremy condra
On Mon, Jul 12, 2010 at 6:00 PM, Jake b wrote: > I'm starting a new python code project. What license do you suggest? I > am searching, but I'm not finding a simple comparison of licenses. So > I don't know which to use. Maybe MIT or Apache or LGPL or BSD? Fair warning: I like and use the GPL a l

Re: Easy questions from a python beginner

2010-07-12 Thread Alf P. Steinbach /Usenet
* Rami Chowdhury, on 13.07.2010 00:14: Perhaps I'm misunderstanding, but ... On Jul 12, 2010, at 13:57 , Alf P. Steinbach /Usenet wrote: Existence of a variable means, among other things, that * You can use the value, with guaranteed effect (either unassigned exception or you get a prop

Python 3 grammar, function parameters

2010-07-12 Thread Junkman
Greetings to Python users, I'm trying to parse Python code using the grammar supplied with the documentation set, and have a question on the grammar for function parameters: funcdef: 'def' NAME parameters ['->' test] ':' suite parameters: '(' [typedargslist] ')' typedargslist: ((tfpdef ['=' test]

Re: multitask http server (single-process multi-connection HTTP server)

2010-07-12 Thread geremy condra
On Mon, Jul 12, 2010 at 4:59 PM, lkcl wrote: > for several reasons, i'm doing a cooperative multi-tasking HTTP > server: >  git clone git://pyjs.org/git/multitaskhttpd.git > > there probably exist perfectly good web frameworks that are capable of > doing this sort of thing: i feel certain that twi

Re: Easy questions from a python beginner

2010-07-12 Thread Rami Chowdhury
Perhaps I'm misunderstanding, but ... On Jul 12, 2010, at 13:57 , Alf P. Steinbach /Usenet wrote: > > Existence of a variable means, among other things, that > > * You can use the value, with guaranteed effect (either unassigned exception >or you get a proper value) Surely by that definiti

Re: Why did I Embrace Islam?

2010-07-12 Thread Alister Ware
On Mon, 12 Jul 2010 14:54:00 -0700, nais-saudi wrote: > Why did I Embrace Islam? Very interesting & good fro you but I cannot find any thing related to python here. -- This place just isn't big enough for all of us. We've got to find a way off this planet. -- http://mail.python.org/mailm

Re: any issues with long running python apps?

2010-07-12 Thread Tim Chase
On 07/12/2010 12:16 PM, John Nagle wrote: On 7/12/2010 7:19 AM, Grant Edwards wrote: On 2010-07-09, Les Schaffer wrote: i have been asked to guarantee that a proposed Python application will run continuously under MS Windows for two months time. And i am looking ^

Help choosing license for new projects

2010-07-12 Thread Jake b
I'm starting a new python code project. What license do you suggest? I am searching, but I'm not finding a simple comparison of licenses. So I don't know which to use. Maybe MIT or Apache or LGPL or BSD? Are there certain licenses to avoid using because of interaction problems between libraries us

Why did I Embrace Islam?

2010-07-12 Thread nais-saudi
Why did I Embrace Islam? This is an extract from Dr. Gronier, a French MP, who embraced Islam. Revealing the reason of embracing Islam he said, I read all of the Ayat (Quranic verses), which have a relation to medical, health, and natural sciences that I studied before and have a wide knowledge of.

Re: how to delete "\n"

2010-07-12 Thread python
Thomas, > split() also splits at other whitespace. Doh! Corrected version follows: print ''.join( open( 'Direct_Irr.txt' ).read().splitlines() ) Broken out: - open(): open file - read(): read its entire contents as one string - splitlines(): split the contents into a list of lines (splits

Re: multitask http server (single-process multi-connection HTTP server)

2010-07-12 Thread Gelonida
Hi lkcl, Do you have any documentation or overview for your project? Questions I would be interested in: - List of features already working - list of features under development - list of features being in in the near future lkcl wrote: > for several reasons, i'm doing a cooperative multi-ta

Re: how to delete "\n"

2010-07-12 Thread Thomas Jollans
On 07/12/2010 11:29 PM, pyt...@bdurham.com wrote: > Jia, > > print ''.join( open( 'Direct_Irr.txt' ).read().split() ) > > Broken out: > > - open(): open file > - read(): read its entire contents as one string > - split(): split the contents into a list of lines > (splits lines at \n; does not

Re: how to delete "\n"

2010-07-12 Thread Jia Hu
Thank you. It works now. if I use 'print' to print the whole list, 'print' will add newline at the end of the list but not each item in the list. right? For the code: for line in fileName: line = line.rstrip('\n') I think this will affect 'fileName' because it assign the value to 'line' ? B

Re: how to delete "\n"

2010-07-12 Thread python
Jia, print ''.join( open( 'Direct_Irr.txt' ).read().split() ) Broken out: - open(): open file - read(): read its entire contents as one string - split(): split the contents into a list of lines (splits lines at \n; does not include \n in split values) - ''.join(): join list of lines with an e

Re: Lua is faster than Fortran???

2010-07-12 Thread Дамјан Георгиевски
On the positive side, Lua supports tail call optimization and coroutines are built in by default. -- дамјан ((( http://damjan.softver.org.mk/ ))) Education is one of the "prices" of freedom that some are unwilling to pay. -- http://mail.python.org/mailman/listinfo/python-list

Standard distutils package problems with MSVC / lacking functionality?

2010-07-12 Thread Alf P. Steinbach /Usenet
I let the setup.py script talk: # 03_1__noddy from distutils.core import setup, Extension import distutils.ccompiler compilerName = distutils.ccompiler.get_default_compiler() options = [] if compilerName == "msvc": # * distutils sets warning level 3: # Overriding with warning level

multitask http server (single-process multi-connection HTTP server)

2010-07-12 Thread lkcl
for several reasons, i'm doing a cooperative multi-tasking HTTP server: git clone git://pyjs.org/git/multitaskhttpd.git there probably exist perfectly good web frameworks that are capable of doing this sort of thing: i feel certain that twisted is one of them. however, the original author of rtm

Re: Easy questions from a python beginner

2010-07-12 Thread Alf P. Steinbach /Usenet
* Rhodri James, on 12.07.2010 22:19: On Mon, 12 Jul 2010 13:56:38 +0100, bart.c wrote: "Steven D'Aprano" wrote in message news:4c3aedd5$0$28647$c3e8...@news.astraweb.com... On Mon, 12 Jul 2010 09:48:04 +0100, bart.c wrote: That's interesting. So in Python, you can't tell what local variabl

Re: Numpy now supports Python3, Scipy to follow soon

2010-07-12 Thread Terry Reedy
On 7/12/2010 4:05 AM, Steven D'Aprano wrote: Pardon me if this has already been mentioned, but I didn't see it, and this is big big news. The latest release of numpy now supports Python 2.x and 3.x out of a single code base, and Scipy is predicted to follow soon. http://www.mail-archive.com/num

Re: how to delete "\n"

2010-07-12 Thread Chris Rebert
On Mon, Jul 12, 2010 at 1:27 PM, Jia Hu wrote: > Hi, I just want to delete "\n" at each line. My operating system is ubuntu > 9.1. The code is as follows > > #!/usr/bin/python > import string > fileName=open('Direct_Irr.txt', 'r') # read file > directIrr = fileName.readlines() > fileName.close() >

Re: Easy questions from a python beginner

2010-07-12 Thread Terry Reedy
On 7/12/2010 4:48 AM, bart.c wrote: >>> def foo(): print("Before:", locals()) x = 0 print("After:", locals()) >>> foo() Before: {} After: {'x': 0} That's interesting. So in Python, you can't tell what local variables a function has just by looking at it's code: You are being fooled by the

Re: Easy questions from a python beginner

2010-07-12 Thread Alister Ware
On Sun, 11 Jul 2010 18:17:49 +, Duncan Booth wrote: > wheres pythonmonks wrote: > >> I'm an old Perl-hacker, and am trying to Dive in Python. I have some >> easy issues (Python 2.6) >> which probably can be answered in two seconds: without going into details on how to do these things in py

Re: how to delete "\n"

2010-07-12 Thread Ian Kelly
On Mon, Jul 12, 2010 at 2:27 PM, Jia Hu wrote: > Hi, I just want to delete "\n" at each line. My operating system is ubuntu > 9.1. The code is as follows > > #!/usr/bin/python > import string > fileName=open('Direct_Irr.txt', 'r') # read file > directIrr = fileName.readlines() > fileName.close() >

Re: how to delete "\n"

2010-07-12 Thread Matteo Landi
I hope this could help: >>> f = open('powersave.sh') >>> map(lambda s: s.strip(), f.readlines()) ['echo 1 > /sys/module/snd_hda_intel/parameters/power_save', 'echo min_power > /sys/class/scsi_host/host0/link_power_management_policy', 'echo 1 > /sys/module/snd_hda_intel/parameters/power_save'] I k

Re: any issues with long running python apps?

2010-07-12 Thread John Bokma
John Nagle writes: >Yesterday, I was running a CNC plasma cutter that's controlled > by Windows XP. This is a machine that moves around a plasma torch that > cuts thick steel plate. A "New Java update is available" window > popped up while I was working. Not good. You can blame that one o

how to delete "\n"

2010-07-12 Thread Jia Hu
Hi, I just want to delete "\n" at each line. My operating system is ubuntu 9.1. The code is as follows #!/usr/bin/python import string fileName=open('Direct_Irr.txt', 'r') # read file directIrr = fileName.readlines() fileName.close() for line in directIrr: line.rstrip('\n') print directIrr

Re: Easy questions from a python beginner

2010-07-12 Thread Rhodri James
On Mon, 12 Jul 2010 13:56:38 +0100, bart.c wrote: "Steven D'Aprano" wrote in message news:4c3aedd5$0$28647$c3e8...@news.astraweb.com... On Mon, 12 Jul 2010 09:48:04 +0100, bart.c wrote: That's interesting. So in Python, you can't tell what local variables a function has just by looking at

Re: iptcinfo: Can not import: Newbie not really knowing what he is doing

2010-07-12 Thread mcl
On Jul 12, 4:11 pm, Nick Raptis wrote: > Hi Richard!> I have downloaded iptcinfo and placed it in > python27\Lib\site-packages > > \iptcinfo > > > I guessed that was the right place, because that is where PIL ended > > up, but that had a fancy installer with it. > > You did place it in the right

Re: Why doesn't python's list append() method return the list itself?

2010-07-12 Thread John Nagle
On 7/11/2010 5:24 PM, Steven D'Aprano wrote: On Sun, 11 Jul 2010 08:59:06 -0700, dhruvbird wrote: Why doesn't python's list append() method return the list itself? For that matter, even the reverse() and sort() methods? I found this link (http://code.google.com/edu/languages/google-python- clas

Re: Why doesn't python's list append() method return the list itself?

2010-07-12 Thread dhruvbird
On Jul 12, 4:20 pm, Hrvoje Niksic wrote: > dhruvbird writes: > > No, I meant x.append(4) > > Except that I want to accomplish it using slices. > > > (I can do it as x[lex(x):] = [item_to_append] but is there any other > > way?) > > It seems that you've found a way to do so, so why do you need ano

Re: round issue

2010-07-12 Thread Mark Dickinson
Emile van Sebille fenx.com> writes: > > On 7/12/2010 2:52 AM Robin Becker said... > > > What value should round(-9.85,1) return? > > Per round's definition, -9.9. No. The float that's represented by the literal '-9.85' *isn't* exactly -9.85, for all the usual binary floating-point reasons. T

Re: any issues with long running python apps?

2010-07-12 Thread CM
On Jul 12, 1:16 pm, John Nagle wrote: > On 7/12/2010 7:19 AM, Grant Edwards wrote: > > > On 2010-07-09, Les Schaffer  wrote: > > >> i have been asked to guarantee that a proposed Python application will > >> run continuously under MS Windows for two months time. And i am looking > >              

Re: Easy questions from a python beginner

2010-07-12 Thread Alf P. Steinbach /Usenet
* Steven D'Aprano, on 12.07.2010 04:39: On Mon, 12 Jul 2010 03:12:10 +0200, Alf P. Steinbach /Usenet wrote: * MRAB, on 12.07.2010 00:37: [...] In Java a variable is declared and exists even before the first assignment to it. In Python a 'variable' isn't declared and won't exist until the firs

GUIs (was: grailbrowser now running under python 2.5 (probably above too))

2010-07-12 Thread John Bokma
MRAB writes: > John Bokma wrote: [..] >> Can't think of why not. Of course not all operations are shared by each >> OS, but /I/ know that I can't do chmod on Windows. But it doesn't mean >> that on Windows I can't make a file only readable by me. Just give me >> the Windows security options on

Re: round issue

2010-07-12 Thread Emile van Sebille
On 7/12/2010 2:52 AM Robin Becker said... What value should round(-9.85,1) return? Per round's definition, -9.9. String interpolation for %n.mf doesn't appear to define it's rounding behavior, so a peek at the source would answer what's being done. It does look inconsistent however, and i

Re: Problems running VirtualEnv under Windows.

2010-07-12 Thread ashconnor
I've resolved this issue by deleting the *.py file association in Windows. You can do this either by associating *.py with something like textpad, using a utility such as http://defaultprogramseditor.com/ or doing so in the registry. Note that when using the command like you need to issue command

Re: Easy questions from a python beginner

2010-07-12 Thread Alf P. Steinbach /Usenet
* sturlamolden, on 12.07.2010 16:59: On 12 Jul, 07:51, "Alf P. Steinbach /Usenet" wrote: We're talking about defining a 'swap' routine that works on variables. I did not miss the point. One cannot make a swap function that rebinds its arguments in the calling stack frame. But a swap function

Node based architecture

2010-07-12 Thread King
Hi, I am planning to build a generic node based framework using python. I would start with a simple image editing application. I hope that experienced users understands what am I trying to say here. In simple words: LoaderNode : Load Image from disk OperatorNode : Performs a specific task on data

Re: any issues with long running python apps?

2010-07-12 Thread John Nagle
On 7/12/2010 7:19 AM, Grant Edwards wrote: On 2010-07-09, Les Schaffer wrote: i have been asked to guarantee that a proposed Python application will run continuously under MS Windows for two months time. And i am looking ^^ IMO, that's going to be your main

Re: grailbrowser now running under python 2.5 (probably above too)

2010-07-12 Thread Thomas Jollans
On 07/12/2010 01:44 AM, rantingrick wrote: > On Jul 11, 11:31 am, Thomas Jollans wrote: >> On 07/11/2010 07:44 AM, rantingrick wrote: > >>> Congratulations on this effort Luke. However you know what project i >>> would really like to see the community get around? ...dramatic pause >>> here... a c

Re: round issue

2010-07-12 Thread Gary Herron
On 07/12/2010 02:52 AM, Robin Becker wrote: A client wants to know why his db number -9.85 gets displayed by some simple code as -9.8 I looked at the number and see that >>> -9.85 -9.8496 ie I expect simple rounding to produce the observed result and indeed >>> '%.1f' % -9.85 '-9

Re: iptcinfo: Can not import: Newbie not really knowing what he is doing

2010-07-12 Thread Nick Raptis
Hi Richard! I have downloaded iptcinfo and placed it in python27\Lib\site-packages \iptcinfo I guessed that was the right place, because that is where PIL ended up, but that had a fancy installer with it. You did place it in the right path, but the "fancy installer" does one more thing, it

Re: ValueError: invalid literal for float(): -1.#IND (pickle.py)

2010-07-12 Thread Mark Dickinson
Alexander Eisenhuth stacom-software.de> writes: >File "C:\Python25\lib\pickle.py", line 954, in load_float > self.append(float(self.readline()[:-1])) > ValueError: invalid literal for float(): -1.#IND > > - I'm not sure what -1.#IND means. Can somebody assist? It's the Windows way of r

Re: Easy questions from a python beginner

2010-07-12 Thread sturlamolden
On 12 Jul, 07:51, "Alf P. Steinbach /Usenet" wrote: > We're talking about defining a 'swap' routine that works on variables. I did not miss the point. One cannot make a swap function that rebinds its arguments in the calling stack frame. But a swap function can swap values, given that the type i

Re: ValueError: invalid literal for float(): -1.#IND (pickle.py)

2010-07-12 Thread Grant Edwards
On 2010-07-12, Grant Edwards wrote: > On 2010-07-12, Alexander Eisenhuth wrote: > >> python: 2.5.1 >> palttform: winXP >> >> I'm using pickle.dump and pickle.load with data that is created in a >> wrapped (boost.python) piece of C++ code. pickle.dump works fine. >> pickle.load creates the followi

Re: ValueError: invalid literal for float(): -1.#IND (pickle.py)

2010-07-12 Thread Grant Edwards
On 2010-07-12, Alexander Eisenhuth wrote: > python: 2.5.1 > palttform: winXP > > I'm using pickle.dump and pickle.load with data that is created in a > wrapped (boost.python) piece of C++ code. pickle.dump works fine. > pickle.load creates the following exception: > > [...] > data = pickle.l

ValueError: invalid literal for float(): -1.#IND (pickle.py)

2010-07-12 Thread Alexander Eisenhuth
Hello together, python: 2.5.1 palttform: winXP I'm using pickle.dump and pickle.load with data that is created in a wrapped (boost.python) piece of C++ code. pickle.dump works fine. pickle.load creates the following exception: [...] data = pickle.load(input) File "C:\Python25\lib\pickl

Re: Easy questions from a python beginner

2010-07-12 Thread Grant Edwards
On 2010-07-11, Thomas Jollans wrote: > On 07/11/2010 08:45 PM, wheres pythonmonks wrote: >> On #3: Sorry this is confusing, but I was browsing some struct array >> code from numpy, in which one of the columns contained strings, but >> the type information, supplied in numpy.array's dtype argument

Re: any issues with long running python apps?

2010-07-12 Thread Grant Edwards
On 2010-07-09, Les Schaffer wrote: > i have been asked to guarantee that a proposed Python application will > run continuously under MS Windows for two months time. And i am looking ^^ IMO, that's going to be your main problem. -- Grant Edwards g

iptcinfo: Can not import: Newbie not really knowing what he is doing

2010-07-12 Thread mcl
My Code `import os from PIL import Image from iptcinfo import IPTCInfo info = IPTCInfo('test.jpg') print info.keywords, info.supplementalCategories, info.contacts caption = info.data['caption/abstract'] print caption` running Win XP SP3 I get the message No module: iptcinfo I have downloaded i

Re: Why doesn't python's list append() method return the list itself?

2010-07-12 Thread Nathan Rice
Stephen: I'm not adverse to being able to do that, but the number of times that I've wanted to do that is greatly outweighed by the number of times I've had to pass a function "(somestring,)" or call "if isinstance(foo, basestring): ..." to avoid producing a bug. The more abstract and adaptive th

Re: Easy questions from a python beginner

2010-07-12 Thread bart.c
"Steven D'Aprano" wrote in message news:4c3aedd5$0$28647$c3e8...@news.astraweb.com... On Mon, 12 Jul 2010 09:48:04 +0100, bart.c wrote: That's interesting. So in Python, you can't tell what local variables a function has just by looking at it's code: def foo(day): if day=="Tuesday": x=0

Re: Why doesn't python's list append() method return the list itself?

2010-07-12 Thread Hrvoje Niksic
dhruvbird writes: > No, I meant x.append(4) > Except that I want to accomplish it using slices. > > (I can do it as x[lex(x):] = [item_to_append] but is there any other > way?) It seems that you've found a way to do so, so why do you need another way? Are you after elegance? Efficiency? Brevi

Re: Only one forum app in Python?

2010-07-12 Thread James Mills
On Mon, Jul 12, 2010 at 8:49 PM, Gilles Ganault wrote: >>There are almost a dozen of Python "forum apps" for Django alone, and >>Python is known as "the language with more web frameworks than keywords". Speaking of frameworks and python forums, sahriswiki 91) is not a forum, but it's goals are to

Re: grailbrowser now running under python 2.5 (probably above too)

2010-07-12 Thread Fuzzyman
On Jul 12, 1:21 am, rantingrick wrote: > On Jul 11, 5:28 pm,Fuzzyman wrote: > > > But why hijack someone else's announcement to do that? Congratulations > > alone would have been great. However good your intentions your message > > came across as "but it would really have been better if you had be

Re: Only one forum app in Python?

2010-07-12 Thread Gilles Ganault
On Sat, 10 Jul 2010 18:37:00 +0200, Bruno Desthuilliers wrote: >There are almost a dozen of Python "forum apps" for Django alone, and >Python is known as "the language with more web frameworks than keywords". Thanks for the tip. I'll head that way. -- http://mail.python.org/mailman/listinfo/pyth

Re: round issue

2010-07-12 Thread Mark Dickinson
On Jul 12, 10:52 am, Robin Becker wrote: > What value should round(-9.85,1) return? Is the result explainable in python > (ie > without resort to the internal FP representations etc etc)? As you observe, the closest float to -9.85 is actually just a little smaller (i.e., closer to 0) than -9.85:

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-12 Thread Jean-Michel Pichavant
rantingrick wrote: On Jul 11, 3:03 am, "Günther Dietrich" wrote: So, it is not a disadvantage that the functions you listed above are named in this way. In the contrary, it is an advantage, as it keeps newcomers from using stupid variable names. "int" for an Integer is stupid? "list"

  1   2   >