Re: Python usage numbers

2012-02-12 Thread Dave Angel
On 02/12/2012 05:27 PM, Roy Smith wrote: In article, Chris Angelico wrote: On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: The situation before ascii is like where we ended up *before* unicode. Unicode aims to replace all those byte encoding and character sets with *one* byte encoding

Re: Python usage numbers

2012-02-12 Thread Dave Angel
On 02/12/2012 05:30 PM, Steven D'Aprano wrote: On Sun, 12 Feb 2012 05:11:30 -0600, Andrew Berg wrote: On 2/12/2012 3:12 AM, Steven D'Aprano wrote: Windows has two separate APIs, one for "wide" characters, the other for single bytes. Depending on which one you use, the directory will appear t

Re: Generating a .pc file using distutils

2012-02-12 Thread Dave Angel
On 02/12/2012 06:04 PM, Tycho Andersen wrote: Just re-bumping this - I am fiddling with this code again and it's gross, so any input would be greatly appreciated :-) \t On Mon, Jan 23, 2012 at 05:31:20PM -0600, Tycho Andersen wrote: Is there some standard way to generate a .pc file (given a .p

Re: Numeric root-finding in Python

2012-02-12 Thread Dave Angel
On 02/12/2012 06:05 PM, Steven D'Aprano wrote: On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: On Feb 12, 6:41 am, Steven D'Aprano wrote: err = -a/b # Estimate of the error in the current w. if abs(err)<= 1e-16: break If the result you'r

Re: Python usage numbers

2012-02-12 Thread Dave Angel
On 02/12/2012 06:29 PM, Steven D'Aprano wrote: On Sun, 12 Feb 2012 17:27:34 -0500, Roy Smith wrote: Hopefully, we will eventually reach the point where storage is so cheap that nobody minds how inefficient UTF-32 is and we all just start using that. Life will be a lot simpler then. No more t

Re: Complexity question on Python 3 lists

2012-02-15 Thread Dave Angel
On 02/15/2012 01:20 PM, Franck Ditter wrote: What is the cost of calling primes(n) below ? I'm mainly interested in knowing if the call to append is O(1), even amortized. Do lists in Python 3 behave like ArrayList in Java (if the capacity is full, then the array grows by more than 1 element) ? d

Re: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-15 Thread Dave Angel
On 02/15/2012 01:36 PM, Miki Tebeka wrote: It depends on the overall runtime of the script vs start time of the vm. But yes in most benchmarks the script start time will bias against scripted languages. On a site note: ALL CAPS is considered shouting, please don't use that in news groups. Whe

Re: writing to a file from within nested loops

2012-02-15 Thread Dave Angel
On 02/15/2012 03:12 PM, Rituparna Sengupta wrote: Hi, I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the inn

Re: signed to unsigned

2012-02-17 Thread Dave Angel
On 02/17/2012 02:22 PM, Brad Tilley wrote: 0x& -327681234 3967286062 Very nice! Thanks for that example. Unsigned long longs: 0x& -9151314442815602945 9295429630893948671L Or more generally, use modulo -13452324 % 2^64 -- DaveA -- http://mail.python.org/mailman/l

Re: Undoing character read from file

2012-02-17 Thread Dave Angel
On 02/17/2012 10:38 PM, Emeka wrote: Hello All, Say I have something like this: mfile = open("cc.txt", "rb") mcount = 0 mset = False while True: c = mfile.read(1) if c == "e" and mset is True and mcount == 0: print c mfile.seek(-1,1) mcount = 1 continue elif c == "e" and mse

Re: netCDF4 variable manipulation

2012-02-20 Thread Dave Angel
On 02/20/2012 03:37 PM, Sheldon wrote: Hi, I'm trying to read a netCDF4 variable from a file (no problem) and then scale it before writing over the original variable in the file. I'm using python 2.7 and the latest netCDF4 module. It's not that I keep getting an error message but I want to do t

Re: Please verify!!

2012-02-23 Thread Dave Angel
On 02/23/2012 05:13 PM, Manish Sharma wrote: Hi I am new to python language. On my first day, somebody told me that if any python script file is opened with any editor except python editor, the file is corrupted. Some spacing or indentation is changed and script stops working. I was opening the s

Re: Please verify!!

2012-02-24 Thread Dave Angel
On 02/24/2012 08:25 PM, Chris Angelico wrote: On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence wrote: Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. PEP 8 applies only to Python code, our standard is across all our languages :) But yes, I'm a horrible sinner and I like tabs.

