recent-files

2023-03-28 Thread g...@uol.com.br
In Python 3.11.2,  the recent-files list keeps always increasing because it is impossible to edit the list; the corresponding .txt file has disappeared. Please help! Giorgio Gambirasio g...@uol.com.br       -- https://mail.python.org/mailman/listinfo/python-list

How best to handle SystemError in ctypes callback

2022-01-05 Thread Jarrod G
With the following code: import ctypes > import readline > from ctypes.util import find_library > > rl = ctypes.cdll.LoadLibrary(find_library('readline')) > > rl_redisplay = rl.rl_redisplay > rl_redisplay.restype = None > rl_redisplay.argtypes = None > > rl_redisplay_function = ctypes.c_void_p.in_

Re: getting source code line of error?

2021-11-20 Thread Paolo G. Cantore
Am 20.11.21 um 20:15 schrieb Ulli Horlacher: Stefan Ram wrote: r...@zedat.fu-berlin.de (Stefan Ram) writes: except Exception as inst: print( traceback.format_exc() ) More to the point of getting the line number: As I wrote in my initial posting: I already have the line number. I am

Re: Errors in python\3.8.3\Lib\nntplib.py

2020-04-29 Thread G Connor
On 4/29/2020 5:29 PM, Chris Angelico wrote: > Try opening the file in binary mode instead. Changed: f = open(postfile,'r')to : f = open(postfile,'rb') and it worked. Thanks man! -- https://mail.python.org/mailman/listinfo/python-list

Errors in python\3.8.3\Lib\nntplib.py

2020-04-29 Thread G Connor
module: python\3.8.2\Lib\nntplib.py lines 903-907 --- for line in f: if not line.endswith(_CRLF): line = line.rstrip(b"\r\n") + _CRLF if line.startswith(b'.'): line = b'.' + line --- When I try

Re: How to create an Excel app that runs Python?

2020-03-28 Thread Paolo G. Cantore
Am 25.03.20 um 15:21 schrieb farayao...@gmail.com: Hello Paolo, Thanks for your reply, indeed now I'm thinking on building a web app, do you have any suggestions for this? I am thinking of using Tkinter, the method that you describe using HTML is also using Javascript? Kind Regards Felipe

Re: How to create an Excel app that runs Python?

2020-03-24 Thread Paolo G. Cantore
On Tue, Mar 24, 2020, 4:45 PM wrote: I have the following scenario: I have created lots of python files that I use to calculate a Cashflow model, when I run these files I get a beautiful pandas DataFrame that contains my final model. My mission is to show this table to the rest of the compan

'python' is not recognized as an internal or external command

2019-09-01 Thread G Kishore
Hi Team, I was installing python in my new windows 10 machine and cpuld able to access python from command window when the location is where I have installed python. The same I have tried to enter the command from Desktop location but "'python' is not recognized as an internal or external comma

Re: Python help needed

2019-08-08 Thread Paolo G. Cantore
Am 08.08.19 um 01:18 schrieb MRAB: On 2019-08-07 21:36, Kuyateh Yankz wrote: #trying to write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a space, with and inserted before the last item. For example, passing the previous sp

RE: Trying to compile Python 3.5 on Linux Mint 19, getting compiler warnings and failing tests

