Re: Hold wxframe (GUI)
On Wednesday, 26 March 2014 10:34:26 UTC+5:30, Jaydeep Patil wrote: I constructed Two frames. One frame consist of GUI which consist of one Ok button. Afer click on OK button another GUI calls. But after Second gui calling, It wont stop further procesees. I need to stop futher proceeses. How can i hold second gui? Please reply Sample Code is: import wx class App(wx.App): ''' classdocs ''' def __init__(self,name=None): ''' Constructor ''' wx.App.__init__(self) self.d = Dashboard() self.d.Show() def _startMainLoop(self): self.MainLoop() pass def start(self): #self.d.Show() self._startMainLoop() pass class Dashboard(wx.Frame): ''' classdocs ''' def __init__(self,name=None): ''' Constructor ''' wx.Frame.__init__(self,None,wx.ID_ANY) print(Frame 1) self.btnOk = wx.Button(self,-1,OK) self.btnOk.Bind(wx.EVT_BUTTON,self.test) def test(self,event): print(Before) self.f = Dashboard1(self) ## I need to Stop here only self.f.Show() self.f.MakeModal(True) print(AFter) class Dashboard1(wx.Frame): ''' classdocs ''' def __init__(self,parent): ''' Constructor ''' wx.Frame.__init__(self,parent,wx.ID_ANY) a = App() a.start() Output is : Frame 1 Before After Hi all, I need to hold the other execution part after next GUI calls? How can do that? Anybody can help me? Regards Jaydeep Patil -- https://mail.python.org/mailman/listinfo/python-list
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
On 25/03/2014 12:39 PM, Mark H Harris wrote: my version semantically is how it is perceived by the user Could you please stop claiming to have insight into the comprehension of anyone other than yourself? Hasty generalisations don't help your argument. -- https://mail.python.org/mailman/listinfo/python-list
Re: gdb python how to output integer for examine memory
Wesley nisp...@gmail.com writes: ... Actually, I can now see the varialbe names at Python level and C level. I just want to verify x command to monitor the memory content. So, in my origin post, I can get variable i's address, and see the value is 1, then, I wanna have a try x command, the issue is, when use x/format i's address, the output is not 1, but other things:-( All Python objects start (at C level) with a header (containing the reference count, a pointer to the associated type and maybe other things); the real value starts behind this header. This means, to see the 1 in your example, you must skip the associated object header -- either in the output or by adding the size of the header to the initial address. -- https://mail.python.org/mailman/listinfo/python-list
Can we hold execution python programming till GUI event close on?
Hi... I have one wxframe. after click on that frame another frame opens and rest part is executed. I need ti stop the next execution after secong gui calls up. please suggest. -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On 25-03-14 23:47, Ethan Furman wrote: On 03/25/2014 12:29 PM, Mark H Harris wrote: On 3/25/14 2:24 PM, MRAB wrote: It's explained in PEP 3131. Basically, a name should to start with a letter (this has been extended to include Chinese characters, etc) or an underscore. λ is a classified as Lowercase_Letter. √ is classified as Math_Symbol. Thanks much! I'll note that for improvements. Any unicode symbol (that is not a number) should be allowed as an identifier. No, it shouldn't. Doing so would mean we could not use √ as the square root operator in the future. And what advantage would that bring over just using it as a function? -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: [newbie] confusion concerning fetching an element in a 2d-array
Op dinsdag 25 maart 2014 20:58:10 UTC+1 schreef Dave Angel: Jean Dubois jeandubois...@gmail.com Wrote in message: Op dinsdag 25 maart 2014 15:42:13 UTC+1 schreef Dave Angel: If your instructor wanted you to copy examples, he would have given you one. please Dave leave that belittling tone behind, there's no instructor whatsoever involved here. It wasn't my intention to belittle you; I'm sorry. But we do get a lot of people here asking for homework help, and not saying that's what it is. And when it's homework we do better explaining than just writing the code. In fact you only needed to add a line like data= infile.read () to Steven's original to get a complete working example. I constructed this example myself as I know very well I have to start with little pieces of code first to be able to master larger problems later. I just wanted to figure this example out first, and as I now learned from Peter's marvellous explanation there _is_ an elegant solution in Python to this kind of problem. So if you are irritated by newbie-questions in the future, just neglect them Not irritated, just temporarily misguided. OK, no hard feelings kind regards, jean -- https://mail.python.org/mailman/listinfo/python-list
Re: [newbie] confusion concerning fetching an element in a 2d-array
Op dinsdag 25 maart 2014 20:15:27 UTC+1 schreef Joel Goldstick: Jean, be aware there is also python tutor list you might like. This is sometimes a tough crowd here. Don't be discouraged. It can be a badge of honor sometimes thanks for the suggestions, I already subscribed to the python tutor list kind regards, jean -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On 26-03-14 03:56, MRAB wrote: On 2014-03-25 22:47, Ethan Furman wrote: On 03/25/2014 12:29 PM, Mark H Harris wrote: On 3/25/14 2:24 PM, MRAB wrote: It's explained in PEP 3131. Basically, a name should to start with a letter (this has been extended to include Chinese characters, etc) or an underscore. λ is a classified as Lowercase_Letter. √ is classified as Math_Symbol. Thanks much! I'll note that for improvements. Any unicode symbol (that is not a number) should be allowed as an identifier. No, it shouldn't. Doing so would mean we could not use √ as the square root operator in the future. Or as a root operator, e.g. 3 √ x (the cube root of x). Personally I would think such an operator is too limited to include in a programming language. This kind of notation is only used with a constant to indicate what kind of root is taken and only with positive integers. Something like the equivallent of the following I have never seen. t = 2.5 x = 8.2 y = t √ x Of course we don't have to follow mathematical convention with python. However allowing any unicode symbol as an identifier doesn't prohibit from using √ as an operator. We do have in and is as operators now, even if they would otherwise be acceptable identifiers. So I wonder, would you consider to introduce log as an operator. 2 log x seems an interesting operation for a programmer. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Time we switched to unicode? (was Explanation of this Python language feature?)
On 26-03-14 01:24, Terry Reedy wrote: The other fact that Chris noted, that '{}' would have been valid but with different meanings in Py1/2 versus Py3, was a factor on the cost side. We generally try to avoid such ambiguities. Except for this last point, I was in favor of the switch. In my estimation the cost would have been bearable. But I understand this kind of things is always a judgement call and different people can legitimately come to different conclusions. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On 26/03/2014 01:19, Ethan Furman wrote: On 03/25/2014 05:58 PM, Roy Smith wrote: One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pythonista, I'm using a timedelta to represent this value. It would be difficult to imagine a less useful default way to print a timedelta: previous sunset: -1 day, 22:25:26.295993 The idea of str() is that it's supposed to return a human-friendly representation of a value. Humans do not say things like, The sun set 1 day ago plus 22 hours and 25 minutes. I'm not sure whether to admire you for your stick-to-it-iveness, or pity you for the plight you are in. Either the first or second time I hit a datetime WTF moment I wrote my own wrapper classes. dateutils for me. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Hold wxframe (GUI)
On 26/03/2014 06:03, Jaydeep Patil wrote: Hi all, I need to hold the other execution part after next GUI calls? How can do that? Anybody can help me? I suggest you try a specific mailing list for wxpython, it's available at gmane.comp.python.wxpython amongst other places. Also would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
calling Python script from another Python script (Windows, multiple installation problem)
Hi all, I am trying to fix a bug in the project which I am working for. The program starts on Windows via bat file which calls a Python script to set up the environment including GUI and allow to launch program-specific tools. Some of the tools are written in C, some in Python. These commands are run via subprocess.Popen class. The Windows installer comes with its own bundled Python which is usually different from possible system-wide Python. This is source of the problems, Python scripts run via subprocess.Popen are launched via system-wide Python version, not desired bundled Python. Except hacks like `Popen(sys.executable, ...)` I am looking for a better solution. I checked virtualenv [1] or Pylauncher [2] but without success, speaking about Python2 not Python3 which comes from version 3.3 with intergrated pylauncher... Thanks in advance for any ideas, suggestions or pointers! Martin [1] http://www.virtualenv.org/en/latest/ [2] https://bitbucket.org/vinay.sajip/pylauncher -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Basic asyncio usage
Hi, I have posted the same question to python-tutor list *, but I'm trying my luck here as advised. I'm trying to get more familiar with asyncio library. Using python 3.4, I wrote simple echo server (see attachement for the code). I know that instead of using bare bone send/recv I could use some of the helper functions, but I want to start with the basics. Using attached code, I can connect from multiple sources, but echo won't work for all clients. Also, please look at the `sendall` mehtod - I have to manually remove write callback, otherwise it will be called all the time. Any tips on solving this problem? * https://mail.python.org/pipermail/tutor/2014-March/100679.html import asyncio import socket import time loop = asyncio.get_event_loop() class Client: def __init__(self, conn): self.conn = conn self.conn.setblocking(False) def recv(self, size): wrap `recv` method with future future = asyncio.Future() def _recv(): try: future.set_result(self.conn.recv(size)) except Exception as exc: future.set_exception(exc) loop.add_reader(self.conn, _recv) return future def sendall(self, data): wrap `sendall` method with future future = asyncio.Future() def _sendall(): try: # XXX manually remove, because otherwise it will be called # forever loop.remove_writer(self.conn) future.set_result(self.conn.sendall(data)) except Exception as exc: future.set_exception(exc) loop.add_writer(self.conn, _sendall) return future def close(self): self.conn.close() def accept(sock): future = asyncio.Future() def _accept_client(): conn, addr = sock.accept() future.set_result((Client(conn), addr)) loop.add_reader(sock, _accept_client) return future def handle_client(conn, addr): print(Client connected: {}.format(addr)) while True: data = yield from conn.recv(1024) if data.strip() == b'quit': conn.close() print(Client disconnected: {}.format(addr)) return yield from conn.sendall(data) @asyncio.coroutine def test(): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(False) sock.bind(('localhost', 12345)) sock.listen(1) while True: conn, addr = yield from accept(sock) asyncio.Task(handle_client(conn, addr)) def main(): loop.run_until_complete(test()) loop.close() if __name__ == __main__: main() -- https://mail.python.org/mailman/listinfo/python-list
Re: calling Python script from another Python script (Windows, multiple installation problem)
2014-03-26 10:40 GMT+01:00 Martin Landa landa.mar...@gmail.com: Hi all, I am trying to fix a bug in the project which I am working for. The program starts on Windows via bat file which calls a Python script to set up the environment including GUI and allow to launch program-specific tools. Some of the tools are written in C, some in Python. These commands are run via subprocess.Popen class. The Windows installer comes with its own bundled Python which is usually different from possible system-wide Python. This is source of the problems, Python scripts run via subprocess.Popen are launched via system-wide Python version, not desired bundled Python. Except hacks like `Popen(sys.executable, ...)` I am looking for a better solution. I checked virtualenv [1] or Pylauncher [2] but without success, speaking about Python2 not Python3 which comes from version 3.3 with intergrated pylauncher... Thanks in advance for any ideas, suggestions or pointers! Martin [1] http://www.virtualenv.org/en/latest/ [2] https://bitbucket.org/vinay.sajip/pylauncher -- https://mail.python.org/mailman/listinfo/python-list Hi, I'm probably missing some requirement of your use case, but I guess, it should be possible to specify the path of the desired python interpreter along with the executed script as an argument to Popen(...). This should make the selection of the used python explicit. Or are there any other disadvantages of the current approach, which you are solving in parallel? hth, vbr -- https://mail.python.org/mailman/listinfo/python-list
Dynamically reference member of array
Hi all, I know that I can dynamically reference a variable with locals()[i], for instance, but I'd like to know how to do this with a variable in an object. If I have an object called device, with variables called attr1, attr2 .. attr50, how could I dynamically reference these? It's fairly academic, but I'd like to avoid code duplication. Thanks, Ben -- https://mail.python.org/mailman/listinfo/python-list
Dynamically reference variable in object
Sorry, subject was wrong. Please see below: On Wednesday, 26 March 2014 11:43:49 UTC, Ben Collier wrote: Hi all, I know that I can dynamically reference a variable with locals()[i], for instance, but I'd like to know how to do this with a variable in an object. If I have an object called device, with variables called attr1, attr2 .. attr50, how could I dynamically reference these? It's fairly academic, but I'd like to avoid code duplication. Thanks, Ben -- https://mail.python.org/mailman/listinfo/python-list
FIXED: Dynamically reference variables in object
Hi all, I know that I can dynamically reference a variable with locals()[i], for instance, but I'd like to know how to do this with a variable in an object. If I have an object called device, with variables called attr1, attr2 .. attr50, how could I dynamically reference these? It's fairly academic, but I'd like to avoid code duplication. Thanks, Ben -- https://mail.python.org/mailman/listinfo/python-list
Re: FIXED: Dynamically reference variables in object
On 26-03-14 12:49, Ben Collier wrote: Hi all, I know that I can dynamically reference a variable with locals()[i], for instance, but I'd like to know how to do this with a variable in an object. If I have an object called device, with variables called attr1, attr2 .. attr50, how could I dynamically reference these? It's fairly academic, but I'd like to avoid code duplication. Thanks, Ben It looks like you are asking for getattr. getattr(device, attr1). However unless you have specific reasons to use atrributes (what you seem to call variables here), it seems you are better of using a dictionary. So you could then use: device[attr1]. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: FIXED: Dynamically reference variables in object
On Wed, Mar 26, 2014 at 10:49 PM, Ben Collier bmcoll...@gmail.com wrote: I know that I can dynamically reference a variable with locals()[i], for instance, but I'd like to know how to do this with a variable in an object. If I have an object called device, with variables called attr1, attr2 .. attr50, how could I dynamically reference these? It's fairly academic, but I'd like to avoid code duplication. Check out the getattr function: http://docs.python.org/3.5/library/functions.html#getattr But if you're doing that sort of thing, you may want to consider using a dictionary instead. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: calling Python script from another Python script (Windows, multiple installation problem)
Hi, it should be possible to specify the path of the desired python interpreter along with the executed script as an argument to Popen(...). This should make the selection of the used python explicit. Or are there any other disadvantages of the current approach, which you are solving in parallel? not really, I am just searching for a better solution based on virtualenv or something similar... Thanks, Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: calling Python script from another Python script (Windows, multiple installation problem)
Dne středa, 26. března 2014 13:29:47 UTC+1 Martin Landa napsal(a): not really, I am just searching for a better solution based on virtualenv or something similar... particularly I am using something like if sys.platform == win32: # get full path including file extension for scripts fcmd = get_real_command(args[0]) if fcmd.endswith('.py'): args[0] = fcmd args.insert(0, sys.executable) where 'args' in subprocess.Popen's argument. I just wonder if there is a better or preferable solution over this kind of a hack. Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: calling Python script from another Python script (Windows, multiple installation problem)
On Wed, Mar 26, 2014 at 11:49 PM, Martin Landa landa.mar...@gmail.com wrote: # get full path including file extension for scripts fcmd = get_real_command(args[0]) What's that function do? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: calling Python script from another Python script (Windows, multiple installation problem)
Dne středa, 26. března 2014 13:54:02 UTC+1 Chris Angelico napsal(a): On Wed, Mar 26, 2014 at 11:49 PM, Martin Landa landa.mar...@gmail.com wrote: # get full path including file extension for scripts fcmd = get_real_command(args[0]) this function returns a full path including file extension for scripts. If 'args[0]' is a binary file in the path, it returns 'args[0]'. If 'args[0]' is detected as a script (it finds in the search path file with such name and given extension, eg. `py`) it returns full path to the file, /path/to/file/args[0].py. -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
It's not clear to me what the correct str should be. I think the desired format changes depending on the relative magnitude of the timedelta object. For small values (less than a day), I agree, the behavior is, well, odd. You can get around that easily enough: d = datetime.timedelta(seconds=-2) str(d) '-1 day, 23:59:58' -%s % -d '-0:00:02' The problem gets more challenging once you get into magnitudes one day: e = datetime.timedelta(days=-4, seconds=3605) e datetime.timedelta(-4, 3605) print e -4 days, 1:00:05 Hmmm... It's printing just what we said, negative four days, positive one hour, five minutes. Let's try the trick from above: print -e 3 days, 22:59:55 -%s % -e '-3 days, 22:59:55' Ehhh... not so much. The fundamental problem here is the scope of the minus sign. My trick assumes it applied to the entire string representation. It's clear that in the first case that it applies to the entire displayed value, as there are no spaces. In the second case, we know it only applies to the days, because it's spitting back exactly what I fed the constructor. So, that means the simple minus sign trick won't work in the third case. Complicating things are that timedelta objects are normalized internally so that the seconds field is always non-negative (explaining the weird -1 day, 23:59:58 string representation of the first case). I'm not sure there's a one-size-fits-all solution to this problem. For offsets of less than a day, I suppose you could argue that the string representation shouldn't include the -1 day bit. Beyond that, I think you kind of have to live with what it gives you. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] [RELEASED] Python 3.4.0
Good job men :D 2014-03-17 14:18 GMT-03:00 Alioune Dia dia.aliou...@gmail.com: yeah , asyncio is a great module, congrat for all jobs you are doing --Ad | Dakar 2014-03-17 18:11 GMT+01:00 Giampaolo Rodola' g.rod...@gmail.com: The what's new looks truly amazing, with pathlib and asyncio being my favourite additions. Thanks for all the hard work. On Mon, Mar 17, 2014 at 5:57 PM, Ryan Gonzalez rym...@gmail.com wrote: YES!!! +1 to the authors of the statistics and pathlib modules. On Mon, Mar 17, 2014 at 1:29 AM, Larry Hastings la...@hastings.orgwrote: On behalf of the Python development team, I'm thrilled to announce the official release of Python 3.4. Python 3.4 includes a range of improvements of the 3.x series, including hundreds of small improvements and bug fixes. Major new features and changes in the 3.4 release series include: * PEP 428, a pathlib module providing object-oriented filesystem paths * PEP 435, a standardized enum module * PEP 436, a build enhancement that will help generate introspection information for builtins * PEP 442, improved semantics for object finalization * PEP 443, adding single-dispatch generic functions to the standard library * PEP 445, a new C API for implementing custom memory allocators * PEP 446, changing file descriptors to not be inherited by default in subprocesses * PEP 450, a new statistics module * PEP 451, standardizing module metadata for Python's module import system * PEP 453, a bundled installer for the *pip* package manager * PEP 454, a new tracemalloc module for tracing Python memory allocations * PEP 456, a new hash algorithm for Python strings and binary data * PEP 3154, a new and improved protocol for pickled objects * PEP 3156, a new asyncio module, a new framework for asynchronous I/O To download Python 3.4.0 visit: http://www.python.org/download/releases/3.4.0/ This is a production release. Please report any issues you notice to: http://bugs.python.org/ Enjoy! -- Larry Hastings, Release Manager larry at hastings.org (on behalf of the entire python-dev team and 3.4's contributors) ___ Python-Dev mailing list python-...@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ rymg19%40gmail.com -- Ryan If anybody ever asks me why I prefer C++ to C, my answer will be simple: It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was nul-terminated. -- https://mail.python.org/mailman/listinfo/python-list -- Giampaolo - http://grodola.blogspot.com ___ Python-Dev mailing list python-...@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/dia.aliounes%40gmail.com ___ Python-Dev mailing list python-...@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/d4n1h4ck%40gmail.com -- Msc. Daniel Pimentel (d4n1 http://about.me/d4n1) -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On 26-03-14 01:58, Roy Smith wrote: One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pythonista, I'm using a timedelta to represent this value. It would be difficult to imagine a less useful default way to print a timedelta: previous sunset: -1 day, 22:25:26.295993 The idea of str() is that it's supposed to return a human-friendly representation of a value. Humans do not say things like, The sun set 1 day ago plus 22 hours and 25 minutes. There is a difference between how people say things and what is useful. I remember when I was studying logarithms, a negative number like -5.73 was written down as ̅6.27 (with a bar only over the six). That notation had the advantage that the part after the decimal point stayed the same if you added or subtracted whole numbers. Even if that would change the sign. I can't give an honest estimation of how useful this notation is because I don't use the datetime module often enough. But I can imagine that those who wrote the module and I expect used it often found it a useful representation. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On Thu, Mar 27, 2014 at 1:02 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: There is a difference between how people say things and what is useful. I remember when I was studying logarithms, a negative number like -5.73 was written down as ̅6.27 (with a bar only over the six). That notation had the advantage that the part after the decimal point stayed the same if you added or subtracted whole numbers. Even if that would change the sign. That's highly significant with logs, especially when you're working with base 10 logs. math.log10(1234) 3.091315159697223 math.log10(12340) 4.091315159697223 math.log10(123400) 5.091315159697223 math.log10(1234000) 6.091315159697223 math.log10(12.34) 1.0913151596972228 math.log10(1.234) 0.09131515969722287 math.log10(.1234) -0.9086848403027772 math.log10(.01234) -1.9086848403027772 By showing those last ones as 1̅.091... and 2̅.091..., you emphasize the floating-point nature of the data: everything after the decimal is the mantissa, and everything before the decimal is the exponent. I can't say for sure as I don't really use that, but I can imagine that there might be something similar with dates and times - it's three days ago at 2:51, not two days and 21:09 ago. Or maybe it's just print it out in a way that more closely matches the internal representation, to simplify debugging :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Errors on text.get()
On Tuesday, March 25, 2014 2:15:11 PM UTC-7, enesk...@gmail.com wrote: Exception in Tkinter callback Traceback (most recent call last): File C:\Python33\lib\tkinter\__init__.py, line 1475, in __call__ return self.func(*args) File C:/Users/User/PycharmProjects/Cesarian Codes/project.py, line 43, in gen_random string = text.get('1.0', 'end') File C:\Python33\lib\tkinter\__init__.py, line 3104, in get return self.tk.call(self._w, 'get', index1, index2) _tkinter.TclError: invalid command name .44500976.44544352 I'm having a strange error. I haven't found anything online so far. If I should supply parts of the code, please post here. Thank you in advance! Thank you bro! -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
Antoon Pardon antoon.par...@rece.vub.ac.be: On 26-03-14 01:58, Roy Smith wrote: previous sunset: -1 day, 22:25:26.295993 The idea of str() is that it's supposed to return a human-friendly representation of a value. Humans do not say things like, The sun set 1 day ago plus 22 hours and 25 minutes. There is a difference between how people say things and what is useful. There is a standard timedelta representation: URL: http://www.schemacentral.com/sc/xsd/t-xsd_duration.html URL: http://en.wikipedia.org/wiki/ISO_8601#Durations If timedelta() were created today, it really should use that one because it is the only standard one, even though few people would use that in a human interface. Thus: -P1DT22H25M26.295993S Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On Wednesday, March 26, 2014 9:37:06 AM UTC-4, Skip Montanaro wrote: The problem gets more challenging once you get into magnitudes one day: e = datetime.timedelta(days=-4, seconds=3605) e datetime.timedelta(-4, 3605) print e -4 days, 1:00:05 Hmmm... It's printing just what we said, negative four days, positive one hour, five minutes. Let's try the trick from above: No, what you said was negative four days, positive 3605 seconds. Why does it make sense to normalize 3605 seconds to 1 hour, 5 seconds, but not extend that normalization to the days portion? Complicating things are that timedelta objects are normalized internally so that the seconds field is always non-negative The whole idea of datatypes is to hide the internal representation. If it's convenient on your platform, you can store timedeltas internally as fempto-years. That should not affect how it prints. -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On Wed, Mar 26, 2014 at 10:04 AM, Roy Smith r...@panix.com wrote: No, what you said was negative four days, positive 3605 seconds. My apologies for not showing all my work, professor. I use datetime and timedelta objects all the time. I did the arithmetic to go from 3605 to one hour, five minutes in my head. The point of my post was that there is no obvious one best way to present negative timedeltas in a human readable form. In my usage it's not generally a big deal, as most of the time I want to display datetime objects. In your case, it's obviously a problem. If Tim thought that timedelta objects would be presented to users as a regular course of doing business, maybe he would have given them a strftime() method. I suggest you write a function to format it the way you want and be done with it. You might consider taking a crack at a strftime() (and strptime?) implementation for timedelta objects that uses the ISO 8601 notation and submit it as a patch for datetimemodule.c. Note though, that the ISO8601 representation isn't without its own flaws (which might explain why Tim avoided it BITD): * It doesn't appear to provide a way to represent fractions of a second (though perhaps all the fields can be fractional) * How many days are in a month or a year? (It has format codes for both. Writing a useful strptime is probably impossible.) * It has other ambiguities (M represents both months and minutes - what were they thinking?) Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On Mar 26, 2014, at 11:39 AM, Skip Montanaro wrote: The point of my post was that there is no obvious one best way to present negative timedeltas in a human readable form. I agree that there are a number of possible representations which might make sense. But, using negative days and positive hours:minutes:seconds is just bizarre. I can't think of any possible application where that would be the desired format. --- Roy Smith r...@panix.com -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
Skip Montanaro s...@pobox.com: Note though, that the ISO8601 representation isn't without its own flaws (which might explain why Tim avoided it BITD): * It doesn't appear to provide a way to represent fractions of a second (though perhaps all the fields can be fractional) * How many days are in a month or a year? (It has format codes for both. Writing a useful strptime is probably impossible.) * It has other ambiguities (M represents both months and minutes - what were they thinking?) I don't have the (nonfree) ISO 8601 at hand, but URL: http://www.schemacentral.com/sc/xsd/t-xsd_duration.html contains the practical answers -- xsd is one important use case for str(timedelta), after all. Fractions of seconds are supported -- the other fields can't be fractional. The letter T separates months and minutes so there's no ambiguity there. str(timedelta()), unfortunately probably can't use anything but seconds since PT1M can be 61 seconds and P1D can be 23 or 25 hours (DST). As you say, P1M really means one month and P1Y means one year. The ambiguity is intentional; if you mean to pay your employees monthly, the interval is one month. Marko -- https://mail.python.org/mailman/listinfo/python-list
Delayed evaluation of expressions [was Re: Time we switched to unicode?]
On Wed, 26 Mar 2014 00:30:21 -0400, Terry Reedy wrote: On 3/25/2014 8:12 PM, Steven D'Aprano wrote: On Tue, 25 Mar 2014 19:55:39 -0400, Terry Reedy wrote: On 3/25/2014 11:18 AM, Steven D'Aprano wrote: The thing is, we can't just create a ∑ function, because it doesn't work the way the summation operator works. The problem is that we would want syntactic support, so we could write something like this: p = 2 ∑(n, 1, 10, n**p) Of course we can. If we do not insist on separating the dummy name from the expression that contains it. this works. def sigma(low, high, func): sum = 0 for i in range(low, high+1): sum += func(i) return sum There is no expression there. There is a function. You cannot pass an expression to a function in Python, One passes an unquoted expression in code by quoting it with either lambda, paired quote marks (Lisp used a single '), Passing *strings* and *functions* is not the same as having compiler support for delayed evaluation. At best its a second-class work-around. Contrast: def if_else(true_function, condition, false_function): if condition: return true_function() else: return false_function() if_else(lambda: x/0, x != 0, lambda: float(inf)) with this: x/0 if x != 0 else float(inf) Aside from the difference between the function form and operator form, the second case is much more direct and natural than the first. or using it in a form that implicitly quotes it (that includes def statements). Unquoted expressions in statements ultimately get passed to an internal functions. I think you are mistaken. Take the unquoted expression `x+1`. It doesn't get passed to anything, it gets compiled into byte code and evaluated: py from dis import dis py dis(x+1) 1 0 LOAD_NAME0 (x) 3 LOAD_CONST 0 (1) 6 BINARY_ADD 7 RETURN_VALUE Perhaps you are thinking of one or two special cases, such as list comps: py dis([x+1 for x in spam]) 1 0 LOAD_CONST 0 (code object listcomp at 0xb7af22a0, file dis, line 1) 3 LOAD_CONST 1 ('listcomp') 6 MAKE_FUNCTION0 9 LOAD_NAME0 (spam) 12 GET_ITER 13 CALL_FUNCTION1 (1 positional, 0 keyword pair) 16 RETURN_VALUE But that's an implementation detail, not a language requirement, and it doesn't apply to all delayed expressions: py dis(1/x if x else y) 1 0 LOAD_NAME0 (x) 3 POP_JUMP_IF_FALSE 14 6 LOAD_CONST 0 (1) 9 LOAD_NAME0 (x) 12 BINARY_TRUE_DIVIDE 13 RETURN_VALUE 14 LOAD_NAME1 (y) 17 RETURN_VALUE Some Python implementations may use internal functions under the hood to delay the evaluation of an expression, but you still need support from the interpreter to compile the expression as an internal function rather than evaluating it. not in the sense I am talking about, well, if you eliminate all the possibilities ... Obviously you can pass an expression to a function in the trivial sense that you can put an expression inside a function call. But that is not what I am talking about, since the expression is evaluated first, then the function is called: py dis(function(spam + eggs*cheese)) 1 0 LOAD_NAME0 (function) 3 LOAD_NAME1 (spam) 6 LOAD_NAME2 (eggs) 9 LOAD_NAME3 (cheese) 12 BINARY_MULTIPLY 13 BINARY_ADD 14 CALL_FUNCTION1 (1 positional, 0 keyword pair) 17 RETURN_VALUE I'm referring to delaying execution of the expression until later. Coincidentally, the Sum function we were discussing is a notable example of Jensen's Device: https://en.wikipedia.org/wiki/Jensen%27s_device which is effectively what I'm referring to. because expressions are not first-class objects. The concept is not a class, and the Python stdlib does not have an expression class. But people have written classes to represent the concept. I used existing classes instead. Expressions are not (normally) mathematical objects either. (An exception is rewriting theory, or other theories, where strings representing expressions or WFFs (well-formed formulas) are the only objects.) Mathematicians quote expression strings by context or positiion. The sigma form is one of many examples. Hmmm. I think you are misunderstanding me, possibly because I wrote first-class object when I should have called it a first-class value. Sorry. I'm not necessarily referring
Re: YADTR (Yet Another DateTime Rant)
On Wed, Mar 26, 2014 at 10:58 AM, Marko Rauhamaa ma...@pacujo.net wrote: Fractions of seconds are supported -- the other fields can't be fractional. Actually, it appears that whatever the last value you give can be fractionated. From the Wikipedia page you referenced: The smallest value used may also have a decimal fraction, as in P0.5Y to indicate half a year. As you say, P1M really means one month and P1Y means one year. The ambiguity is intentional; if you mean to pay your employees monthly, the interval is one month. True. Your comment about monthly intervals makes me realize that you probably can't map timedelta objects onto this ISO8601 duration stuff. It seems like if you want to specify pay my employees on the first of every month, then timedelta objects are the wrong thing. You want a recurrence relation, which is a more complex beast. For that, you want something like dateutil.rrule. There is a good reason that the internal units of timedelta objects are days, seconds, and microseconds. They are well-defined outside of a calendar context. So, I guess Roy is back to square one. He can always roll his own timedelta subclass and give it a __str__ implementation... S -- https://mail.python.org/mailman/listinfo/python-list
Re: unicode as valid naming symbols
On Wed, Mar 26, 2014 at 2:52 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: On 26-03-14 03:56, MRAB wrote: Or as a root operator, e.g. 3 √ x (the cube root of x). Personally I would think such an operator is too limited to include in a programming language. This kind of notation is only used with a constant to indicate what kind of root is taken and only with positive integers. Something like the equivallent of the following I have never seen. t = 2.5 x = 8.2 y = t √ x An example is taking the geometric mean of an arbitrary number of values: product = functools.reduce(operator.mul, values, 1) n = len(values) geometric_mean = n √ product I might argue though for the inverted syntax (product √ n) to more closely parallel division. Of course we don't have to follow mathematical convention with python. However allowing any unicode symbol as an identifier doesn't prohibit from using √ as an operator. We do have in and is as operators now, even if they would otherwise be acceptable identifiers. So I wonder, would you consider to introduce log as an operator. 2 log x seems an interesting operation for a programmer. If it's going to become an operator, then it has to be a keyword. Changing a token that is currently allowed to be an identifier into a keyword is generally avoided as much as possible, because it breaks backward compatibility. in and is have both been keywords for a very long time, perhaps since the initial release of Python. -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
Skip Montanaro s...@pobox.com: There is a good reason that the internal units of timedelta objects are days, seconds, and microseconds. They are well-defined outside of a calendar context. So, I guess Roy is back to square one. He can always roll his own timedelta subclass and give it a __str__ implementation... If you don't want to mix the intricacies of calendars to datetime and timedelta, why use them? (Epoch) seconds do everything for you unambiguously. Yes, yes. The physicists ought to stop fricking around with leap seconds. They should declare a 3000-year moratorium on leap seconds. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?]
On Wednesday, March 26, 2014 9:35:53 PM UTC+5:30, Steven D'Aprano wrote: On Wed, 26 Mar 2014 00:30:21 -0400, Terry Reedy wrote: On 3/25/2014 8:12 PM, Steven D'Aprano wrote: On Tue, 25 Mar 2014 19:55:39 -0400, Terry Reedy wrote: On 3/25/2014 11:18 AM, Steven D'Aprano wrote: The thing is, we can't just create a ∑ function, because it doesn't work the way the summation operator works. The problem is that we would want syntactic support, so we could write something like this: p = 2 ∑(n, 1, 10, n**p) Of course we can. If we do not insist on separating the dummy name from the expression that contains it. this works. def sigma(low, high, func): sum = 0 for i in range(low, high+1): sum += func(i) return sum There is no expression there. There is a function. You cannot pass an expression to a function in Python, One passes an unquoted expression in code by quoting it with either lambda, paired quote marks (Lisp used a single '), Passing *strings* and *functions* is not the same as having compiler support for delayed evaluation. At best its a second-class work-around. Contrast: Once the language has lambda, most else can be fashioned See the classic papers lambda the ultimate imperative lambda the ultimate declarative lambda the ultimate goto at here http://library.readscheme.org/page1.html Coincidentally, the Sum function we were discussing is a notable example of Jensen's Device: https://en.wikipedia.org/wiki/Jensen%27s_device which is effectively what I'm referring to. because expressions are not first-class objects. The concept is not a class, and the Python stdlib does not have an expression class. But people have written classes to represent the concept. I used existing classes instead. Expressions are not (normally) mathematical objects either. (An exception is rewriting theory, or other theories, where strings representing expressions or WFFs (well-formed formulas) are the only objects.) Mathematicians quote expression strings by context or positiion. The sigma form is one of many examples. Hmmm. I think you are misunderstanding me, possibly because I wrote first-class object when I should have called it a first-class value. Sorry. I'm not necessarily referring to creating something like an arithmetic expression class with methods and attributes. For example, sympy has things like that, so you can perform symbolic operations on the expression. That's not what I mean. What I mean is that you, the programmer, writes down an ordinary Python expression, using ordinary expression syntax, and the compiler treats it as a value in and of itself, rather than evaluating it to find out what value it has. In Python this will probably be some sort of object, but that's not the important part. The important part is that it is a *value*. (Compare to languages where functions are not first-class values. You cannot pass a function to another function, or stick them in a list, or create them on the fly. You can only call them, evaluating them immediately.) In Algol60, the compiler used thunks, which are a type of closure; in CPython, list comps use a hidden function object; the ternary if compiles byte code for a test and jump. In case you haven't read the article on Jensen's Device above, in Algol60 you can write a Sum function that behaves as a mathematician would expect. For example, to sum the entries of an array V for indexes 1 through 100, a mathematician might write it something like this: 10 ∑ V[i] i=1 which we can rearrange to function-call syntax like this: Sum(i, 1, 100, V[i]) In Algol60, this function call would: - pass the name i (not a string!) as the first argument; - pass 1 as the second argument; - pass 100 as the third argument; - pass the expression V[i] (not a string!) as the fourth argument and then *inside* the function Sum the expressions i and V[i] can be evaluated or assigned to as needed. Using Python syntax rather than Algol syntax: def Sum(name, lower, upper, expression): total = 0 for name in range(lower, upper+1): total += expression return total This doesn't work in Python! Python lacks call-by-name semantics, so the function call would: - evaluate the expression i, and pass that value as the first argument; - pass 1 as the second argument; - pass 100 as the third argument; - evaluate V[i] and pass that value as the fourth argument and then inside the function Sum name refers to the local variable name, not the caller's variable i. Likewise expression refers to a local variable, and not the caller's expression V[i]. Python has no general way of doing this. There are a few ad-hoc special cases, like list comps, the ternary if operator, etc. which are hard- coded in the compiler to delay execution of expressions. For the rest, you have a choice: -
Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?]
On Wednesday, March 26, 2014 11:02:04 PM UTC+5:30, Rustom Mody wrote: On Wednesday, March 26, 2014 9:35:53 PM UTC+5:30, Steven D'Aprano wrote: On Wed, 26 Mar 2014 00:30:21 -0400, Terry Reedy wrote: One passes an unquoted expression in code by quoting it with either lambda, paired quote marks (Lisp used a single '), Passing *strings* and *functions* is not the same as having compiler support for delayed evaluation. At best its a second-class work-around. Contrast: Once the language has lambda, most else can be fashioned See the classic papers lambda the ultimate imperative lambda the ultimate declarative lambda the ultimate goto at here http://library.readscheme.org/page1.html Details of Jensen implementation snipped Which I should have summarized as: lambda is the essential Delay operator. So much so that in scheme thaw and freeze are defined as (using pseudo-python syntax) def thaw(x) : return x() freeze(x) is a 'special-form' (aka macro) such that freeze(x) ≡ lambda : x -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On 2014-03-26, Skip Montanaro s...@pobox.com wrote: On Wed, Mar 26, 2014 at 10:58 AM, Marko Rauhamaa ma...@pacujo.net wrote: Fractions of seconds are supported -- the other fields can't be fractional. Actually, it appears that whatever the last value you give can be fractionated. From the Wikipedia page you referenced: We're still just papering-over the basic problem: the entire time/calendar system use by western civilization is a mess. I don't know a lot about other systems in use, but from what I have seen they were all pretty much just as bad. We should fix the basic problem first, then I bet the Python library problems will sort themselves out pretty easily. Of course to simplify matters, we're going to have to stop worrying so much about seasons and whether it's light or dark outside... -- Grant Edwards grant.b.edwardsYow! Hey, wait at a minute!! I want a gmail.comdivorce!! ... you're not Clint Eastwood!! -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
Grant Edwards invalid@invalid.invalid writes: We're still just papering-over the basic problem: the entire time/calendar system use by western civilization is a mess. I don't know a lot about other systems in use, but from what I have seen they were all pretty much just as bad. We should fix the basic problem first, then I bet the Python library problems will sort themselves out pretty easily. I see from my calendar that 1 April is still several days away. So I wonder how serious you are: we should forestall dealing with the reality of calendars, until the world fixes our difficulties for us? Of course to simplify matters, we're going to have to stop worrying so much about seasons and whether it's light or dark outside... Not too serious, I suppose. So what *do* you recommend we do? It's easy to point at the real world and say it's messy and distasteful to deal with, but that's a big part of the job we take on as programmers. -- \“… Nature … is seen to do all things Herself and through | `\ herself of own accord, rid of all gods.” —Titus Lucretius | _o__) Carus, c. 40 BCE | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Dynamically reference variable in object
On Mar 26, 2014 5:48 AM, Ben Collier bmcoll...@gmail.com wrote: Sorry, subject was wrong. Please see below: On Wednesday, 26 March 2014 11:43:49 UTC, Ben Collier wrote: Hi all, I know that I can dynamically reference a variable with locals()[i], for instance, but I'd like to know how to do this with a variable in an object. If I have an object called device, with variables called attr1, attr2 .. attr50, how could I dynamically reference these? It's fairly academic, but I'd like to avoid code duplication. You want to access object attributes, not variables. You can do this using the functions getattr and setattr like so: class Foo(object): pass ... obj = Foo() setattr(obj, x, 42) print(obj.x) 42 print(getattr(obj, x)) 42 -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
- Original Message - One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pythonista, I'm using a timedelta to represent this value. It would be difficult to imagine a less useful default way to print a timedelta: previous sunset: -1 day, 22:25:26.295993 The idea of str() is that it's supposed to return a human-friendly representation of a value. Humans do not say things like, The sun set 1 day ago plus 22 hours and 25 minutes. I can think of a less useful default way: previous sunset: 1 sunset ago This is how humans have been saying things for thousands of years before inventing the clock. Beside that, I think datetime has all the formatters required to do pretty much anything. Note : I don't see what's wrong in your example, however I have the feeling the term stupiditie is a little bit strong ;) 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. -- https://mail.python.org/mailman/listinfo/python-list
datetime
I want to keep a collection of data organized by collection date and I'll use datetime like this... datetime.date.today() datetime.date(2014, 3, 26) I'll format the date and create directories like /mydata/-mm-dd When I create a directory for today, I need to know the directory name for yesterday and tomorrow. In perl I could get seconds since the epoch using time and then add or subtract from that number for tomorrow or yesterday and feed that into localtime to get the date string. It would be convenient if datetime.date.today() accepted an argument as an offset from today, like datetime.date.today(-1). Is there an easy way to do this with datetime? -- https://mail.python.org/mailman/listinfo/python-list
Re: calling Python script from another Python script (Windows, multiple installation problem)
On 26Mar2014 05:49, Martin Landa landa.mar...@gmail.com wrote: Dne středa, 26. března 2014 13:29:47 UTC+1 Martin Landa napsal(a): not really, I am just searching for a better solution based on virtualenv or something similar... particularly I am using something like if sys.platform == win32: # get full path including file extension for scripts fcmd = get_real_command(args[0]) if fcmd.endswith('.py'): args[0] = fcmd args.insert(0, sys.executable) where 'args' in subprocess.Popen's argument. I just wonder if there is a better or preferable solution over this kind of a hack. Personally, the above is what I would do in your situation. Any solution involving virtualenv or the like will still need to point at the right python executable. Provided your code above is in a handy function, I wouldn't modify it. What virtualenv (presumably a virtualenv bundled in your package) _will_ give you is a stable and predictable collection of library files to go with your python interpreter. That could well be a significant benefit, especially in the face or an unknown target machine. So you may have a good case for putting a virtualenv in your bundle, but still using the _same_ code above to invoke stuff - the python in the virtualenv will set its sys.path, so the easy way is to use your existing code to access the virtualenv python executable. The only catch is that I do not know how mobile a virtualenv is; if your bundle is unpacked in an unknown temporary location, maybe virtualenv won't work correctly. Needs testing. Disclaimer: I'm a UNIX guy. Just my 2c. Hope it is helpful, -- Cameron Simpson c...@zip.com.au Carpe Datum - John Sloan jsl...@ncar.ucar.edu -- https://mail.python.org/mailman/listinfo/python-list
Re: datetime
Victor Engle wrote: I want to keep a collection of data organized by collection date and I'll use datetime like this... datetime.date.today() datetime.date(2014, 3, 26) I'll format the date and create directories like /mydata/-mm-dd When I create a directory for today, I need to know the directory name for yesterday and tomorrow. In perl I could get seconds since the epoch using time and then add or subtract from that number for tomorrow or yesterday and feed that into localtime to get the date string. It would be convenient if datetime.date.today() accepted an argument as an offset from today, like datetime.date.today(-1). Is there an easy way to do this with datetime? import datetime ONE_DAY = datetime.timedelta(days=1) today = datetime.date.today() today datetime.date(2014, 3, 26) today - ONE_DAY datetime.date(2014, 3, 25) today + ONE_DAY datetime.date(2014, 3, 27) -- https://mail.python.org/mailman/listinfo/python-list
Re: datetime
Victor Engle victor.en...@gmail.com writes: It would be convenient if datetime.date.today() accepted an argument as an offset from today, like datetime.date.today(-1). Is there an easy way to do this with datetime? The types defined in ‘datetime’ can perform calendar arithmetic:: import datetime today = datetime.date.today() one_day = datetime.timedelta(days=1) yesterday = today - one_day tomorrow = today + one_day URL:http://docs.python.org/3/library/datetime.html#datetime.timedelta -- \“Most people, I think, don't even know what a rootkit is, so | `\ why should they care about it?” —Thomas Hesse, Sony BMG, 2006 | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
Chris Angelico wrote: By showing those last ones as 1̅.091... and 2̅.091..., you emphasize the floating-point nature of the data: everything after the decimal is the mantissa, and everything before the decimal is the exponent. The reason for writing them that way is so that you can look the last part up in your log tables to find the antilog. I can't think of any corresponding justification for timedeltas. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?]
On Thu, Mar 27, 2014 at 4:32 AM, Rustom Mody rustompm...@gmail.com wrote: Now actual python def sumjensen(i_get, i_set,lower,upper,exp): tot = 0 i_set(lower) while i_get() = upper: tot += exp_get() i_set(i_get() + 1) return tot i=0 a=[3,4,5] i_get = lambda : i def i_set(val): global i i = val exp_get = lambda : a[i_get()] call as sumjensen(i_get, i_set, lower, upper, exp_get) [Note that because of lambda's restriction to being only an expression I have to make it a def because of need for global] You prove here that Python has first-class expressions in the same way that 80x86 assembly language has garbage collection. Sure, you can implement it using the primitives you have, but that's not support. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions
Chris Angelico ros...@gmail.com: You prove here that Python has first-class expressions in the same way that 80x86 assembly language has garbage collection. Sure, you can implement it using the primitives you have, but that's not support. I was more reminded of STL and Boost. For example: std::for_each(v.begin(), v.end(), ( switch_statement( _1, case_statement0(std::cout constant(zero)), case_statement1(std::cout constant(one)), default_statement(cout constant(other: ) _1) ), cout constant(\n) ) ); (URL: http://www.boost.org/doc/libs/1_55_0/doc/html/lambda/ le_in_details.html#lambda.switch_statement) Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Dynamically reference variable in object
On Wed, 26 Mar 2014 15:19:03 -0600, Ian Kelly wrote: You want to access object attributes, not variables. In fairness to the OP, the terminology instance variables meaning attributes or members of an instance is (sadly, in my opinion) common in some other languages, such as Java, and occasionally creeps into even the Python docs. I've often ranted about this, and won't repeat it now, only point out that the preferred and most common terminology in Python circles is attribute, or instance attribute if you need to distinguish it from class attribute. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?]
On Thu, 27 Mar 2014 09:24:49 +1100, Chris Angelico wrote: On Thu, Mar 27, 2014 at 4:32 AM, Rustom Mody rustompm...@gmail.com wrote: Now actual python def sumjensen(i_get, i_set,lower,upper,exp): tot = 0 i_set(lower) while i_get() = upper: tot += exp_get() i_set(i_get() + 1) return tot i=0 a=[3,4,5] i_get = lambda : i def i_set(val): global i i = val exp_get = lambda : a[i_get()] call as sumjensen(i_get, i_set, lower, upper, exp_get) [Note that because of lambda's restriction to being only an expression I have to make it a def because of need for global] You prove here that Python has first-class expressions in the same way that 80x86 assembly language has garbage collection. Sure, you can implement it using the primitives you have, but that's not support. +1 Any language can work around the lack of a language feature by sufficient layers of indirection, but that's not the same as having that language feature. Beyond a certain minimum feature set, all languages are Turing complete, and so in one sense are of equivalent power. But they're not all of equal expressiveness. Python is awesome, it is very expressive, but there are certain things you can't write directly in Python, and have to resort to circumlocutions instead. See also Paul Graham's Blub language essay: http://paulgraham.com/avg.html -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On 03/26/2014 04:25 PM, Dennis Lee Bieber wrote: On Tue, 25 Mar 2014 20:58:27 -0400, Roy Smith r...@panix.com declaimed the following: One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pythonista, I'm using a timedelta to represent this value. It would be difficult to imagine a less useful default way to print a timedelta: previous sunset: -1 day, 22:25:26.295993 The idea of str() is that it's supposed to return a human-friendly representation of a value. Humans do not say things like, The sun set 1 day ago plus 22 hours and 25 minutes. Makes sense to me -- the key being time DELTA... IE, a difference from some (unspecified) instance in time... If you want an instance of time, you need to add some known instance and the delta value. Making sense is not the same as user friendly... Hey, when did Bob get here? About 15 minutes ago. vs About an hour ago, plus 45 minutes. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On Wed, 26 Mar 2014 19:25:45 -0400, Dennis Lee Bieber wrote: On Tue, 25 Mar 2014 20:58:27 -0400, Roy Smith r...@panix.com declaimed the following: One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pythonista, I'm using a timedelta to represent this value. It would be difficult to imagine a less useful default way to print a timedelta: previous sunset: -1 day, 22:25:26.295993 The idea of str() is that it's supposed to return a human-friendly representation of a value. Humans do not say things like, The sun set 1 day ago plus 22 hours and 25 minutes. Makes sense to me -- the key being time DELTA... IE, a difference from some (unspecified) instance in time... If you want an instance of time, you need to add some known instance and the delta value. I think you have missed the point of the rant. Roy is not ranting that he has a timedelta. He wants a timedelta. He is ranting that the timedelta displays in a totally unintuitive fashion. Paraphrasing: the previous sunset was (one day less 22 hours and 25 minutes) ago instead of the previous sunset was (1 hour and 35 minutes) ago where the parts in the brackets come directly from the timedelta object. I think that you misread Roy's example as: 1 day plus 22 hours 25 minutes ago instead of: 1 day ago plus 22 hours 25 minutes (that is, 22 hours and 25 minutes after 1 day ago). The problem here, I believe, is that there are two ways of interpreting remainders for negative numbers. Dividing -5 by 2 can give either -2 with remainder -1, or -3 with remainder +1. Mathematically, it is *usually* more useful to go with the version with the positive remainder, and that's what Python does. But I think it's the wrong choice for timedelta. Let's take a simple example: a timedelta of 30 hours. What's that in days and hours? py divmod(30, 24) (1, 6) That makes perfect intuitive sense: 30 hours is 1 day with 6 hours remaining. In human-speak, we'll say that regardless of whether the timedelta is positive or negative: we'll say 1 day and 6 hours from now or 1 day and 6 hours ago. But when we specify the sign: py divmod(-30, 24) (-2, 18) If an event happened 30 hours ago, it is correct to say that it occurred 18 hours after 2 days ago, but who talks that way? -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?]
I agree that we have not been understanding each other. From you original post that I responded to: The thing is, we can't just create a ∑ function, because it doesn't work the way the summation operator works. The problem is that we would want syntactic support, so we could write something like this: p = 2 ∑(n, 1, 10, n**p) The initial misunderstanding is that I interpreted 'something like this' more loosely than you meant it. So I wrote something that was 'something like the above' to me but not to you. I interpreted 'something like' semantically* whereas you apparently meant is syntactically. I added the one or the other little marks needed to make the above work in python as it is whereas your 'something like' excludes such marks or any other current possibility I can think of. So I actually agree that can't is correct in relation to what you meant, as opposed to what I understood. Changing can't to can would requires a major change to Python. That change is one I would strongly oppose and I will try to explain more clearly why. [*When I qualify doc suggestions on the tracker with 'something like', as I usually do, I mean something that conveys the same meaning. So I edited your call text to convey the intended meaning in Python.] Lets start with things we should agree on. The first two are mostly not specific to Python. 1. When a compiler encounters an expression in code, there are at least three things it can do: 1a. compile it so that it is immediately executed when encountered at runtime (let this be the default); 1b. compile it so that it is somehow saved for execution later or elsewhere (the alternative of concern here); 1c. compile it for a different alternative, such as turning an implied 'get' operation into a 'set' operation. 2. A code writer who wants an alternative treatment for a particular must somehow delineate the expresion with boundary markers that, in context at least, also indicate the alternative treatment. There are, broadly, two possibilities: 2a. Use a generic quotation mechanism that can be applied to any expression most any place. I call this explicit quoting. 2b. Use the expression in a special form that the compiler knows about. The special form must have begin-end markers of some sort. I call this implicit quoting. If human readers do not know that a particular form is a special form, they may have a problem understanding the code. Python has 2 pairs of generic explicit delimiters: open-close quote marks and lambda-EndofLambda, where EndofLambda is ',', ')', EndofLine, or maybe something else. If these are not present, the default immediate execution mode is used for expressions in function calls that are not themselves marked for alternative treatment. Python's special forms are statements. Each has its own pair of delimiters. Assignments use BeginningofLine and '='. 'For' loops use 'for' and 'in'. Other statements use 'as' and usually EndofLine. Statements and functions call are syntactically very distinct, so there is little possibility of confusion. I consider this a major feature of python and I would oppose breaking it. Lisp, for instance, uses s-expressions for everything, including what would either function calls or statements in Python. Special functions implicitly quote some argument expressions, but not necessarily all, while normal functions do not quote any. The only way to know is to know, and I found it confusing and difficult to remember. Sum(i, 1, 100, V[i]) In Algol60, this function call would: - pass the name i (not a string!) as the first argument; - pass 1 as the second argument; - pass 100 as the third argument; - pass the expression V[i] (not a string!) as the fourth argument which depends for this operation on https://en.wikipedia.org/wiki/Jensen%27s_device I read the whole article, including the criticisms and the fact that it was not widely adopted and has been more or less superceded by macros. It did not answer the obvious question: suppose the call is Sum(i, l, h, V[i]). How is the reader supposed to know that 'i' and 'V[i]' get quoted and the other args do not? The article included real procedure Sum(k, l, u, ak) value l, u; integer k, l, u; real ak; comment k and ak are passed by name; begin real s; s := 0; for k := l step 1 until u do s := s + ak; Sum := s end; If that is supposed to be real code that can be compiled, I see no way for the comment to be true. Or is the mechanism limited to builtin functions? -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: python installation on windows
On Tue, 25 Mar 2014 18:17:30 -, rborol...@gmail.com wrote: Thanks for your comment but i also edited httpd.conf file then my wamp not running LoadModule php5_module c:/wamp/bin/php/php5.3.0/php5apache2_2.dll This line i added on line 128 but nothing. Wampserver showing yellow. I'm not getting what happening. I'm doing as per suggested in documentation And again if i'm removing this line then wampserver works properly I'm totally confused. You started out asking about problems getting mod_wsgi to load, and now without any indication that you've actually got mod_wsgi to load you are asking a Python group about a PHP module. Slow down, do one thing at a time and please don't assume that we can read your mind. Also please read https://wiki.python.org/moin/GoogleGroupsPython and take appropriate action. This post was unreadable when it got to me, and I nearly didn't bother putting in the effort to make it readable. -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: gdb python how to output integer for examine memory
在 2014年3月26日星期三UTC+8下午3时10分23秒,dieter写道: Wesley nisp...@gmail.com writes: ... Actually, I can now see the varialbe names at Python level and C level. I just want to verify x command to monitor the memory content. So, in my origin post, I can get variable i's address, and see the value is 1, then, I wanna have a try x command, the issue is, when use x/format i's address, the output is not 1, but other things:-( All Python objects start (at C level) with a header (containing the reference count, a pointer to the associated type and maybe other things); the real value starts behind this header. This means, to see the 1 in your example, you must skip the associated object header -- either in the output or by adding the size of the header to the initial address. Most like this. I will try later. -- https://mail.python.org/mailman/listinfo/python-list
Re: Time we switched to unicode? (was Explanation of this Python language feature?)
On Tue, 25 Mar 2014 06:12:50 -, Chris Angelico ros...@gmail.com wrote: Because the shorter symbols lend themselves better to the super-tokenization where you don't read the individual parts but the whole. The difference between 40 and forty is minimal, but the difference between 86400 and eighty-six thousand [and] four hundred is significant; the first is a single token, which you could then instantly recognize as the number of seconds in a day (leap seconds aside), but the second is a lengthy expression. It's not quite that simple, sadly (for me). I have mild dyscalculia, which in my case is another way of saying that collections of digits *aren't* tokens to me unless I ascribe a specific meaning to them. I don't work with day-level time differences a lot, so 86400 is just a string of digits to me. Powers of two and one less than powers of two I use a lot, so 65535 for example is a token. The more digits there are in the number, the harder it is for me to take in in a way that doesn't happen with letters. Even forty is better than 40 if you want me to recall it! -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: Time we switched to unicode? (was Explanation of this Python language feature?)
On Thu, Mar 27, 2014 at 12:16 PM, Rhodri James rho...@wildebst.org.uk wrote: It's not quite that simple, sadly (for me). I have mild dyscalculia, which in my case is another way of saying that collections of digits *aren't* tokens to me unless I ascribe a specific meaning to them. I don't work with day-level time differences a lot, so 86400 is just a string of digits to me. Powers of two and one less than powers of two I use a lot, so 65535 for example is a token. The more digits there are in the number, the harder it is for me to take in in a way that doesn't happen with letters. Even forty is better than 40 if you want me to recall it! Interesting. This suggests that your brain works happily with words (since you can recall forty more easily), but not with digits. But even in the normal case, that will be true to some extent. It's common to break up long numbers into groups of three or four digits - look at credit cards and phone numbers, for two very common examples. Treating 86400 as a single token comes more easily when you know it's the number of seconds in a day, and recognizing 604800 as the number of seconds in a week is pretty much essential to seeing it as a single token. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On Thu, Mar 27, 2014 at 11:16 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: If an event happened 30 hours ago, it is correct to say that it occurred 18 hours after 2 days ago, but who talks that way? That response demonstrates real genius. Rue the datetime? Who talks like that? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
In article mailman.8597.1395883727.18130.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Thu, Mar 27, 2014 at 11:16 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: If an event happened 30 hours ago, it is correct to say that it occurred 18 hours after 2 days ago, but who talks that way? That response demonstrates real genius. Rue the datetime? Who talks like that? I had a dangling pointer error, and blew my stack to half past last wednesday -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?]
On Thursday, March 27, 2014 5:13:21 AM UTC+5:30, Steven D'Aprano wrote: On Thu, 27 Mar 2014 09:24:49 +1100, Chris Angelico wrote: wrote: Now actual python def sumjensen(i_get, i_set,lower,upper,exp): tot = 0 i_set(lower) while i_get() = upper: tot += exp_get() i_set(i_get() + 1) return tot i=0 a=[3,4,5] i_get = lambda : i def i_set(val): global i i = val exp_get = lambda : a[i_get()] call as sumjensen(i_get, i_set, lower, upper, exp_get) [Note that because of lambda's restriction to being only an expression I have to make it a def because of need for global] You prove here that Python has first-class expressions in the same way that 80x86 assembly language has garbage collection. Sure, you can implement it using the primitives you have, but that's not support. +1 Any language can work around the lack of a language feature by sufficient layers of indirection, but that's not the same as having that language feature. Beyond a certain minimum feature set, all languages are Turing complete, and so in one sense are of equivalent power. But they're not all of equal expressiveness. Python is awesome, it is very expressive, but there are certain things you can't write directly in Python, and have to resort to circumlocutions instead. Of course. And there are different grades of circumlocution -- of 'coding-up' -- a missing feature. Terry said: One passes an unquoted expression in code by quoting it with either lambda, paired quote marks (Lisp used a single '), Steven responded: Passing *strings* and *functions* is not the same as having compiler support for delayed evaluation. At best its a second-class work-around. I was merely pointing out that 'passing strings' and 'passing functions' as 'coding-up' of some desirable but unavailable feature are very different levels of work-around. In fact there are actually 3 styles and levels of circumlocution 1. You dont have a certain language -- blub?? -- feature set. So... code it up and write its interpreter as eval_blub. 2. You dont have a feature-set but can see similarity in some obtuse host-language (in this case python). So you code up a mini-translator for your feature-set neatly written to obtuse hostly written and then eval (note python eval not blub eval) 3. You dont go outside the language framework and into any eval-ish mode at all. Good ol subroutine libraries to classes for abstraction to first-class functional abstraction -- all fall into this category -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?]
On Wed, 26 Mar 2014 20:44:17 -0400, Terry Reedy wrote: I agree that we have not been understanding each other. From you original post that I responded to: The thing is, we can't just create a ∑ function, because it doesn't work the way the summation operator works. The problem is that we would want syntactic support, so we could write something like this: p = 2 ∑(n, 1, 10, n**p) The initial misunderstanding is that I interpreted 'something like this' more loosely than you meant it. So I wrote something that was 'something like the above' to me but not to you. I interpreted 'something like' semantically* whereas you apparently meant is syntactically. I added the one or the other little marks needed to make the above work in python as it is whereas your 'something like' excludes such marks or any other current possibility I can think of. So I actually agree that can't is correct in relation to what you meant, as opposed to what I understood. Changing can't to can would requires a major change to Python. That change is one I would strongly oppose and I will try to explain more clearly why. I'm not making a serious proposal to change Python's behaviour. In context, this came up because I said that allowing arbitrary maths symbols in Python wouldn't work, because you can't get the behaviour right, and used the example of ∑(n, 1, 10, n**p) as something where the behaviour would be different from what a mathematician would like. Given that the semantics would be so different, there's little point in trying to match the symbol ∑ too. Just write it as sum() in the Pythonic style. Python is not Mathematica. (However, you could, perhaps, write Mathematica in Python.) That was the context of introducing delayed evaluation to the discussion. But having raised it, I do think it is an important and useful feature. Python already has it in various ad hoc places, such as list comps and generator expressions, ternary if, and/or, and it came up again recently in the PEP for try...except expressions. It doesn't happen every day, but there is a steady trickle of requests (some successful, some not) for compiler support for something that includes delaying the evaluation of some expression until later. Some day, if all the pieces come into place, I may make a serious proposal for a generic mechanism for delaying execution of expressions. But that is not this day. [...] Lets start with things we should agree on. The first two are mostly not specific to Python. 1. When a compiler encounters an expression in code, there are at least three things it can do: 1a. compile it so that it is immediately executed when encountered at runtime (let this be the default); 1b. compile it so that it is somehow saved for execution later or elsewhere (the alternative of concern here); 1c. compile it for a different alternative, such as turning an implied 'get' operation into a 'set' operation. I don't actually understand what 1c is, or rather I understand what you mean, I don't understand why a compiler would do that. But I don't think it is important, so carry on. 2. A code writer who wants an alternative treatment for a particular must somehow delineate the expresion with boundary markers that, in context at least, also indicate the alternative treatment. Not necessarily. That's not how it works in Pascal and Algol. In the case of Algol, argument passing is pass-by-name unless declared otherwise. In the case of Pascal, expressions are always evaluated first (pass-by- value), except for one special case: if the expression consists of a single name, AND the function declares the parameter to be a var parameter, Pascal uses pass-by-reference, which you can think of as conceptually like a cut-down restricted version of pass-by-name. But the point is that the decision whether to evaluate the expression immediately or not could be up to the compiler, not the caller. In fact, that's what Python already does: mylist and mylist[0] always delays evaluation of the second clause, the caller doesn't have to do anything special except to ensure she writes them in the right order. The problem with the Pascal approach, where the function declares what calling mechanism to use, is that this needs the function to be known at compile time so that the compiler knows what mechanism to use to pass the argument into the function. As far as I know, the languages which offer a choice of calling convention (Pascal, Basic?) have static function declarations known at compile-time. I'm not sure about Perl. Anyway, the point is that in principle there is another mechanism: the compiler knows whether to delay evaluation or not, and the caller has no say in it. There are, broadly, two possibilities: 2a. Use a generic quotation mechanism that can be applied to any expression most any place. I call this explicit quoting. Skipping ahead: Python has 2 pairs of
regex line by line over file
I can't get this to work. It runs but there is no output when I try it on a file. #!/usr/bin/python import os import sys import re from datetime import datetime #logDir = '/nfs/projects/equinox/platformTools/RTLG/RTLG_logs'; #os.chdir( logDir ); programName = sys.argv[0] fileName = sys.argv[1] #pattern = re.compile('\s*\\SHELF-.*,SC,.*,:\\Log Collection In Progress\\') re.M p = re.compile('^\s*\SHELF-.*,SC,.*,:\\\Log Collection In Progress\\\') l = 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE' # this works :-) m = p.match( l ) if m: print( l ) # this doesn't match anything (or the if doesn't work) :-( with open(fileName) as f: for line in f: # debug code (print the line without adding a linefeed) # sys.stdout.write( line ) if p.match(line): print(line) The test file just has one line: SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE -- https://mail.python.org/mailman/listinfo/python-list
Re: regex line by line over file
On Thu, Mar 27, 2014 at 2:23 PM, James Smith bjloc...@lockie.ca wrote: re.M p = re.compile('^\s*\SHELF-.*,SC,.*,:\\\Log Collection In Progress\\\') If you're expecting this to be parsed as a multiline regex, it won't be. Probing re.M doesn't do anything on its own; you have to pass it as an argument to compile. Not sure if that's your problem or not, though. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: YADTR (Yet Another DateTime Rant)
On Thu, 27 Mar 2014 00:16:57 +, Steven D'Aprano wrote: py divmod(-30, 24) (-2, 18) If an event happened 30 hours ago, it is correct to say that it occurred 18 hours after 2 days ago, but who talks that way? Well, not *exactly*, but: If today happens to be Wednesday, and an event occurred last Friday, I might say a week ago Friday. Similarly, today, I could also say it'll be two years at my new job next month. For an event that occurred approximately 310 days ago, I might say less than a year ago, and for an event that occurred approximately 350 days ago, I might say a little less than a year ago. Or did you forget to put the winky there, and I fell for it? 11 years, 2 months, 26 days, 9 hours, 3 minutes, 27.4 seconds'ly yours, Dan -- https://mail.python.org/mailman/listinfo/python-list
Re: regex line by line over file
On Wednesday, March 26, 2014 11:23:29 PM UTC-4, James Smith wrote: I can't get this to work. It runs but there is no output when I try it on a file. #!/usr/bin/python import os import sys import re from datetime import datetime #logDir = '/nfs/projects/equinox/platformTools/RTLG/RTLG_logs'; #os.chdir( logDir ); programName = sys.argv[0] fileName = sys.argv[1] #pattern = re.compile('\s*\\SHELF-.*,SC,.*,:\\Log Collection In Progress\\') re.M p = re.compile('^\s*\SHELF-.*,SC,.*,:\\\Log Collection In Progress\\\') l = 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE' # this works :-) m = p.match( l ) if m: print( l ) # this doesn't match anything (or the if doesn't work) :-( with open(fileName) as f: for line in f: # debug code (print the line without adding a linefeed) # sys.stdout.write( line ) if p.match(line): print(line) The test file just has one line: SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE I tried the re.M in the compile and that didn't help. -- https://mail.python.org/mailman/listinfo/python-list
Re: regex line by line over file
On Thursday, March 27, 2014 8:53:29 AM UTC+5:30, James Smith wrote: I can't get this to work. It runs but there is no output when I try it on a file. #!/usr/bin/python import os import sys import re from datetime import datetime #logDir = '/nfs/projects/equinox/platformTools/RTLG/RTLG_logs'; #os.chdir( logDir ); programName = sys.argv[0] fileName = sys.argv[1] #pattern = re.compile('\s*\\SHELF-.*,SC,.*,:\\Log Collection In Progress\\') re.M p = re.compile('^\s*\SHELF-.*,SC,.*,:\\\Log Collection In Progress\\\') l = 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE' # this works :-) m = p.match( l ) if m: print( l ) # this doesn't match anything (or the if doesn't work) :-( with open(fileName) as f: for line in f: # debug code (print the line without adding a linefeed) # sys.stdout.write( line ) if p.match(line): print(line) The test file just has one line: SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE Some suggestions (Im far from an re expert!) 1. Use raw strings for re's 2. You probably need non-greedy '*' (among other things) 3. Better to hack out your re in the interpreter For that 4. Avoid compile (at least while hacking) 5. Findall will show you whats happening better than match Heres a 'hack-session' from re import findall l = 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE' # Start simple findall(r'^\s',l) [' '] findall(r'^\s*',l) [''] findall(r'^\s*',l) [''] findall(r'^\s*SHELF-',l) ['SHELF-'] findall(r'^\s*SHELF-.*',l) ['SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:Log Collection In Progress,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE'] findall('^\s*SHELF-.*',l) ['SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:Log Collection In Progress,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE'] findall('^\s*SHELF-.SC*',l) [] findall('^\s*SHELF-.*SC',l) ['SHELF-17:LOG_COLN_IP,SC'] findall('^\s*SHELF-.*?SC',l) ['SHELF-17:LOG_COLN_IP,SC'] findall('^\s*SHELF-.*?,SC',l) ['SHELF-17:LOG_COLN_IP,SC'] findall('(^\s*)SHELF-.*?,SC',l) [''] findall('\(^\s*\)SHELF-.*?,SC',l) [] findall('(^\s*)SHELF-.*?,SC',l) [''] findall('(^\s*)(SHELF-.*?,SC)',l) [('', 'SHELF-17:LOG_COLN_IP,SC')] -- https://mail.python.org/mailman/listinfo/python-list
Re: regex line by line over file
On Thu, Mar 27, 2014 at 3:14 PM, James Smith bjloc...@lockie.ca wrote: I tried the re.M in the compile and that didn't help. Okay. Try printing out the repr of the line at the point where you have the commented-out write to stdout. That might tell you if there's some other difference. At that point, you'll know if the issue is with reading it from the file. Also, please either stop using Google Groups, or clean up its messes. I don't like having to read through piles of double-spaced junk in the quoted text. Thanks! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Delayed evaluation of expressions
On Thursday, March 27, 2014 4:15:19 AM UTC+5:30, Marko Rauhamaa wrote: Chris Angelico : You prove here that Python has first-class expressions in the same way that 80x86 assembly language has garbage collection. Sure, you can implement it using the primitives you have, but that's not support. I was more reminded of STL and Boost. For example: std::for_each(v.begin(), v.end(), ( switch_statement( _1, case_statement0(std::cout constant(zero)), case_statement1(std::cout constant(one)), default_statement(cout constant(other: ) _1) ), cout constant(\n) ) ); (URL: http://www.boost.org/doc/libs/1_55_0/doc/html/lambda/ le_in_details.html#lambda.switch_statement) I must admit I have a hard time reading C++! However that link seems to be saying more or less what I am -- viz. lambda is a delay operator -- https://mail.python.org/mailman/listinfo/python-list
Re: regex line by line over file
On Wed, 26 Mar 2014 20:23:29 -0700, James Smith wrote: I can't get this to work. It runs but there is no output when I try it on a file. Simplify, simplify, simplify. Either you will find the problem, or you will find the simplest example that demonstrates the problem. In this case, the problem is that your regex is not matching what you expect it to match. So eliminate all the irrelevant cruft that is just noise, complicating the problem. Start with the simplest thing that works and add complexity until the problem returns. Eliminate the file. You can embed your data in a string, and try to match the regex against the string. Eliminate all the old commented-out code, that's just irrelevant. Eliminate reading from sys.argv, that has nothing to do with the problem. So we get down to this: import re pat = re.compile('^\s*\SHELF-.*,SC,.*,:\\\Log Collection In Progress\\\') line1 = 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE' print(pat.match(line1)) which matches. Now let's get rid of those leaning toothpicks. We can use print to see the repr() of the pattern, and a raw string to clean it up. At the interactive interpreter: py print(pat.pattern) ^\s*SHELF-.*,SC,.*,:\Log Collection In Progress\ Similarly for line1. I'll also use implicit concatenation to split it over multiple source lines. Raw strings, r'' or r, don't need to escape the backslashes. Implicit concatenation means that two strings with no operator between them is implicitly concatenated into a single string: 'abc' def becomes 'abcdef'. By putting the pieces inside parentheses, I can put each piece on a separate line, which makes it easier to read compared to one giant long line. pat = re.compile( r'^\s*SHELF-.*,SC,.*,:\Log Collection In Progress\' ) line1 = ( 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:' 'Log Collection In Progress,NONE:170035-6364-1048,:' 'YEAR=2014,MODE=NONE' ) And at the interactive interpreter, I get a match: py pat.match(line1) _sre.SRE_Match object at 0xb721ad78 So now we move on to the content of the one-line file. I don't have access to the file, so all I have to go by is what you state it contains: [quote] The test file just has one line: SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE [end quote] which I interpret like this: line2 = 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\Log Collection In Progress\,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE\n' (note the newline at the end), or if you prefer: line2 = ( 'SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:' 'Log Collection In Progress,NONE:170035-6364-1048,:' 'YEAR=2014,MODE=NONE\n' ) Except for the newline, it equals line1, and it also matches the pattern: py pat.match(line2) _sre.SRE_Match object at 0xb721ab48 So now we know that the regex matches the data you think you have. The next questions are: - are you reading the right file? - are you mistaken about the content of the file? I can't help you with the first. But the second: try running this: # line2 and pat as defined above filename = sys.argv[1] with open(filename) as f: for line in f: print(len(line), line==line2, repr(line)) print(repr(pat.match(line))) which will show you what you have and whether or not it matches what you think it has. I expect that the file contents is not what you think it is, because the regex is matching the sample line. Good luck! -- Steven -- https://mail.python.org/mailman/listinfo/python-list
[issue21045] fix layout to generate documentation for Qt Assistant
Georg Brandl added the comment: Thanks for the report! -- nosy: +georg.brandl resolution: fixed - stage: committed/rejected - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21045 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21045] fix layout to generate documentation for Qt Assistant
Changes by Georg Brandl ge...@python.org: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21045 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21067] Support Multiple finally clauses.
Raymond Hettinger added the comment: If you think this should go forward please discuss it on the python-ideas list. For it to go forward a PEP will likely need to be written. I concur with this assessment. Marking this as closed. -- nosy: +rhettinger resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21067 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21069] urllib unit tests failing without ssl module
New submission from Daniel Farrell: I'm seeing quite a few unit test failures in urllib (urlopen error unknown url type: https). From what I've gathered on IRC, this seems to be because I'm missing the ssl module. I'm seeing these errors in 3.4.0, after a simple `./configure; make; make test`. Test results: http://pastebin.com/5LBAjkVW I'm not seeing them after `hg clone http://hg.python.org/cpython; ./configure --with-pydebug make -j2; ./python -m test -j3`, via http://docs.python.org/devguide/#quick-start. Issue 20939 is the closest thing I've found to this, but it seems to be more narrowly scoped (http - https change at python.org). Nice people on IRC suggest that this is a different enough problem to warrant a new issue. I'm on an up-to-date Fedora 20 install. -- files: test_failures.txt messages: 214882 nosy: dfarrell07 priority: normal severity: normal status: open title: urllib unit tests failing without ssl module versions: Python 3.4 Added file: http://bugs.python.org/file34626/test_failures.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21069 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20210] Provide configure options to enable/disable Python modules and extensions
Arfrever Frehtes Taifersar Arahesis added the comment: If it is planned to support BSD make, then partial rewrite of patches will be needed. Example of syntax of GNU make: ifeq (something,something) … endif Example of syntax of FreeBSD make: .if ${variable}==something … .endif -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20210] Provide configure options to enable/disable Python modules and extensions
Arfrever Frehtes Taifersar Arahesis added the comment: According to koobs, building of CPython with FreeBSD make works at least with -j1 (and sporadically fails with higher value). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20210] Provide configure options to enable/disable Python modules and extensions
koobs added the comment: More precisely: Python 3.3 fails at anything -j1 (switching to gmake makes this go away) Python 3.4 has not failed up to -j8 (with bsd make) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21057] TextIOWrapper does not support reading bytearrays or memoryviews
Serhiy Storchaka added the comment: If someone is willing to do the work (and I am), is there a reason *not* to allow TextIOWrapper to accept bytes-like objects? Yes, there are. The code which works only with bytes is much simpler. Not only TextIOWrapper, but many other classes in the stdlib (GzipFile, BZ2File, LZMAFile, ZipFile) expect that the read method of underlied file object returns bytes, so your MyByteStream is just broken for such cases. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21057 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20526] python: Modules/gcmodule.c:379: visit_decref: Assertion `((gc)-gc.gc_refs (1)) != 0' failed.
STINNER Victor added the comment: I encounter a quite similar issue with python 3.4.0 and cx_Oracle. Your issue is different, compare the top frames: My trace: #0 0x003f3a835c59 in raise () from /lib64/libc.so.6 #1 0x003f3a837368 in abort () from /lib64/libc.so.6 #2 0x003f3a82ebb6 in __assert_fail_base () from /lib64/libc.so.6 #3 0x003f3a82ec62 in __assert_fail () from /lib64/libc.so.6 #4 0x0043ac66 in visit_decref ( op=Frame 0x7f013c001398, for file x.py, line 43 (...) at Modules/gcmodule.c:379 #5 0x004336bd in tb_traverse (tb=0x7f01493a66e8, visit=0x43abb4 visit_decref, arg=0x0) at Python/traceback.c:64 #6 0x0043acdc in subtract_refs (containers=0x8f1a20 generations+64) at Modules/gcmodule.c:398 cx_Oracle trace: #0 0x0043ab98 in visit_decref (op=0xb, data=0x0) at Modules/gcmodule.c:373 #1 0x0048193a in BaseException_traverse (self=0x70f645f8, visit=0x43ab64 visit_decref, arg=0x0) at Objects/exceptions.c:97 #2 0x004dc4cc in subtype_traverse (self=0x70f645f8, visit=0x43ab64 visit_decref, arg=0x0) at Objects/typeobject.c:972 In my trace, visit_decref() is called on a frame and fail with an assertion error. In cx_Oracle trace, visit_decref() is called on a NULL pointer which comes from an Exception. In my experience, it's a bug in cx_Oracle. If you think that I'm wrong and that it's a bug in Python, please open a *new* issue since the trace is different. -- For your cx_Oracle, issue: #1 0x0048193a in BaseException_traverse (self=0x70f645f8, visit=0x43ab64 visit_decref, arg=0x0) at Objects/exceptions.c:97 Can you go this frame (in gdb, type frame 1) and dump the Exception object: (gdb) print _PyObject_Dump(0x0048193a) Note for myself: I should write a documentation explaining how to debug Python in gdb. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20526 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20210] Provide configure options to enable/disable Python modules and extensions
STINNER Victor added the comment: Antoine Pitrou wrote: I don't really like the idea of complicating our build tools even more. Can't you simply prune the install tree yourself? In the embedded world, the (cross) compilation process is very complex and slow. Being able to disable features makes this task simpler. Éric Araujo wrote: The main issue with the proposed changes is that it redefines what “the Python standard library” is. I disagree. It's a common practice that a vendor gives the user the choice to enable or disable some features. On Gentoo and FreeBSD, you can disable features like IPv6 or shared memory on some packages. I don't think that it's currently possible on Python, but I would not be surprised to be able to enable or disable some features. Éric Araujo wrote: Right now, users can mostly expect modules listed in the official Python docs to be available in their installation, regardless of how they got their Python. How you get Python matters :-) Python documentations describes the vanilla flavor distributed at python.org. But the Python license allows to strip some features without changing the name of the Python. -- 0002-Add-an-option-to-disable-installation-of-test-module.patch is interested. I never understand why Python installs its test suite. Who use this test suite installed on the system? Maybe the packager of the module to test Python. Ok, but the test suite can then be removed. I like the overall approach, by individual patches may be discussed. For example, 0008-Add-an-option-to-disable-expat.patch breaks Python XML modules. Are they still be installed? I mean the modules implemented in Python and relying on the expat Python module. The changes should be be documented somewhere. In the Python documentation, or at least in the devguide. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20951] SSLSocket.send() returns 0 for non-blocking socket
Antoine Pitrou added the comment: I vote -1 to adding a new flag to control whether it returns zero or raises and +0 to just fixing it in Python 3.5 (I don't think returning zero is an unreasonable thing to do; it's not obvious to me from send(2) that it is guaranteed to never return zero although I believe that to be the case). It'll break Tornado, but there will be plenty of time to get a fix out before then. If that's your opinion then I'm inclined to trust you. Another option may be to have SSLSocket.send() convert the WANT_WRITE exception into a socket.error with errno EAGAIN. I don't think it's a good idea, since it hides the true reason of the error (also, it suppresses the distinction between WANT_READ and WANT_WRITE, which tells you whether you need to select() the socket for reading or writing). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20951 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20526] python: Modules/gcmodule.c:379: visit_decref: Assertion `((gc)-gc.gc_refs (1)) != 0' failed.
Antoine Pitrou added the comment: In cx_Oracle trace, visit_decref() is called on a NULL pointer which comes from an Exception. Unless C conventions changed, 0xb is not a NULL pointer :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20526 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21057] TextIOWrapper does not support reading bytearrays or memoryviews
STINNER Victor added the comment: 2014-03-26 0:35 GMT+01:00 Antoine Pitrou rep...@bugs.python.org: - they are immutable: you can keep an internal reference to a bytes object and be sure it won't change under your feet Is it possible to request this feature using PyObject_GetBuffer()? I don't see such flag. If it's not possible, a new flag is maybe needed? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21057 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20210] Provide configure options to enable/disable Python modules and extensions
Antoine Pitrou added the comment: Antoine Pitrou wrote: I don't really like the idea of complicating our build tools even more. Can't you simply prune the install tree yourself? In the embedded world, the (cross) compilation process is very complex and slow. Being able to disable features makes this task simpler. That's not really the point. The question is why we should have to maintain this ourselves. It is easy for interested people to maintain their own forks, especially when *removing* stuff. For the record, we don't have a single cross-compiling buildbot: it isn't a supported setup. 0002-Add-an-option-to-disable-installation-of-test-module.patch is interested. I never understand why Python installs its test suite. Who use this test suite installed on the system? Maybe the packager of the module to test Python. Ok, but the test suite can then be removed. How else do you want to test that your Python installation works, other than running the test suite? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20210] Provide configure options to enable/disable Python modules and extensions
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21057] TextIOWrapper does not support reading bytearrays or memoryviews
STINNER Victor added the comment: class MyByteStream(BytesIO): def read1(self, len_): return memoryview(super().read(len_)) bs = MyByteStream(b'some data in ascii\n') I guess that you are trying to implement a zero-copy I/O. The problem is that BytesIO does copy data. Example: data=b'abcdef' x=io.BytesIO(data) x.read() is data False Before trying to avoid copies in the buffered layer, something should be done for the raw layer (BytesIO in this case). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21057 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20526] python: Modules/gcmodule.c:379: visit_decref: Assertion `((gc)-gc.gc_refs (1)) != 0' failed.
STINNER Victor added the comment: Unless C conventions changed, 0xb is not a NULL pointer :-) Ooops, I missed the B :-) By the way, my gdb example is wrong: you should pass self :-) #1 0x0048193a in BaseException_traverse (self=0x70f645f8, visit=0x43ab64 visit_decref, arg=0x0) at Objects/exceptions.c:97 = (gdb) print _PyObject_Dump(0x70f645f8) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20526 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20904] HAVE_PY_SET_53BIT_PRECISION for m68k
Larry Hastings added the comment: (And hooray for that, given the meteoric rise of AtheOS. :| ) I'm going to go way out on a limb and say that Guido hasn't made a pronouncement here. Also, the discussions cited by Martin are about entire new platforms (AtheOS, Haiku), whereas what we're talking about here is an additional architecture for an existing platform (m68k on linux). So I'm going to use my best judgement. I'm willing to accept the patch for 3.5, provided that: * it's understood that m68k is not an officially supported platform, and * this is sufficient, we won't need loads of other m68k support patches. (As the saying goes, this patch should not be a foot in the door.) I do have two questions: * With this patch applied, how much of the test suite passes? * Is there a way that the configure check could be skipped on non-m68k platforms? Because 99.99% of the time, that check is irrelevant, and configure is already slow enough. Could you possibly just drop the GCC check? Do you genuinely support m68k on linux using revisions of GCC that don't support inline assembly? Finally, Mark Dickinson is right: since this patch changes behavior in an incompatible way, it's not permissible to check it in for 3.4. Sorry. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20904 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20210] Provide configure options to enable/disable Python modules and extensions
Martin v. Löwis added the comment: I'm +1 on the general idea, but -1 on the implementation strategy used. Instead of coming up with configure options for selected (apparently problematic) modules, I'd like to see a solution that covers *all* extension modules. One approach could be to reserve the option prefix --enable-mod-XXX for this kind of configuration, allowing people to specify --disable-mod-zipimport (for example). Another approach (closer to what we already have) would be to support a *disabled* marker in Modules/Setup (and Modules/Setup.local), so anybody wishing to disable modules could put *disabled* zipimport _sre unicodedata into Modules/Setup.local (rather than specifying it on the configure command line). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21069] urllib unit tests failing without ssl module
R. David Murray added the comment: What makes you think this is a different issue? It sounds like a duplicate to me. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21069 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21069] urllib unit tests failing without ssl module
R. David Murray added the comment: Ah, in case I wasn't clear: what unittest failures that you are seeing are not covered by issue 20939? In order to diagnose this issue, we'll need to know that :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21069 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21057] TextIOWrapper does not support reading bytearrays or memoryviews
Nikolaus Rath added the comment: On 03/26/2014 03:43 AM, STINNER Victor wrote: class MyByteStream(BytesIO): def read1(self, len_): return memoryview(super().read(len_)) bs = MyByteStream(b'some data in ascii\n') I guess that you are trying to implement a zero-copy I/O. The problem is that BytesIO does copy data. Right on the first count, but wrong on the second. The class I'm concerned with wants to do zero-copy I/O, but is not related to BytesIO. I only picked that to produce a minimal example. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21057 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20062] Remove emacs page from devguide
Changes by Albert Looney aloo...@capital.edu: Removed file: http://bugs.python.org/file34503/index.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20062 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16043] xmlrpc: gzip_decode has unlimited read()
Changes by jan matejek jmate...@suse.cz: -- nosy: +matejcik ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16043 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21069] urllib unit tests failing without ssl module
Daniel Farrell added the comment: Ah, in case I wasn't clear: what unittest failures that you are seeing are not covered by issue 20939? The unit test failures I'm seeing are different in at least two ways: 1) A larger set of tests failing than mentioned in Issue 20939; 2) Their failure was an assertion FAIL, mine are ERRORS related to https being an unknown URL type. Here are the unit tests that are failing, extracted from that massive dump of info. The following block are all failing with urllib.error.URLError: urlopen error unknown url type: https: test_license_exists_at_url (test.test_site.ImportSideEffectTests) ... ERROR ... test_issue16464 (test.test_urllib2.MiscTests) ... ERROR ... test_close (test.test_urllib2net.CloseSocketTest) ... ERRO ... test_http_basic (test.test_urllib2net.TimeoutTest) ... ERROR test_http_default_timeout (test.test_urllib2net.TimeoutTest) ... ERROR test_http_no_timeout (test.test_urllib2net.TimeoutTest) ... ERROR test_http_timeout (test.test_urllib2net.TimeoutTest) ... ERROR ... testURLread (test.test_urllibnet.URLTimeoutTest) ... ERROR test_basic (test.test_urllibnet.urlopenNetworkTests) ... ERROR test_fileno (test.test_urllibnet.urlopenNetworkTests) ... ERROR ... test_geturl (test.test_urllibnet.urlopenNetworkTests) ... ERROR test_info (test.test_urllibnet.urlopenNetworkTests) ... ERROR test_readlines (test.test_urllibnet.urlopenNetworkTests) ... ERROR test_basic (test.test_urllibnet.urlretrieveNetworkTests) ... ERROR test_data_header (test.test_urllibnet.urlretrieveNetworkTests) ... ERROR test_header (test.test_urllibnet.urlretrieveNetworkTests) ... ERROR test_reporthook (test.test_urllibnet.urlretrieveNetworkTests) ... ERROR test_specified_path (test.test_urllibnet.urlretrieveNetworkTests) ... ERROR This one is failing with the very similar OSError: [Errno url error] unknown url type: 'https: test_getcode (test.test_urllibnet.urlopenNetworkTests) ... ERROR -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21069 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21069] urllib unit tests failing without ssl module
R. David Murray added the comment: Well, I just looked at one of those tests at random, and it is using an http://www.python.org url, so it would be covered by 20939. Can you re-run your tests after applying the patches from that issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21069 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21070] test_xmlrpc waits forever instead of reporting failure
New submission from jan matejek: Testcases derived from BaseServerTestCase will launch a server process in a separate thread. This server will shut itself down after handling a specified number of requests. If the test case fails before performing enough requests, the server thread will continue to wait indefinitely. Fix for issue 14001 removed timeout from the wait on server thread, so now if a test fails, it will hang forever. To reproduce: put self.assertTrue(False) at start of any testcase. This matters in two cases: 1. If a testcase performs more than one request, an assertion failure on the first one will freeze the rest 2. If you make a mistake when writing a testcase, the test will hang instead of telling you that you did something wrong, and with no indication of what caused the problem (because your testcase won't be part of the backtrace when you break the wait) -- components: Tests messages: 214902 nosy: matejcik priority: normal severity: normal status: open title: test_xmlrpc waits forever instead of reporting failure type: behavior versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21070 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21070] test_xmlrpc waits forever instead of reporting failure
Changes by jan matejek jmate...@suse.cz: -- versions: -Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21070 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21071] struct.Struct.format is bytes, but should be str
New submission from Zbyszek Jędrzejewski-Szmek: In Python 2, Struct.format used to be a str. In Python 3 it is bytes, which is unexpected. Why do I expect .format to be a string: - This format is pretty much the same as a {}-format - plain text - according to documentation it is composed of things like characters from a closed set '.=@hi...', a subset of ASCII, - it is always called format string in the documentation Why is this a problem: - If I use a str format in constructor, I expect to get a str format, - Comparisons are broken: struct.Struct('x').format == 'x' False struct.Struct('x').format[0] == 'x' False - doctests are broken struct.Struct('x').format 'x' # in Python 2 b'x' # in Python 3 -- components: Library (Lib) messages: 214903 nosy: zbysz priority: normal severity: normal status: open title: struct.Struct.format is bytes, but should be str type: behavior versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21071 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com