Re: wcout issue

2012-02-28 Thread Dave Angel
On 02/27/2012 10:26 PM, Ben Held wrote: Hello, After upgrading from Python 2.6 to 3.2 in our application we noticed that after calling Py_Initialize, our output from std::wcout has extra spaces in it: wcout<< L"Just a test\n"; now prints out: J u s t a t e s t Any clue why? Ben Held

Re: Listing children processes

2012-02-28 Thread Dave Angel
On 02/28/2012 06:41 PM, Mark Lawrence wrote: On 28/02/2012 21:47, Arnaud Delobelle wrote: Please don't top-post! Also, psutil.Process.get_children() looks to me like it "does" children. You are incorrect. I've been told of by the BDFL for stating that people should not top post on any Pyth

Re: Problem using s.strip() to remove leading whitespace in .csv file

2012-02-29 Thread Dave Angel
On 02/29/2012 04:05 AM, Guillaume Chorn wrote: Thanks, the suggestion print name.decode("utf-8").strip() worked like a charm. When I did the print repr(name) I got exactly what you predicted. I'm not yet sure what all of this means, but I'm going to read this

Re: Why this fails??

2012-02-29 Thread Dave Angel
On 02/29/2012 04:07 AM, Smiley 4321 wrote: Why below fails - #!/usr/bin/python import pickle class MyClass(object): Field1 = None Field2 = None def __init__(self, dictionary): self.__dict__.update(dictionary) my_List = {'Field1': 'Apple', 'Field2': 'Orange'

Re: On u'Unicode string literals' (Py3)

2012-02-29 Thread Dave Angel
Just who are you replying to? On 02/29/2012 08:45 AM, jmfauth wrote: For those who do not know: The u'' string literal trick has never worked in Python 2. No trick there. If you have something explicit to say, then say it. sys.version '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32

Re: sys.stdout.detach() results in ValueError

2012-03-07 Thread Dave Angel
On 03/07/2012 02:41 PM, Peter Kleiweg wrote: I want to write out some binary data to stdout in Python3. I thought the way to do this was to call detach on sys.stdout. But apparently, you can't. Here is a minimal script: #!/usr/bin/env python3.1 import sys fp = sys.stdout.detach()

Re: cython + scons + c++

2012-03-08 Thread Dave Angel
On 03/08/2012 09:23 AM, Neal Becker wrote: Is there a version of cython.py, pyext.py that will work with c++? I asked this question some time ago, but never got an answer. I tried the following code, but it doesn't work correctly. If the commented lines are uncommented, the gcc command is tota

Re: Finding MIME type for a data stream

2012-03-08 Thread Dave Angel
On 03/08/2012 04:55 PM, Tobiah wrote: I'm pulling image data from a database blob, and serving it from a web2py app. I have to send the correct Content-Type header, so I need to detect the image type. Everything that I've found on the web so far, needs a file name on the disk, but I only have t

Re: What's the best way to write this regular expression?

2012-03-08 Thread Dave Angel
On 03/08/2012 04:40 PM, John Salerno wrote: http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Nothing to do with Python, but you'd save us all a lot of space and bandwidth if you learned how to copy/paste from a Windows cmd window. If you're just doing it rarely, you can rig

Re: Finding MIME type for a data stream

2012-03-08 Thread Dave Angel
On 03/08/2012 05:28 PM, Tobiah wrote: I should simplify my question. Let's say I have a string that contains image data called 'mystring'. I want to do mime_type = some_magic(mystring) and get back 'image/jpg' or 'image/png' or whatever is appropriate for the image data. Thanks! Tobiah

Re: What's the best way to write this regular expression?

2012-03-08 Thread Dave Angel
On 03/08/2012 06:02 PM, Prasad, Ramit wrote: Actually in quick-edit mode (XP and higher) you just select with left click and then hit enter which copies it to the clipboard. If you also enable insert mode (not sure if this is Win7 specific) you can even right click to paste into the console, just

Re: Launching A Truly Disjoint Process