2019-02-18 Thread Marcin G
Hmm. From looking at your full log (THANK YOU for posting that, btw - so many people don't), it looks like an issue with certificate checking. Might be a bug in the test itself. Does the same thing happen with a more recent Python build? It could be a weirdness with specific versions of OpenSSL. H

Trying to compile Python 3.5 on Linux Mint 19, getting compiler warnings and failing tests

2019-02-18 Thread Marcin G
My boss wants my code to run on Python 3.5, so I thought I'd install 3.5 to be able to ascertain this. But Linux Mint 19 ships with Python 3.6 and python.org only provides source code for 3.5.6. So I thought I'd try compiling 3.5.6 myself.

Re: acircle.getCenter() to (x,y) coordinates in Python

2017-12-24 Thread G Yu
Ah, I get it now. I have to store the acircle.getCenter() in a point Point, and then access Point.getX() and Point.getY() separately. It was just that middle step that I was missing. Thanks so much! -- https://mail.python.org/mailman/listinfo/python-list

Re: acircle.getCenter() to (x,y) coordinates in Python

2017-12-23 Thread G Yu
> But your code has: > > moving_circle.move(P_to_R/P_to_E, E_to_R/P_to_E) > > so won't that move the circle and change what: > > moving_circle.getCenter() > > returns? Yes, moving the circle changes the value of moving_circle.getCenter(). The problem is interpreting the output. The

Re: acircle.getCenter() to (x,y) coordinates in Python

2017-12-23 Thread G Yu
I did try that. The problem is that I already declared a point moving_object_center = (-555,-555), because that's the point I used as the center to draw the moving_object circle itself. So the moving_object_center.getX() will return -555 no matter what I do. That's why I need to calculate the

acircle.getCenter() to (x,y) coordinates in Python

2017-12-23 Thread G Yu
My program has two circles: one stationary circle, drawn at a random location; and one moving circle, consistently drawn in the same place in the graphics window. The moving circle moves towards the stationary one. However, when the moving circle hits the stationary one (when the x-coordinates

Run Windows commands from Python console

2017-09-03 Thread g . morkvenas
Hello, I run Python console in Windows. Can I run cmd prompt commands there? If I run command dir I have: >>> dir What does it means? If i trying to create file I have error: >>> type NUL > hh.txt File "", line 1 type NUL > hh.txt ^ SyntaxError: invalid syntax What means

Simple code and suggestion

2016-11-30 Thread g thakuri
Dear Python friends, I have a simple question , need your suggestion the same I would want to avoid using multiple split in the below code , what options do we have before tokenising the line?, may be validate the first line any other ideas cmd = 'utility %s' % (file) out, err, exitcode = co

correct way to catch exception with Python 'with' statement

2016-11-28 Thread g thakuri
Dear Python friends, Any suggestion on how to add exception and make the below program look better , I am using Python 2.7 and Linux def create_files_append(): """ """ try: os.makedirs

Re: Tracing memory in production django process with systemtap

2016-08-04 Thread Lei G
在 2016年8月5日星期五 UTC+8上午1:41:04,Lei G写道: > Hi all, > > Recently I met some python memory problems with Django and uwsgi, and found > to find exactly which part is causing the problem, so I went to use systemtap > to tracing the problem, and here are some problems that I met:

Tracing memory in production django process with systemtap

2016-08-04 Thread Lei G
Hi all, Recently I met some python memory problems with Django and uwsgi, and found to find exactly which part is causing the problem, so I went to use systemtap to tracing the problem, and here are some problems that I met: It seems python needs to patch some 'probes' into the source code,

for loop in python

2016-04-28 Thread g . v . aarthi
start_list = [5, 3, 1, 2, 4] square_list = [] # Your code here! for square_list in start_list: x = pow(start_list, 2) square_list.append(x) square_list.sort() print square_list TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int' Please provide me the solution for the

Re: Extending the 'function' built-in class

2013-12-02 Thread G.
Le 02-12-2013, Steven D'Aprano a écrit : > There are plenty of ways to extend functions. Subclassing isn't one of > them. Thank you very mych for your complete answer; I falled back to your last proposal by myself in my attempts; I am happyt to learn about the other ways a

Re: Extending the 'function' built-in class

2013-12-01 Thread G.
es, indeed. The 'function' built-in class was the following one: >>> type(lambda x: 2*x) but I am interested by answers concerning other similar types also. Regards, G. -- https://mail.python.org/mailman/listinfo/python-list

Re: Extending the 'function' built-in class

2013-12-01 Thread G.
not an acceptable base type > > So, we're back to asking what version you're using and what error > message you got. Hi, I don't care that much for the version, since I wanted rather to perform some tests. I tried your code with various versions and got the same message

Extending the 'function' built-in class

2013-12-01 Thread G.
Hi, I can't figure out how I can extend the 'function' built-in class. I tried: class test(function): def test(self): print("test") but I get an error. Is it possible ? Regards, G. -- https://mail.python.org/mailman/listinfo/python-list

JSON translated into SQL by python

2013-11-22 Thread Aaron G.
I am new to programming python for JSON to SQL and I was wondering why this does not work. All the values for entering the DB are correct. The EnterpriseValue data is not entering the database. #collect data from JSON source at Yahoo url = ["db", "http://y.ahoo.it/wlB89";] #check all sites che

How to read a particular cell by using "wb = load_workbook('path', True)" in openpyxl

2013-09-30 Thread somesh g
Hi..there I have written code for reading the large excel files but my requirement is to read a particular cell in a excel file when i kept "True" in "wb = load_workbook('Path', True)" any body please help me... CODE: from openpyxl import load_workbook wb = load_workbook('Path', True)

unable to read combo boxes in excel by xlrd package in python

2013-09-27 Thread somesh g
Hi..there I want to read the combo box in excel by using "xlrd" but in the output it is showing empty message, its not reading the combo box can u guys help me how to read the combo box in excel by "xlrd" code written like this workbook = xlrd.open_workbook('path of the file') worksheet = work

Re: How to write in to already opened excel file by using openpyxl

2013-09-27 Thread somesh g
hi..Neil yes i dint saved that time and i added the save option and it saved Thanks for the response -- https://mail.python.org/mailman/listinfo/python-list

Re: How to write in to already opened excel file by using openpyxl

2013-09-27 Thread somesh g
Hi..joel what is said is correct i dint added save to that after adding its working perfect thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Can't run any script without it failing due to calling tkinter for no reason

2012-10-14 Thread Adam G
On Sunday, October 14, 2012 7:19:24 PM UTC-7, Benjamin Kaplan wrote: > On Sun, Oct 14, 2012 at 6:47 PM, wrote: > > > Hello All, > > > > > > > > > I'm running python 3.2 on Freebsd 9.0 Release and I must've screwed up my > > environment somehow, because now I can't run any script without it f

Re: Software Engineer -

2012-03-13 Thread Pedro H. G. Souto
On 2012-03-13 12:44 PM, Paul Rudin wrote: Just out of interest why do people object to job adverts here? Seems harmless enough... Wannabe list admins... Or list admins with a need to proof themselves... Or none of the above. -- http://mail.python.org/mailman/listinfo/python-list

Re: whitespace cleanup

2011-12-06 Thread Pedro Henrique G. Souto
idy If you like to write your own script, or if what you want is similar, but not the same, the source code is a good place to start: http://lacusveris.com/PythonTidy/PythonTidy-1.20.python -- Att; Pedro Henrique G. Souto -- http://mail.python.org/mailman/listinfo/python-list

Re: whitespace cleanup

2011-12-06 Thread Pedro Henrique G. Souto
a Python script. > I looked up around but I can't find anything useful, any advice? You can use the strip() method: [http://docs.python.org/release/2.3/lib/module-string.html] While reading the file as strings, the strip() method rips out all of the extra whitespace. > Thanks, > A

Re: Install Python on Windows without Start Menu icons?

2011-12-03 Thread Pedro Henrique G. Souto
nt of view. If you just want to run python scripts in those machines (not developing in it), you can use something like py2exe [http://www.py2exe.org/]. It converts a python script to a standalone executable. Good luck! -- Att; Pedro Henrique G. Souto ╔═╗

Re: Complete beginner, any help appreciated :) - For Loops

2011-12-01 Thread Pedro Henrique G. Souto
) Thanks a lot. That means (in a free translation) "For each one of 'x' in 'y', do this" 'y' is a list, for example, then it means: "For each one of the elements of the list 'y' (the element on the current iteration is named 'x'), do t

Re: Total newbie question: Best practice

2011-11-30 Thread Pedro Henrique G. Souto
On 30/11/2011 06:50, Shambhu Rajak wrote: Collins Congratulations for your first step into Python Programming. You can call them script or programs(not necessarily but depends on what your coding for). Yaa..it's always a good practice to call it through main(), but it doesn't really matter you

Re: Fwd: os.statvfs bug or my incompetence ?

2011-10-17 Thread Peter G. Marczis
Hi, not yet, I will check it today, thanks for the idea ! We may have some deeper problem... Br, Peter. On 10/15/2011 05:46 PM, ext Kev Dwyer wrote: Peter G. Marczis wrote: Hello Peter, Welcome to the list. Have you tried calling statvfs from a C program? What happens if you do? Best

Fwd: os.statvfs bug or my incompetence ?

2011-10-14 Thread Peter G. Marczis
 Hi list, I'm happy to join to this nice mail list. At my company we use python to handle system administration tasks. I found the next problem during my work: test.py: # cat test.py #!/usr/bin/python import os os.statvfs('/') r

Could you please give me some advise on this piece of code?

2011-09-12 Thread G.
uld have a look on my code and could maybe see why it does nothing after "print test", please. Thank you very much. Kind regards, G. # To change this template, choose Tools | Templates # and open the template in the editor. __author__="User" __date__ ="$11.09.2011 1

SMS

2011-07-20 Thread TERESA G
One method you can use is to connect to an SMS API provider from your web application, which will enable you to send SMS via an internet connection, typically using a protocol like HTTP; You can try Nexmo SMS API, it supports HTTP REST and SMPP and we have documentation published in our website wi

Example of exec_proxy

2010-09-27 Thread Prathibha G
Hi Team, I am very new to this python world. Below is my problem. I have a "Machine A" where i want to execute some commands(dos commands from command prompt), delete/create some files, delete/create some directories. All this i need to do from my local host. Is there a way which i can do? Can

Cannot send email

2010-07-15 Thread G F
A while back I was working for a company and set up a little python script to send out maintenance emails for some equipment we had set up in the field. The script collected information about the equipment composed an email and sent it out to interested persons. Then I left the company and they

Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Alan G Isaac
On 7/6/2010 12:11 PM, Ritchy lelis wrote: My intention with de for loop was to iterate each point of the arrays Vi and Vref at the math calculations. The V0 it's the result of the math expressions between the Vi and Vref. I can't just create one V0 by a function set by parametters (i don't see ho

Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Alan G Isaac
On 7/6/2010 8:05 AM, Ritchy lelis wrote: 1 - "import numpy as np import matplotlib.pyplot as plt" In what help's me making the call's of the libraries that way? http://bytebaker.com/2008/07/30/python-namespaces/ 2 - What's the instruction linspace means/does? >>> help(np.lins

Re: Plot problem.. ?? No sign at all

2010-07-05 Thread Alan G Isaac
On 7/5/2010 7:45 AM, Ritchy lelis wrote: from pylab import* Vref = arange(1, 20, 0.02) Vi = arange(1, 10,0.1) for i in Vref: for n in Vi: if n> i/4: V0 = 2*n-i elif (-i/4)<= n and n<= i/4: V0 = 2*n elif Vi< -i/4:

Re: improving IDLE

2010-06-25 Thread Alan G Isaac
On 6/25/2010 1:24 PM, rantingrick wrote: the "if __name__ == '__main__' tests" use root.quit instead of root.destroy! On Jun 25, 12:46 pm, Alan G Isaac wrote: Did you open an issue?http://bugs.python.org/ On 6/25/2010 4:26 PM, rantingrick wrote: If *I* open an issu

Re: best way to increment an IntVar?

2010-06-25 Thread Alan G Isaac
On 6/25/2010 3:52 PM, Dave Angel wrote: I said "default", not "only" behavior. I suspect list provides an __iadd__ method to provide this ability. Integers do not, and therefore neither does the object the OP was asking about. I have no idea what "default behavior" is supposed to mean. Mut

value of: None is None is None

2010-06-25 Thread Alan G Isaac
Surprising for a moment, if you don't immediatelyrecognize it as a chained comparison. (Just sharing.) Alan Isaac None is None is None True (None is None) is None False None is (None is None) False -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to increment an IntVar?

2010-06-25 Thread Alan G Isaac
On 6/25/2010 1:24 PM, rantingrick wrote: the "if __name__ == '__main__' tests" use root.quit instead of root.destroy! Did you open an issue? http://bugs.python.org/ Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to increment an IntVar?

2010-06-25 Thread Alan G Isaac
On 6/25/2010 1:14 PM, Dave Angel wrote: the default behavior of += is to assign a new object with the new value, rather than changing the previous object. a = [] temp = a a += [2] temp [2] Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to increment an IntVar?

2010-06-25 Thread Alan G Isaac
On 6/24/2010 1:59 AM, Dennis Lee Bieber wrote: It is NOT a numeric "variable" in Python realms. Sure, but why does it not behave more like one? It seems both obvious and desirable, so I'm guessing there is a good reason not to do it. So var+=increment can't be used because Python woul

best way to increment an IntVar?

2010-06-23 Thread Alan G Isaac
Of course one can do myintvar.set(myintvar.get()+1) but surely there is a better way? I'm surprsied that myintvar += 1 is not allowed. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

ttk Scale: missing attributes

2010-06-23 Thread Alan G Isaac
Tkinter's Scale widget had a `label` and a `resolution` attribute. These appear to be missing from the Ttk Scale widget. Is there a reason? These were important attributes. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANNC] pynguin-0.8 python turtle graphics application

2010-06-09 Thread Alan G Isaac
On 6/8/2010 6:59 PM, Lee Harr wrote: Pynguin is a python-based turtle graphics application. It combines an editor, interactive interpreter, and graphics display area. Do you start from scratch or make use of the very useful new (2.6) turtle module? I hope the latter, and that you ar

modify XMP data (Python/Windows)

2010-06-05 Thread Alan G Isaac
I want to modify XMP data for a bunch of JPEG files, using Python if possible, on Windows. I expected PIL would support this. But no? I found the Python XMP Toolkit http://www.spacetelescope.org/static/projects/python-xmp-toolkit/docs/installation.html#requirements but no reports of successful

Re: documentation bug? (format spec mini language)

2010-05-12 Thread Alan G Isaac
On 5/11/2010 5:05 PM, Terry Reedy wrote: http://bugs.python.org/issue8691 Thanks! Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: documentation bug? (format spec mini language)

2010-05-11 Thread Alan G Isaac
On 5/11/2010 3:19 PM, MRAB wrote: You usually want numbers to be right-aligned so that the decimal points line up when writing a columns of them. Yes. I'm not questioning the wisdom of the implementation, just the documentation of it. Thanks, Alan -- http://mail.python.org/mailman/listinfo/

documentation bug? (format spec mini language)

2010-05-11 Thread Alan G Isaac
The documentation at http://docs.python.org/py3k/library/string.html#format-specification-mini-language '<' Forces the field to be left-aligned within the available space (This is the default.) The conflicting example:: >>> format(3.2,'10.5f') ' 3.2' >>>

Re: change an exception's message and re-raise it

2009-12-31 Thread Alan G Isaac
On 12/31/2009 7:30 PM, Steven D'Aprano wrote: The message attribute is deprecated from Python 2.6 and will print a warning if you try to use it. http://bugs.python.org/issue6844 fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Raw string substitution problem

2009-12-18 Thread Alan G Isaac
On 12/18/2009 12:17 PM, MRAB wrote: In simple cases you might be replacing with the same string every time, but other cases you might want the replacement to contain substrings captured by the regex. Of course that "conversion" is needed in the replacement. But e.g. Vim substitutions handle th

Re: Raw string substitution problem

2009-12-18 Thread Alan G Isaac
On 12/17/2009 7:59 PM, Rhodri James wrote: "re.compile('a\\nc')" passes a sequence of four characters to re.compile: 'a', '\', 'n' and 'c'. re.compile() then does it's own interpretation: 'a' passes through as is, '\' flags an escape which combined with 'n' produces the newline character (0x0a),

Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac
On 12/17/2009 2:45 PM, MRAB wrote: re.compile('a\\nc') _does_ compile to the same as regex as re.compile('a\nc'). However, regex objects never compare equal to each other, so, strictly speaking, re.compile('a\nc') != re.compile('a\nc'). However, having said that, the re module contains a cache

Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac
Alan G Isaac wrote: >>> re.sub('abc', r'a\nb\n.c\a','123abcdefg') == re.sub('abc', 'a\\nb\\n.c\\a','123abcdefg') == re.sub('abc', 'a\nb\n.c\a','123abcdefg') True Why are the

Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac
On 12/17/2009 11:24 AM, Richard Brodie wrote: A raw string is not a distinct type from an ordinary string in the same way byte strings and Unicode strings are. It is a merely a notation for constants, like writing integers in hexadecimal. (r'\n', u'a', 0x16) ('\\n', u'a', 22) Yes, that was

Re: Raw string substitution problem

2009-12-17 Thread Alan G Isaac
En Wed, 16 Dec 2009 11:09:32 -0300, Ed Keith escribió: I am having a problem when substituting a raw string. When I do the following: re.sub('abc', r'a\nb\nc', '123abcdefg') I get """ 123a b cdefg """ what I want is r'123a\nb\ncdefg' On 12/16/2009 9:35 AM, Gabriel Genellina wrote: Fr

Re: Beginner Q. interrogate html object OR file search?

2009-12-02 Thread Mark G
e the html file > parsing script you say you have already, or how the date is 'modified > from' the meta-data. > > On Wed, Dec 2, 2009 at 10:24 PM, Mark G wrote: > > Hi all, > > > I am new to python and don't yet know the libraries well. What would > >

Beginner Q. interrogate html object OR file search?

2009-12-02 Thread Mark G
Hi all, I am new to python and don't yet know the libraries well. What would be the best way to approach this problem: I have a html file parsing script - the file sits on my harddrive. I want to extract the date modified from the meta-data. Should I read through lines of the file doing a string.f

Re: restriction on sum: intentional bug?

2009-10-17 Thread Alan G Isaac
On 10/16/2009 8:16 PM, Terry Reedy wrote: The fact that two or three people who agree on something agree on the thing that they agree on confirms nothing. On 10/17/2009 7:03 PM, Terry Reedy wrote: If you disagree with this, I think *you* are being silly. Well, ... Alan G Isaac wrote: Of

Re: restriction on sum: intentional bug?

2009-10-17 Thread Alan G Isaac
On 10/17/2009 7:06 AM, Carl Banks wrote: I'm basically saying here is, by shutting out strings from sum, you don't really lose much in terms of duck typing, because duck typing wouldn't have been that helpful anyway. That boils down to an argument for type checking whenever you cannot imagine m

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
Alan G Isaac gmail.com> writes: So of course join is better, as originally noted, but that does not constitute a reason to intentionally violate duck typing. On 10/16/2009 1:03 PM, Benjamin Peterson wrote: As Stephen pointed out, duck typing is not an absolute. I do not recall any

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
On 10/16/2009 8:16 PM, Terry Reedy wrote: The fact that two or three people who agree on something agree on the thing that they agree on confirms nothing. One could just as well argue that summing anything but numbers is semantically incoherent, not correct. Certainly, my dictionary points in tha

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
On 10/16/2009 5:03 PM, Christian Heimes wrote: It's not going to happen. That's a prediction, not a justification. As Tim explained in detail, and as Peter explained with brevity, whether it will happen or not, it should happen. This conversation has confirmed that current behavior is a wart:

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
On 10/16/2009 3:40 PM, Tim Chase wrote: What's always wrong is giving me an *error* when the semantics are perfectly valid. Exactly. Which is why I expected this to be fixed in Python 3. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
Alan G Isaac schrieb: I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last): File "", line 1, in TypeError: sum() can't sum strings [use ''.join(seq) instead] Of course it is not a good

restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last): File "", line 1, in TypeError: sum() can't sum strings [use ''.join(seq) instead] Of course it is not a good way to join strings, but it should work, should it not? Naturally, '' + 'ab' + 'cd'

