Re: Too many python installations. Should i remove them all and install the latest?
On 01/06/2013, Νικόλαος Κούρας wrote: > > Why so many pythons in my system. Explained below, underneath each pertinent info you provided. First, let's discuss Python 2.6: On 01/06/2013, Νικόλαος Κούρας wrote: > I'am using CentOS v6.4 on my VPS and hence 'yum' install manager and i just > tried: > > Code: > root@nikos [~]# which python > /usr/bin/python This is the version of that CentOS 6 is using. It is Python 2.6 as shown in the next paragraph. This version is essential to CentOS 6. This cannot be changed or upgraded without so much work that no sane person on the planet would bother. Stop worrying about it. On 01/06/2013, Νικόλαος Κούρας wrote: > > root@nikos [~]# python -V > Python 2.6.6 See above. On 01/06/2013, Νικόλαος Κούρας wrote: > > root@nikos [/]# ls -l /usr/bin/python* > -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python* > lrwxrwxrwx 1 root root6 Apr 5 20:34 /usr/bin/python2 -> python* > -rwxr-xr-x 3 root root 4864 Feb 22 02:00 /usr/bin/python2.6* > -rwxr-xr-x 1 root root 1418 Feb 22 02:00 /usr/bin/python2.6-config* [... python3 line removed for clarity ...] > lrwxrwxrwx 1 root root 16 Apr 5 20:35 /usr/bin/python-config -> > python2.6-config* Apart from the bizarre trailing '*' characters which for which I have no sane explanation, all of the above is standard for Python 2.6 which is essential for Centos 6. Stop worrying about it. Now let's talk about yum: On 01/06/2013, Νικόλαος Κούρας wrote: > root@nikos [~]# yum remove python3 [...] > No Match for argument: python3 [...] > root@nikos [~]# yum remove python3.3 [...] > No Match for argument: python3.3 > > i don'y understand, why didnt it removed it neither of ways? Your yum setup does not find python3 or python3.3 packages. So you could not have used yum to install it. Therefore, you cannot use yum to remove it. And, you cannot use yum to install it. Now let's talk about Python 2.7: On 01/06/2013, Νικόλαος Κούρας wrote: > root@nikos [~]# which python3 > /root/.local/lib/python2.7/bin/python3 There's a python2.7 directory there under /root/.local. Maybe you installed python2.7 from source using some kind of 'make install' command (ie not using yum)? If so, and you wish to remove it, there will probably be another 'make' command to remove it, which must be run from the same directory that you ran 'make install'. Try 'make help' in that directory. Maybe someone else can explain why there is a python3 command under that directory, because I can't. Now let's talk about Python 3: On 01/06/2013, Νικόλαος Κούρας wrote: > > root@nikos [~]# ls -al /usr/bin/python* [...] > lrwxrwxrwx 1 root root 24 Apr 7 22:10 /usr/bin/python3 -> > /opt/python3/bin/python3* There's a python3 directory there under /opt. Maybe you installed python3 from source using some kind of 'make install' command (ie not using yum)? If so, and you wish to remove it, there will probably be another 'make' command to remove it, which must be run from the same directory that you ran 'make install'. Try 'make help' in that directory. On 01/06/2013, Νικόλαος Κούρας wrote: > > OMG i gave by mistake > > root@nikos [/]# rm -rf /root/.local/ > > did i screwed up my remote VPS which i host 10 peoples webpages? When trying something you don't fully understand, first experiment somewhere you don't care if bad things happen. On 01/06/2013, Νικόλαος Κούρας wrote: > Should i remove them all and install the latest? No. Different versions do different things. Don't install or remove them until you understand the different things they do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Too many python installations. Should i remove them all and install the latest?
On 01/06/2013, Chris Angelico wrote: > On Sat, Jun 1, 2013 at 8:50 AM, David wrote: >> >> Apart from the bizarre trailing '*' characters which for which I have >> no sane explanation... > > I believe that indicates that his 'ls' is aliased to 'ls --classify', > which puts * after executables (and / after directories, and @ after > symlinks, also a few others). Not a problem. Ah, old skool. I have seen that before now that you mention it. Thanks for the correction. I knew I didn't have all the answers, but felt that I'd try some pig wrestling anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish => Greek (subprocess complain)
On 02/06/2013, Mark Lawrence wrote: > On 02/06/2013 08:01, Giorgos Tzampanakis wrote: >> >> You are not offering enough information, because you have not posted the >> contents of your files.py script. Thus it's difficult to help you. Please >> post your code to pastebin or somewhere similar because posting long >> lines >> on usenet is considered bad etiquette. >> > > I would much prefer to have a code snippet that shows the problem > inline. Plus, what happens in six months time if someone finds this > thread but can't find the code online as it's expired? I agree, and this is also the policy enforced in freenode #bash. Please do not encourage people to pastebin entire scripts, because very few people will bother to read them. The ideal approach is to post a minimal code snippet that allows us to comprehend or reproduce the problem. This encourages the question to be well-framed. Otherwise idiots will dump their entire scripts into a pastebin and write to us "why it not work?". -- http://mail.python.org/mailman/listinfo/python-list
Re: Question:Programming a game grid ...
First, you should be getting an error on vars()[var] = Button(f3, text = "00", bg = "white") as vars() has not been declared and it does not appear to be valid Python syntax. I don't see a reason to store a reference to the button since you won't be modifying them. Also, you can not mix pack() and grid(). It produces unpredictable results. try: import Tkinter as tk ## Python 2.x except ImportError: import tkinter as tk ## Python 3.x def leftclick(*args): print "leftclick called" def rightclick(*args): print "rightclick called" root = tk.Tk() f3 = tk.Frame(root, bg = "white", width = 500) f3.grid() this_row=0 this_column=0 for ctr in range(0, 89): b = tk.Button(f3, text = "%0d" % (ctr), bg = "white") b.grid(row=this_row, column=this_column) b.bind('', leftclick) # bind left mouse click b.bind('', rightclick) # bind left mouse click this_column += 1 if this_column > 6: this_column=0 this_row += 1 root.title('Puzzle Grid') root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: My first ever Python program, comments welcome
On 22/07/2012, Lipska the Kat wrote: > On 21/07/12 21:10, Dave Angel wrote: >> >> A totally off-the-wall query. Are you using a source control system, >> such as git ? It can make you much braver about refactoring a working >> program. > > Thanks for your comments, I've taken them on board, > I'm most familiar with with cvs and svn for source control. I've also > used Microsoft source safe. I generally just use what's given to me by > whoever is paying me and don't worry too much about the details. Many in > the Linux world seem to use git. Seeing as I've been using Linux at home > since the early days of slackware I suppose I'd better look into it. What Dave said. I used CVS briefly and then git and its gui tools for last 5 years. Took me a while to get comfortable with it, but now it turns managing complex, evolving text files into fun and I cannot imagine working without its power and flexibility. First thing I do on any programming task: git init -- http://mail.python.org/mailman/listinfo/python-list
Re: python package confusion
On 23/07/2012, Lipska the Kat wrote: > Hello again pythoners [snip] > Any help much appreciated. Hi Lipska Glad you got it sorted. In case you are not aware of this: Tutor maillist - tu...@python.org http://mail.python.org/mailman/listinfo/tutor The tutor list caters specifically for requests for basic assistance such as you made in this thread, and code review such as in your thread prior. It too is a busy list, and many of the people who have responded to your previous threads here are also present there, so you'll get the same high quality answers there too. By the way, I had a followup to my previous message to you re git, and emailed it to you directly because it would be off-topic here, but the email bounced. It seems that you are displaying an invalid email address, at least here I get: $ ping lipskathekat.com ping: unknown host lipskathekat.com So if you are interested in that, feel free to email me directly, or not as you wish. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python a commercial proposition ?
On 30/07/2012, lipska the kat wrote: > On 30/07/12 14:06, Roy Smith wrote: >> >> These days, I'm working on a fairly large web application (songza.com). > > "We are very sorry to say that due to licensing constraints we cannot > allow access to Songza for listeners located outside of the United States." > > Arse :-( A free[1] US proxy could bypass[2] that page ... eg something like http://www.airproxy.ca/ [1] as in beer [2] for research purposes -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python a commercial proposition ?
On 01/08/2012, lipska the kat wrote: > On 31/07/12 14:52, David wrote: >> >> [1] as in beer >> [2] for research purposes > > There's one (as in 1 above) in the pump for you. Great, more beer => better research => \o/\o/\o/ But, "pump" sounds a bit extreme .. I usually sip contentedly from a glass :p -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python a commercial proposition ?
On 01/08/2012, lipska the kat wrote: > On 01/08/12 09:06, Mark Lawrence wrote: >> >> You complete ignoramus, if it gets poured in advance that's no good to >> anybody as it'll go flat. Has to stay in the pump until you're ready to >> drink it from the glass. Don't you know anything about the importance of >> process and timing? :) > > Heh heh, obviously never got drunk ... er I mean served behind the bar > at uni/college/pub %-} Nah, obviously *is* drunk ;p -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python a commercial proposition ?
On 01/08/2012, Stefan Behnel wrote: > > Would you mind taking this slightly off-topic discussion off the list? I always strive to stay on-topic. In fact immediately this thread went off topic, 4 messages back, I did try to go off list, but got this result from the OP: Delivery to the following recipient failed permanently: lip...@yahoo.co.uk Technical details of permanent failure: Google tried to deliver your message, but it was rejected by the recipient domain. We recommend contacting the other email provider for further information about the cause of this error. The error that the other server returned was: 554 554 delivery error: dd This user doesn't have a yahoo.co.uk account (lip...@yahoo.co.uk) [-5] - mta1050.mail.ukl.yahoo.com (state 17). Date: Wed, 1 Aug 2012 09:31:43 +1000 Subject: Re: Is Python a commercial proposition ? From: David To: lipska the kat Then, if someone is going to call me an ignoramus on a public list, they will receive a response in the same forum. So, I apologise to the list, but please note the unusual circumstances. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: python CAD libraries?
> Thank you. But this is for 2D. Thank you. But this is for 2D. 3-d is just manipulating what's shown in x/y points(and not as easy as it sounds) . I went with cartesian coordinate, a 360x360 canvas(with 90x90 degree view port), and a little trig for front/back/left/right/up/down, and amplitude or z distance for my first attempt, with a few others that locked a center of an object,and held point rotation, and now porting it into the Blender game engine. I've used maya(I think that was the name), and matplotlib, but Blender.org(open source) is great for 3d rendering/game engine, etc, and has a nice python API, with great tutorials everywhere. If you checkout my homepage in my sig, you can see a roughdraft of somethings I was working on for it. I'd say go with an earlier version(more tuts/examples), but they put them out pretty quick, so 2.6 my be best to start with, and it uses python 3.x. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python CAD libraries?
Thank you. But this is for 2D. 3-d is just manipulating what's shown in x/y points(and not as easy as it sounds) . I went with cartesian coordinate, a 360x360 canvas(with 90x90 degree view port), and a little trig for front/back/left/right/up/down, and amplitude or z distance for my first attempt, and now porting it into the Blender game engine. I've used maya(I think that was the name), and matplotlib, but Blender.org(open source) is great for 3d rendering/game engine, etc, and has a nice python API, with great tutorials everywhere. If you checkout my homepage in my sig, you can see a roughdraft of somethings I was working on for it. I'd say go with an earlier version(more tuts/examples), but they put them out pretty quick, so 2.6 my be best to start with, and it uses python 3.x. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Add if...else... switch to doctest?
Hello, how to add if...else... switch to doctest? E.g. function outputs different value when global_var change. """ if (global_var == True): >>> function() [1,2] else: >>> function() [1,2,3] """ Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list
Recursive Generator Error?
I have a tree-like data structure, the basic elements are hash tables, and they are grouped into lists, like [[{'a':1},[{'b':2}]]]. And I want to flat the lists and visit hash table one by one, like {'a':1}, {'b':2}. But my program didn't work as I wish. When it entered the 2nd flat_yield, it threw a GeneratorExit. Is there anything wrong? Thank you very much! #- - - - - - - - - - def flat_yield(tbl_list): for t in tbl_list: if type(t) == type({}): yield t elif type(t) == type([]): flat_yield(t) a = [[{'a':1},[{'b':2}]]] for i in flat_yield(a): print i -- http://mail.python.org/mailman/listinfo/python-list
Re: Recursive Generator Error?
On Monday, October 22, 2012 7:59:53 AM UTC+8, Terry Reedy wrote: > On 10/21/2012 7:29 PM, David wrote: > > > I have a tree-like data structure, the basic elements are hash tables, > > > and they are grouped into lists, like [[{'a':1},[{'b':2}]]]. > > > And I want to flat the lists and visit hash table one by one, like {'a':1}, > > {'b':2}. > > > But my program didn't work as I wish. When it entered the 2nd > > > flat_yield, it threw a GeneratorExit. Is there anything wrong? > > > > 1. The Python version is not specified. > > 2. You used 2.x; in 3.3 the code does exactly what I would expect, which > > is to say, nothing. No output, no error, no traceback ;-) > > 3. The traceback is missing from this post. > > > > > #- - - - - - - - - - > > > def flat_yield(tbl_list): > > > for t in tbl_list: > > > if type(t) == type({}): > > > yield t > > > elif type(t) == type([]): > > > flat_yield(t) > > > > 4. Think harder about what that expression does. > > > > > a = [[{'a':1},[{'b':2}]]] > > > for i in flat_yield(a): > > > print i > > > > Hint: it calls flat_yield, which returns a generator, which is then > > discarded. You might have well written 'pass'. > > > > Solution: use the recursively called generator and recursively yield > > what it yields. Replace 'flat_yield(t)' with > > > > for item in flat_yield(t): > > yield item > > > > and the output is what you want. > > > > -- > > Terry Jan Reedy Hi Terry, thank you! I use Python 2.7, and your solution works! I have thought harder, still not very clear. If I have one "yield" in function, the function will become generator, and it can only be called in the form like "for item in function()" or "function.next()", and call the function directly will raise error, is it right? -- http://mail.python.org/mailman/listinfo/python-list
Re: namespace question
Your code updated to show the difference between a variable, a class variable, and an instance variable. c = [1, 2, 3, 4, 5] class TEST(): c = [5, 2, 3, 4, 5] ## class variable (TEST.c) def __init__(self): self.c = [1, 2, 3, 4, 5] ## instance variable (a.c) def add(self, c): self.c[0] = 15 ## instance variable TEST.c[0] = -1 ## class variable c[0] = 100 ## variable/list return c a = TEST() c = a.add(c) print( c, a.c, TEST.c ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Use a locally built Tk for Python?
Python uses the Tkinter wrapper around TCL/TK and it remains the same no matter how may versions of TCL/TK are installed. You will have to build Tkinter against whatever version you like and make sure that it gets installed in the /usr/lib64/python directory that you want. -- http://mail.python.org/mailman/listinfo/python-list
Re: Paramiko Threading Error
Il Tue, 7 Jun 2011 19:25:43 -0700 (PDT), mud ha scritto: > Hi All, > > Does anybody know what the following error means with paramiko, and > how to fix it. > > I don't know what is causing it and why. I have updated paramiko to > version 1.7.7.1 (George) but still has the same issue. > > Also I can not reproduce the problem and therefore debugging is harder > for me. > > > Exception in thread Thread-4 (most likely raised during interpreter > shutdown): > Traceback (most recent call last): > File "/usr/lib64/python2.6/threading.py", line 532, in > __bootstrap_inner > File "/usr/lib/python2.6/site-packages/paramiko/transport.py", line > 1574, in run > : 'NoneType' object has no attribute > 'error' if I remember rightly, I got that kind of error when I tried to use a transport without setting up the paramiko's logging subsystem. Try to put in head of your code the line: pk.util.log_to_file("log file name.txt") D. -- http://mail.python.org/mailman/listinfo/python-list
Python bug? Indexing to matrices
Should the following line work for defining a matrix with zeros? c= [[0]*col]*row where "col" is the number of columns in the matrix and "row" is of course the number of rows. If this a valid way of initializing a matrix in Python 3.2.1, then it appears to me that a bug surfaces in Python when performing this line: c[i][j] = c[i][j] + a[i][k] * b[k][j] It writes to the jth column rather than just the i,j cell. I'm new at Python and am not sure if I'm just doing something wrong if there is really a bug in Python. The script works fine if I initialize the matrix with numpy instead: c = np.zeros((row,col)) So, I know my matrix multiply algorithm is correct (I know I could use numpy for matrix multiplication, this was just to learn Python). I've attached my source code below. TIA, David - #!python # dot.py - Matrix multiply in matricies: [c] = [a] * [b] import numpy as np a = [[3, 7], [-2, 1], [2, 4]] b = [[2, 1, -3, 1], [4, 3, -2, 3]] print("a = {0}, b = {1}".format(a,b)) row = len(a) col = len(b[0]) #c = np.zeros((row,col))# <- Correct results when using this line c= [[0]*col]*row# <- Incorrect results when using this line print(c) for i in range(row):# Index into rows of [a] for j in range(col):# Index into columns of [b] c[i][j] = 0 for k in range(len(b)): # Index into columns of [a] and rows of [b] print("c[{0}][{1}] + a[{2}][{3}] * b[{4}][{5}] = {6} + {7} * {8}".format(i,j,i,k,k,j,c[i][j],a[i][k],b[k][j])) c[i][j] = c[i][j] + a[i][k] * b[k][j] print(c) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python bug? Indexing to matrices
Thank all for the very helpful replies. The goal of the matrix multiply exercise was just to help my son and I learn Python better. I now understand *why* my initialization of [c] was wrong and I am continuing to check out numpy and scipy. Regards, David -- http://mail.python.org/mailman/listinfo/python-list
Re: Spam
If you click the "more options" link, there is an option in the sub- menu to report a post as spam. You can also forward it along with the offending e-mail address to s...@uce.gov -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - cannot import tklib
On Tue, 21 Jun 2022 at 09:22, Wolfgang Grafen wrote: > I am an experienced Python user and struggle with following statement: > > >>> from tklib import * > Traceback (most recent call last): > File "", line 1, in > ModuleNotFoundError: No module named 'tklib' [...] > I did not find a python module called tklib to install. Ok, see below for how to find that file. [...] > I assume it should be installed by default with every python installation It appears that your assumption is wrong. It appears to me that the missing file is part of the tk-tutorial project. > https://tk-tutorial.readthedocs.io/en/latest/intro/intro.html?highlight=app# > First time that I cannot help myself. Please help, what do I do wrong? Hi, here is a description how I found the file you seek: Go to https://tk-tutorial.readthedocs.io/en/latest/intro/intro.html At the top right of the page, see hyperlink "Edit on GitHub". Click hyperlink takes you to https://github.com/rasql/tk-tutorial/blob/master/docs/intro/intro.rst which is the same content rendered from 'rst' format I assume. At top left of that page, see hyperlinks "tk-tutorial"/"docs"/"intro" and "rasql"/"tk-tutorial". Click one of the "tk-tutorial" hyperlinks to go to the top directory of the project at: https://github.com/rasql/tk-tutorial On that page near the very top, see a list of hyperlinks to directories and files of the project. One of those hyperlinks is labelled "tklib.py". Click that link to see the file at https://github.com/rasql/tk-tutorial/blob/master/tklib.py On that page, click the "Raw" button. Then you can use "save as" in your browser. Or you can just download it by some other method from the link given in the previous paragraph. -- https://mail.python.org/mailman/listinfo/python-list
Re: Mutating an HTML file with BeautifulSoup
On Sat, 20 Aug 2022 at 04:31, Chris Angelico wrote: > What's the best way to precisely reconstruct an HTML file after > parsing it with BeautifulSoup? > Note two distinct changes: firstly, whitespace has been removed, and > secondly, attributes are reordered (I think alphabetically). There are > other canonicalizations being done, too. > I'm trying to make some automated changes to a huge number of HTML > files, with minimal diffs so they're easy to validate. That means that > spurious changes like these are very much unwanted. Is there a way to > get BS4 to reconstruct the original precisely? On Sat, 20 Aug 2022 at 07:02, Chris Angelico wrote: > On Sat, 20 Aug 2022 at 05:12, Barry wrote: > > I recall that in bs4 it parses into an object tree and loses the detail > > of the input. I recently ported from very old bs to bs4 and hit the > > same issue. So no it will not output the same as went in. > So I'm left with a few options: > 1) Give up on validation, give up on verification, and just run this >thing on the production site with my fingers crossed > 2) Instead of doing an intelligent reconstruction, just str.replace() one >URL with another within the file > 3) Split the file into lines, find the Nth line (elem.sourceline) and >str.replace that line only > 4) Attempt to use elem.sourceline and elem.sourcepos to find the start of >the tag, manually find the end, and replace one tag with the >reconstructed form. > I'm inclined to the first option, honestly. The others just seem like > hard work, and I became a programmer so I could be lazy... Hi, I don't know if you will like this option, but I don't see it on the list yet so ... I'm assuming that the phrase "with minimal diffs so they're easy to validate" means being eyeballed by a human. Have you considered two passes through BS? Do the first pass with no modification, so that the intermediate result gets the BS default "spurious" changes. Then do the second pass with the desired changes, so that the human will see only the desired changes in the diff. -- https://mail.python.org/mailman/listinfo/python-list
Re: What is the reason from different output generate using logical 'and' and 'or' operator in Python 3.10.8
On Tue, 8 Nov 2022 at 03:08, ICT Ezy wrote: > Please explain how to generate different output in following logical > operations > >>> 0 and True > 0 > >>> 0 or True > True > >>> 1 and True > True > >>> 1 or True > 1 Hi, The exact explanation of how 'and' and 'or' behave can be read here: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not The "Notes" there explain what you see. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fast lookup of bulky "table"
On Mon, 16 Jan 2023 at 16:15, Dino wrote: > BTW, can you tell me what is going on here? what's := ? > > while (increase := add_some(conn,adding)) == 0: See here: https://docs.python.org/3/reference/expressions.html#assignment-expressions https://realpython.com/python-walrus-operator/ -- https://mail.python.org/mailman/listinfo/python-list
Re: bool and int
On Wed, 25 Jan 2023 at 12:19, Mike Baskin via Python-list wrote: > Will all of you please stop sending me emails Hi. We don't have the power to do that. Because this is a public list, which works by people adding and removing themselves. You, or perhaps someone messing with you, added your email address to it. So you have to remove yourself. The link to do that is at the bottom of every message. See here: https://mail.python.org/mailman/listinfo/python-list Go to the bottom, enter your email address, click the button next to it named "Unsubscribe or edit options" and follow the instructions. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?
On Thu, 26 Jan 2023 at 04:24, Jach Feng wrote: > Chris Angelico 在 2023年1月25日 星期三下午1:16:25 [UTC+8] 的信中寫道: > > On Wed, 25 Jan 2023 at 14:42, Jach Feng wrote: > > You're still not really using argparse as an argument parser. Why not > > just do your own -h checking? Stop trying to use argparse for what > > it's not designed for, and then wondering why it isn't doing what you > > expect it to magically know. > I just don't get what you mean? Hi, I am writing because there seems to be a communication problem here, not a programming problem. The thread is long and seems to be making no progress. You seem like a traveller who is lost and keeps looking at the map, but they have the wrong map for where they are. You seem to be not understanding the purpose of argparse. In this thread, you have not mentioned any reason that requires the use of argparse. argparse is intended to help when your program accepts >>> more than one kind of argument <<< and then uses those different kinds of argument >>> for different purposes <<<. The programmer can handle that situation without argparse. But argparse makes it easier. In this thread, you have not described your program as accepting different kinds of arguments. Therefore the people replying to you are telling you that you do not need it. You seem to be not listening to that, and you have not explained why, you seem to just keep ignoring what people are telling you. If you disagree with this, then a way forward is for you to think harder about what benefits you are getting in your program by using argparse, and >>> explain those benefits clearly to your readers here <<<. An alternative approach would be for you to remove argparse from your program, and try to write your program without it. And then ask here about any difficulties that you have with doing that, and I imagine people will be glad to help you. All of the replies you have received so far are trying to help you, even if you don't feel that. Good luck. -- https://mail.python.org/mailman/listinfo/python-list
Using pytest, sometimes does not capture stderr
Hi, I have just begun using pytest at a basic level and I am seeing behaviour that I do not understand. My platform is Debian 10.9 There are 3 files involved, contents are provided below, and attached. - module_1.py passes the test as expected - module_2.py has a tiny change, and fails unexpectedly. - my_test.py runs the same test on each module Can anyone explain why the module_2.py test fails? Is it because stderr during module import is not the same as during test? Is it something to do with mutable defaults? How to investigate this? And how can I get the test to pass without changing module_2? Thanks :) #- Here is the file module_1.py: #!/usr/bin/python3 import sys def msg(*args): print(*args, file=sys.stderr) #- Here is the file module_2.py: #!/usr/bin/python3 import sys MSG_DESTINATION = sys.stderr def msg(*args): print(*args, file=MSG_DESTINATION) #- Here is the file: my_test.py #!/usr/bin/python3 import module_1 import module_2 def test__1(capsys): module_1.msg("a", "message") captured = capsys.readouterr() assert captured.err == """a message\n""" def test__2(capsys): module_2.msg("a", "message") captured = capsys.readouterr() assert captured.err == """a message\n""" #- Here is the pytest output: $ pytest-3 test session starts = platform linux -- Python 3.7.3, pytest-3.10.1, py-1.7.0, pluggy-0.8.0 rootdir: /mnt/hart/home/d10/david/work/src/py/lab/pytest/capture/bug, inifile: collected 2 items my_test.py .F [100%] == FAILURES == __ test__2 ___ capsys = <_pytest.capture.CaptureFixture object at 0x7ff6457134a8> def test__2(capsys): module_2.msg("a", "message") captured = capsys.readouterr() > assert captured.err == """a message\n""" EAssertionError: assert '' == 'a message\n' E + a message my_test.py:14: AssertionError Captured stderr call a message = 1 failed, 1 passed in 0.03 seconds = = test session starts == platform linux -- Python 3.7.3, pytest-3.10.1, py-1.7.0, pluggy-0.8.0 rootdir: /mnt/hart/home/d10/david/work/src/py/lab/pytest/capture/bug, inifile: collected 2 items my_test.py .F[100%] === FAILURES === ___ test__2 capsys = <_pytest.capture.CaptureFixture object at 0x7f9f8cc33278> def test__2(capsys): module_2.msg("a", "message") captured = capsys.readouterr() > assert captured.err == """a message\n""" EAssertionError: assert '' == 'a message\n' E + a message my_test.py:14: AssertionError - Captured stderr call - a message == 1 failed, 1 passed in 0.03 seconds == -- https://mail.python.org/mailman/listinfo/python-list
Re: Using pytest, sometimes does not capture stderr
On Mon, 5 Apr 2021 at 13:44, Cameron Simpson wrote: > On 05Apr2021 13:28, David wrote: > >Can anyone explain why the module_2.py test fails? > >Is it because stderr during module import is not the same as during test? > >Is it something to do with mutable defaults? > >How to investigate this? > >And how can I get the test to pass without changing module_2? > The code in module_2.py runs at different times. > When it is imported, sys.stderr is the OS-provided stderr. That > reference is kept in MSG_DESTINATION. > Then your test code runs, and changes sys.stderr. It then runs msg(), > which writes to the _original_ sys.stderr as preserved by > MSG_DESTINATION. Thus not captured. > By contrast, module_1.py looks up sys.stderr inside msg(), and finds the > new one the code harness put at sys.stderr. So it writes to the thing > that captures stuff. Hi Cameron, Thanks for confirming my suspicions so quickly. What you wrote makes sense, but there are two points that still puzzle me. 1) The final line of the pytest failure output seems to shows that pytest did capture (or is at least aware of) the stderr message from module_2. 2) My actual code that I would like to test does look like module_2. Is there any way to test it with pytest? Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Using pytest, sometimes does not capture stderr
On Mon, 5 Apr 2021 at 14:26, Cameron Simpson wrote: > On 05Apr2021 13:56, David wrote: > >Thanks for confirming my suspicions so quickly. What you wrote > >makes sense, but there are two points that still puzzle me. > >1) The final line of the pytest failure output seems to shows that > >pytest did capture (or is at least aware of) the stderr message > >from module_2. > Yes. Unsure what's going on there. It could be timing. Suppose this > happens: > - pytest pushes a capturing stderr onto sys.stderr > - pytest loads your module, which imports module_1 and module_2 > - the test runner pushes a separate stderr capturer for the test? > - module_1 finds the per-test sys.stderr value > - module_2 finds pytest's outermost capturer (present when it was > imported), and doesn't look up sys.stderr at test time, instead using > the outer capturer Ok. I do understand that my function parameter defaults are defined when the function is defined, so something like this could happen. > >2) My actual code that I would like to test does look like module_2. > >Is there any way to test it with pytest? > I'd be inclined to give msg() an optional file= parameter: Understood. > If you truly need to test msg() _without_ the file= parameter, you could > monkey patch module_2: I tried this, it works too. Thanks so much for your guidance! It's great to be steered through puzzlement by experts. I hope you're having a good day, you made mine better :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Cleaning up conditionals
On 31 December 2016 at 10:00, Deborah Swanson wrote: > > Oops, indentation was messed up when I copied it into the email. The indentation of your latest message looks completely broken now, you can see it here: https://mail.python.org/pipermail/python-list/2016-December/717758.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 4 January 2017 at 11:50, Deborah Swanson wrote: > Erik wrote, on January 03, 2017 3:30 PM >> >> When you start a new topic on the list, could you please write a new >> message rather than replying to an existing message and changing the >> title/subject? >> > Certainly. I've been on many other lists before (but none since about > 2011), and no one complained of or even mentioned this problem. But if > it's a problem with some email readers now, I can easily just start a > new message. Just being lazy and following old habits, I guess. ;) To be clear, the problem is not "with some email readers". The problem is that it breaks the thread management features that are built into every email message, making it impossible to display threads correctly. As can be seen here for example: https://mail.python.org/pipermail/python-list/2017-January/thread.html Note how most threads start in the leftmost column and replies are indented. But this does not occur where you began the new subject: "Clickable hyperlinks". Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 4 January 2017 at 11:50, Deborah Swanson wrote: > Erik wrote, on January 03, 2017 3:30 PM >> >> When you start a new topic on the list, could you please write a new >> message rather than replying to an existing message and changing the >> title/subject? >> > Certainly. I've been on many other lists before (but none since about > 2011), and no one complained of or even mentioned this problem. But if > it's a problem with some email readers now, I can easily just start a > new message. Just being lazy and following old habits, I guess. ;) To be clear, the problem is not "with some email readers". The problem is that it breaks the thread management features that are built into every email message, making it impossible to display threads correctly. As can be seen here for example: https://mail.python.org/pipermail/python-list/2017-January/thread.html Note how most threads start in the leftmost column and replies are indented. But this does not occur where you began the new subject: "Clickable hyperlinks". Thanks. -- https://mail.python.org/mailman/listinfo/python-list
asyncio and subprocesses
Is this a bug in the asyncio libraries? This code: ''' proc = yield from asyncio.create_subprocess_exec(*cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) # read all data from subprocess pipe, copy to nextCoro ln = yield from proc.stdout.read(1024) while ln: yield from nextCoro.process(ln) ln = yield from proc.stdout.read(1024) ''' will throw this exception: Traceback (most recent call last): File "/usr/project/bulk_aio.py", line 52, in db_source ln = yield from proc.stdout.read(1024) File "/usr/lib/python3.4/asyncio/streams.py", line 462, in read self._maybe_resume_transport() File "/usr/lib/python3.4/asyncio/streams.py", line 349, in _maybe_resume_transport self._transport.resume_reading() File "/usr/lib/python3.4/asyncio/unix_events.py", line 364, in resume_reading self._loop.add_reader(self._fileno, self._read_ready) AttributeError: 'NoneType' object has no attribute 'add_reader' The exception always happens at the end of the subprocess's run, in what would be the last read. Whether it happens correlates with the time needed for nextCoro.process. If each iteration takes more than about a millisecond, the exception will be thrown. It *seems* that when the transport loses the pipe connection, it schedules the event loop for removal immediately, and the _loop gets set to None before the data can all be read. This is the sequence in unix_events.py _UnixReadPipeTransport._read_ready. Is there a workaround to avoid this exception? Is this a fixed bug, already? I am using Python 3.4.2 as distributed in Ubuntu Lucid, with built-in asyncio. Thank you. David -- https://mail.python.org/mailman/listinfo/python-list
Re: Logging - have logger use caller's function name and line number
On Sun, 30 Dec 2018 at 05:58, Malcolm Greene wrote: > > I have a class method that adds additional context to many of the > class's log messages. Rather than calling, for example, logger.info( > 'message ...' ) I would like to call my_object.log( 'message ...' ) so > that this additional context is managed in a single place. I'm actually > doing that and its working great except that ... as expected ... all my > log records have the my_object.log method's name and line numbers vs the > callers' names and line numbers. > Is there a technique I can use to have my custom log method inject the > caller's name and line numbers in the log output? You can use this: https://docs.python.org/3/library/inspect.html#the-interpreter-stack -- https://mail.python.org/mailman/listinfo/python-list
Re: About the #python irc channel on freenode.
On Tue, 13 Aug 2019 at 10:00, Hongyi Zhao wrote: > > But I always be put into the #python-unregistered channel as follows: > > -- > Now talking on #python-unregistered > * Topic for #python-unregistered is: Welcome to #python-unregistered! > You've been put here because #python requires you to register your > nickname with Freenode. For more information about registering on > Freenode, ask #freenode. For more information about #python,#python-* > moderation, #python-ops. > * Topic for #python-unregistered set by lvh!~lvh@python/psf/lvh (Fri Jul > 1 16:44:19 2011) > - > > I've tried to register the nickname as it told. But still cannot success. The #python channel always works for me. The best place to ask for help is to do what it says in the message you were given ... "For more information about registering on Freenode, ask #freenode. " Have you asked for help in the #freenode channel? /join #freenode and ask there, no registration is required to do that. Be sure to communicate in short, clear sentences. Then wait for someone to answer you. Do not leave the channel after asking for help, wait for at least an hour. Any person might answer you, and sometimes random people there make mischief. But the people who are "ops" in that channel are freenode staff. They will help you and they have admin powers. Sometimes depending on time of day or day of week the staff might be absent. If so, just wait a few hours and try again. -- https://mail.python.org/mailman/listinfo/python-list
Re: local variable 'p' referenced before assignment
On Sun, 8 Sep 2019 at 19:55, Pankaj Jangid wrote: > > Why this code is giving local variable access error when I am accessing > a global variable? > p = 0 > def visit(): >m = 1 >if m > p: >p = m https://docs.python.org/3/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python " If a variable is assigned a value anywhere within the function’s body, it’s assumed to be a local unless explicitly declared as global." So to avoid causing this error, inside your function you must explicitly declare p as global before you try to assign to it. Inside your function, you need a statement: global p before you try to assign to p. -- https://mail.python.org/mailman/listinfo/python-list
Re: Is it 'fine' to instantiate a widget without parent parameter?
On Sun, 8 Sep 2019 at 20:25, wrote: > > If I have two widgets created this way: > t0 = tkinter.Text() > t1 = tkinter.Text() > How many Tk objects will there be? $ python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> t0 = tkinter.Text() >>> t1 = tkinter.Text() >>> t0 is t1 False >>> t0 >>> t1 >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: Is it 'fine' to instantiate a widget without parent parameter?
On Sun, 8 Sep 2019 at 21:05, wrote: > David於 2019年9月8日星期日 UTC+8下午6時44分55秒寫道: > > On Sun, 8 Sep 2019 at 20:25, wrote: > > > If I have two widgets created this way: > > > t0 = tkinter.Text() > > > t1 = tkinter.Text() > > > How many Tk objects will there be? > Sorry, didn't make it clear. I mean Sorry I didn't read more carefully. But I think that the method I demonstrated can give the answer to your question. >>> import tkinter >>> t0 = tkinter.Text() >>> t1 = tkinter.Text() >>> t0.master >>> t1.master >>> t0.master is t1.master True >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: regular expressions help
On Thu, 19 Sep 2019 at 17:51, Pradeep Patra wrote: > > pattern=re.compile(r'^my\-dog$') > matches = re.search(mystr) > > In the above example both cases(match/not match) the matches returns "None" Hi, do you know what the '^' character does in your pattern? -- https://mail.python.org/mailman/listinfo/python-list
Re: regular expressions help
On Thu, 19 Sep 2019 at 18:41, Pradeep Patra wrote: > On Thursday, September 19, 2019, Pradeep Patra > wrote: >> On Thursday, September 19, 2019, David wrote: >>> On Thu, 19 Sep 2019 at 17:51, Pradeep Patra >>> wrote: >>> > pattern=re.compile(r'^my\-dog$') >>> > matches = re.search(mystr) >>> > In the above example both cases(match/not match) the matches returns >>> > "None" >>> Hi, do you know what the '^' character does in your pattern? >> Beginning of the string. But I tried removing that as well and it still >> could not find it. When I tested at www.regex101.com and it matched >> successfully whereas I may be wrong. Could you please help here? > I am using python 2.7.6 but I also tried on python 3.7.3. $ python2 Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> mystr= "where is my-dog" >>> pattern=re.compile(r'my-dog$') >>> matches = re.search(mystr) # this is syntax error, but it is what you >>> showed above Traceback (most recent call last): File "", line 1, in TypeError: search() takes at least 2 arguments (1 given) >>> matches = re.search(pattern, mystr) >>> matches.group(0) 'my-dog' >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: regular expressions help
On Thu, 19 Sep 2019 at 19:34, Pradeep Patra wrote: > Thanks David for your quick help. Appreciate it. When I tried on python 2.7.3 > the same thing you did below I got the error after matches.group(0) as > follows: > > AttributeError: NoneType object has no attribute 'group'. > > I tried to check 'None' for no match for re.search as the documentation says > but it's not working. > > Unfortunately I cannot update the python version now to 2.7.13 as other > programs are using this version and need to test all and it requires more > testing. Any idea how I can fix this ? I am ok to use any other re method(not > only tied to re.search) as long as it works. Hi again Pradeep, We are now on email number seven, so I am going to try to give you some good advice ... When you ask on a forum like this for help, it is very important to show people exactly what you did. Everything that you did. In the shortest possible way that demonstrates whatever issue you are facing. It is best to give us a recipe that we can follow exactly that shows every step that you do when you have the problem that you need help with. And the best way to do that is for you to learn how to cut and paste between where you run your problem code, and where you send your email message to us. Please observe the way that I communicated with you last time. I sent you an exact cut and paste from my terminal, to help you by allowing you to duplicate exactly every step that I made. You should communicate with us in the same way. Because when you write something like your most recent message > I got the error after matches.group(0) as follows: > AttributeError: NoneType object has no attribute 'group'. this tells us nothing useful!! Because we cannot see everything you did leading up to that, so we cannot reproduce your problem. For us to help you, you need to show all the steps, the same way I did. Now, to help you, I found the same old version of Python 2 that you have, to prove to you that it works on your version. So you talking about updating Python is not going to help. Instead, you need to work out what you are doing that is causing your problem. Again, I cut and paste my whole session to show you, see below. Notice that the top lines show that it is the same version that you have. If you cut and paste my commands into your Python then it should work the same way for you too. If it does not work for you, then SHOW US THE WHOLE SESSION, EVERY STEP, so that we can reproduce your problem. Run your python in a terminal, and copy and paste the output you get into your message. $ python Python 2.7.3 (default, Jun 20 2016, 16:18:47) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> mystr = "where is my-dog" >>> pattern = re.compile(r'my-dog$') >>> matches = re.search(pattern, mystr) >>> matches.group(0) 'my-dog' >>> I hope you realise that the re module has been used by thousands of programmers, for many years. So it's extremely unlikely that it "doesn't work" in a way that gets discovered by someone who hardly knows how to use it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Recursive method in class
On Wed, 2 Oct 2019 at 15:15, ast wrote: > Le 01/10/2019 à 20:56, Timur Tabi a écrit : > > Could you please fix your email software so that it shows a legitimate > > email address in the From: line? > I choose: ast.donotans...@gmail.com Hi ast, Please look here to see how your email looks on gmail: https://imgur.com/a/jqBNhLu This is how gmail shows you to everyone. gmail says: "ast uses a fake email address on our domain. It is a lie. So not trust him." The problem is that you use @gmail.com that is not owned by you and gmail tells the world about that. It makes you look bad. You should use .@invalid for this purpose. It will do what you want without making you look bad and annoying everyone that you try to talk with. -- https://mail.python.org/mailman/listinfo/python-list
Re: a &= b
On Fri, 4 Oct 2019 at 19:02, Hongyi Zhao wrote: > > Could you please give me some more hints on: > > a &= b $ python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> a = 15 >>> b = 3 >>> c = a & b >>> d = a >>> d &= b >>> for i in [a, b, c, d]: ... print('{:04b}'.format(i)) ... 0011 0011 0011 >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: Using Makefiles in Python projects
On Fri, 8 Nov 2019 at 09:43, Cameron Simpson wrote: [...] > _help: > @echo '_build: make $(py_static_bundle)' > @echo '_deploy_tip: formally deploy the current tip to the dev > host dev tree:' > @echo '_sync_dev: rsync the current working files into the dev > tip tree' [...] > Things to note: > > "Virtual targets" are actions rather than result files, and start with > an underscore. > > The default target is _help, which recites a description of the other > targets. Hi, as you might be aware, the above recipe will not be run if a file named '_help' exists. The Gnu make documentation term for what you call "virtual targets" is "phony targets", and it discusses them here: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets I would add the line: .PHONY: _help And similar for all the other phony targets. Doing this has other advantages as described in the linked docs. In particular, it saves 'make' wasting time searching for built-in implicit rules that might build these never-built targets. 'make -d' will reveal this. -- https://mail.python.org/mailman/listinfo/python-list
Re: insert data in python script
On Tue, 18 Feb 2020 at 20:45, alberto wrote: > Il giorno martedì 18 febbraio 2020 09:34:51 UTC+1, DL Neil ha scritto: > > > my code preos in one file preos.py > > > my commands are > > > > > > alberto@HENDRIX ~/PREOS $ python3.5 > > > Python 3.5.2 (default, Oct 8 2019, 13:06:37) > > > [GCC 5.4.0 20160609] on linux > > > Type "help", "copyright", "credits" or "license" for more information. > > import preos > > methane = Molecule("methane", -82.59 + 273.15, 45.99, 0.011) > > > Traceback (most recent call last): > > >File "", line 1, in > > > NameError: name 'Molecule' is not defined > honestly i don't understand what i have to do. $ python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print(digits) Traceback (most recent call last): File "", line 1, in NameError: name 'digits' is not defined >>> print(string.digits) Traceback (most recent call last): File "", line 1, in NameError: name 'string' is not defined >>> import string >>> print(digits) Traceback (most recent call last): File "", line 1, in NameError: name 'digits' is not defined >>> print(string.digits) 0123456789 >>> -- https://mail.python.org/mailman/listinfo/python-list
>> Unlimited Free Music Downloads ! <
Download Unlimited Free Music Click Here! -- http://mail.python.org/mailman/listinfo/python-list
Problem with py2exe
I am unable to use py2exe to create an executable, even on the simple sample that comes with the package. There seems to be a problem when it is copying files. The ‘build’ and ‘dist’ directories are created and populated, but there is no executable created. The error message says: setup.py returned exit code: can’t copy c:\Python24\Lib\sit I am running on Windows XP with distribution 2.4.2 and executing the setup.py from Pythonwin Build 204 I downloaded py2exe from sourceforge the version of py2exe for Python 2.4 Can anyone suggest what may be wrong? Thanks in advance David -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with py2exe
David wrote: > I am unable to use py2exe to create an executable, even on the simple > sample that comes with the package. There seems to be a problem when it > is copying files. The ‘build’ and ‘dist’ directories are created and > populated, but there is no executable created. The error message says: > > setup.py returned exit code: can’t copy c:\Python24\Lib\sit > > I am running on Windows XP with distribution 2.4.2 and executing the > setup.py from Pythonwin Build 204 > > I downloaded py2exe from sourceforge the version of py2exe for Python 2.4 > > Can anyone suggest what may be wrong? > > Thanks in advance > > David OK, I was a bit hasty in posting. I am now able to create the 'hello' executable, but am still puzzled. By going into the windows 'cmd' window and executing Python from the command line, the py2exe build is done properly. But when I do the execution of the setup.py from the Pythonwin prompt I get the failure originally reported. Is it possible to run py2exe from Pythonwin? David -- http://mail.python.org/mailman/listinfo/python-list
help with sending data out the parallel port
I'm wondering if python is capable of fairly precise timing and also sending data out the parallel port. For example ; making a 7.5 KHz square wave come out of one of the data pins on the printer port. I've tried to help myself with this one but searching in the "Python Library Reference" that installed with my version, [ Python 2.4.1. ] yielded nothing on the subject of either timing or parallel port. Id be thankful for any help. David KG2LI -- http://mail.python.org/mailman/listinfo/python-list
I am looking for some python script to compare two files
hi: The file can be PDF or Word format. Any help? thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking Python script to compare two files
Hello Tim: Thanks for your reply! I want to compare PDF-PDF files and WORD-WORD files. It seems that the right way is : First, extract text from PDF file or Word file. Then, use Difflib to compare these text files. Would you please give me some more information about the external diff tools? Thx! -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking Python script to compare two files
Hello Tim: One more thing: There some Python scripts that can extract text from PDF or WORD file? Thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking Python script to compare two files
Hello Tim: One more thing: There some Python scripts that can extract text from PDF or WORD file? Thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking Python script to compare two files
Hello Tim: One more thing: There some Python scripts that can extract text from PDF or WORD file? Thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking Python script to compare two files
Thanks for the quick replies! So if I want to use these tools: antiword,pdf2text, can I pack these tools and python script into a windows EXE file? I know there is open source tool which can pack python script and libs and generate the windows EXE file. Yes, this approach can't handle the pictures in the PDF/WORD file. There is a way to play around it? maybe it's very hard. Regards -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking Python script to compare two files
Thanks Tim! I will have a try,maybe this weekend and let you know the result. -- http://mail.python.org/mailman/listinfo/python-list
TypeError error on tkinter.createfilehandler dummy example
Hi, I'm getting the following error: Traceback (most recent call last): File "..\kk.py", line 37, in ? tkinter.createfilehandler(filex, tkinter.READABLE, _dispatch) TypeError: 'NoneType' object is not callable when executing this code on my Windows box: from Tkinter import * def _dispatch(self, *args): print "voila" filex = open('d:\\zz.txt', 'r') tkinter.createfilehandler(filex, tkinter.READABLE, _dispatch) Any ideas? What am I missing? I've been searching for something like this with no luck. I cannot imagine a simpler code for testing tkinter.createfilehandler functionality but it does not work :( TIA -- David Santiago -- http://mail.python.org/mailman/listinfo/python-list
Cgi scripts in apache not working
I've looked all over the place for an answer, and the only one I can find doesn't mean anything to me. The end of line issue with writting it in Windows and then uploading it doesn't help me since I'm doing this all from Linux. I've been trying to get python cgi scripts to work, and I always end up with a "Premature end of script headers" in the error log. The scripts are executable by all and my httpd.conf seems fine. I also tested it out in /var/www/cgi-bin/ and there it seems to work fine. test2.py: #!/usr/bin/python print "Content-type: text/html\n\n" print """ Hello World """ httpd.conf: << Tried it with "" and no "" Options ExecCGI << Tried with "Options +ExecCGI" AddHandler cgi-script .cgi .py << Tried with "SetHandler cgi-script", but still no go error_log: [Thu Jul 28 11:44:53 2005] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: test2.py suexec.log: [2005-07-28 11:44:53]: uid: (500/davidnoriega) gid: (500/500) cmd: test2.py [2005-07-28 11:44:53]: directory is writable by others: (/home/davidnoriega/public_html/cgi) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python classes for reading/writing/parsing MIDI files
On 20 November 2013 12:57, Steven D'Aprano wrote: > On Wed, 20 Nov 2013 10:32:08 +1000, alex23 wrote: >> >> They appear to be resurrecting a 12 year old thread. > > Wow, that's one slow News server. http://en.wikipedia.org/wiki/Slow_Movement :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 2.x and 3.x usage survey
On 1 January 2014 23:38, Steve Hayes wrote: > > I was thinking or of this: > python g:\work\module1.py > File "", line 1 > python g:\work\module1.py >^ > > Which gave a different error the previous time I did it. > > But, hey, it worked from the DOS prompt > > C:\Python32>python g:\work\module1.py > Hello Module World Your windows command shell prompt looks like this: "C:\Python32>" It indicates that windows shell is waiting for you to type something. It expects the first word you type to be an executable command. If you do this: C:\Python32>python g:\work\module1.py it tells the shell to run the python interpreter and feed it all the python statments contained in the file g:\work\module1.py If you do this: C:\Python32>python it tells the shell to run the python interpreter interactively, and wait for you to directly type python statements. When the python intepreter is ready for you to type a python statement, it gives you a ">>>" prompt. It expects you to type a valid python language statement. The reason this gave an error: >>> python g:\work\module1.py is because you are using the python interpreter as shown by ">>>", but you typed a windows shell command, not a python statement. -- https://mail.python.org/mailman/listinfo/python-list
setup.py install and compile errors
How does a setup script conditionally change what modules are installed based on version? Background: I have a python2.x/3.x module that puts 3.3-only code in submodules. When the module imports those submodules using an older python version, the compiler raises SyntaxErrors in the submodule which show as import errors in the module, get caught and ignored. The features in the submodule won't be available, but they wont stop the module from functioning. The problem syntax to be masked is the 'yield from' expression. Problem: Thie above works, resulting in a functioning module under a range of python versions, but older versions want to compile all .py modules as part of setup.py install, and that produces ugly install messages, with stack-traces. I would like to avoid the ugliness. I can add python code to setup.py, before the setup(...) call, but it is unclear what will be available to that code, at that time. I can test for whether setup.py is being run in install mode using "if 'install' in sys.argv:", and delete the offending .py submodules, but can I assume that the dir holding setup.py is the current dir during install? Does the MANIFEST need to be altered, also, to match the changed file collection? Alternatively, I could alter the MANIFEST.in to add 'prune..' statements, but is that file even used as part of install? -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On 1 February 2014 12:34, Chris Angelico wrote: > On Sat, Feb 1, 2014 at 12:14 PM, Scott W Dunning wrote: > >> Also, I think I found out through a little trial and error that I had two >> different hours, mins, and sec so I had to use one uppercase and one lower >> case. Is that frowned upon? And should I have come up with a different >> name instead? >> >> SECONDS = 1 >> MINUTES = 60 * SECONDS >> HOURS = 60 * MINUTES What is actually being defined here are constants to be used for scaling or conversion of some quantity (a time) into different units. So in this situation would I define the conversion constant with an upper case name like this: SECONDS_PER_MINUTE = 60 and I would use it like this seconds = minutes * SECONDS_PER_MINUTE where "seconds" and "minutes" are the names holding the numeric data. That line has the extra benefit that it is clear to me why the units are seconds on both sides of the equals sign (because on the right hand side the minute-units cancel thus: m*s/m=s), whereas this is much less clear to me in Scott's line. Scott's message quoted above did not reach me, only Chris's quote of it, so I say: Scott once you begin a discussion on a mailing list like this one, please make sure that every reply you make goes to "python-list@python.org" and not to the individual. That way we can all participate in the discussion, that is best for everyone especially you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with some python homework...
On 1 February 2014 14:17, David wrote: > > Scott's message quoted above did not reach me, only Chris's quote of > it, so I say: Scott once you begin a discussion on a mailing list like > this one, please make sure that every reply you make goes to > "python-list@python.org" and not to the individual. That way we can > all participate in the discussion, that is best for everyone > especially you. Please disregard the above paragraph Scott. Because 8 messages from you were just delivered to me, including that one, all via the list, some were 5 hours old. Sorry for any confusion I caused due to that delay. -- https://mail.python.org/mailman/listinfo/python-list
Re: Trailing zeros of 100!
On 2 January 2016 at 22:49, wrote: > Hi, newbie here! Hi Yehuda > I'm trying to write a python program to find how many trailing zeros are in > 100! (factorial of 100). > I used factorial from the math module, but my efforts to continue failed. > Please help. There is a special mailing list to help newbies write code: https://mail.python.org/mailman/listinfo/tutor Subscribe to that list and post whatever *code you have already written* there, and explain exactly how you want it to be better. -- https://mail.python.org/mailman/listinfo/python-list
Re: Geezer learns python
On 5 March 2014 10:03, notbob wrote: > > I'm trying to learn python. I'm doing it via Zed Shaw's Learn Python > the Hard Way. Sure enough, 16 lessons in and I've run aground. Is it > OK for a painfully stupid ol' fart to ask painfully stupid noob > questions, here? I'm a long time usenet fan and prefer it to irc. The python-tutor mailing list exists for precisely those kind of questions: https://mail.python.org/mailman/listinfo/tutor You might also find it interesting to browse/download previous messages in the archive at that link. See you there :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode Chars in Windows Path
On 4 April 2014 01:17, Chris Angelico wrote: > > -- Get info on all .pyc files in a directory and all its subdirectories -- > C:\>dir some_directory\*.pyc /s > $ ls -l `find some_directory -name \*.pyc` > > Except that the ls version there can't handle names with spaces in > them, so you need to faff around with null termination and stuff. Nooo, that stinks! There's no need to abuse 'find' like that, unless the version you have is truly ancient. Null termination is only necessary to pass 'find' results *via the shell*. Instead, ask 'find' to invoke the task itself. The simplest way is: find some_directory -name '*.pyc' -ls 'find' is the tool to use for *finding* things, not 'ls', which is intended for terminal display of directory information. If you require a particular feature of 'ls', or any other command, you can ask 'find' to invoke it directly (not via a shell): find some_directory -name '*.pyc' -exec ls -l {} \; 'Find' is widely under utilised and poorly understood because its command line syntax is extremely confusing compared to other tools, plus its documentation compounds the confusion. For anyone interested, I offer these key insights: Most important to understand is that the -name, -exec and -ls that I used above (for example) are *not* command-line "options". Even though they look like command-line options, they aren't. They are part of an *expression* in 'find' syntax. And the crucial difference is that the expression is order-dependent. So unlike most other commands, it is a mistake to put them in arbitrary order. Also annoyingly, the -exec syntax utilises characters that must be escaped from shell processing. This is more arcane knowledge that just frustrates people when they are in a rush to get something done. In fact, the only command-line *options* that 'find' takes are -H -L -P -D and -O, but these are rarely used. They come *before* the directory name(s). Everything that comes after the directory name is part of a 'find' expression. But, the most confusing thing of all, in the 'find' documentation, expressions are composed of tests, actions, and ... options! These so-called options are expression-options, not command-line-options. No wonder everyone's confused, when one word describes two similar-looking but behaviourally different things! So 'info find' must be read very carefully indeed. But it is worthwhile, because in the model of "do one thing and do it well", 'find' is the tool intended for such tasks, rather than expecting these capabilities to be built into all other command line utilities. I know this is off-topic but because I learn so much from the countless terrific contributions to this list from Chris (and others) with wide expertise, I am motivated to give something back when I can. And given that in the past I spent a little time and effort and eventually understood this, I summarise it here hoping it helps someone else. The unix-style tools are far more capable than the Microsoft shell when used as intended. There is good documentation on find at: http://mywiki.wooledge.org/UsingFind -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode Chars in Windows Path
On 4 April 2014 12:16, Chris Angelico wrote: > On Fri, Apr 4, 2014 at 11:15 AM, David wrote: >> On 4 April 2014 01:17, Chris Angelico wrote: >>> >>> -- Get info on all .pyc files in a directory and all its subdirectories -- >>> C:\>dir some_directory\*.pyc /s >>> $ ls -l `find some_directory -name \*.pyc` >>> >>> Except that the ls version there can't handle names with spaces in >>> them, so you need to faff around with null termination and stuff. >> >> Nooo, that stinks! There's no need to abuse 'find' like that, unless >> the version you have is truly ancient. Null termination is only >> necessary to pass 'find' results *via the shell*. Instead, ask 'find' >> to invoke the task itself. >> >> The simplest way is: >> >> find some_directory -name '*.pyc' -ls >> >> 'find' is the tool to use for *finding* things, not 'ls', which is >> intended for terminal display of directory information. > > I used ls only as a first example, and then picked up an extremely > common next example (deleting files). It so happens that find can > '-delete' its found files, but my point is that on DOS/Windows, every > command has to explicitly support subdirectories. If, instead, the > 'find' command has to explicitly support everything you might want to > do to files, that's even worse! So we need an execution form... > >> If you require a particular feature of 'ls', or any other command, you >> can ask 'find' to invoke it directly (not via a shell): >> >> find some_directory -name '*.pyc' -exec ls -l {} \; > > ... which this looks like, but it's not equivalent. > That will execute > 'ls -l' once for each file. You can tell, because the columns aren't > aligned; for anything more complicated than simply 'ls -l', you > potentially destroy any chance at bulk operations. Thanks for elaborating that point. But still ... > equivalent it *must* pass all the args to a single invocation of the > program. You need to instead use xargs if you want it to be > equivalent, and it's now getting to be quite an incantation: > > find some_directory -name \*.pyc -print0|xargs -0 ls -l > > And *that* is equivalent to the original, but it's way *way* longer > and less convenient, which was my point. If you are not already aware, it might interest you that 'find' in (GNU findutils) 4.4.2. has -- Action: -execdir command {} + This works as for `-execdir command ;', except that the `{}' at the end of the command is expanded to a list of names of matching files. This expansion is done in such a way as to avoid exceeding the maximum command line length available on the system. Only one `{}' is allowed within the command, and it must appear at the end, immediately before the `+'. A `+' appearing in any position other than immediately after `{}' is not considered to be special (that is, it does not terminate the command). I believe that achieves the goal, without involving the shell. It also has an -exec equivalent that works the same but has an unrelated security issue and not recommended. But if that '+' instead of ';' feature is not available on the target system, then as far as I am aware it would be necessary to use xargs as you say. Anyway, the two points I wished to contribute are: 1) It is preferable to avoid shell command substitutions (the backticks in the first example) and expansions where possible. 2) My observations on 'find' syntax, for anyone interested. Cheers, David -- https://mail.python.org/mailman/listinfo/python-list
Re: [tkinter] trouble running imported modules in main program
On 8 August 2013 14:06, snakeinmyboot wrote: > > for REAL you guys...wtf does this even mean lol. what is a boilerplate test > code? Did you try at all to find the answer to this yourself? I ask because it took me only a few seconds to go to wikipedia and search for "boilerplate" find this for you: http://en.wikipedia.org/wiki/Boilerplate_code Tip: To successfully use forums like this one (where a lot of very smart people read), the more care/effort/thought you demonstrate that you tried to solve your issue before asking, the more likely you are to receive a response. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On 9 August 2013 14:11, Adam Mercer wrote: > > I'm trying to write a script that writes some content to a file root > through sudo, but it's not working at all. I am using: [...] At a quick glance, I have a couple of suggestions. > command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] sudo doesn't work like this. It doesn't read from standard input. You need to supply the command as an argument to sudo. Get the sudo syntax correct by learning to use it in a shell (eg terminal running bash ) before trying to use it from python code. Also, I think that passing the pipe character '|' as an argument to Popen is not the correct way to use pipes. So, if you figure out how to use sudo without '|' you will solve both these issues. -- http://mail.python.org/mailman/listinfo/python-list
Re: [tkinter] trouble running imported modules in main program
On 9 August 2013 14:28, snakeinmyboot wrote: > On Thursday, August 8, 2013 1:13:48 AM UTC-4, David wrote: >> On 8 August 2013 14:06, snakeinmyboot wrote: >> >> Did you try at all to find the answer to this yourself? >> >> I ask because it took me only a few seconds to go to wikipedia and >> search for "boilerplate" find this for you: >> >> http://en.wikipedia.org/wiki/Boilerplate_code >> >> Tip: To successfully use forums like this one (where a lot of very >> smart people read), the more care/effort/thought you demonstrate that >> you tried to solve your issue before asking, the more likely you are >> to receive a response. > > I did read that article but I couldnt really figure out how to apply it to > the code he was giving as an example of making it "conditional". Did you try the research method I gave you in my previous answer? -- http://mail.python.org/mailman/listinfo/python-list
Re: Using sudo to write to a file as root from a script
On 9 August 2013 23:21, Adam Mercer wrote: > On Thu, Aug 8, 2013 at 11:47 PM, David wrote: > >> At a quick glance, I have a couple of suggestions. >> >>> command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] >> >> sudo doesn't work like this. It doesn't read from standard input. You >> need to supply the command as an argument to sudo. Get the sudo syntax >> correct by learning to use it in a shell (eg terminal running bash ) >> before trying to use it from python code. > > The above does works in the terminal: Ah, sorry, I didn't pay close attention to what you are doing (with tee). >> So, if you figure out how to use sudo without '|' you will solve both >> these issues. At least I wasn't 100% wrong :) Anyway I'm glad some smarter people helped you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Encapsulation unpythonic?
On 17 August 2013 22:26, wrote: > > 1) Is there a good text where I can read about the language philosophy? What > practices are "pythonic" or "unpythonic"? > > 2) If it is in fact true that encapsulation is rarely used, how do I deal > with the fact that other programmers can easily alter the values of members > of my classes? Try this: http://dirtsimple.org/2004/12/python-is-not-java.html -- http://mail.python.org/mailman/listinfo/python-list
Re: New VPS Provider needed
On 27 August 2013 17:13, Νικόλαος wrote: > > I know this isn't the place to ask Νικόλαος is 100% correct about this. So, this list is also not the correct place to answer. So please everyone, do not respond. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Good Python Book
On 9 October 2013 23:55, Schneider wrote: > > I'm looking for a good advanced python book. Most books I looked at up to > now are on beginners level. > I don't need a reference (that's online) or a book explaining how to use the > interpreter or how to use list comprehensions on the one side and skipping > topics like decorators, metaclasses on the other side. > > any suggestions? https://wiki.python.org/moin/AdvancedBooks -- https://mail.python.org/mailman/listinfo/python-list
Re: Complex literals (was Re: I am never going to complain about Python again)
On 11 October 2013 00:25, Chris Angelico wrote: > On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: > > I've never been well-up on complex numbers; can you elaborate on this, > please? All I know is that I was taught that the square root of -1 is > called i, and that hypercomplex numbers include i, j, k, and maybe > even other terms, and I never understood where j comes from. Why is > Python better for using j? Pretty well covered here: http://en.wikipedia.org/wiki/Complex_number Plus, the simple overview is that they are useful because they are two-dimensional, and so can be used to simply calculations involving two-dimensional quantities. Very useful for electrical engineers who use them to represent the two dimensions of amplitude,phase in Fourier or Laplace circuit analysis. As others have pointed out, they use the symbol j for the square root of -1 to avoid confusion with the symbol i used for current. I have never heard the term "hypercomplex" numbers. I guess you are referring to vectors with more dimensions than two. A three dimensional vector is described as having components in i,j,k directions. Although this is very like an extension of complex numbers into higher dimensions, the symbols used (i,j,k) are not the same as the i or j used for complex numbers. Instead they represent orthogonal unit vectors; which are similar in concept (because real and imaginary components of complex numbers are orthogonal), but not the *same*. So don't think of the i *or* j of a complex number being related to the i *and* j etc components of a vector. These are useful for example to describe three dimensional space, and scalar or vector functions in that space. -- https://mail.python.org/mailman/listinfo/python-list
Re: Complex literals (was Re: I am never going to complain about Python again)
On 11 October 2013 06:29, Oscar Benjamin wrote: > > I learned to use i for sqrt(-1) while studying theoretical physics. > When I later found myself teaching maths to engineers I asked why j > was used and was given this explanation. I'm still unconvinced by it > though. Please don't be. We need different symbols to distinguish between so many different aspects of current (average, dynamic, instantaneous, rms, peak, sinusoidal-amplitude, sinusoidal-phasor) that we use up all possible variations of bold, italic, subscript just to distinguish those different aspects of i. It gets confusing enough as it is, because typically we are describing many current variables (in one or more of the above aspects) simultaneously, not just one. And the same holds for current density, but less common. That's why we prefer j for sqrt(-1), not because we are unconvincing :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Complex literals (was Re: I am never going to complain about Python again)
On 11 October 2013 12:27, Steven D'Aprano wrote: > On Fri, 11 Oct 2013 00:25:27 +1100, Chris Angelico wrote: > >> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: >>> BTW, one of the earliest things that turned me on to Python was when I >>> discovered that it uses j as the imaginary unit, not i. All >>> right-thinking people will agree with me on this. >> >> I've never been well-up on complex numbers; can you elaborate on this, >> please? All I know is that I was taught that the square root of -1 is >> called i, and that hypercomplex numbers include i, j, k, and maybe even >> other terms, and I never understood where j comes from. Why is Python >> better for using j? > > Being simple souls and not Real Mathematicians, electrical engineers get > confused by the similarity between I (current) and i (square root of -1), > so they used j instead. [...] > No, electrical engineers need many symbols for current for the same reason that eskimos need many words for snow :) [*] [*] https://en.wikipedia.org/wiki/Eskimo_words_for_snow -- https://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.x ever become the actual standard?
On 23 October 2013 22:57, wrote: > > a LARGE number of Python programmers has not even bothered learning version > 3.x. OMG. Please provide their names. We'll send Doug & Dinsdale. -- https://mail.python.org/mailman/listinfo/python-list
Running Python programmes
I am an absolute beginner and am working through the book Python Programming for the Absolute Beginner by Michael Dawson. Everything is fine except if I run a scripted programme, or one I have downloaded, and then run another one, the second one will not run, I just get the >>> in the interactive window. I have to exit Python and start again, when the second programme then runs fine. Any suggestions much appreciated. David -- https://mail.python.org/mailman/listinfo/python-list
Re: Question on Manipulating List and on Python
> word1=line_word[0] > if word1==001: You are comparing a string and an integer assuming you are reading a text file. integers word1=int(line_word[0]) if word1=1: strings word1=line_word[0] if word1=="001:" -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
linuxfreak wrote: > Which is a better python IDE SPE or WingIDE in terms of features > You might want to look at a review of Python IDEs at http://spyced.blogspot.com/2005/09/review-of-6-python-ides.html david lees -- http://mail.python.org/mailman/listinfo/python-list
Socket programming design problem
After programming with Python for a few hours, I've come up with some code: http://p.shurl.net/3n. However, now I've realised there's a bit of a problem with the original design. I have a number of questions, if anybody could answer I'd be grateful. a) Big problem, I can't see how to receive from more than one socket at once. I need to do this so that data from the TCP connection can be sent out on the UDP one and vice versa. Do I need a thread for each, or is there some other way I can listen on two sockets at once (maybe non-blocking ones?) b) If the script dies prematurely, e.g. I mistyped something and Python throws an exception, it is caught by the generic handler at the bottom. However, the socket does not seem to be cleaned up properly, as if I try to run it again immediately I get an error that it is still in use. lsof doesn't show it in use though, which seems weird. Is there any particular reason for this? Thanks, David -- http://mail.python.org/mailman/listinfo/python-list
Display of JPEG images from Python
I would like to display a JPEG image from Python on a Windows machine. I Googled 'python jpeg display' and have not found what I am looking for, which is code I can call directly and pass the image. I see the PIL library lets me do all sorts of image manipulation, but is there a convenient way to display results? I guess I could issue shell commands to a graphics display package such as IrfanView, but I thought there might be a cleaner method. david lees -- http://mail.python.org/mailman/listinfo/python-list
Re: Display of JPEG images from Python
Svien and Michel, Thanks for your help. Much appreciated. David Lees -- http://mail.python.org/mailman/listinfo/python-list
About iServicePro
iServicePro is an innovative approach to offering affordable tools for Java and J2EE developers. in particular, we are a professional team for applying oneself to develop and integrate eclipse plug-in for user applications. Our mission now is to deliver business value and to maximize developers' productivity by consistently delivering reliable products and a true end-to-end seamless J2EE development environment. iServicePro is the eclipse plug-in solution for all your UML, Web, J2EE, JSP, XML, Struts, JSF, Hibernate and application server integration needs. We are committed to the success of your trial. If you need to see a demonstration of Data Service or need assistance during the trial process, please do not hesitate to contact us. www.iservicepro.com -- http://mail.python.org/mailman/listinfo/python-list
Re: matrix Multiplication
Il 18 Oct 2006 04:17:29 -0700, Sssasss ha scritto: > hi evrybody! > > I wan't to multiply two square matrixes, and i don't understand why it > doesn't work. Can I suggest a little bit less cumbersome algorithm? def multmat2(A,B): "A*B" if len(A)!=len(B): return "error" # this check is not enough! n = range(len(A)) C = [] for i in n: C.append([0]*len(A)) # add a row to C for j in n: a = A[i]# get row i from A b = [row[j] for row in B] # get col j from B C[i][j] = sum([x*y for x,y in zip(a,b)]) return C regards D. -- http://mail.python.org/mailman/listinfo/python-list
Re: python to sharepoint ?
You might want to check out IronPython: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython It's a port of the .NET FW for Python, which probably exposes the API you'll need. -David curtin wrote: > anyone have code that allows me to post files direct to sharepoint from > python? > > any pointers, FAQ, etc, appreciated! > > thanks, > > craig -- http://mail.python.org/mailman/listinfo/python-list
wxPython: StaticText Event
Plaese look at this simple class. import wx class MyFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, "Hide test", size=(160,160)) # create widgets self.pnl = wx.Panel(self) self.st = wx.StaticText(self.pnl, -1, "Static Text Control", pos=(30,20)) self.tc = wx.TextCtrl(self.pnl, -1, pos=(30,100)) self.Layout() # Binding self.st.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterStArea) self.tc.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterTcArea) def OnEnterStArea(self, event): print "Mouse entering in STATIC text control area" def OnEnterTcArea(self, event): print "Mouse entering in text control area" app = wx.PySimpleApp() frame = MyFrame(None, -1) frame.Show() app.MainLoop() Hovering mouse over the StaticText Control should generate an EVT_ENTER_WINDOW event like the TextCtrl Control, but it does not happen. How can I make the StaticText event working? thank you David -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython: StaticText Event
Il Fri, 08 Sep 2006 10:24:52 +1000, John McMonagle ha scritto: > If you want to create static text that responds to mouse events, try > using the wx.lib.stattext.GenStaticText class. > > Add the following import: > > import wx.lib.stattext > > Then, > > self.st = wx.lib.stattext.GenStaticText(self.pnl, -1, 'Static Text > Control', pos=(30,20)) Thankyou very much! Best regards, David -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython: StaticText Event
Il Fri, 08 Sep 2006 02:32:41 +0200, Amaury Forgeot d'Arc ha scritto: > I quick Google search found the following thread: > > http://lists.wxwidgets.org/archive/wx-users/msg31855.html > or > http://lists.wxwidgets.org/archive/wx-users/msg31983.html > > It suggest that you use another kind of control instead. > Is a disabled TextCtrl acceptable? > > Hope this helps, Yes, it does! Thankyou! Best regards David -- http://mail.python.org/mailman/listinfo/python-list
wxPython, how to autoresize a frame?
Dear all, In a wxPyhton frame I make a group of controls hiding by pressing a button and i want the whole frame to resize accordingly. The test GUI I wrote is structured like this: frame | +-sizer0 (BoxSizer, 1 slot) | +-panel (style=wx.EXPAND) | +-sizer1 (BoxSizer vertical, 2 slots) | +-sizer2 (FlexGridSizer, 2x2) | | | +-controls to hide | +-button The problem is that, when sizer2 containig hidden controls collapses to zero dimensions, the panel resizes, but sizer1 and sizer0 don't! Consequently the frame does not want to autoresize. You con dowload the code here: http://www.box.net/public/evfxs7cp5j Someone con help me? Thanks David -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython, how to autoresize a frame?
Il Sun, 10 Sep 2006 19:15:40 +0200, David ha scritto: > The problem is that, when sizer2 containig hidden controls collapses to > zero dimensions, the panel resizes, but sizer1 and sizer0 don't! > Consequently the frame does not want to autoresize. > > You con dowload the code here: > http://www.box.net/public/evfxs7cp5j > > Someone con help me? Best help came from mysef: the problem was in .SetSizeHints() statement that prevented resizind of objects. D. -- R: Perche' incasina l'ordine con cui la gente normalmente legge un messaggio D: Perche' quotare sotto da' cosi' fastidio? R: Quotare sotto. D: Qual e' la cosa piu' seccante su usenet e in e-mail? -- http://mail.python.org/mailman/listinfo/python-list
How can I get the function's caller?
Inside a function I need to get the function's caller's name. How can I get it? thanks in advance. David -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
Il Wed, 13 Sep 2006 07:34:45 +0100, Steve Holden ha scritto: > What do you need this name for, just as a materr of interest? There are > ways of manipulating the stack frames, but they'll be slow and possibly > unreliable. I am writing a big (for me) program and it would be helpful to have a dummy function like this: def function_A_subfunction_B(self, ) dummy() that display a standard message like this: "Dummy: 'function_A_subfunction_B' in module 'module' is not defined yet" regards David -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
Il 13 Sep 2006 00:31:47 -0700, John Machin ha scritto: > David wrote: >> Inside a function I need to get the function's caller's name. How can I get >> it? >> > > Check out the thread "__LINE__ and __FILE__ functionality in Python?" > (messages posted 2006-0813). I'll check thankyou! Traffic in this NG is so high that is difficult to stay uptodate. David. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the function's caller?
Il Thu, 14 Sep 2006 13:37:24 +0200, Fredrik Lundh ha scritto: [...] > in Python. Thanks to all of you! David -- http://mail.python.org/mailman/listinfo/python-list
Reference to base namespace in a class.
Hi, I'm working on a project where we're juggling with two potential implementations. In the two scenarios, we create objects in the base namespace. These objects are interdependent, in the sense that to compute something, they have to look up the value of the other objects (their parents). The objects are functions, by the way, with some additional attributes. In the first scenario, as the objects are created, they immediately share references and can call each other's value. All these objects are then referenced in a class that defines some methods accessing those objects. The advantage is that you can call the functions from the base namespace and they'll know where to look to make the computations. The downsize is that if you delete one object by mistake, nothing works anymore, that is, the methods from the class will no longer reference the right objects. In the second scenario, as the objects are created, they only know the name of their parents, and don't have their actual reference. To compute something, we have to pass the values of the other objects explicitely. A class is then instantiated, where we look up the __main__ dictionary for the names of the parents given by each function, copy the objects inside the class, create an attribute for each object on the fly and link the objects together using the parents names. The advantage is that even if an object in the base namespace is destroyed, the class methods will still work since the references are all internal to the class instance. The disadvantage is that the objects in the base namespace are dummy objects, ie they don't speak to each other. I guess it's hard to understand the context from this quick description, but the code would look equally opaque. Here is an attempt to put that into a simple question: Are there counter indications to reference objects in the base namespace from a class ? Thanks for your help. David Huard -- http://mail.python.org/mailman/listinfo/python-list
Are there memory limits for external C modules?
I've been working on an external C module for Python in order to use some of the functionality from Ethereal. Right now I'm getting segfaults originating from within the Ethereal source code, but the same code works fine when used normally (i.e. through Ethereal or Tethereal). I'm wondering if there's some sort of memory limitation the Python interpreter imposes on the C code it calls that I might be running into, and if so, any ways to increase it? Thanks, David -- http://mail.python.org/mailman/listinfo/python-list
Authenticating to Kerberos
Hi, I've had a quick look but cannot find a module that will let me authenticate against Kerberos. There appears to be a krb5 module that hasn't been updated for a long time and I can't find much on it except the pages at starship.python.net. I don't need to do anything except authenticate and gain the correct credentials. Are there any modules that I could use to authenticate against Kerberos (perhaps there is another module will do just the auth, e.g. for LDAP?). Cheers. -- http://mail.python.org/mailman/listinfo/python-list