2012-03-11 Thread Dave Angel
On 03/11/2012 05:01 PM, Ami Tavory wrote: Hello, I'm encountering a problem using the multiprocessing module to create a process that is truly disjoint from the parent process: i.e., one that contains no "memory" of the parent process, nor any record in the parent process that it is its ch

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Dave Angel
On 03/14/2012 01:27 PM, Prasad, Ramit wrote: It seems like an excellent thing to add to the "os" module. If 'prctl' is a standard POSIX system call, then it should be a candidate for inclusion in the os module if someone opens a tracker enhancement issue and presents an argument in favor. I th

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-15 Thread Dave Angel
On 03/15/2012 03:26 AM, xliiv wrote: Like the topic.. . I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what. I did google, I've played with Exemaker (it works perfect, but not py3) and i've seen questions on St

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-15 Thread Dave Angel
On 03/15/2012 02:39 PM, Grant Edwards wrote: On 2012-03-15, Dave Angel wrote: On 03/15/2012 03:26 AM, xliiv wrote: Like the topic.. . I use Python a lot, both Windows and Linux, and it's little weird to have many python process without fast distinction which is what. I did google,

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-23 Thread Dave Angel
On 03/23/2012 02:28 PM, Peter Otten wrote: Ethan Furman wrote: Nathan Rice wrote: Logo. It's turtles all the way down. +1 QOTW Surely you're joking, Mr Furman! Cracking safes was the best chapter. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any difference between print 3 and print '3' in Python ?

2012-03-26 Thread Dave Angel
On 03/26/2012 07:45 AM, redstone-c...@163.com wrote: I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ? This is a non-question. The input is the same, the

Re: python segfault

2012-03-27 Thread Dave Angel
On 03/27/2012 06:27 PM, Michael Poeltl wrote: hi, can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2, 2.6.X or python 2.7.2 segfault? def get_steps2(pos=0, steps=0): ... if steps == 0: ... pos = random.randint(-1,1) ... if pos == 0: ... retur

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Dave Angel
On 03/28/2012 04:56 AM, Peter Daum wrote: Hi, is there any way to convert a string to bytes without interpreting the data in any way? Something like: s='abcde' b=bytes(s, "unchanged") Regards, Peter You needed to specify that you are using Python 3.x . In pyt

Re: tabs/spaces

2012-03-29 Thread Dave Angel
On 03/29/2012 03:18 AM, Ulrich Eckhardt wrote: Am 28.03.2012 20:26, schrieb Terry Reedy: On 3/28/2012 8:28 AM, Ulrich Eckhardt wrote: [...] # call testee and verify results try: ...call function here... except exception_type as e: if not exception is None: self.assertEqual(e, exception) Did

Re: tabs/spaces

2012-03-30 Thread Dave Angel
On 03/30/2012 03:05 AM, Ulrich Eckhardt wrote: Am 29.03.2012 17:25, schrieb Terry Reedy: I am using Thunderbird, win64, as news client for gmane. The post looked fine as originally received. The indents only disappeared when I hit reply and the >s were added. I can confirm this misbehaviour of

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-03 Thread Dave Angel
On 04/03/2012 11:16 AM, Mark Lawrence wrote: > On 03/04/2012 15:56, Chris Angelico wrote: >> On Wed, Apr 4, 2012 at 12:46 AM, Grant >> Edwards wrote: >>> Anybody remember DEC's VAX/VMS "patch" utility? Apparently, DEC >>> thought it was a practical way to fix things. It had a built-in >>> assemb

Re: Python Gotcha's?