Re: Is there a better way to code variable number of return arguments?

2009-10-08 Thread Alan G Isaac
Dr. Phillip M. Feldman writes: I currently have a function that uses a list internally but then returns the list items as separate return values as follows: if len(result)==1: return result[0] if len(result)==2: return result[0], result[1] (and so on). Is there a cleaner way to accomplish the

Re: Programming ideas?

2009-09-20 Thread Alan G Isaac
You could learn a lot of Python contributing to docutils or bibstuff, and if you write papers or presentations, it may pay off directly. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a pure Python chart drawing module

2009-09-16 Thread Alan G Isaac
Alan G Isaac wrote: There's John Zelle's graphics.py: http://mcsp.wartburg.edu/zelle/python/ provides basic functionality. On 9/16/2009 12:33 AM, John Nagle wrote: "The package is a wrapper around Tkinter". It runs Tkinter in a separate thread and sends commands to it.

Re: Looking for a pure Python chart drawing module

2009-09-15 Thread Alan G Isaac
There's John Zelle's graphics.py: http://mcsp.wartburg.edu/zelle/python/ provides basic functionality. Pmw.Blt http://heim.ifi.uio.no/~hpl/Pmw.Blt/doc/reference.html pygooglechart You suggested this needs a browser, but not so, you can download the PNGs and use the default viewer to display them

