Re: Possible to create a read-only complex object?

2010-07-12 Thread Terry Reedy
On 7/11/2010 12:51 PM, pyt...@bdurham.com wrote: I have a complex object with attributes that contain lists, sets, dictionaries, and other objects. The lists and dictionaries may themselves contain complex objects. I would like to provide a read-only version of this type of object for other devel

Re: Possible to create a read-only complex object?

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 02:56:34 -0400, Terry Reedy wrote: > On 7/11/2010 12:51 PM, pyt...@bdurham.com wrote: >> I have a complex object with attributes that contain lists, sets, >> dictionaries, and other objects. The lists and dictionaries may >> themselves contain complex objects. >> I would like t

Re: Netbeans plugin and Python 3

2010-07-12 Thread Nitin Pawar
Hi, I never tried python3.0 with netbeans but I use python 2.6.5 with netbean 6.7.1 Here is how I managed to change from python 2.5 (netbeans default) to 2.6.5 1) From the tools-> plugins section install python plugin 2) Once plugin is installed just restart netbeans so that plugin is activated

PIL Query

2010-07-12 Thread Ankit Jhalaria
Hi I was using the PIL. I found it pretty useful. I was wondering if you could please let me know, whether I could change the image size. What I mean is if suppose I have 100 points having the same latitude and longitude, the point on the map appears (for instance as a red circle). My question to

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

2010-07-12 Thread Cameron Simpson
On 12Jul2010 02:43, Steven D'Aprano wrote: | On Mon, 12 Jul 2010 02:40:07 +, Steven D'Aprano wrote: | > On Mon, 12 Jul 2010 01:31:14 +0100, Mark Lawrence wrote: | >> Well said Steven, or is it Stephen, or Stephan, or Stefen, or what? | > | > For some reason, when I answer the phone and say "

Numpy now supports Python3, Scipy to follow soon

2010-07-12 Thread Steven D'Aprano
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/numpy-discuss...@scipy.org/msg26524.html If I c

Design questions for C++ support for Python extensions (cppy)

2010-07-12 Thread Alf P. Steinbach /Usenet
Hi. With the current cppy code the Python 3.1.1 doc's spam example extension module looks like this (actual working code): #include #include using namespace progrock; namespace { class Spam: public cppy::Module { public: Spam(): cppy::M

Re: Possible to create a read-only complex object?

2010-07-12 Thread Chris Rebert
On Mon, Jul 12, 2010 at 12:45 AM, Steven D'Aprano wrote: > On Mon, 12 Jul 2010 02:56:34 -0400, Terry Reedy wrote: >> On 7/11/2010 12:51 PM, pyt...@bdurham.com wrote: >>> I have a complex object with attributes that contain lists, sets, >>> dictionaries, and other objects. The lists and dictionarie

Re: Netbeans plugin and Python 3

2010-07-12 Thread Chris Rebert
On Fri, Jul 9, 2010 at 9:27 AM, Nitin Pawar wrote: > Hi, > I never tried python3.0 with netbeans but I use python 2.6.5 with netbean > 6.7.1 > Here is how I managed to change from python 2.5 (netbeans default) to 2.6.5 > 1) From the tools-> plugins section install python plugin > 2) Once plugin is

Re: Numpy now supports Python3, Scipy to follow soon

2010-07-12 Thread Almar Klein
On 12 July 2010 10:05, Steven D'Aprano wrote: > Pardon me if this has already been mentioned, but I didn't see it, and > this is big big news. > I haven't heard it yet, this is great news! Almar -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible to create a read-only complex object?

2010-07-12 Thread Steven D'Aprano
On Mon, 12 Jul 2010 01:11:53 -0700, Chris Rebert wrote: > On Mon, Jul 12, 2010 at 12:45 AM, Steven D'Aprano > wrote: >> On Mon, 12 Jul 2010 02:56:34 -0400, Terry Reedy wrote: >>> On 7/11/2010 12:51 PM, pyt...@bdurham.com wrote: I have a complex object with attributes that contain lists, sets