2012-04-05 Thread Dave Angel
On 04/05/2012 08:02 PM, Cameron Simpson wrote: > On 05Apr2012 19:13, Alain Ketterlin wrote: > | Miki Tebeka writes: > | > (Note that I want over http://wiki.python.org/moin/PythonWarts already). > | > | The "local variable and scoping" is, imho, something to be really > | careful about. Here is

Re: f python?

2012-04-08 Thread Dave Angel
On 04/08/2012 08:04 PM, David Robinow wrote: > On Sun, Apr 8, 2012 at 6:55 PM, Dennis Lee Bieber > wrote: >>The main reason, as I recall, for the command line using \ for file >> paths is that it inherited / as command OPTION prefix from CP/M; MS-DOS >> being a 32-bit work-alike for CP/M

Re: pygame.Rect question

2012-04-08 Thread Dave Angel
On 04/08/2012 07:58 PM, Scott Siegler wrote: > Hello, > > I am new to Python and began using pygame to start some game programming. I > was hoping someone could help me out with something that seems simple but is > really confusing me. > > I am creating a rect and then using the attributes of th

Re: How to filter a dictionary ?

2012-04-10 Thread Dave Angel
On 04/10/2012 02:04 AM, Shashank Singh wrote: > On Mon, Apr 9, 2012 at 10:49 PM, Nikhil Verma wrote: > >> I am trying this but its giving me a generator object. >> >> In [9]: (k for k,v in for_patient_type.iteritems() if v == 'Real') >> > Iterating over a dict gives you all the keys, not the key v

Re: functions which take functions

2012-04-11 Thread Dave Angel
On 04/11/2012 06:55 AM, Kiuhnm wrote: > On 4/10/2012 23:43, Eelco wrote: >> On Apr 10, 3:36 am, Kiuhnm wrote: >>> On 4/10/2012 14:29, Ulrich Eckhardt wrote: >>> Am 09.04.2012 20:57, schrieb Kiuhnm: > Do you have some real or realistic (but easy and self-contained) > examples when you

Re: How to execute/run a *.py file, win7, py3.2..?

2012-04-15 Thread Dave Angel
On 04/16/2012 12:30 AM, vmars316 wrote: > Greetings, > windows7, portablePython3.2: > What if i wanted to send myProg.py to a friend to RUN (who has python > installed). > Isn't there a way just to doubleClick on myProg.py, to get it into the > interpret/RUN? > Could i RUN a myProg.o ? > There must

Re: sort by column a csv file case insensitive

2012-04-15 Thread Dave Angel
On 04/16/2012 01:11 AM, Lee Chaplin wrote: > Hi all, > > I am trying to sort, in place, by column, a csv file AND sort it case > insensitive. > I was trying something like this, with no success: Could you perhaps qualify that "no success" bit? Do you mean it didn't output a file, or that the file

Re: how to count the total number of strings (in the list) used in Python?

2012-04-16 Thread Dave Angel
Did you have a reason to spam us with a second copy of the message after only 3 minutes? Usually, you should wait a few days, and then REPLY to the earlier one, don't leave another with the same subject. The way you did it, some people might respond to one, and some to the other, creating two sep

Re: Different results for different versions of urllib2

2012-04-20 Thread Dave Angel
On 04/20/2012 06:47 PM, Diego Manenti Martins wrote: > Hi. > Anybody knows the data is sent in a different way for Python 2.5, 2.6 > and 2.7 using this code: > import urllib2 url = 'http://server.com/post_image?tid=zoV6LJ' f = open('test.jpg') data = f.read() res = urllib2.

Fwd: Re: Different results for different versions of urllib2

2012-04-20 Thread Dave Angel
You forgot to include the list in your response. I don't normally respond to private messages, but I'll make an exception. On Fri, Apr 20, 2012 at 10:08 PM, Dave Angel wrote: > On 04/20/2012 06:47 PM, Diego Manenti Martins wrote: >> Hi. >> Anybody knows the data is se

Re: Unable to Concatenate a file - destination kept getting overwritten

2012-04-20 Thread Dave Angel
On 04/20/2012 09:03 PM, Foster Rilindo wrote: > I can't seem to concatenate. > > I got binary files here: > > yvaine:disk rilindo$ ls -lah > total 61440 > drwxr-xr-x 4 rilindo staff 136B Apr 20 19:47 . > drwxr-xr-x 10 rilindo staff 340B Apr 20 19:45 .. > -rw-r--r-- 1 rilindo staff20

Re: Different results for different versions of urllib2

2012-04-20 Thread Dave Angel
On 04/20/2012 11:06 PM, Diego Manenti Martins wrote: > On Fri, Apr 20, 2012 at 11:09 PM, Dave Angel wrote: >> You forgot to include the list in your response. I don't normally >> respond to private messages, but I'll make an exception. > Sorry about that and thanks.

Re: why () is () and [] is [] work in other way?

2012-04-20 Thread Dave Angel
On 04/20/2012 11:25 PM, Rotwang wrote: > On 21/04/2012 01:01, Roy Smith wrote: >> In article<877gxajit0@dpt-info.u-strasbg.fr>, >> Alain Ketterlin wrote: >> >>> Tuples are immutable, while lists are not. >> >> If you really want to have fun, consider this classic paradox: >> > [] is [] >

Re: some beginners questions about programming

2012-04-21 Thread Dave Angel
On 04/21/2012 06:03 AM, Santosh Kumar wrote: > Hello Python Developers, > > I have a very less experience with programming. I have digged a little bit > of all (I mean *C, **Java, JavaScript, PHP*) at introductory level and now > I have two question about it. > >1. Are *Arrays* and *Lists* same

Re: Appending to []

2012-04-21 Thread Dave Angel
On 04/21/2012 08:48 AM, Bernd Nawothnig wrote: > On 2012-04-20, Rotwang wrote: >> since a method doesn't assign the value it returns to the instance on >> which it is called; what it does to the instance and what it returns are >> two completely different things. > Returning a None-value is prett

Re: why () is () and [] is [] work in other way?

2012-04-21 Thread Dave Angel
On 04/21/2012 09:02 AM, Bernd Nawothnig wrote: > On 2012-04-20, dmitrey wrote: >> I have spent some time searching for a bug in my code, it was due to >> different work of "is" with () and []: > () is () >> True > You should better not rely on that result. I would consider it to be > an impleme

Re: why () is () and [] is [] work in other way?

2012-04-21 Thread Dave Angel
On 04/21/2012 09:48 AM, Bernd Nawothnig wrote: > On Sat, Apr 21, 2012 at 09:21:50AM -0400, Dave Angel wrote: >>>>>>> [] is [] >>>> False >>> Same for that. >> >> Here I have to disagree. If an implementation reused the list object >&

Re: global vars across modules

2012-04-22 Thread Dave Angel
On 04/22/2012 05:08 PM, Kiuhnm wrote: > On 4/22/2012 21:39, mambokn...@gmail.com wrote: >> I need to use global var across files/modules: >> >> # file_1.py >> a = 0 >> def funct_1() : >> a = 1# a is global >> print(a) >> >> >> # file_2.py >> from file_1 import * >> def main() : >>

Re: why () is () and [] is [] work in other way?

2012-04-22 Thread Dave Angel
On 04/23/2012 12:42 AM, Devin Jeanpierre wrote: > On Mon, Apr 23, 2012 at 12:34 AM, Steven D'Aprano > wrote: >> On Sun, 22 Apr 2012 12:43:36 -0700, John Nagle wrote: >> >>> On 4/20/2012 9:34 PM, john.tant...@gmail.com wrote: On Friday, April 20, 2012 12:34:46 PM UTC-7, Rotwang wrote: >>>

Re: Set Date and Time on Python

2012-04-26 Thread Dave Angel
On 04/26/2012 03:09 AM, viral shah wrote: > Hi > > I'm very new to Python programming. > > Please help me to add date and time ! > > Following is the code done by me. > > import datetime > class Module > type(datetime.datetime) > > Now what's the next to do for displaying date and time ? > You

Re: set PYTHONPATH for a directory?

2012-05-04 Thread Dave Angel
On 05/04/2012 08:21 AM, Neal Becker wrote: > I'm testing some software I'm building against an alternative version of a > library. So I have an alternative library in directory L. Then I have in an > unrelated directory, the test software, which I need to use the library > version > from dire

Re: Real time event accuracy

2012-05-09 Thread Dave Angel
On 05/09/2012 11:52 AM, Tobiah wrote: > I'd like to send MIDI events from python to another > program. I'd like advice as to how to accurately > time the events. I'll have a list of floating point > start times in seconds for the events, and I'd like to send them > off as close to the correct tim

Re: tee-like behavior in Python

2012-05-09 Thread Dave Angel
On 05/09/2012 11:35 AM, Florian Lindner wrote: > Hello, > > how can I achieve a behavior like tee in Python? > > * execute an application > * leave the output to stdout and stderr untouched > * but capture both and save it to a file (resp. file-like object) > > I have this code > > proc = subproces

Re: How do I find out what file an import is using?

2012-05-09 Thread Dave Angel
On 05/09/2012 01:52 PM, Rob Richardson wrote: > I am trying to work with a Python script someone else wrote. The script > includes the line > from Level3Utils import * > > I need to look at the functions that are included in that import. In an > effort to identify exactly which file is be

Re: Real time event accuracy

2012-05-09 Thread Dave Angel
On 05/09/2012 03:26 PM, Tobiah wrote: >> I don't think you can really do this accurately enough to get good >> sound, but the basic mechanism is time.sleep(t) which takes a floating >> point argument. That turns into the appropriate microsleep, I think. > I think the time would have to come from a

Re: parallel programming in Python

2012-05-10 Thread Dave Angel
On 05/10/2012 08:14 AM, Jabba Laci wrote: > Hi, > > I would like to do some parallel programming with Python but I don't > know how to start. There are several ways to go but I don't know what > the differences are between them: threads, multiprocessing, gevent, > etc. > > I want to use a single ma

Re: Dealing with the __str__ method in classes with lots of attributes

2012-05-11 Thread Dave Angel
On 05/11/2012 07:16 AM, Andreas Tawn wrote: >> >> This is a very interesting solution. >> >> I think it might be better suited (for my purpose) to __repr__ rather than >> __str__, mostly because I still lose control of the order the attributes >> appear. I have no idea why using __repr__ versus

Re: Opening a csv file in python on a mac

2012-05-12 Thread Dave Angel
On 05/12/2012 06:50 PM, Brian Heese wrote: > I created a csv file called python test file.csv. It is stored on my Desktop > directory. When I try to open it using the command open ('Desktop python > test file.csv') I get the following error: "No such file or directory". The > same thing happens

Re: Hashability questions

2012-05-14 Thread Dave Angel
On 05/14/2012 07:38 PM, Chris Kaynor wrote: > On Sun, May 13, 2012 at 12:11 PM, Bob Grommes wrote: >> >> >> The rule is that, if two objects return different results from >> __hash__, they should never compare equal. The opposite rule also >> holds true: if two objects compare equal, they should

Re: ucs2 and ucs4 python

2012-05-16 Thread Dave Angel
On 05/16/2012 05:20 AM, zayatzz wrote: > On May 16, 11:50 am, Matej Cepl wrote: >> On 16.5.2012 10:36, zayatzz wrote: >> >>> /opt/bin/python^M: bad interpreter: No such file or directory >> Your script has CRLF end-of-lines. Change it to plain Unix LF. >> >> Matěj > Thanks :) but i have no idea wh