Re: string interpolation mystery in Python 2.6

2009-09-12 Thread Alan G Isaac
On 9/11/2009 9:42 PM, Steven D'Aprano wrote: However, I must admit I'm perplexed why the original example is calling __unicode__() in the first place! Given the line: raise self.severe('Problems with "%s" directive path:\n%s: %s.' % (self.name, error.__class__.__name__, error)) it looks to

Re: string interpolation mystery in Python 2.6

2009-09-11 Thread Alan G Isaac
Michael Foord came up with a much simpler illustration. With Python 2.6:: >>> try: ... open('flooble') ... except Exception as e: ... pass ... >>> e IOError(2, 'No such file or directory') >>> unicode(e) u"(2, 'No such fil

Re: Use python to execute a windows program

2009-09-11 Thread Alan G Isaac
Does the Windows application offer a COM interface? http://oreilly.com/catalog/pythonwin32/chapter/ch12.html http://sourceforge.net/projects/pywin32/ Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

string interpolation mystery in Python 2.6

2009-09-11 Thread Alan G Isaac
MYSTERY: how can "%s"%error be different from "%s"%str(error) in Python 2.6? APOLOGY: I tried to strip this down, but could not find a simple way to reproduce the problem. This way works, however. (There is a discussion on the docutils-develop list.) Although there are several steps, we are ta