Re: Easy questions from a python beginner

2010-07-12 Thread bart.c
"MRAB" wrote in message news:mailman.591.1278900548.1673.python-l...@python.org... Alf P. Steinbach /Usenet wrote: def foo(): print( blah ) blah = "this is both an assignment and a declaration causing it to exist" foo() Clearly when the exception is raised, referring to the

Re: Possible to create a read-only complex object?

2010-07-12 Thread geremy condra
On Mon, Jul 12, 2010 at 3:45 AM, Steven D'Aprano wrote: > On Mon, 12 Jul 2010 02:56:34 -0400, Terry Reedy wrote: > >> On 7/11/2010 12:51 PM, pyt...@bdurham.com wrote: >>> I have a complex object with attributes that contain lists, sets, >>> dictionaries, and other objects. The lists and dictionari

Re: 'reload M' doesn't update 'from M inport *'

2010-07-12 Thread Jean-Michel Pichavant
Aahz wrote: In article , Jean-Michel Pichavant wrote: PS : You're misusing the del statement. It does not remove any object >from mmory, however, it removes the reference to it, the object is still in memory. They are very few cases where del is usefull in python, so try to avoid

Re: 'reload M' doesn't update 'from M inport *'

2010-07-12 Thread Jean-Michel Pichavant
Hi, Don't use reload, this is nothing but a trap, espacially if your using it to update your objects with the code you are writting. JM I've found "reload" very usable for development in IDLE. IDLE memorizes my input, and the variables I assign output to. If restart IDLE I lose it all

round issue

2010-07-12 Thread Robin Becker
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.8' however, when I use round I get an unexp

Python conference and user group statistics

2010-07-12 Thread M.-A. Lemburg
Hello, I am currently working on a Python Software Foundation (PSF) project to create marketing material for Python with the aim of providing this to Python conferences and user groups. In order to come up with reasonable figures for the number of brochures and flyers to print, I'd like to get a

Re: Easy questions from a python beginner

2010-07-12 Thread Duncan Booth
"Alf P. Steinbach /Usenet" wrote: > * sturlamolden, on 12.07.2010 06:52: >> On 11 Jul, 21:37, "Alf P. Steinbach /Usenet"> +use...@gmail.com> wrote: >> >>> Oh, I wouldn't give that advice. It's meaningless mumbo-jumbo. >>> Python works like Java in this respect, that's all; neither Java nor >>> P

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

2010-07-12 Thread dhruvbird
On Jul 12, 5:30 am, News123 wrote: > dhruvbird wrote: > > > On a side note, is there any other way to append to a list using > > slices (apart from the one below): > > x[len(x):len(x)] = [item to append] > > dy you mean > x.extend([1,2,3]) No, I meant x.append(4) Except that I want to accomplish

Re: Easy questions from a python beginner

2010-07-12 Thread Steven D'Aprano
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: In the presence of "exec", you can't really tell *anything*. >>> def f(s): ... exec s ... print locals() ... >>> f("x =

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

2010-07-12 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: My complaint (an oddly enough the title of this thread!) concerns the fact that Python treats 0 as False and every integer above and below 0 as True. Which is another example of how *some* aspects of Python support bad coding styles. Yes, Python does support bad codi

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"

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: 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: 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 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: 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: 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 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

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: 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

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

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: 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

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: 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 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: 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: 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: 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: 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

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: 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

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: 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

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: 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

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: 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: 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: 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: 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: 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

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: 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

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: 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: 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: 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: 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: 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: 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

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

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

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

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: 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 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: 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 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

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.

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

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 ^

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: 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: 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

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: 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

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: 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 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: 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: 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: 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: 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: 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 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: 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 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 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: 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

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: 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

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: 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

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: 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 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: 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 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

  1   2   >