Re: Newbie questions on import & cmd line run

2012-05-17 Thread Dave Angel
On 05/17/2012 12:54 AM, alex23 wrote: > On May 17, 11:45 am, gwhite wrote: > > I don't think that only-one-import is true for scripts that are run > from the command line, though. They can exist as both '__main__' and > their actual name in the module table. (Someone please correct me if > this

Re: append method

2012-05-23 Thread Dave Angel
On 05/23/2012 03:13 PM, Emile van Sebille wrote: > On 5/23/2012 5:23 AM 水静流深 said... >> >>> s=[1,2,3] >> >>> s.append(5) >> >>> s >> [1, 2, 3, 5] >> >>> s=s.append(5) >> >>> s >> >>> print s >> None >> >> why can't s=s.append(5) > > It could, but it doesn't. > > >> ,what is the reason? > > >

Re: Help doing it the "python way"

2012-05-24 Thread Dave Angel
On 05/24/2012 04:22 PM, Scott Siegler wrote: > Hello, > > I am an experienced programmer but a beginner to python. As such, I can > figure out a way to code most algorithms using more "C" style syntax. > > I am doing something now that I am sure is a more python way but i can't > quite get it ri

Re: Scoping Issues

2012-05-24 Thread Dave Angel
On 05/24/2012 09:23 PM, SherjilOzair wrote: > def adder(): > s = 0 > def a(x): > s += x > return sum > return a > > pos, neg = adder(), adder() > for i in range(10): > print pos(i), neg(-2*i) > > This should work, right? Why does it not? > Guess that dep