Re: incorrect DeprecationWarning (patch needed)

2009-09-08 Thread Alan G Isaac
On 9/5/2009 5:50 PM, Alan G Isaac wrote: I've filed a bug report: http://bugs.python.org/issue6844 This is now an accepted bug with a patch request. Can someone on this list please assist with a patch? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: incorrect DeprecationWarning?

2009-09-05 Thread Alan G Isaac
I've filed a bug report: http://bugs.python.org/issue6844 Sadly the Twisted developers apparently did not file a bug report when they were bitten by this ... Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: incorrect DeprecationWarning?

2009-09-05 Thread Alan G Isaac
On 9/5/2009 9:07 AM, exar...@twistedmatrix.com wrote: You are using the deprecated practice. Clearly not, or it would fail in Python 3, which it does not. Attributes are not scoped to a particular class. There is only one "message" attribute on your "MyError" instance. It does not belong just

Re: incorrect DeprecationWarning?

2009-09-05 Thread Alan G Isaac
Alan G Isaac wrote: Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. class MyError(Exception): ... def __init__(self, message): ... Exception._

incorrect DeprecationWarning?

2009-09-04 Thread Alan G Isaac
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. class MyError(Exception): ... def __init__(self, message): ... Exception.__init__(self) ... self.message = message ...

Re: Select column from a list

