[ANN] Leipzig Python User Group - Meeting, December 11 2012, 08:00 p.m.
=== Leipzig Python User Group === We will meet on Tuesday, December 11 at 8:00 p.m. at the training center of Python Academy in Leipzig, Germany ( http://www.python-academy.com/center/find.html ). Our main subjects this time are concurrency and parallelism. Everybody who uses Python, plans to do so or is interested in learning more about the language is encouraged to participate. While the meeting language will be mainly German, we will provide English translation if needed. Food and soft drinks are provided. Please send a short confirmation mail to i...@python-academy.de, so we can prepare appropriately. Current information about the meetings are at http://www.python-academy.com/user-group . Stefan == Leipzig Python User Group === Wir treffen uns am Dienstag, 11.12.2012 um 20:00 Uhr im Schulungszentrum der Python Academy in Leipzig ( http://www.python-academy.de/Schulungszentrum/anfahrt.html ). Diesmal haben wir die Schwerpunkte Nebenläufigkeit und Parallelisierung. Willkommen ist jeder, der Interesse an Python hat, die Sprache bereits nutzt oder nutzen möchte. Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter i...@python-academy.de wäre nett, damit wir genug Essen besorgen können. Aktuelle Informationen zu den Treffen sind unter http://www.python-academy.de/User-Group zu finden. Viele Grüße Stefan -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: A question about readability
- Original Message - On Dec 7, 6:46 pm, Marco name.surn...@gmail.com wrote: Hi all, do you think this code: $ more myscript.py for line in open('data.txt'): result = sum(int(data) for data in line.split(';')) print(result) that sums the elements of the lines of this file: $ more data.txt 30;44;99;88 11;17;16;50 33;91;77;15 $ python3.3 myscript.py 261 94 216 is explicit enough? Do you prefer a clearer solution? Thanks in advance, Marco -- Marco Interpreting your question as a general question of stylistics, my experience is that a 3 line script often becomes a 10 line or a 50 line script at which point the direct printing will have to be modified to create an internal data structure. So on the whole I find it expedient to start with that assumption and write it as: def linesums(file): return [sum(int(i) for i in l.split(';')) for l in open(file, 'r')] Why change the OP's namings ? 'data' and 'line' were more suitable than 'i' and 'l'. Of course we're nitpicking, no one will get hurt. JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about readability
On Dec 10, 3:03 pm, Jean-Michel Pichavant jeanmic...@sequans.com wrote: - Original Message - On Dec 7, 6:46 pm, Marco name.surn...@gmail.com wrote: Hi all, do you think this code: $ more myscript.py for line in open('data.txt'): result = sum(int(data) for data in line.split(';')) print(result) that sums the elements of the lines of this file: $ more data.txt 30;44;99;88 11;17;16;50 33;91;77;15 $ python3.3 myscript.py 261 94 216 is explicit enough? Do you prefer a clearer solution? Thanks in advance, Marco -- Marco Interpreting your question as a general question of stylistics, my experience is that a 3 line script often becomes a 10 line or a 50 line script at which point the direct printing will have to be modified to create an internal data structure. So on the whole I find it expedient to start with that assumption and write it as: def linesums(file): return [sum(int(i) for i in l.split(';')) for l in open(file, 'r')] Why change the OP's namings ? 'data' and 'line' were more suitable than 'i' and 'l'. Of course we're nitpicking, no one will get hurt. JM Yes, l is an undesirable name because it can look like 1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Noob Question.
Am 05.12.2012 21:24, schrieb Owatch: Thanks a TON for your answer thought, this is exactly what I really hoped for. The problem for me is that I don't actually know anything about writing a function that opens a network socket, and connects to that plugin und asks it for the information you require. That plugin should have some documentation which should tell you something about how to connect to it and how to request information. When you know that you can turn to the python documentation and find out how to do this in python. That's all really beyond me, all I can do is what I did so far, which is make it ask for your temperature value, and then test it to see if its an integer Then (I added this for testing) It asks for any temperature value. And if it exceeds the given limit, it rings an alarm. Until it freezes and becomes unresponsive :D If you have specific problems with code you have written, try to build up a minimal working example that shows the problem plus any error messages/exceptions/stack traces you get back. We might be able to help you with your code. I don't know how to make it 'query' or grab values constantly, if you don't mind my potentially incorrect terminology. This is typically done with some kind of loop, e.g. run = True while run: #do something repeatedly and do run = False if you want to stop pass Greetings Alexander -- http://mail.python.org/mailman/listinfo/python-list
Dropbox Hires Away Google’s Guido Van Rossum
http://techcrunch.com/2012/12/07/dropbox-guido-van-rossum-python/ -- http://mail.python.org/mailman/listinfo/python-list
why the conut( ) can not get the number?
i wnat to get the number of a atrributes in a xpath,here is my code,why i can not get the number ? import urllib import lxml.html down=http://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html; file=urllib.urlopen(down).read() root=lxml.html.document_fromstring(file) for order,node in enumerate(root.xpath('//li[@class=toctree-l1]')): print order,node.xpath('.//a[count(*)]')-- http://mail.python.org/mailman/listinfo/python-list
Re: why the conut( ) can not get the number?
水静流深 wrote: i wnat to get the number of a atrributes in a xpath,here is my code,why i can not get the number ? import urllib import lxml.html down=http://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html; file=urllib.urlopen(down).read() root=lxml.html.document_fromstring(file) for order,node in enumerate(root.xpath('//li[@class=toctree-l1]')): print order,node.xpath('.//a[count(*)]') This looks more like an xpath than a python problem. I'm no xpath expert -- and you don't describe the expected outcome -- maybe you want print order, node.xpath(count(.//a)) -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with usbtmc-communication
On 7 dec, 14:46, Jean Dubois jeandubois...@gmail.com wrote: On 6 dec, 21:15, w...@mac.com wrote: On Dec 6, 2012, at 2:41 PM, Jean Dubois jeandubois...@gmail.com wrote: On 6 dec, 15:50, w...@mac.com wrote: On Dec 6, 2012, at 8:50 AM, Jean Dubois jeandubois...@gmail.com wrote: [byte] It seems there is some misunderstanding here. What I meant with how to do the equivalent in Python refered to reading characters rather than lines. I have written working code myself for another Keithleu which does use RS232 for communication. The problem now is specifically for the new Keithley which doesn't allow RS232 but only USB-communication over usbtmc. So if the buffer-problem could be changed by reading characters that would be great. regards, Jean -- http://mail.python.org/mailman/listinfo/python-list Sorry about the misunderstanding (and subsequent waste of bandwidth). However, if you will look at the serial reads and writes in that handler, you will see that it does things like serial.read(n) where n is an explicit number, the number of bytes to be read from the serial buffer. -Bill I tried changing measurementcurr=usbkeith.readline() to measurementcurr=usbkeith.read(1) but this leads to trouble with theusbtmc-thing: Measured current 1: Traceback (most recent call last): File ./keith2200rev2.py, line 26, in module measurementvolt=usbkeith.read(1) IOError: [Errno 110] Connection timed out and hereafter I need to restart the Keithley...:-( regards, Jean -- http://mail.python.org/mailman/listinfo/python-list Several comments: 1) I can't be sure, but that would seem to be asking the Keithley to be providing 10,000 readings. I don't know about the GPIB bus (which thisUSBTMClibrary seems to be trying to emulate), but most serial devices expect to provide one answer per read-write handshake. That is, you send one read command and get one answer back. That answer may contain several bytes, but I'd be surprised it it contained 10,000. The typical cycle is something like send-an-initialize, read-status, send-mode-set-up, read-status, send trigger command, read-answer… lather and repeat. (Or some logical equivalent of all that). On the assumption that theUSBTMCAPI handles most of that, I'd try usbkeith.read(n) where n is the number of decimal digits you expect to get back plus sign. 1 wasn't a good guess indeed - 2) I took a quick look at the Keithley and National Instruments web sites (where the documentation is at best, VERY poorly indexed and hard to search for). USBTMC*appears* to be a software layer designed to allow newer Tektronix and Keithley instruments to be driven using older software that drove GPIB equipment. To make matters worse, if I'm reading it right (I didn't study in detail) it appears to ALSO be providing a GPIB-like API to Windows versions of National Instruments LabView. 3) If I understand what you are trying to do, you want to go straight from python to the Keithley USB port, without detouring (USB-to-GPIB and GPIB back to USB). Yes indeed, that's exactly what I want 4) I did find (but did not try to read in detail) the following link: http://www.ni.com/white-paper/4478/en which documents direct USB control of instruments. The python serial library provides quite transparent control of reading and writing to the USB interface. Maybe following this link will get you going. Thanks for the link, but as you can see there they want to push NI- VISA forward as the solution, which under Linux means more complexity and surely isn't as simple to install as they claim, so if possible I'd avoid ni-visa. I'll experiment further Monday with read() and keep you informed regards, Jean I changed the program as below an experimentally found out I have to use an number of characters between 11 and 4095 I doesn't seem to make any difference which value I choose in that interval, however the results are as follows: 0.0077219 0.0295029; this is rubbish 0.0249596 0.261837; this should have been the first data pair 0.0499763 0.516741; this should have been the 2nd data pair 0.0750685 0.767388; this should have been the 3rd data pair 4th data pair is missing As you can see this approach suffers from the same buffer problem as the approach with readline did. One now good argue as a workaround: get rid of the first data pair and add an extra measure command for the missing data pair, however this still does not explain why this problem is there in Python and not in Octave and I also fear I'll get more trouble when sending combined commands e.g. such as that to create a staircase current So my question is, how to modify the Python-code such that the first data pair is indeed the first data pair thanks, jean Here follows the new code: #!/usr/bin/python
Re: The Zen of Zope, by Alex Clark
On 2012-12-10 04:24:00 +, Steven D'Aprano said: On Sun, 09 Dec 2012 20:13:43 -0500, Alex Clark wrote: import other The Zen of Zope, by Alex Clark I expect that I would find that hilarious if I knew anything about Zope :) Well, you are in luck! Because it's a tutorial too: https://github.com/aclark4life/other/blob/master/other.py :-) -- Alex Clark · https://www.gittip.com/aclark4life/ -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with usbtmc-communication
On Dec 10, 2012, at 8:31 AM, Jean Dubois jeandubois...@gmail.com wrote: [byte] As you can see this approach suffers from the same buffer problem as the approach with readline did. One now good argue as a workaround: get rid of the first data pair and add an extra measure command for the missing data pair, however this still does not explain why this problem is there in Python and not in Octave and I also fear I'll get more trouble when sending combined commands e.g. such as that to create a staircase current So my question is, how to modify the Python-code such that the first data pair is indeed the first data pair thanks, jean Here follows the new code: #!/usr/bin/python import time import os import sys measurementcurr='' measurementvolt='' timesleepdefault=5 print Enter a numofchar (11 =numchar =4095):, numofchar = int(raw_input()) filename ='mydata.txt' usbkeith = open('/dev/usbtmc1','r+') usbkeith.flush() usbkeith.write(*IDN?\n) It seems like a real leap of faith to be opening /dev/usbtmc1 as though it were a file-oriented device. I've never heard of ANY instrument interface implemented this way. Where did you see example code that did that. Have you tried to access /dev/usbtmc1 as though it were a serial device? #strip blank line: identification=usbkeith.readline().strip() print 'Found device: ',identification usbkeith.write(SYST:REM + \n) usbkeith.write(:SENS:VOLT:PROT 1.5\n) keithdata = open(filename,'w') usbkeith.write(:OUTP:STAT ON\n) for number, current_in in enumerate(('0.025', '0.050', '0.075', '0.100'), 1): usbkeith.write(:SOUR:CURR %s\n % current_in) time.sleep(timesleepdefault) usbkeith.write(:MEAS:CURR?\n) measurementcurr=usbkeith.read(numofchar) print 'Measured current %d: ' % number, measurementcurr usbkeith.write(:MEAS:VOLT?\n) measurementvolt=usbkeith.read(numofchar) print 'Measured voltage %d: ' % number, measurementvolt keithdata.write(measurementcurr.strip()+' '+measurementvolt) usbkeith.write(:OUTP:STAT OFF\n) print Goodbye, data logged in file: print filename usbkeith.close() keithdata.close() -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: using smtp sent large file upto 60MB
On 12月5日, 下午11時01分, Michael Torrie torr...@gmail.com wrote: On 12/04/2012 05:54 PM, moonhkt wrote: Our SMTP can send file more than 60MB. But our notes server can configured 100MB,30MB or 10MB. My notes Mail box can receive 100MB. In UNIX, by below command send smtp mail. uuencode $xfn $xfn | mail -s $SUBJECT $NAME Just continue to use this set of commands. You can use the subprocess module to interact with these programs. OK. Will try using subprocess. -- http://mail.python.org/mailman/listinfo/python-list
About open file for Read
Hi All I am new in Python. When using open and then for line in f . Does it read all the data into f object ? or read line by line ? f=open(file, 'r') for line in f: if userstring in line: print file: + os.path.join(root,file) break f.close() moonhk -- http://mail.python.org/mailman/listinfo/python-list
Re: forking and avoiding zombies!
On 12/10/2012 12:42 PM, andrea crotti wrote: So I implemented a simple decorator to run a function in a forked process, as below. It works well but the problem is that the childs end up as zombies on one machine, while strangely I can't reproduce the same on mine.. I know that this is not the perfect method to spawn a daemon, but I also wanted to keep the code as simple as possible since other people will maintain it.. What is the easiest solution to avoid the creation of zombies and maintain this functionality? thanks def on_forked_process(func): from os import fork Decorator that forks the process, runs the function and gives back control to the main process def _on_forked_process(*args, **kwargs): pid = fork() if pid == 0: func(*args, **kwargs) _exit(0) else: return pid return _on_forked_process Ou. yo need to use something more advanced. This is the code from book ('Unix Network Programing' - the python implementation) import sys, os def daemonize (stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): # Perform first fork. try: pid = os.fork( ) if pid 0: sys.exit(0) # Exit first parent. except OSError, e: sys.stderr.write(fork #1 failed: (%d) %s\n % (e.errno, e.strerror)) sys.exit(1) # Decouple from parent environment. os.chdir(/) os.umask(0) os.setsid( ) # Perform second fork. try: pid = os.fork( ) if pid 0: sys.exit(0) # Exit second parent. except OSError, e: sys.stderr.write(fork #2 failed: (%d) %s\n % (e.errno, e.strerror)) sys.exit(1) # The process is now daemonized, redirect standard file descriptors. for f in sys.stdout, sys.stderr: f.flush( ) si = file(stdin, 'r') so = file(stdout, 'a+') se = file(stderr, 'a+', 0) os.dup2(si.fileno( ), sys.stdin.fileno( )) os.dup2(so.fileno( ), sys.stdout.fileno( )) os.dup2(se.fileno( ), sys.stderr.fileno( )) Put this file and named daemon.py, then just for your program by calling import this file. Like this. from daemon import daemonize def main(): while True: print 'I'm Alive :)' if __name__ == '__main__': daemonize(stdout='/var/log/run_time.log', stderr='/var/log/error.log') main() -- http://mail.python.org/mailman/listinfo/python-list
Re: About open file for Read
On 12/10/2012 11:36 AM, moonhkt wrote: Hi All I am new in Python. When using open and then for line in f . Does it read all the data into f object ? or read line by line ? f=open(file, 'r') for line in f: if userstring in line: print file: + os.path.join(root,file) break f.close() moonhk open() does not read the whole file into any object. There is buffering that goes on in the C libraries that open() calls, but that should be transparent to you for regular files. When you ask for a line, it'll read enough to fulfill that request, and maybe some extra that'll get held somewhere in the C runtime library. You should look into the 'with' statement, to avoid that f.close(). That way the file will be closed, regardless of whether you get an exception or not. http://docs.python.org/2/reference/compound_stmts.html#index-15 with open(file,. r) as f: for line in f: etc. BTW, since you're in version 2.x, you should avoid hiding the builtin file object. Call it something like file_name, or infile_name. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: About open file for Read
Dave Angel wrote: On 12/10/2012 11:36 AM, moonhkt wrote: Hi All I am new in Python. When using open and then for line in f . Does it read all the data into f object ? or read line by line ? f=open(file, 'r') for line in f: if userstring in line: print file: + os.path.join(root,file) break f.close() moonhk open() does not read the whole file into any object. There is buffering that goes on in the C libraries that open() calls, but that should be transparent to you for regular files. When you ask for a line, it'll read enough to fulfill that request, and maybe some extra that'll get held somewhere in the C runtime library. You should look into the 'with' statement, to avoid that f.close(). That way the file will be closed, regardless of whether you get an exception or not. http://docs.python.org/2/reference/compound_stmts.html#index-15 with open(file,. r) as f: for line in f: etc. BTW, since you're in version 2.x, you should avoid hiding the builtin file object. Call it something like file_name, or infile_name. Python does a bit of buffering on its own (which is why you cannot mix file iteration and .readline() calls): with open(tmp.txt, w) as f: f.writelines(%s\n % i for i in range(10**6)) ... f = open(tmp.txt) f.readline() '0\n' f.tell() 2 f.readline() '1\n' f.tell() 4 next(f) # a for-loop does this implicitly '2\n' f.tell() 8196 # after a next() call or the first loop iteration # part of the file is now in a buffer. f.readline() Traceback (most recent call last): File stdin, line 1, in module ValueError: Mixing iteration and read methods would lose data f.seek(0, 2) f.tell() 690 This is Python 2, in Python 3 f.tell() would fail after a next(f) call, but f.readline() continues to work. -- http://mail.python.org/mailman/listinfo/python-list
accessing an OLE Automation (IDispatch) server from python which requires the use of out params
I have an existing Windows application which provides an OLE Automation (IDispatch) interface. I'm not able to change that interface. I'd like to call it from a scripting language. I figure this would provide a nice quick way to invoke on the app. I initially tried this with Windows Powershell but ran into the following problem. I was able to create the object and invoke simple methods on it. However the interface for this app has methods which take out params. i.e. you pass in a reference to a variable and the server fills in the value. I couldn't get that to work. I finally gave up and decided it was just a limitation of Powershell, not being able to work with those out params. My next thought was to do it in python. I've been reading up on python and I've found a decent amount of into out there on doing OLE and I'm optimistic. But, I thought that I'd ask the question before digging too much farther into it... When calling an OLE Automation (IDispatch) server from python can I make use of out params defined by the interface? To get more specific, here's an example from the server's IDL for one of its methods. [id(15), helpstring(method GetSettingValue)] VARIANT_BOOL GetSettingValue(BSTR settingName, BSTR* settingValue); As you can see, you have to pass in an out param for settingValue. The server fills this in for you. And this is what I couldn't get to work in Powershell. Anyone know whether or not OLE from python will allow passing in out params? Do you think this will work? -- http://mail.python.org/mailman/listinfo/python-list
Re: Using poplib to parse headers - Thank You All!
Hello Jean-Claude! Thank you for your post, it helped me a lot! I'm not too new to Python but still struggling to make use of that great language's features. I haven't tested it but since you are interested in syntactic subtleties, I think you can save one iterator (k): for j in popconnection.retr( i+1): if type( j) == list: outString = for line in j: outString += line outString += '\n' L. -- http://mail.python.org/mailman/listinfo/python-list
date-time comparison, aware vs naive
I want to compare a user entered date-and-time against the date-and-time of a pdf file. I posted on this (how to get a file's date-time) before, was advised to do it like: import datetime, os, stat mtime = os.lstat(filename)[stat.ST_MTIME] // the files modification time dt = datetime.datetime.fromtimestamp(mtime) I am having problems with the comparison, that line is failing. I think I may have figured out the issue -- I think it is a matter of the file's time being 'aware' and the user-input date-time being 'naive'. The user-input date-time has a parameter type of date (calender and time tool supplied to enter), but is it 'aware'? The comparison is not working so I think that it is not aware. I can successfully compare two pdf file times against one another. So, is there a way to cast that user-input value (prints as 2/10/2012 3:19:57 PM) as an 'aware' date-time? How? And can anyone confirm that my findings are probably correct? Thanks for any help. -- http://mail.python.org/mailman/listinfo/python-list
Re: date-time comparison, aware vs naive
In 21eb3e6f-9a82-47aa-93ff-8f4083d18...@googlegroups.com noydb jenn.du...@gmail.com writes: I want to compare a user entered date-and-time against the date-and-time of a pdf file. I posted on this (how to get a file's date-time) before, was advised to do it like: import datetime, os, stat mtime = os.lstat(filename)[stat.ST_MTIME] // the files modification time dt = datetime.datetime.fromtimestamp(mtime) I am having problems with the comparison, that line is failing. What line? You haven't posted any comparison line of code here. Please post the actual code you're using, instead of telling us about it. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: date-time comparison, aware vs naive
Found this, and it solved my problem http://blogs.law.harvard.edu/rprasad/2011/09/21/python-string-to-a-datetime-object/ -- http://mail.python.org/mailman/listinfo/python-list
Matplotlib/Pylab Error
Dear Group, I am trying to enumerate few interesting errors on pylab/matplotlib. If any of the learned members can kindly let me know how should I address them. I am trying to enumerate them as follows. i) import numpy import pylab t = numpy.arange(0.0, 1.0+0.01, 0.01) s = numpy.cos(2*2*numpy.pi*t) pylab.plot(t, s) [matplotlib.lines.Line2D object at 0x021122D0] pylab.show() Exception in Tkinter callback Traceback (most recent call last): File C:\Python26\lib\lib-tk\Tkinter.py, line 1410, in __call__ return self.func(*args) File C:\Python26\Lib\site-packages\matplotlib\backends\backend_tkagg.py, line 236, in resize self.show() File C:\Python26\Lib\site-packages\matplotlib\backends\backend_tkagg.py, line 239, in draw FigureCanvasAgg.draw(self) File C:\Python26\Lib\site-packages\matplotlib\backends\backend_agg.py, line 421, in draw self.figure.draw(self.renderer) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\figure.py, line 898, in draw func(*args) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\axes.py, line 1997, in draw a.draw(renderer) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\axis.py, line 1045, in draw tick.draw(renderer) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\axis.py, line 239, in draw self.label1.draw(renderer) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\text.py, line 591, in draw ismath=ismath) File C:\Python26\Lib\site-packages\matplotlib\backends\backend_agg.py, line 167, in draw_text font.draw_glyphs_to_bitmap(antialiased=rcParams['text.antialiased']) TypeError: draw_glyphs_to_bitmap() takes no keyword arguments ii) Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. IDLE 2.6.1 import networkx as nx G=nx.Graph() G.add_node(1) G.add_nodes_from([2,3]) H=nx.path_graph(10) G.add_nodes_from(H) G.add_node(H) G.add_edge(1,2) G.draw() Traceback (most recent call last): File pyshell#8, line 1, in module G.draw() AttributeError: 'Graph' object has no attribute 'draw' import matplotlib.pyplot as plt plt.show() nx.draw(G) plt.show() Exception in Tkinter callback Traceback (most recent call last): File C:\Python26\lib\lib-tk\Tkinter.py, line 1410, in __call__ return self.func(*args) File C:\Python26\Lib\site-packages\matplotlib\backends\backend_tkagg.py, line 236, in resize self.show() File C:\Python26\Lib\site-packages\matplotlib\backends\backend_tkagg.py, line 239, in draw FigureCanvasAgg.draw(self) File C:\Python26\Lib\site-packages\matplotlib\backends\backend_agg.py, line 421, in draw self.figure.draw(self.renderer) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\figure.py, line 898, in draw func(*args) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\axes.py, line 1997, in draw a.draw(renderer) File C:\Python26\Lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\text.py, line 591, in draw ismath=ismath) File C:\Python26\Lib\site-packages\matplotlib\backends\backend_agg.py, line 167, in draw_text font.draw_glyphs_to_bitmap(antialiased=rcParams['text.antialiased']) TypeError: draw_glyphs_to_bitmap() takes no keyword arguments Regards, Subhabrata. -- http://mail.python.org/mailman/listinfo/python-list
Re: About open file for Read
On Mon, 10 Dec 2012 08:36:22 -0800, moonhkt wrote: Hi All I am new in Python. When using open and then for line in f . Does it read all the data into f object ? or read line by line ? Have you read the Fine Manual? http://docs.python.org/2/library/stdtypes.html#file-objects If you have read it, and the answer is still not clear, then please tell us so we can improve the documentation. `for line in open(file, r):` does not read the entire file into memory at once, it iterates over the file reading one line at a time. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: date-time comparison, aware vs naive
On Mon, 10 Dec 2012 11:57:37 -0800, noydb wrote: I want to compare a user entered date-and-time against the date-and-time of a pdf file. I posted on this (how to get a file's date-time) before, was advised to do it like: import datetime, os, stat mtime = os.lstat(filename)[stat.ST_MTIME] // the files modification time What language are you writing? Using // for comments is not Python. dt = datetime.datetime.fromtimestamp(mtime) I am having problems with the comparison, that line is failing. You haven't shown us the comparison line. Would you like us to guess what it does? My guess is that you are doing this: if mtime is dtime: ... Am I close? If not, please forgive me, my crystal ball is often faulty. I think I may have figured out the issue -- I think it is a matter of the file's time being 'aware' and the user-input date-time being 'naive'. Aware of what? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of out params
On 12/10/2012 2:13 PM, bitbucket wrote: I have an existing Windows application which provides an OLE Automation (IDispatch) interface. I'm not able to change that interface. I'd like to call it from a scripting language. I figure this would provide a nice quick way to invoke on the app. I believe the easiest way to do that is to install the pywin extensions http://sourceforge.net/projects/pywin32/?source=directory I assume it can handle out params. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: date-time comparison, aware vs naive
On Monday, December 10, 2012 3:52:55 PM UTC-5, Steven D'Aprano wrote: On Mon, 10 Dec 2012 11:57:37 -0800, noydb wrote: I want to compare a user entered date-and-time against the date-and-time of a pdf file. I posted on this (how to get a file's date-time) before, was advised to do it like: import datetime, os, stat mtime = os.lstat(filename)[stat.ST_MTIME] // the files modification time What language are you writing? Using // for comments is not Python. dt = datetime.datetime.fromtimestamp(mtime) I am having problems with the comparison, that line is failing. You haven't shown us the comparison line. Would you like us to guess what it does? My guess is that you are doing this: if mtime is dtime: ... Am I close? If not, please forgive me, my crystal ball is often faulty. I think I may have figured out the issue -- I think it is a matter of the file's time being 'aware' and the user-input date-time being 'naive'. Aware of what? -- Steven Forgive me, I was just copying the code from the original reply to my orignal question. Forgive me for not posting the comparison line, it goes something like if one_time another_time: Forgive me - the 'aware' time vs 'naive' time refers to documentation I found for the datetime module, see second sentence down http://docs.python.org/2/library/datetime.html -- http://mail.python.org/mailman/listinfo/python-list
Re: date-time comparison, aware vs naive
On 12/10/2012 03:52 PM, Steven D'Aprano wrote: On Mon, 10 Dec 2012 11:57:37 -0800, noydb wrote: I want to compare a user entered date-and-time against the date-and-time of a pdf file. I posted on this (how to get a file's date-time) before, was advised to do it like: import datetime, os, stat mtime = os.lstat(filename)[stat.ST_MTIME] // the files modification time What language are you writing? Using // for comments is not Python. dt = datetime.datetime.fromtimestamp(mtime) I am having problems with the comparison, that line is failing. You haven't shown us the comparison line. Would you like us to guess what it does? My guess is that you are doing this: if mtime is dtime: ... Am I close? If not, please forgive me, my crystal ball is often faulty. I think I may have figured out the issue -- I think it is a matter of the file's time being 'aware' and the user-input date-time being 'naive'. Aware of what? http://docs.python.org/2/library/datetime An object of type *time* or *datetime* may be naive or *aware aware refers to time-zone and daylight savings time, such political ephemerals. Two times can only be changed if one knows they're both in the same one, or if one knows precisely what each is. * naive assumes the former, while aware trusts the latter. To the OP: please specify your python version, your OS, and show your source. Also show the complete error traceback. And while you're at it, it might be useful to know the type of drive the file is on, since Windows uses local times on FAT32 partitions, and gmt on NTFS partitions. I suspect you're on Windows, so I can't help you with this nonsense. But I can at least help you ask a clear question. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
strptime - dates formatted differently on different computers
Follow-on question to this earlier topic - https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion Was curious to know if there was a way to handle different user computers with different operating system set date formats. 2/10/2006 vs 2-10-2006, for example. Not an issue for my current task, but was just curious how this could be handled? If in my code I am declaring the user entered date foramtted as x = datetime.datetime.strptime(user_entered_time , %m/%d/%Y %I:%M:%S %p) # format for my computer but on another person's computer, their's is set as 2-10-2006 14:26:06, the code fails. Can this be accounted for? -- http://mail.python.org/mailman/listinfo/python-list
Re: date-time comparison, aware vs naive
http://docs.python.org/2/library/datetime An object of type *time* or *datetime* may be naive or *aware aware refers to time-zone and daylight savings time, such political ephemerals. Two times can only be changed if one knows they're both in the same one, or if one knows precisely what each is. * naive assumes the former, while aware trusts the latter. To the OP: please specify your python version, your OS, and show your source. Also show the complete error traceback. And while you're at it, it might be useful to know the type of drive the file is on, since Windows uses local times on FAT32 partitions, and gmt on NTFS partitions. I suspect you're on Windows, so I can't help you with this nonsense. But I can at least help you ask a clear question. -- DaveA Fair enough, thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: strptime - dates formatted differently on different computers
NTFS partition Windows 7 Python 2.7 -- http://mail.python.org/mailman/listinfo/python-list
Re: strptime - dates formatted differently on different computers
On 12/10/2012 04:18 PM, noydb wrote: Follow-on question to this earlier topic - https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion For those who avoid googlegroups with a passion, and/or don't have internet access, the subject of that thread is date-time comparison, aware vs naive, on this same mailing list. Was curious to know if there was a way to handle different user computers with different operating system set date formats. 2/10/2006 vs 2-10-2006, for example. Not an issue for my current task, but was just curious how this could be handled? If in my code I am declaring the user entered date foramtted as x = datetime.datetime.strptime(user_entered_time , %m/%d/%Y %I:%M:%S %p) # format for my computer but on another person's computer, their's is set as 2-10-2006 14:26:06, the code fails. You can save people a lot of time if you just think before posting. What do you define as failure? is your motherboard smoking, or is the final result off by a second? Please reread my last message on the previous thread. If you want us to give you code advice, show us what you're doing, don't just describe it in vague terms. Can this be accounted for? When accepting input from a user, consider their environment. Perhaps they're in a different timezone than your program (or your native location), or use some other ordering for the date (for example, the Japanese sensibly put year first, then month, then day. Other regions have different conventions. If you can't detect the user environment, then you'd better tell them yours. For example,by prompting for day, month, and year separately. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of out params
On Monday, December 10, 2012 3:58:33 PM UTC-5, Terry Reedy wrote: I believe the easiest way to do that is to install the pywin extensions http://sourceforge.net/projects/pywin32/?source=directory I assume it can handle out params. That definitely looks like a good starting point. Just hoping someone knows whether or not it'll support the out params before I spend too much time digging into it. -- http://mail.python.org/mailman/listinfo/python-list
open URL in the current tab
Hi, With the webbrowser module you can open a URL in a new tab. But how could I tell Firefox from Python to open a URL in the _current_ tab? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: open URL in the current tab
On Mon, Dec 10, 2012 at 5:27 PM, Jabba Laci jabba.l...@gmail.com wrote: Hi, With the webbrowser module you can open a URL in a new tab. But how could I tell Firefox from Python to open a URL in the _current_ tab? The docs say this: webbrowser.open_new(*url*) Open *url* in a new window of the default browser, if possible, otherwise, open *url* in the only browser window. webbrowser.open_new_tab(*url*) Open *url* in a new page (“tab”) of the default browser, if possible, otherwise equivalent to open_new()http://docs.python.org/2/library/webbrowser.html#webbrowser.open_new . Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick -- http://mail.python.org/mailman/listinfo/python-list
String manipulation in python..NEED HELP!!!!
I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i have the basic code but need help with how to mainpulate the string to do the encryption/decryption. please help here is my code so far: crypto.py Implements a simple substitution cypher alpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ key = XPMGTDHLYONZBWEARKJUFSCIQV def main(): keepGoing = True while keepGoing: response = menu() if response == 1: plain = raw_input(text to be encoded: ) print encode(plain) elif response == 2: coded = raw_input(code to be decyphered: ) print decode(coded) elif response == 0: print Thanks for doing secret spy stuff with me. keepGoing = False else: print I don't know what you want to do... i really need help on how to encrypt it im not sure how to go about doing that please help. -- http://mail.python.org/mailman/listinfo/python-list
Re: open URL in the current tab
Don't think that it's possible with webbrowser, you should try with Selenium. For example with sst (Simple Selenium Test), it open url in current tab or create a new one if no one exists: from sst.actions import * go_to('http://www.ubuntu.com/') 2012/12/10 Jabba Laci jabba.l...@gmail.com: Hi, With the webbrowser module you can open a URL in a new tab. But how could I tell Firefox from Python to open a URL in the _current_ tab? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: open URL in the current tab
Thanks. I've found something interesting since then: https://addons.mozilla.org/en-US/firefox/addon/mozrepl/ https://github.com/bard/mozrepl/wiki It allows you to connect to your Firefox via telnet. Then changing the URL: content.location.href = new_url However, for this you need to install this add-on. Laszlo On Mon, Dec 10, 2012 at 11:43 PM, Boris FELD lothiral...@gmail.com wrote: Don't think that it's possible with webbrowser, you should try with Selenium. For example with sst (Simple Selenium Test), it open url in current tab or create a new one if no one exists: from sst.actions import * go_to('http://www.ubuntu.com/') 2012/12/10 Jabba Laci jabba.l...@gmail.com: Hi, With the webbrowser module you can open a URL in a new tab. But how could I tell Firefox from Python to open a URL in the _current_ tab? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: String manipulation in python..NEED HELP!!!!
In d6779e35-32b8-417a-abf9-72454573b...@googlegroups.com qbai...@ihets.org writes: crypto.py Implements a simple substitution cypher alpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ key = XPMGTDHLYONZBWEARKJUFSCIQV def main(): keepGoing = True while keepGoing: response = menu() if response == 1: plain = raw_input(text to be encoded: ) print encode(plain) elif response == 2: coded = raw_input(code to be decyphered: ) print decode(coded) elif response == 0: print Thanks for doing secret spy stuff with me. keepGoing = False else: print I don't know what you want to do... i really need help on how to encrypt it im not sure how to go about doing that please help. def encode(plain): '''Return a substituted version of the plain text.''' encoded = '' for ch in plain: encoded += key[alpha.index(ch)] return encoded -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: open URL in the current tab
On Tue, Dec 11, 2012 at 9:27 AM, Jabba Laci jabba.l...@gmail.com wrote: Hi, With the webbrowser module you can open a URL in a new tab. But how could I tell Firefox from Python to open a URL in the _current_ tab? If this is for use on somebody else's system, *please don't*. My current tab is my business, not your program's. But if this is your own system (eg you want to use Firefox as your GUI), there are a few options. The easiest, I think, is to have the previous page handle the transition - trigger it in some way, and then it simply does: location.href = some_new_url How you go about triggering this is the next problem :) But that depends hugely on what you're trying to accomplish. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: String manipulation in python..NEED HELP!!!!
2012/12/10 qbai...@ihets.org: I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i have the basic code but need help with how to mainpulate the string to do the encryption/decryption. please help here is my code so far: crypto.py Implements a simple substitution cypher alpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ key = XPMGTDHLYONZBWEARKJUFSCIQV def main(): keepGoing = True while keepGoing: response = menu() if response == 1: plain = raw_input(text to be encoded: ) print encode(plain) elif response == 2: coded = raw_input(code to be decyphered: ) print decode(coded) elif response == 0: print Thanks for doing secret spy stuff with me. keepGoing = False else: print I don't know what you want to do... i really need help on how to encrypt it im not sure how to go about doing that please help. -- http://mail.python.org/mailman/listinfo/python-list Hi, if I understand correctly, for the data shown in the code, you may probably use the translate method of the string (and the corresponding maketrans method); cf.: python 2.7 import string ABCDEF...VWXYZ.translate(string.maketrans(ABCDEFGHIJKLMNOPQRSTUVWXYZ, XPMGTDHLYONZBWEARKJUFSCIQV)) 'XPMGTD...SCIQV' python 3.2 ABCDEF...VWXYZ.translate(.maketrans(ABCDEFGHIJKLMNOPQRSTUVWXYZ, XPMGTDHLYONZBWEARKJUFSCIQV)) 'XPMGTD...SCIQV' hth, vbr -- http://mail.python.org/mailman/listinfo/python-list
Re: String manipulation in python..NEED HELP!!!!
On Tue, Dec 11, 2012 at 9:38 AM, qbai...@ihets.org wrote: I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i have the basic code but need help with how to mainpulate the string to do the encryption/decryption. please help A few starting tips. Firstly, I'm going to assume here that this is a homework question; you haven't said so, but it seems rather more likely than the alternative (that you're actually going to use such an incredibly low-grade cipher and an interactive prompt like this). Please be honest about this; it's okay to ask for help, but we're not here to do your homework for you. (We do NOT want to help you to get a certificate you don't merit, then get a job using that certificate, and then write code that we'll be staring at in our next jobs. There are already more than enough incompetent programmers in the world; I'd rather that you either learn the material for real, or if you can't, fail the course honestly. Sorry if that sounds harsh, but I'm sure you'd rather that I didn't have a certificate entitling me to drive a truck on roads near you/your kids, because I do not know how to drive one safely.) Secondly, putting NEED HELP in your subject line doesn't, in fact, help. :) It just makes you sound demanding. So! On to the actual problem. What you need to do is find the letter that corresponds to the one you have. Decryption is the same as encryption but with the alpha and key switched, so I recommend creating a function that accepts those two as arguments - something like this: clear = ABCDEFGHIJKLMNOPQRSTUVWXYZ key = XPMGTDHLYONZBWEARKJUFSCIQV def crypt(msg,from,to): # and put your code in here # To encrypt: encrypted = crypt(original, clear, key) # To decrypt: message = crypt(encrypted, key, clear) The details of the encryption you can put together from John's and/or vbr's responses, but make sure you understand the code yourself. For example: What will each of them do with any non-alphabetic characters? Suppose your original message is HELLO, WORLD! - what will happen to the comma, space, and exclamation mark? Be sure you know *why* this is how it is, too. If you run into trouble, post your non-working code and exactly how it's not working, and we'll try to help you understand why it's not working. :) In the meantime, here's a document that you may want to familiarize yourself with: http://www.catb.org/esr/faqs/smart-questions.html It's a great explanation of the how and, more importantly, the why of asking questions of volunteer geeks. All the best! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: open URL in the current tab
Hi, If this is for use on somebody else's system, *please don't*. My This is for me. I have a simple GUI that produces some URL that I want to open in the current tab. Since I want to verify several URLs, I don't want to open dozens of new tabs. Here is my working solution. It requires the MozRepl Firefox add-on that I mentioned in the previous message. Laszlo === import telnetlib HOST = 'localhost' PORT = 4242# MozRepl default def open_curr_tab(url): tn = telnetlib.Telnet(HOST, PORT) cmd = content.location.href = '{url}'.format(url=url) tn.read_until(repl ) tn.write(cmd + \n) tn.write(repl.quit()\n) # if __name__ == __main__: open_curr_tab('http://www.python.org') -- http://mail.python.org/mailman/listinfo/python-list
MySQLdb insert HTML code error
Hi all, I'm facing an issue inserting an html code into the DB, it comes out with a syntax error but I face it only when I have html code. Could help me escape the error somehow ? Here is my code def InsertSpecsDB(product_id, spec, lang, name): db = MySQLdb.connect(localhost,getit,opencart) cursor = db.cursor() sql = (INSERT INTO product_description (product_id, language_id, name, description) VALUES ('%s','%s','%s','%s')) params = (product_id, lang, name, spec) cursor.execute(sql, params) id = cursor.lastrowid printUpdated ID %s description %s %(int(id), lang) return id Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: open URL in the current tab
On Tue, Dec 11, 2012 at 11:05 AM, Jabba Laci jabba.l...@gmail.com wrote: Hi, If this is for use on somebody else's system, *please don't*. My This is for me. I have a simple GUI that produces some URL that I want to open in the current tab. Since I want to verify several URLs, I don't want to open dozens of new tabs. Here is my working solution. It requires the MozRepl Firefox add-on that I mentioned in the previous message. Looks good! Since it's your own single system, the add-on requirement isn't too onerous (but even if it's an all-mine system, I'd hesitate to deploy an add-on to more than a handful of computers). Specific problem, specific solution. I like it. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb insert HTML code error
On 11/12/2012 00:04, Anatoli Hristov wrote: Hi all, I'm facing an issue inserting an html code into the DB, it comes out with a syntax error but I face it only when I have html code. Could help me escape the error somehow ? Here is my code def InsertSpecsDB(product_id, spec, lang, name): db = MySQLdb.connect(localhost,getit,opencart) cursor = db.cursor() sql = (INSERT INTO product_description (product_id, language_id, name, description) VALUES ('%s','%s','%s','%s')) params = (product_id, lang, name, spec) cursor.execute(sql, params) id = cursor.lastrowid printUpdated ID %s description %s %(int(id), lang) return id Thanks As much use as a chocolate teapot, all you've given is a function/method definition. No indication of your OS, Python version, calling code, what you expect to happen, what actually happened, apart from that your request for assistance is perfect. Usually I'd be able to help but sadly my crystal ball is in for repairs at the moment. Would you please be kind enough to elucidate. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb insert HTML code error
As much use as a chocolate teapot, all you've given is a function/method definition. No indication of your OS, Python version, calling code, what you expect to happen, what actually happened, apart from that your request for assistance is perfect. Usually I'd be able to help but sadly my crystal ball is in for repairs at the moment. Would you please be kind enough to elucidate. Thanks for your answer, the OS is CentOS release 5.7. MySQL - 5.0.96 As I said the function is working right, except when I insert an HTML code. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb insert HTML code error
On Tue, Dec 11, 2012 at 1:29 AM, Anatoli Hristov toli...@gmail.com wrote: As much use as a chocolate teapot, all you've given is a function/method definition. No indication of your OS, Python version, calling code, what you expect to happen, what actually happened, apart from that your request for assistance is perfect. Usually I'd be able to help but sadly my crystal ball is in for repairs at the moment. Would you please be kind enough to elucidate. Thanks for your answer, the OS is CentOS release 5.7. MySQL - 5.0.96 As I said the function is working right, except when I insert an HTML code. Thanks And sorry, Python 2.4 -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb insert HTML code error
On 11/12/2012 00:29, Anatoli Hristov wrote: As much use as a chocolate teapot, all you've given is a function/method definition. No indication of your OS, Python version, calling code, what you expect to happen, what actually happened, apart from that your request for assistance is perfect. Usually I'd be able to help but sadly my crystal ball is in for repairs at the moment. Would you please be kind enough to elucidate. Thanks for your answer, the OS is CentOS release 5.7. MySQL - 5.0.96 As I said the function is working right, except when I insert an HTML code. Thanks Brilliant, I think your problem is in line 97 of the code that you *HAVEN'T QUOTED*. Please go here, read and inwardly digest before you say anything else http://www.sscce.org/ -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb insert HTML code error
On 2012-12-11 00:04, Anatoli Hristov wrote: Hi all, I'm facing an issue inserting an html code into the DB, it comes out with a syntax error but I face it only when I have html code. Could help me escape the error somehow ? Here is my code def InsertSpecsDB(product_id, spec, lang, name): db = MySQLdb.connect(localhost,getit,opencart) cursor = db.cursor() sql = (INSERT INTO product_description (product_id, language_id, name, description) VALUES ('%s','%s','%s','%s')) params = (product_id, lang, name, spec) cursor.execute(sql, params) id = cursor.lastrowid printUpdated ID %s description %s %(int(id), lang) return id You're using a parametrised query (which is good :-)), but you've included quotes around the placeholders. There's no need to do that. They'll be quoted automatically when necessary: sql = INSERT INTO product_description (product_id, language_id, name, description) VALUES (%s,%s,%s,%s) -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb insert HTML code error
You're using a parametrised query (which is good :-)), but you've included quotes around the placeholders. There's no need to do that. They'll be quoted automatically when necessary: sql = INSERT INTO product_description (product_id, language_id, name, description) VALUES (%s,%s,%s,%s) Thanks a lot it wrks. I was looking in the wrong direction (escape str. raw etc) Thanks again :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of out params
On 11/12/2012 8:39 AM, bitbucket wrote: On Monday, December 10, 2012 3:58:33 PM UTC-5, Terry Reedy wrote: I believe the easiest way to do that is to install the pywin extensions http://sourceforge.net/projects/pywin32/?source=directory I assume it can handle out params. That definitely looks like a good starting point. Just hoping someone knows whether or not it'll support the out params before I spend too much time digging into it. out params are best supported if the object supplied a typelib - then Python knows the params are out and does the right thing automagically. If out params are detected, the result of the function will be a tuple of (real_result, out_param1, ...) Even if no typelib is supported, you can access them with a little pain via the win32com.client.Dispatch() object. You might like to follow up to the python-wi...@python.org mailing list where many people will be able to help. HTH, Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: strptime - dates formatted differently on different computers
On Mon, 10 Dec 2012 16:36:37 -0500, Dave Angel wrote: When accepting input from a user, consider their environment. Perhaps they're in a different timezone than your program (or your native location), or use some other ordering for the date (for example, the Japanese sensibly put year first, then month, then day. Other regions have different conventions. If you can't detect the user environment, then you'd better tell them yours. For example,by prompting for day, month, and year separately. +1 In a nutshell, you can't know ahead of time what the user will be using as a date format, or what their computer will be set to use as date format. Unless you control the operating system and can force a particular date format, you are at the OS's mercy. Having stated that the problem is hard, what's the solution? I expect that it will depend on the OS. Presumably under Windows there is some way of asking Windows What is the current date format?. I defer to Windows users for that. On Linux, and probably Mac OS X, I think this is the right way to get the system's preferred date format: py import locale py locale.setlocale(locale.LC_ALL, '') # You MUST call this first. 'en_AU.utf8' py locale.nl_langinfo(locale.D_FMT) '%d/%m/%y' You can pass that string on to strptime: py import time py time.strptime(11/12/13, '%d/%m/%y') time.struct_time(tm_year=2013, tm_mon=12, tm_mday=11, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=346, tm_isdst=-1) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
Thesaurus: A different way to call a dictionary. Thesaurus is a new a dictionary subclass which allows calling keys as if they are class attributes and will search through nested objects recursively when __getitem__ is called. You will notice that the code is disgusting simple. However I have found that this has completely changed the way I program in python. I've re-written some exiting programs using Thesaurus, and often realized 15-30% code reduction. Additionally I find the new code much easier to read. If you find yourself programing with nested dictionaries often, fighting to generate output or command lines for external programs, or wish you had a dictionary that could act (sort of) like a class, Thesaurus may be for you. #!/usr/bin/env python thesaurus.py 2012-09-13 Copyright (c) 2012 Dave Cinege Licence: python, Copyright notice may not be altered. Thesaurus: A different way to call a dictionary. Thesaurus is a new a dictionary subclass which allows calling keys as if they are class attributes and will search through nested objects recursivly when __getitem__ is called. You will notice that the code is disgusting simple. However I have found that this has completely changed the way I program in python. I've re-written some exiting programs using Thesaurus, and often relized 15-30% code reduction. Additionally I find the new code much easier to read. If you find yourself programing with nested dictionaries often, fighting to generate output or command lines for external programs, or wish you had a dictionary that could act (sort of) like a class, Thesaurus may be for you. By example: --- #!/usr/bin/env python import thesaurus thes = thesaurus.Thesaurus # I like to create a master global object called 'g'. # No more 'global' statements for me. g = thes() g.prog = thes() g['prog']['VERSION'] = '1.0' # I can do this like a normal nested dictionary g.prog.VERSION = '1.0' # But isn't this so much cleaner? g.prog.NAME = 'Thesaurus' class TestClass: no = 'Class' way = 'this' def main (): L = thes() # Some local varibles L.tc = TestClass() # We can also recurse to class attributes L.l = list() # And recurse to indices too! L.l.append('Some') L.l.append('objects') g.L = L # Easily make these locals global # Here's the real magic. Creating output without a fight. print ''' When programing python using %(prog.NAME)s, it is very easy to access your %(L.l.1)s. %(L.l.0)s people might say %(prog.NAME)s has no %(L.tc.no)s. '''.replace('\t','')[1:-1] % g del g.L # Clean locals up out of global space # If I was using a storage class, I must use hasattr() or an ugly eval. # But we can still use a str for the key name and 'in' like on any # regular dictionary. if 'VERSION' in g.prog: print 'But I challenge them to write code %(tc.way)s clean without it!' % L if __name__ == '__main__': main() --- __VERSION__ = 20120913 class Thesaurus (dict): def __getattr__(self, name): return self.__getitem__(name) def __setattr__(self, name, value): return dict.__setitem__(self, name, value) def __delattr__(self, name): return dict.__delitem__(self, name) def __getitem__(self, key): if '.' not in key: return dict.__getitem__(self, key) l = key.split('.') if isinstance(l[0], (dict, Thesaurus)): a = self.data else: a = self for i in range(len(l)): # Walk keys recursivly try: a = a[l[i]] # Attempt key except: try: a = getattr(a, l[i]) # Attempt attr except: try: a = a[int(l[i])] # Attempt indice except: raise KeyError(key + ' [%s]' % i) return a -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
Thesaurus is a new a dictionary subclass which allows calling keys as if they are class attributes and will search through nested objects recursively when __getitem__ is called. Good stuff. You might consider: 1) Licensing under an OSI-approved license (http://opensource.org/licenses/index.html). 2) Posting your code at ActiveState.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: strptime - dates formatted differently on different computers
On 12/10/2012 02:18 PM, noydb wrote: Follow-on question to this earlier topic - https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion Was curious to know if there was a way to handle different user computers with different operating system set date formats. 2/10/2006 vs 2-10-2006, for example. Not an issue for my current task, but was just curious how this could be handled? If in my code I am declaring the user entered date foramtted as x = datetime.datetime.strptime(user_entered_time , %m/%d/%Y %I:%M:%S %p) # format for my computer but on another person's computer, their's is set as 2-10-2006 14:26:06, the code fails. Can this be accounted for? I use a module I got from pypi called dateutil. It has a nice submodule called parser that can handle a variety of date formats with good accuracy. Not sure how it works, but it handles all the common American date formats I've thrown at it. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
On Mon, Dec 10, 2012 at 8:48 PM, Dave Cinege d...@cinege.com wrote: Thesaurus: A different way to call a dictionary. Thesaurus is a new a dictionary subclass which allows calling keys as if they are class attributes and will search through nested objects recursively when __getitem__ is called. You will notice that the code is disgusting simple. However I have found that this has completely changed the way I program in python. I've re-written some exiting programs using Thesaurus, and often realized 15-30% code reduction. Additionally I find the new code much easier to read. If you find yourself programing with nested dictionaries often, fighting to generate output or command lines for external programs, or wish you had a dictionary that could act (sort of) like a class, Thesaurus may be for you. I have a few critiques on the code. First, you might want to use __getattribute__ instead of __getattr__. Otherwise you'll end up running into bugs like this: thes = Thesaurus() thes.update = 'now' thes.update built-in method update of Thesaurus object at 0x01DB30C8 Hey, where'd my data go? The answer is that it is in the Thesaurus: thes['update'] 42 But it's not visible as an attribute because it is shadowed by the dict methods. Using __getattribute__ instead of __getattr__ would mean that those non-special methods simply wouldn't be visible at all. Second, in __getitem__ you start a loop with for i in range(len(l)):, and then you use i as an index into l several times. It would be cleaner and more Pythonic to do for i, part in enumerate(l):, and then you can replace every occurrence of l[i] with part (or whatever you want to call that variable). Third, also in __getitem__ you have this code: if '.' not in key: return dict.__getitem__(self, key) l = key.split('.') if isinstance(l[0], (dict, Thesaurus)): a = self.data else: a = self It's not clear to me what the isinstance call here is meant to be testing for. The prior statements require key to be a string. If key is a string, then by construction l[0] is also a string. So it seems to me that the isinstance check here will always be False. In any case, the key splitting here seems to be done primarily to support the use of formatting placeholders like %(L.l.1)s in the examples. I want to point out that this use case is already well supported (I might even say better supported since it cleanly distinguishes index elements from attributes with syntax) by the str.format style of string formatting: L = {'l': ['zero', 'one']} There should be {L[l][1]}-- and preferably only {L[l][1]} --obvious way to do it..format(L=L) 'There should be one-- and preferably only one --obvious way to do it.' Lastly, you have several bare except clauses in the code. Bare excepts are almost always incorrect. I appreciate that it's not easy to predict exactly what exceptions might turn up here (although I posit that for all of these, subsets of (TypeError, KeyError, AttributeError, IndexError) are sufficient), but at the very minimum you should specify except Exception, so that you're not inadvertently catching things like SystemExit and KeyboardInterrupt. Cheers and hope this is helpful, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with usbtmc-communication
On 10 dec, 16:34, w...@mac.com wrote: On Dec 10, 2012, at 8:31 AM, Jean Dubois jeandubois...@gmail.com wrote: [byte] As you can see this approach suffers from the same buffer problem as the approach with readline did. One now good argue as a workaround: get rid of the first data pair and add an extra measure command for the missing data pair, however this still does not explain why this problem is there in Python and not in Octave and I also fear I'll get more trouble when sending combined commands e.g. such as that to create a staircase current So my question is, how to modify the Python-code such that the first data pair is indeed the first data pair thanks, jean Here follows the new code: #!/usr/bin/python import time import os import sys measurementcurr='' measurementvolt='' timesleepdefault=5 print Enter a numofchar (11 =numchar =4095):, numofchar = int(raw_input()) filename ='mydata.txt' usbkeith = open('/dev/usbtmc1','r+') usbkeith.flush() usbkeith.write(*IDN?\n) It seems like a real leap of faith to be opening /dev/usbtmc1 as though it were a file-oriented device. I've never heard of ANY instrument interface implemented this way. Where did you see example code that did that. I found examples in the usbtmc kernel driver documentation (the examples there are given in C): http://www.home.agilent.com/upload/cmc_upload/All/usbtmc.htm?cc=BElc=dut Have you tried to access /dev/usbtmc1 as though it were a serial device? Yes, I did, as I used to do when communicating with rs232 devices. I first tried to communicate to with the Keithley using cutecom but I soon discovered you can't work that way because as soon as you open the device it closes immediately thereafter. You really have to use usbtmc (unfortunately) I'm missing the correct flushing commands to do it correctly in Python...Maybe I should try to call the octave code from within Python? thanks jean #strip blank line: identification=usbkeith.readline().strip() print 'Found device: ',identification usbkeith.write(SYST:REM + \n) usbkeith.write(:SENS:VOLT:PROT 1.5\n) keithdata = open(filename,'w') usbkeith.write(:OUTP:STAT ON\n) for number, current_in in enumerate(('0.025', '0.050', '0.075', '0.100'), 1): usbkeith.write(:SOUR:CURR %s\n % current_in) time.sleep(timesleepdefault) usbkeith.write(:MEAS:CURR?\n) measurementcurr=usbkeith.read(numofchar) print 'Measured current %d: ' % number, measurementcurr usbkeith.write(:MEAS:VOLT?\n) measurementvolt=usbkeith.read(numofchar) print 'Measured voltage %d: ' % number, measurementvolt keithdata.write(measurementcurr.strip()+' '+measurementvolt) usbkeith.write(:OUTP:STAT OFF\n) print Goodbye, data logged in file: print filename usbkeith.close() keithdata.close() -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb insert HTML code error
First thing -- DON'T put quotes around the %s place-holders... The whole purpose of using the parameterized .execute() is to let the database adapter properly escape the parameters before putting them into the SQL (since MySQL didn't have prepared statements before v5, it was producing full SQL statements for each insert, even with .executemany() ) Thank you, this solved my problem.:) -- http://mail.python.org/mailman/listinfo/python-list
[issue1218234] inspect.getsource doesn't update when a module is reloaded
Changes by Berker Peksag berker.pek...@gmail.com: -- versions: +Python 3.3, Python 3.4 -Python 3.1 Added file: http://bugs.python.org/file28272/issue1218234.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1218234 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1218234] inspect.getsource doesn't update when a module is reloaded
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1218234 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Roundup Robot added the comment: New changeset c9b9f786ec25 by Hynek Schlawack in branch '3.2': #15872: Add tests for a 3.3 regression in the new fd-based shutil.rmtree http://hg.python.org/cpython/rev/c9b9f786ec25 New changeset fc394216c724 by Hynek Schlawack in branch '3.3': #15872: Fix 3.3 regression introduced by the new fd-based shutil.rmtree http://hg.python.org/cpython/rev/fc394216c724 New changeset c70d964b26fe by Hynek Schlawack in branch 'default': #15872: Fix 3.3 regression introduced by the new fd-based shutil.rmtree http://hg.python.org/cpython/rev/c70d964b26fe -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Roundup Robot added the comment: New changeset 5211391928bc by Hynek Schlawack in branch '3.2': #15872: Fix shutil.rmtree error tests for Windows http://hg.python.org/cpython/rev/5211391928bc New changeset 4b2fca8ad07b by Hynek Schlawack in branch '3.3': #15872: Fix shutil.rmtree error tests for Windows http://hg.python.org/cpython/rev/4b2fca8ad07b New changeset ae1ef62954f7 by Hynek Schlawack in branch 'default': #15872: Fix shutil.rmtree error tests for Windows http://hg.python.org/cpython/rev/ae1ef62954f7 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Serhiy Storchaka added the comment: Thank you, Hynek, for review and committing. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Serhiy Storchaka added the comment: Thank you, Hynek, for review and committing. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Changes by Serhiy Storchaka storch...@gmail.com: -- Removed message: http://bugs.python.org/msg177269 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15701] AttributeError from HTTPError when using digest auth
Senthil Kumaran added the comment: Even though 2.x is in security fix mode, this can be fixed by a overriding the base class's info method in the HTTPError class and returning the .hdrs attribute instead of .headers. -- Added file: http://bugs.python.org/file28273/Issue1571.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15701] AttributeError from HTTPError when using digest auth
Roundup Robot added the comment: New changeset ad1c1164f68b by Senthil Kumaran in branch 'default': Fix Issue15701 : add .headers attribute to urllib.error.HTTPError http://hg.python.org/cpython/rev/ad1c1164f68b -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16602] weakref can return an object with 0 refcount
Amaury Forgeot d'Arc added the comment: PyWeakref_GET_OBJECT is also potentially dangerous: since the refcount is not incremented, it's very possible that the GC collects it. The only safe operation after PyWeakref_GET_OBJECT is to Py_XINCREF the result. Should we provide a PyWeakRef_LockObject()? -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16602 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Roundup Robot added the comment: New changeset 7ce8f4a70ccd by Hynek Schlawack in branch '3.2': #15872: More shutil test fixes for Windows http://hg.python.org/cpython/rev/7ce8f4a70ccd New changeset a05e2d4094ea by Hynek Schlawack in branch '3.3': #15872: More shutil test fixes for Windows http://hg.python.org/cpython/rev/a05e2d4094ea New changeset c23659e2ec1a by Hynek Schlawack in branch 'default': #15872: More shutil test fixes for Windows http://hg.python.org/cpython/rev/c23659e2ec1a -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15390] PEP 3121, 384 refactoring applied to datetime module
Robin Schreiber added the comment: I have updated the patch to work again with the current version of the _datetimemodule. Regarding the suggestion of separating PEP3121 and PEP384. It might be true that datetime and other modules do not benefit directly from PEP 384, however it is still a fact that the stdlib modules should be seen as a set of reference modules, that are all implemented in a way that complies with the implementation fo the xxmodules. I have talked with Martin von Löwis about this, and as far as I understood him correctly he also sees the PEP384 refactoring applied to the whole stdlib as a nessecary signal to other developers to refactor their modules accordingly. Anyway I am planning to start to commit all of the open changes that I have created during my GSOC in the next few months. So a decision regarding this separation concern might be helpful. :-) -- keywords: +patch Added file: http://bugs.python.org/file28274/_datetimemodule_pep3121-384_v3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15390 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16645] Wrong test_extract_hardlink() in test_tarfile.py
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file28260/test_tarfile_test_extract_hardlink.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16645 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16645] Wrong test_extract_hardlink() in test_tarfile.py
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file28275/test_tarfile_test_extract_hardlink.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16645 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Roundup Robot added the comment: New changeset 2d953d47d634 by Hynek Schlawack in branch '3.2': #15872: Be flexible with appending *.* in shutil.rmtree test case http://hg.python.org/cpython/rev/2d953d47d634 New changeset edb747c6c479 by Hynek Schlawack in branch '3.3': #15872: Be flexible with appending *.* in shutil.rmtree test case http://hg.python.org/cpython/rev/edb747c6c479 New changeset a0a25ffdec9d by Hynek Schlawack in branch 'default': #15872: Be flexible with appending *.* in shutil.rmtree test case http://hg.python.org/cpython/rev/a0a25ffdec9d -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16653] reference kept in f_locals prevents the tracing/profiling of a destructor
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16653 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
New submission from anatoly techtonik: This critical bug is one of the reasons that non-English speaking communities doesn't adopt Python as broadly as it happens in English world compared to other technologies (PHP etc.). # -*- coding: utf-8 -*- import os os.mkdir(u'Русское имя') os.mkdir(u'English name') for r, dirs, files in os.walk('.'): print dirs This gives: ['English name'] [] Windows Vista. dir /b English name test.py Русское имя -- components: Library (Lib) messages: 177276 nosy: techtonik priority: normal severity: normal status: open title: os.walk ignores international dirs on Windows versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15390] PEP 3121, 384 refactoring applied to datetime module
Marc-Andre Lemburg added the comment: On 10.12.2012 11:39, Robin Schreiber wrote: Robin Schreiber added the comment: I have updated the patch to work again with the current version of the _datetimemodule. Please use _Py_ prefixes for private symbols you put in the header files, e.g. _datetimemodulestate and the macros. Question: What happens if PyModule_GetState() or PyState_FindModule() raise an exception and return NULL ? The current code will segfault in such a situation. Thanks, -- Marc-Andre Lemburg eGenix.com -- nosy: +lemburg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15390 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
Serhiy Storchaka added the comment: It is reproduced on 3.x? -- nosy: +serhiy.storchaka type: - behavior versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
Changes by Serhiy Storchaka storch...@gmail.com: -- Removed message: http://bugs.python.org/msg177278 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
Serhiy Storchaka added the comment: Is it reproduced on 3.x? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16650] Popen._internal_poll() references errno.ECHILD outside of the local scope
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16650 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings
R. David Murray added the comment: I'm personally OK with the option of removing the registry support (or making it optional-by-default), but I'm not going to make that call, we need a windows dev opinion. Maintaining the list of windows exceptions shouldn't be much worse than maintaining the list of mime types. I can't imagine that Microsoft changes it all that often, given that you say they haven't bothered to update the zip type yet. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15207 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1748064] inspect.getargspec fails on built-in or slot wrapper methods
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1748064 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16645] Wrong test_extract_hardlink() in test_tarfile.py
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16645 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
R. David Murray added the comment: No. -- nosy: +r.david.murray resolution: - out of date status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16647] LMTP.connect() loses socket error details
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16647 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
R. David Murray added the comment: Oops, clicked submit too soon. It isn't likely to get fixed in 2.7, because 2.7's unicode support problems is the major reason python3 was developed. -- stage: - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
R. David Murray added the comment: For that matter, it isn't reproduced in python2.7, either: for r, dirs, files in os.walk(u'.'): ... print dirs ... [u'\u0420\u0443\u0441\u0441\u043a\u043e\u0435 \u0438\u043c\u044f'] [] -- resolution: out of date - invalid ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
Jeremy Kloth added the comment: The problem exhibited is not coming from the os.walk() implementation, but from the use of a byte-string as the argument to it. The directories are created with unicode literals and therefore the argument must also be a unicode literal (u'.') for them to be shown. See the note in the listdir() documentation. As it stands, I suggest that this is closed as invalid, or at the minimum that it could be a documentation bug for walk() not also having a similar note as listdir(). -- nosy: +jkloth ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16656] os.walk ignores international dirs on Windows
R. David Murray added the comment: Works for me without the u'.', too, though less usefully: for r, dirs, files in os.walk('.'): ... print dirs ... ['\xd0\xa0\xd1\x83\xd1\x81\xd1\x81\xd0\xba\xd0\xbe\xd0\xb5 \xd0\xb8\xd0\xbc\xd1\x8f'] Maybe that doesn't work on Windows, though. I am, of course, assuming that python3 does the right thing on Windows, but I can't imagine Victor would have overlooked that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16656 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16631] tarfile.extractall() doesn't extract everything if .next() was used
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16631 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16632] Enable DEP and ASLR
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16632 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings
Dave Chambers added the comment: (I'm a windows dev type) I would say that there are 2 issues with relying on the registry: 1) Default values (ie. set by Windows upon OS install) are broken and MS never fixes them. 2) The values can be changed at any time, by any app. Thus the values are unreliable. If I were to code it from scratch today, I'd create a three-pronged approach: a) Hardcode a list of known types (fast reliable). b) Have a default case where unknown types are pulled from the registry. Whatever value is retrieved is likely better than returning e.g. application/octet-stream. c) When we neither find it in hardcoded list or in the registry, return a default value (e.g. application/octet-stream) For what it's worth, my workaround will be to have my app delete the HKCR\MIME\Database\Content Type\image/x-png regkey, thus forcing the original braindead mimetypes.py code to use HKCR\MIME\Database\Content Type\image/png And, for what it's worth, my patch is actually faster than the current mimetypes.py code because I'm not doing reverse lookups. Thus any argument about a difference in speed is moot. Arguments about the speed of pulling mimetypes from registry are valid. Another registry based approach would be to build a dictionary of mimetypes on demand. In this scenario, at startup, the dictionary would be empty. When python needs the mimetype for .png, on the 1st request it would cause a slow registry lookup for only that type but on all subsequent requests for the type it would use the fast value from the dictionary. Given that an app will probably use only a handful of mimetypes but will use that same handful over and over, such a solution would have the benefits of (a) not using hardcoded values (thus no ongoing maintenance), (b) performing slow stuff only on demand, (c) optimizing repeat calls, and (d) consuming zero startup time. I'll code his up run some timing tests if anyone thinks it's worthwhile. BTW, who makes the final determination as to if/when any such changes would be incorporated? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15207 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16657] traceback.format_tb incorrect docsting
New submission from Marius Gedminas: The docstring for traceback.format_tb says A shorthand for 'format_list(extract_stack(f, limit)). which is incorrect -- it's actually a shorthand for format_list(extract_tb(tb, limit)). Patch attached. -- components: Library (Lib) files: fix-format_tb-docstring.patch keywords: patch messages: 177288 nosy: mgedmin priority: normal severity: normal status: open title: traceback.format_tb incorrect docsting versions: Python 2.7, Python 3.5 Added file: http://bugs.python.org/file28276/fix-format_tb-docstring.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16657 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15872] shutil.rmtree(..., ignore_errors=True) doesn't ignore all errors
Hynek Schlawack added the comment: “I wish I were wrangling inconsistent Windows buildbots.” Nobody. Ever. *sigh* It appears they are appeased now, so finally closing. Thanks for the patches everyone! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16632] Enable DEP and ASLR
Martin v. Löwis added the comment: I don't think much caution is needed. If problems don't show up in the beta releases, we can still revert the change for 3.4.1. Christian, please go ahead and check this in. -- stage: test needed - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16632 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15207] mimetypes.read_windows_registry() uses the wrong regkey, creates wrong mappings
R. David Murray added the comment: I would say Brian Curtin, Tim Golden, and/or Martin von Löwis, as they are the currently active committers with significant Windows expertise. Other committers may have opinions as well. If you don't get an answer here in a reasonable amount of time, please post a discussion of the issue to python-dev (it may end up there anyway). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15207 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12915] Add inspect.locate and inspect.resolve
Changes by Berker Peksag berker.pek...@gmail.com: -- keywords: +patch nosy: +berker.peksag versions: +Python 3.4 -Python 3.3 Added file: http://bugs.python.org/file28277/issue12915.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16651] Find out what stdlib modules lack a pure Python implementation
Brett Cannon added the comment: So expat doesn't count as that literally wraps the expat library. Random also requires accessing the system randomization libraries to work properly so I don't think that is a candidate either. As for the compression libraries, those could be re-implemented, but I view those as wrappers around the libraries (same as the crypto stuff). I mean it doesn't have to be that way, but I'm trying to keep this framed in a tractable problem to start. So to summarize the non-contentious modules (including adding functools) in alphabetical order, that puts us at: array audioop binascii cjkcodecs csv functools itertools re struct I would be curious to see what frequency these modules are used to know what might be higher priority so that the least used modules could eventually be marked as CPython-specific. And to answer Chris' question, there is no need to be able to generate this from the docs until there is some PEP listing what modules must be implemented by a VM in order to considers its stdlib complete. And thanks for the help so far, everyone! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16651 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3073] Cookie.Morsel breaks in parsing cookie values with whitespace
Berker Peksag added the comment: The bug has been fixed in issue 8826. Related changeset: - http://hg.python.org/cpython/rev/cb231b79693e/ - Backport: http://hg.python.org/cpython/rev/84363c747c21 In Python 2.7.3: from Cookie import SimpleCookie cookies = SimpleCookie() cookies.load('foo=baz; expires=Sat, 10-Jun-1978 09:41:04 GMT') cookies SimpleCookie: foo='baz' cookies['foo']['expires'] 'Sat, 10-Jun-1978 09:41:04 GMT' cookies.load('foo=baz; expires=2008-06-10T09:44:45.963024') cookies['foo']['expires'] '2008-06-10T09:44:45.963024' -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3073 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16651] Find out what stdlib modules lack a pure Python implementation
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16651 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16651] Find out what stdlib modules lack a pure Python implementation
Amaury Forgeot d'Arc added the comment: PyPy has a pure Python implementation of sqlite (using ctypes): https://bitbucket.org/pypy/pypy/src/default/lib_pypy/_sqlite3.py It most probably works on CPython as well. Does it belong to this list? -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16651 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com