Re: Scoping Issues

2012-05-24 Thread Dave Angel
On 05/24/2012 10:27 PM, Andrew Berg wrote: > On 5/24/2012 8:59 PM, Dave Angel wrote: >> so I fixed that, and got >> inconsistent use of tabs and spaces in indentation >> >> because you mistakenly used tabs for indentation. > Not to start another tabs-vs.-s

Re: getting started

2012-05-25 Thread Dave Angel
On 05/25/2012 09:12 AM, Harvey Greenberg wrote: > elementary ques...I set > s.name = ["a","b"] > s.value = [3,5] > > I get error that s is not defined. How do I define s and proceed to > give its attributes? You just have to initialize s as an object that's willing to take those attributes. The

Re: mistake in python tutorial

2012-06-05 Thread Dave Angel
On 06/05/2012 09:43 PM, Miriam Gomez Rios wrote: > Hello, I think that the example in section 4.4 in the tutorial for python > 2.7X is wrong. > > http://docs.python.org/tutorial/controlflow.html > > > > It will end up printing this if you run the exact code listed in the tutorial. > > > > 3 is a p

Re: Searching 2 Strings in A File

2012-06-06 Thread Dave Angel
On 06/06/2012 05:10 PM, dohoang4...@comcast.net wrote: > hi all, (You forgot to include the list in your reply) > > thanks a lot for your quick response. > > Dave, actually it's a 2 arguments. Sorry, i did not make it clear in my > question. I used Ramit's hint an