2009-08-28 Thread Alan G Isaac
On 8/28/2009 3:45 AM hoffik wrote: > I'm quite new in Python and I have one question. I have a 2D matrix of > values stored in list (3 columns, many rows). I wonder if I can select one > column without having to go through the list with 'for' command. Not quite what you asked but ... >>> rows = [

Re: difference between raw_input() and input()

2009-08-22 Thread Juraj G.
if you prefix number with zero, it will turn into octal number... I too wasn't aware of it... at least in python :/ http://en.wikipedia.org/wiki/Octal It seems like bad practice to put zeroes before any decimal number in any language :) Juraj -- http://mail.python.org/mailman/listinfo/python-list

Re: flatten a list of list

2009-08-16 Thread Alan G Isaac
On 8/16/2009 5:47 AM Terry apparently wrote: > Is there a simple way (the pythonic way) to flatten a list of list? > rather than my current solution: > new_list=[] > for l in list_of_list: > new_list.extend(l) new_list = list(xi for lst in list_of_list for xi in lst) hth, Alan Isaac -- h

Re: random.gauss vs. random.normalvariate

2009-08-15 Thread Alan G Isaac
> On Aug 15, 12:49 pm, Alan G Isaac wrote: >> Quotinghttp://docs.python.org/3.1/library/random.html#random.gauss: >> Gaussian distribution. mu is the mean, and sigma is the >> standard deviation. This is slightly faster than the >> normalvariate() funct

random.gauss vs. random.normalvariate

2009-08-15 Thread Alan G Isaac
Quoting http://docs.python.org/3.1/library/random.html#random.gauss: Gaussian distribution. mu is the mean, and sigma is the standard deviation. This is slightly faster than the normalvariate() function defined below. So since both are offered and gauss is faster, I assume it must have

Re: retrieve item from nested list given index tuple

2009-08-14 Thread Alan G Isaac
On 8/14/2009 1:09 PM Steven D'Aprano apparently wrote: > Try this instead: > from operator import getitem reduce(getitem, (2, 1, 0), lst) > 'aaa' reduce(getitem, (2, 1, 0, 0), lst) > 'a' > > operator.getitem is less ugly too. Yes, that's better. Thanks, Alan -- http://mail.pytho

retrieve item from nested list given index tuple

2009-08-14 Thread Alan G Isaac
`lst` is a nested list `tpl` is the indexes for an item in the list What is the nice way to retrieve the item? (Speedy access is nice.) I don't want to use NumPy, but I'd like somehow to avoid an explicit loop. I did consider using eval. E.g., eval('lst' + '[%d]'*len(tpl)%tpl). It works but se

Re: csv.DictWriter.write_header()

2009-08-14 Thread Alan G Isaac
> On Aug 13, 1:15 pm, Alan G Isaac wrote: >> I do not understand the reason for your silly, sarcastic response. On 8/13/2009 7:58 AM John Machin apparently wrote: > Duck typing: ask a silly question, get a silly answer. Maybe if you learned to be a more generous reader, fewer que

Re: csv.DictWriter.write_header()

2009-08-12 Thread Alan G Isaac
> On Aug 13, 6:45 am, Alan G Isaac wrote: >> Given a csv.DictWriter instance `dw` >> I think it would be nice to be able to >> say dw.write_header() >> instead of >> dw.writer.writerow(dw.fieldnames) >> >> Good idea? On 8/12/2009 10:24 PM John Mac

csv.DictWriter.write_header()

2009-08-12 Thread Alan G Isaac
Given a csv.DictWriter instance `dw` I think it would be nice to be able to say dw.write_header() instead of dw.writer.writerow(dw.fieldnames) Good idea? Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: invoke method on many instances

2009-07-22 Thread Alan G Isaac
>>> On Fri, 17 Jul 2009 05:19:50 +0000, Alan G Isaac wrote: >>>> def apply2(itr, methodname, *args, **kwargs): >>>> f = operator.methodcaller(methodname, *args, **kwargs) >>>> for item in itr: >>>> f(item) >> On 7/1

  1   2   3   4   >