Re: what gui designer is everyone using

2012-06-07 Thread Dave Cook
dates in over six years. I've been using wxFormBuilder since last summer. It's reasonably easy to use, and there are regular releases by the developers. I have a coworker who's had a lot of success using Boa for everything. It would be a shame if Boa is allowed to bitrot in to c

Re: Where to set default data - where received, or where used

2012-06-11 Thread Dave Angel
On 06/11/2012 02:37 PM, Dennis Carachiola wrote: > I'm programming a project which will use a file to save parameters > needed by the program. There are already two previous file formats, > each of which can only be run by the version of the program which > created them. I'm trying to avoid that

multiprocessing: excepthook not getting called

2012-06-12 Thread Dave Cook
me__=='__main__': p = mp.Process(target=target) p.start() p.join() # try it here in main target() Thanks, Dave Cook -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads vs subprocesses

2012-06-15 Thread Dave Angel
On 06/15/2012 09:49 AM, John O'Hagan wrote: > I have a program in which the main thread launches a number of CPU-intensive > worker threads. For each worker thread two python subprocesses are started, > each of which runs in its own terminal: one displays output received from the > worker thread vi

Re: module name vs '.'

2012-06-18 Thread Dave Angel
On 06/18/2012 09:19 AM, Neal Becker wrote: > Am I correct that a module could never come from a file path with a '.' in > the > name? > No. Simple example: Create a directory called src.directory In that directory, create two files ::neal.py:: import becker print becker.__file__ print becker.h

Re: module name vs '.'

2012-06-18 Thread Dave Angel
On 06/18/2012 09:47 AM, Neal Becker wrote: > I meant a module > > src.directory contains > __init__.py > neal.py > becker.py > > from src.directory import neal > > > On Mon, Jun 18, 2012 at 9:44 AM, Dave Angel wrote: > >> On 06/18/2012 09:19 AM,

Re: Py3.3 unicode literal and input()

2012-06-18 Thread Dave Angel
On 06/18/2012 10:00 AM, jmfauth wrote: > > A string is a string, a "piece of text", period. I do not see why a > unicode literal and an (well, I do not know how the call it) a "normal > class " should behave differently in code source or as an answer > to an input(). Wrong. The rules for parsi

Re: Py3.3 unicode literal and input()

2012-06-18 Thread Dave Angel
On 06/18/2012 12:55 PM, Andrew Berg wrote: > On 6/18/2012 11:32 AM, Jussi Piitulainen wrote: >> jmfauth writes: >> >>> Thinks are very clear to me. I wrote enough interactive >>> interpreters with all available toolkits for Windows > r = input() >> u'a >> Traceback (most recent call last): >>

Re: Newby Python help needed with functions

2011-06-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Cathy James wrote: I need a jolt here with my python excercise, please somebody!! How can I make my functions work correctly? I tried below but I get the following error: if f_dict[capitalize]: KeyError: Code below: def capitalize (s): """capitalize accepts a

Re: test_popen

2011-06-09 Thread Dave Angel
On 01/-10/-28163 02:59 PM, harrismh777 wrote: Looks like my 2.7 test_popen failure is an open issue7671... since Jan 2010. Looks like it really does function ok. At any rate, I was able to test Popen myself today, and it ran fine. I needed to write a script that will disable the touch pad on thi

Re: Any Better logic for this problem..

2011-06-09 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Chris Rebert wrote: On Thu, Jun 9, 2011 at 1:31 AM, Ganapathy Subramanium wrote: Hi Guru's, I'm working on a solution to find the prime factor of the number This part of the code works.. http://www.pastie.org/2041584 For the archives, that code is: num =3195 #num

Re: working with raw image files

2011-06-14 Thread Dave Angel
On 01/-10/-28163 02:59 PM, kafooster wrote: On 14 Cze, 22:26, MRAB wrote: Multiply the numpy array by a scaling factor, which is float(max_8bit_value) / float(max_16bit_value). could you please explain it a little? I dont understand it. like multiplying each element? You said in an earlie

Re: working with raw image files

2011-06-14 Thread Dave Angel
On 01/-10/-28163 02:59 PM, kafooster wrote: On 15 Cze, 01:25, Dave Angel wrote: On 01/-10/-28163 02:59 PM, kafooster wrote: On 14 Cze, 22:26, MRABwrote: Multiply the numpy array by a scaling factor, which is float(max_8bit_value) / float(max_16bit_value). could you please explain

Re: break in a module

2011-06-14 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Eric Snow wrote: Unfortunately not. Most of this line of thinking is the result of looking at import functionality in different ways, including with regards to the problem of modules getting imported twice (once as __main__). I've been doing work on multi-file modul

Re: NEED HELP-process words in a text file

2011-06-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Cathy James wrote: Dear Python Experts, First, I'd like to convey my appreciation to you all for your support and contributions. I am a Python newborn and need help with my function. I commented on my program as to what it should do, but nothing is printing. I know I

Re: Significant figures calculation

2011-06-27 Thread Dave Angel
(You top-posted your reply, instead of writing your response following the part you were quoting) On 01/-10/-28163 02:59 PM, Lalitha Prasad K wrote: In numerical analysis there is this concept of machine zero, which is computed like this: e=1.0 while 1.0+e> 1.0: e=e/2.0 print e The numb

Re: Problem!!

2011-07-04 Thread Dave Angel
On 01/-10/-28163 02:59 PM, amir chaouki wrote: the problem is when i use the seek function on windows it gives me false results other then the results on *ux. the file that i work with are very large about 10mb. If you still care about this problem, you should take some of the other suggestio

Re: Finding duplicated photo

2011-07-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, TheSaint wrote: Hello, I came across the problem that Gwenview moves the photo from the camera memory by renaming them, but later I forgot which where moved. Then I tought about a small script in python, but I stumbled upon my ignorance on the way to do that. PIL can

Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Anthony Kong wrote: Hi, all, Lately I am giving some presentations to my colleagues about the python language. A new internal project is coming up which will require the use of python. One of my colleague asked an interesting: *If Python use indentation to denote sco

Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-11 Thread Dave Cook
editor I like, I don't see the need to tie GUI layout to a code editor. If you want something with more sophisticated Python specific features, there's PyDev. Dave Cook -- http://mail.python.org/mailman/listinfo/python-list

abort python script from trace function

2011-07-15 Thread Dave Stark
Hello, I have a multithreaded application that uses embedded python extensively. The main thread creates python objects that interface test equipment, and users execute their own python scripts that run in a separate thread. The users need to be able to pause/resume/abort a script that is curr

Re: Re: Virtual functions are virtually invisible!

2011-07-16 Thread Dave Angel
On 01/-10/-28163 02:59 PM, rantingrick wrote: On Jul 16, 5:34 pm, Fabio Zadrozny wrote: I also like the idea of override annotations and I've created a blog post at:http://pydev.blogspot.com/2011/06/overrideimplements-templates-on-pyd... to explain how I do use it (and in a way that I think sh

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Steven D'Aprano wrote: Tim Chase wrote: On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments abou

Re: Partial Function Application -- Advantages over normal function?

2011-07-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Terry Reedy wrote: On 7/18/2011 8:24 AM, Paul Woolcock wrote: Partial function application (or "currying") is the act of taking a function with two or more parameters, and applying some of the arguments in order to make a new function. The "hello world" example for th

Re: Re: Partial Function Application -- Advantages over normal function?

2011-07-19 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Thomas 'PointedEars' Lahn wrote: Dave Angel wrote: On 01/-10/-28163 02:59 PM, Terry Reedy wrote: def makeadder(y) def _add(x): return x+y add2 = makeadder(2) A couple of typos in that code: def makeaddr(y): def _add(x): return x+y retu

Re: How to iterate through two dicts efficiently

2011-07-19 Thread Dave Angel
On 01/-10/-28163 02:59 PM, J wrote: Hello, I am looking to improve the performance of the following piece of Python code:- for cc in StatusContainer: for srv in StatusContainer[cc]: for id in StatusContainer[cc][srv]['RECV']: if id in StageContain

Re: Decorator behavior

2011-07-22 Thread Dave Angel
On 01/-10/-28163 02:59 PM, mhearne808[insert-at-sign-here]gmail[insert-dot-here]com wrote: I am just trying to wrap my head around decorators in Python, and I'm confused about some behavior I'm seeing. Run the code below (slightly adapted from a Bruce Eckel article), and I get the following outp

<    4   5   6   7   8   9   10   11   12   13   >