Re: Python Game Development?
On 07/06/13 16:53, letsplaysf...@gmail.com wrote: I was planning on making a small 2D game in Python. Are there any libraries for this? I know of: • Pygame - As far as I know it's dead and has been for almost a year • PyOgre - Linux and Windows only(I do have those, but I want multi-platform) • Cocos2D - Won't install and cant find any support • PyCap - Can't find any documentation • Panda3D - Dead since 2011 + overkill for what I need • PyOpenGL - Overkill Any help on what to do with this would be appreciated. I am making games mainly in Lua but I'd like to make one in Python for fun. I also understand that Python isn't exactly the *BEST* choice programming a game, but I have heard it is possible. Tell me if it's true. Thanks! You might also wish to consider Kivy (kivy.org). Regards, Ian F -- http://mail.python.org/mailman/listinfo/python-list
Re: Idiomatic Python for incrementing pairs
On Fri, 07 Jun 2013 21:32:39 -0500, Tim Chase wrote: Playing around, I've been trying to figure out the most pythonic way of incrementing multiple values based on the return of a function. Something like [...skip misleading and irrelevant calculate() function...] alpha = beta = 0 temp_a, temp_b = calculate(...) alpha += temp_a beta += temp_b Is there a better way to do this without holding each temporary result before using it to increment? Not really. The above idiom is not really terribly Pythonic. It's more like the sort of old-fashioned procedural code I'd write in Pascal or COBOL or similar. For just two variables, it's not so bad, although I'd probably save a line and a temporary variable and write it as this: alpha = beta = 0 tmp = calculate(...) alpha, beta = alpha+tmp[0], beta+tmp[1] But if you have many such values, that's a sign that you're doing it wrong. Do it like this instead: values = [0]*17 # or however many variables you have increments = calculate(...) values = [a+b for a,b in zip(values, increments)] Or define a helper function: add(v1, v2): Vector addition. add([1, 2], [4, 5]) [5, 7] return [a+b for a,b in zip(v1, v2)] values = [0]*17 increments = calculate(...) values = add(values, increments) Much nicer! And finally, if speed is absolutely critical, this scales to using fast vector libraries like numpy. Just use numpy arrays instead of lists, and + instead of the add helper function, and Bob's yer uncle. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Idiomatic Python for incrementing pairs
Tim Chase wrote: On 2013-06-07 23:46, Jason Swails wrote: On Fri, Jun 7, 2013 at 10:32 PM, Tim Chase def calculate(params): a = b = 0 if some_calculation(params): a += 1 if other_calculation(params): b += 1 return (a, b) alpha = beta = 0 temp_a, temp_b = calculate(...) alpha += temp_a beta += temp_b Is there a better way to do this without holding each temporary result before using it to increment? alpha = beta = 0 alpha, beta = (sum(x) for x in zip( (alpha, beta), calculate(...) ) ) Yeah, I came up with something similar, but it was so opaque I fell back to the more readable version I had above. With only the two variables to increment in this case, the overhead of duplicating code doesn't seem as worth it as it might be if there were umpteen counters being returned as a tuple and umpteen corresponding variables being updated (at which point, it might make more sense to switch to another data structure like a dict). Ah well. Glad to see at least I'm not the only one stymied by trying to make it more pythonic while at least keeping it readable. -tkc You can hide the complexity in a custom class: class T(tuple): ... def __add__(self, other): ... return T((a+b) for a, b in zip(self, other)) ... t = T((0, 0)) for pair in [(1, 10), (2, 20), (3, 30)]: ... t += pair ... t (6, 60) (If you are already using numpy you can do the above with a numpy.array instead of writing your own T.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
Τη Σάββατο, 8 Ιουνίου 2013 5:52:22 π.μ. UTC+3, ο χρήστης Cameron Simpson έγραψε: On 07Jun2013 11:52, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= nikos.gr...@gmail.com wrote: | ni...@superhost.gr [~/www/cgi-bin]# [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] File /home/nikos/public_html/cgi-bin/files.py, line 81 | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] if( flag == 'greek' ) | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] ^ | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] SyntaxError: invalid syntax | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] Premature end of script headers: files.py | --- | i dont know why that if statement errors. Python statements that continue (if, while, try etc) end in a colon, so: Oh iam very sorry. Oh my God i cant beleive i missed a colon *again*: I have corrected this: # # Collect filenames of the path dir as bytes filename_bytes = os.listdir( b'/home/nikos/public_html/data/apps/' ) for filename in filename_bytes: # Compute 'path/to/filename' into bytes filepath_bytes = b'/home/nikos/public_html/data/apps/' + b'filename' flag = False try: # Assume current file is utf8 encoded filepath = filepath_bytes.decode('utf-8') flag = 'utf8' except UnicodeDecodeError: try: # Since current filename is not utf8 encoded then it has to be greek-iso encoded filepath = filepath_bytes.decode('iso-8859-7') flag = 'greek' except UnicodeDecodeError: print( '''I give up! File name is unreadable!''' ) if flag == 'greek': # Rename filename from greek bytes -- utf-8 bytes os.rename( filepath_bytes, filepath.encode('utf-8') ) == Now everythitng were supposed to work but instead iam getting this surrogate error once more. What is this surrogate thing? Since i make use of error cathcing and handling like 'except UnicodeDecodeError:' then it utf8's decode fails for some reason, it should leave that file alone and try the next file? try: # Assume current file is utf8 encoded filepath = filepath_bytes.decode('utf-8') flag = 'utf8' except UnicodeDecodeError: This is what it supposed to do, correct? == [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] File /home/nikos/public_html/cgi-bin/files.py, line 94, in module [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] cur.execute('''SELECT url FROM files WHERE url = %s''', (filename,) ) [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] File /usr/local/lib/python3.3/site-packages/PyMySQL3-0.5-py3.3.egg/pymysql/cursors.py, line 108, in execute [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] query = query.encode(charset) [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] UnicodeEncodeError: 'utf-8' codec can't encode character '\\udcce' in position 35: surrogates not allowed -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
Τη Παρασκευή, 7 Ιουνίου 2013 11:47:58 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: On 07/06/2013 19:24, Νικόλαος Κούρας wrote: Τη Παρασκευή, 7 Ιουνίου 2013 5:32:09 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: Can find what? koukos.py is there inside the cg-bin dir with 755 perms. It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'. Its looking for its self?!?! Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in there? Yes it is. ni...@superhost.gr [~/www/cgi-bin]# ls -l total 56 drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./ drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../ -rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py* -rwxr-xr-x 1 nikos nikos 5434 Jun 7 14:51 files.py* -rw-r--r-- 1 nikos nikos170 May 30 15:18 .htaccess -rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py* -rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py* -rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py* ni...@superhost.gr [~/www/cgi-bin]# The prompt says ~/www/cgi-bin. Is that the same as /home/nikos/public_html/cgi-bin? Try: ls -l /home/nikos/public_html/cgi-bin Good day MRAB, yes '~/www' its a symlink to '~/public_html' ni...@superhost.gr [~/www/data/apps]# ls -ld /home/nikos/www/ drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 /home/nikos/www// ni...@superhost.gr [~/www/data/apps]# ls -ld /home/nikos/public_html/ drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 /home/nikos/public_html// ni...@superhost.gr [~/www/data/apps]# ls -l /home/nikos/public_html/cgi-bin total 56 drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./ drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../ -rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py* -rwxr-xr-x 1 nikos nikos 5793 Jun 8 09:39 files.py* -rw-r--r-- 1 nikos nikos170 May 30 15:18 .htaccess -rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py* -rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py* -rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py* ni...@superhost.gr [~/www/data/apps]# ls -l /home/nikos/www/cgi-bin/ total 56 drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./ drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../ -rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py* -rwxr-xr-x 1 nikos nikos 5793 Jun 8 09:39 files.py* -rw-r--r-- 1 nikos nikos170 May 30 15:18 .htaccess -rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py* -rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py* -rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py* ni...@superhost.gr [~/www/data/apps]# -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On Sat, Jun 8, 2013 at 4:49 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Oh my God i cant beleive i missed a colon *again*: For most Python programmers, this is a matter of moments to solve. Run the program, get a SyntaxError, fix it. Non-interesting event. (Maybe even sooner than that, if the editor highlights it for you.) This is why you really need to start yourself a testbox. DO NOT PLAY ON YOUR LIVE SYSTEM. This is sysadminning 101. And Python programming 101: The error traceback points to the error, or just after it. Get to know how error messages work. This is not even Python-specific. *Every* language behaves this way. You look at the highlighted line, if you can't see an error there you look a little bit higher. You should not need to beg for help for such trivial problems. This is the mark of a novice. You ought no longer to be a novice, based on how long you've been doing this stuff. You ought not to behave like one. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
On Sat, Jun 8, 2013 at 4:53 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Τη Παρασκευή, 7 Ιουνίου 2013 11:47:58 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: On 07/06/2013 19:24, Νικόλαος Κούρας wrote: \ Τη Παρασκευή, 7 Ιουνίου 2013 5:32:09 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'. Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in there? Yes it is. ni...@superhost.gr [~/www/cgi-bin]# ls -l -rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py* The prompt says ~/www/cgi-bin. Is that the same as /home/nikos/public_html/cgi-bin? Good day MRAB, yes '~/www' its a symlink to '~/public_html' More basics. When someone asks you to check something, check exactly that. It really does not help to check something unrelated. If you'd shown in your prompt ~/public_html/cgi-bin rather than your symlink of www, there would have been less confusion; putting the full path in as a parameter would eliminate all trouble. By using the symlink, you demand that we understand or assume something about your system, and that's unnecessary. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On Fri, 07 Jun 2013 23:49:17 -0700, Νικόλαος Κούρας wrote: [...] Oh iam very sorry. Oh my God i cant beleive i missed a colon *again*: I have corrected this: [snip code] Stop posting your code after every trivial edit!!! -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On Sat, Jun 8, 2013 at 5:26 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 07 Jun 2013 23:49:17 -0700, Νικόλαος Κούρας wrote: [...] Oh iam very sorry. Oh my God i cant beleive i missed a colon *again*: I have corrected this: [snip code] Stop posting your code after every trivial edit!!! I think he uses the python-list archives as ersatz source control. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On Thu, 06 Jun 2013 23:35:33 -0700, nagia.retsina wrote: Working with bytes is only for when the file names are turned to garbage. Your file names (some of them) are turned to garbage. Fix them, and then use file names as strings. Can't '~/data/apps/' is filled every day with more and more files which are uploaded via FileZilla client, which i think it behaves pretty much like putty, uploading filenames as greek-iso bytes. Well, that is certainly a nuisance. Try something like this: # Untested. dir = b'/home/nikos/public_html/data/apps/' # This must be bytes. files = os.listdir(dir) for name in files: pathname_as_bytes = dir + name for encoding in ('utf-8', 'iso-8859-7', 'latin-1'): try: pathname = pathname_as_bytes.decode(encoding) except UnicodeDecodeError: continue # Rename to something valid in UTF-8. if encoding != 'utf-8': os.rename(pathname_as_bytes, pathname.encode('utf-8')) assert os.path.exists(pathname) break else: # This only runs if we never reached the break. raise ValueError('unable to clean filename %r'%pathname_as_bytes) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
Νικόλαος Κούρας schreef: Session settings afaik is for putty to remember hosts to connect to, not terminal options. I might be worng though. No matter how many times i change its options next time i run it always defaults back. Putty can most definitely remember its settings: - Start PuTTY; you should get the PuTTY Configuration window - Select a session in the list of sessions - Click Load - Change any setting you want to change - Go back to Session in the Category treeview - Click Save HTH -- People almost invariably arrive at their beliefs not on the basis of proof but on the basis of what they find attractive. -- Pascal Blaise r...@roelschroeven.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Idiomatic Python for incrementing pairs
On Sat, Jun 8, 2013 at 2:47 AM, Peter Otten __pete...@web.de wrote: You can hide the complexity in a custom class: class T(tuple): ... def __add__(self, other): ... return T((a+b) for a, b in zip(self, other)) ... t = T((0, 0)) for pair in [(1, 10), (2, 20), (3, 30)]: ... t += pair ... t (6, 60) (If you are already using numpy you can do the above with a numpy.array instead of writing your own T.) I do this frequently when I want data structures that behave like vectors but don't want to impose the numpy dependency on users. (Although I usually inherit from a mutable sequence so I can override __iadd__ and __isub__). It seemed overkill for the provided example, though... All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Game Development?
On 07.06.2013 18:53, letsplaysf...@gmail.com wrote: I was planning on making a small 2D game in Python. Are there any libraries for this? I know of: • Pygame - As far as I know it's dead and has been for almost a year • PyOgre - Linux and Windows only(I do have those, but I want multi-platform) • Cocos2D - Won't install and cant find any support • PyCap - Can't find any documentation • Panda3D - Dead since 2011 + overkill for what I need • PyOpenGL - Overkill Any help on what to do with this would be appreciated. I am making games mainly in Lua but I'd like to make one in Python for fun. I also understand that Python isn't exactly the *BEST* choice programming a game, but I have heard it is possible. Tell me if it's true. Thanks! Hi, I only have looked closer in pygame. But before asking for an general overview of possible gaming libraries, I would start to answer the question of what kind of game you want to make and what features do you really need. For some space game for example it is most unlikely that you will face the requirement of having a bleeding edge physics engine. Especially if you make use of 2d objects versus 3d models of any type. I guess you can expand the latter to any extend here. Also it is a common thing I might guess bravely, that the basics of game programming are done similar in all game engines. - Setting up a game loop - Calculation present and future ob objects - Handling user input by using events - Redraw the screen And this is in pygame quite simply, but I also had trouble finding the right entrance to it, as you have to read a bit up on how components fit together in that library. An example basic setup looks like (with classing), I remove my code and limited it to basic event/input handling and also the drawing of a screen object in which you can add images and stuff. Sorry for the formatting, I copied from idle and formatted in my email client. # class gameApp: def __init__(self): pygame.init() self.clock = pygame.time.Clock() self.screen = pygame.display.set_mode( (640, 480), DOUBLEBUF|SRCALPHA ) self.run() def run(self): while not self.close_app: self.clock.tick(60) for event in pygame.event.get(): #print event if event.type == KEYUP: # Press tab for player info if event.key == 9: pass # Do something in tab key elif event.type == MOUSEBUTTONDOWN: if event.button == 1: pass # Left click, mouse button is pressend elif event.type == MOUSEMOTION: mx = event.rel[0] my = event.rel[1] continue elif event.type == QUIT: self.close_app = True self.screen.fill( (0,0,0) ) # Self interaction is a screen drawing object self.screen.blit(self.interactions, (0,0), special_flags=BLEND_RGBA_ADD) pygame.display.flip() pygame.quit() if __name__ == '__main__': import pygame from pygame.locals import * gameApp() # Regards Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Game Development?
On Fri, 07 Jun 2013 08:53:03 -0700, letsplaysforu wrote: I was planning on making a small 2D game in Python. Are there any libraries for this? I know of: [snip] There's also Pyglet. -- http://mail.python.org/mailman/listinfo/python-list
Riemann and Bernhard, a distributed systems monitor and Python client
This may be of interest to the group: Riemann and Bernhard, a distributed systems monitor and Python client http://jugad2.blogspot.in/2013/06/riemann-and-bernhard-distributed.html - Vasudev Ram dancingbison.com Python training and consulting -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
Τη Σάββατο, 8 Ιουνίου 2013 10:01:51 π.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: On Sat, Jun 8, 2013 at 4:53 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Τη Παρασκευή, 7 Ιουνίου 2013 11:47:58 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: On 07/06/2013 19:24, Νικόλαος Κούρας wrote: \ Τη Παρασκευή, 7 Ιουνίου 2013 5:32:09 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'. Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in there? Yes it is. ni...@superhost.gr [~/www/cgi-bin]# ls -l -rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py* The prompt says ~/www/cgi-bin. Is that the same as /home/nikos/public_html/cgi-bin? Good day MRAB, yes '~/www' its a symlink to '~/public_html' More basics. When someone asks you to check something, check exactly that. It really does not help to check something unrelated. If you'd shown in your prompt ~/public_html/cgi-bin rather than your symlink of www, there would have been less confusion; putting the full path in as a parameter would eliminate all trouble. By using the symlink, you demand that we understand or assume something about your system, and that's unnecessary. Well, www as symlink to public_html is always a symlink to any system i have used so its something defaulted. -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
On Sun, Jun 9, 2013 at 1:36 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Τη Σάββατο, 8 Ιουνίου 2013 10:01:51 π.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: On Sat, Jun 8, 2013 at 4:53 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Τη Παρασκευή, 7 Ιουνίου 2013 11:47:58 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: On 07/06/2013 19:24, Νικόλαος Κούρας wrote: \ Τη Παρασκευή, 7 Ιουνίου 2013 5:32:09 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'. Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in there? Yes it is. ni...@superhost.gr [~/www/cgi-bin]# ls -l -rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py* The prompt says ~/www/cgi-bin. Is that the same as /home/nikos/public_html/cgi-bin? Good day MRAB, yes '~/www' its a symlink to '~/public_html' More basics. When someone asks you to check something, check exactly that. It really does not help to check something unrelated. If you'd shown in your prompt ~/public_html/cgi-bin rather than your symlink of www, there would have been less confusion; putting the full path in as a parameter would eliminate all trouble. By using the symlink, you demand that we understand or assume something about your system, and that's unnecessary. Well, www as symlink to public_html is always a symlink to any system i have used so its something defaulted. It's most certainly not the default, it's definitely not universal, and that has nothing to do with what I said. Use the exact same path, it reduces confusion. Also, I think it's time to mention again: Get yourself off Google Groups, or start trimming out the stupid double spacing! It's getting extremely annoying. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Game Development?
On Fri, 07 Jun 2013 08:53:03 -0700, letsplaysforu wrote: I was planning on making a small 2D game in Python. Are there any libraries for this? I know of: It wasn't your question, but I was happy to find out that box2d exists for python. -- http://mail.python.org/mailman/listinfo/python-list
Installing PyGame?
Perhaps this isn't the right place to post this, but it's the only place I could find. I asked yesterday or the day before about Python Game Development, and have found a few tutorials on PyGame. Now I have a bigger problem: HOW THE HECK DO I INSTALL PYGAME!?!?! System Details: • Mac OS X 10.8.4 Mountain Lion • 4GB DDR3 RAM I do have Window's installed, as well as Ubuntu 11.04 but I would like to use Mac OS X if possible. I've tried using MacPorts, Fink, the Mac DMG, source installing, installing NumPY, just about every way possible. I can't seem to get it working, I keep getting an error in all my versions of IDLE. I've tried: • IDLE 2.5 • IDLE 2.7.2 • IDLE 2.7.3 • IDLE 3.1 • IDLE 3.3.1 None of the versions work. I'm using PyGame 1.9.1. Thanks! Any help is appreciated! -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On 08/06/2013 07:49, Νικόλαος Κούρας wrote: Τη Σάββατο, 8 Ιουνίου 2013 5:52:22 π.μ. UTC+3, ο χρήστης Cameron Simpson έγραψε: On 07Jun2013 11:52, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= nikos.gr...@gmail.com wrote: | ni...@superhost.gr [~/www/cgi-bin]# [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] File /home/nikos/public_html/cgi-bin/files.py, line 81 | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] if( flag == 'greek' ) | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] ^ | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] SyntaxError: invalid syntax | [Fri Jun 07 21:49:33 2013] [error] [client 79.103.41.173] Premature end of script headers: files.py | --- | i dont know why that if statement errors. Python statements that continue (if, while, try etc) end in a colon, so: Oh iam very sorry. Oh my God i cant beleive i missed a colon *again*: I have corrected this: # # Collect filenames of the path dir as bytes filename_bytes = os.listdir( b'/home/nikos/public_html/data/apps/' ) for filename in filename_bytes: # Compute 'path/to/filename' into bytes filepath_bytes = b'/home/nikos/public_html/data/apps/' + b'filename' flag = False try: # Assume current file is utf8 encoded filepath = filepath_bytes.decode('utf-8') flag = 'utf8' except UnicodeDecodeError: try: # Since current filename is not utf8 encoded then it has to be greek-iso encoded filepath = filepath_bytes.decode('iso-8859-7') flag = 'greek' except UnicodeDecodeError: print( '''I give up! File name is unreadable!''' ) if flag == 'greek': # Rename filename from greek bytes -- utf-8 bytes os.rename( filepath_bytes, filepath.encode('utf-8') ) == Now everythitng were supposed to work but instead iam getting this surrogate error once more. What is this surrogate thing? Since i make use of error cathcing and handling like 'except UnicodeDecodeError:' then it utf8's decode fails for some reason, it should leave that file alone and try the next file? try: # Assume current file is utf8 encoded filepath = filepath_bytes.decode('utf-8') flag = 'utf8' except UnicodeDecodeError: This is what it supposed to do, correct? == [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] File /home/nikos/public_html/cgi-bin/files.py, line 94, in module [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] cur.execute('''SELECT url FROM files WHERE url = %s''', (filename,) ) [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] File /usr/local/lib/python3.3/site-packages/PyMySQL3-0.5-py3.3.egg/pymysql/cursors.py, line 108, in execute [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] query = query.encode(charset) [Sat Jun 08 09:39:34 2013] [error] [client 79.103.41.173] UnicodeEncodeError: 'utf-8' codec can't encode character '\\udcce' in position 35: surrogates not allowed Look at the traceback. It says that the exception was raised by: query = query.encode(charset) which was called by: cur.execute('''SELECT url FROM files WHERE url = %s''', (filename,) ) But what is 'filename'? And what has it to do with the first code snippet? Does the traceback have _anything_ to do with the first code snippet? -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
On 8 Jun 2013 17:17, Eam onn letsplaysf...@gmail.com wrote: I keep getting an error in all my versions of IDLE. What error is that? Show us. Errors carry strong hints. Also, are you following an install guide/tutorial? Which one? Cheers -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
Sorry for th delay guys, was busy with other thigns today and i am still reading your resposes, still ahvent rewad them all just Cameron's: Here is what i have now following Cameron's advices: # # Collect filenames of the path directory as bytes path = b'/home/nikos/public_html/data/apps/' filenames_bytes = os.listdir( path ) for filename_bytes in filenames_bytes: try: filename = filename_bytes.decode('utf-8) except UnicodeDecodeError: # Since its not a utf8 bytestring then its for sure a greek bytestring # Prepare arguments for rename to happen utf8_filename = filename_bytes.encode('utf-8') greek_filename = filename_bytes.encode('iso-8859-7') utf8_path = path + utf8_filename greek_path = path + greek_filename # Rename current filename from greek bytes -- utf8 bytes os.rename( greek_path, utf8_path ) == I know this is wrong though. Since filename_bytes is the current filename encoded as utf8 or greek-iso then i cannot just *encode* what is already encoded by doing this: utf8_filename = filename_bytes.encode('utf-8') greek_filename = filename_bytes.encode('iso-8859-7') -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
Τη Σάββατο, 8 Ιουνίου 2013 7:03:57 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: On Sun, Jun 9, 2013 at 1:36 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Well, www as symlink to public_html is always a symlink to any system i have used so its something defaulted. It's most certainly not the default, it's definitely not universal and that has nothing to do with what I said. Use the exact same path, it reduces confusion. Also, I think it's time to mention again: Get yourself off Google Groups, or start trimming out the stupid double spacing! It's getting extremely annoying. its very tedious to always triming everything for me and i know it is for you to ead it assuc. Damn google groups, why is it behaving as such? Dont the programmers know about it? Also everytime i post it always display to me different addresses to get responses back. Any way what did you say and i havent understand you correctly? What path do you want me to show to you? What does this error means anyway? -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
On Saturday, June 8, 2013 5:41:40 PM UTC+1, Fábio Santos wrote: On 8 Jun 2013 17:17, Eam onn letspl...@gmail.com wrote: I keep getting an error in all my versions of IDLE. What error is that? Show us. Errors carry strong hints. Also, are you following an install guide/tutorial? Which one? Cheers I'm not following a guide, but I have followed about 20 - No exaggeration. Here's the error I am getting: ERROR 1: Terminal COMMAND: import pygame File stdin, line 1, in module File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py, line 95, in module from pygame.base import * ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found. Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper ERROR 2: IDLE (all versions) COMMAND: import pygame Traceback (most recent call last): File pyshell#0, line 1, in module import pygame ImportError: No module named 'pygame' Any idea as to what is going on? Terminal is V2.7.3 of Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Idiomatic Python for incrementing pairs
On 6/8/2013 12:16 AM, Tim Chase wrote: On 2013-06-08 07:04, Carlos Nepomuceno wrote: alpha, beta = (1 if some_calculation(params) else 0, 1 if other_calculation(params) else 0) This one sets them to absolute values, rather than the incrementing functionality in question: alpha += temp_a beta += temp_b The actual code in question does the initialization outside a loop: alphas_updated = betas_updated = 0 for thing in bunch_of_things: a, b = process(thing) alphas_updated += a betas_updated += b I am pretty sure that this is the faster way to get the result. and it just bugs me as being a little warty for having temp variables when Python does things like tuple-unpacking so elegantly. So use it ;-). That said, as mentioned in a contemporaneous reply to Jason, I haven't found anything better that is still readable. The generalization of what you want is a mutable vector with an in-place augmented assignment version of element by element addition. That probably has been written. Nnmpy arrays do vector addition and maybe do it in-place also (I just do ot know). But here is a custom class for the problem you presented. def process(val): return val, 2*val class Pair(list): def __init__(self, a, b): self.append(a) self.append(b) def inc(self, a, b): self[0] += a self[1] += b pair = Pair(0, 0) for val in [1,2,3]: pair.inc(*process(val)) print(pair) [6, 12] This is cleaner but a bit slower than your in-lined version. I did not use __iadd__ and += because unpacking 'other' (here the process return) in the call does the error checking ('exactly two values') for 'free'. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
Okey after reading also Steven post, i was relived form the previous suck position i was, so with an alternation of a few variable names here is the code now: # # Collect directory and its filenames as bytes path = b'/home/nikos/public_html/data/apps/' files = os.listdir( path ) for filename in files: # Compute 'path/to/filename' filepath_bytes = path + filename for encoding in ('utf-8', 'iso-8859-7', 'latin-1'): try: filepath = filepath_bytes.decode( encoding ) except UnicodeDecodeError: continue # Rename to something valid in UTF-8 if encoding != 'utf-8': os.rename( filepath_bytes, filepath.encode('utf-8') ) assert os.path.exists( filepath ) break else: # This only runs if we never reached the break raise ValueError( 'unable to clean filename %r' % filepath_bytes ) = I dont know why it is still failing when it tried to decode stuff since it tries 3 ways of decoding. Here is the exact error. ni...@superhost.gr [~/www/cgi-bin]# [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] Error in sys.excepthook: [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] ValueError: underlying buffer has been detached [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] Original exception was: [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] Traceback (most recent call last): [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] File /home/nikos/public_html/cgi-bin/files.py, line 78, in module [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] assert os.path.exists( filepath ) [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] File /usr/local/lib/python3.3/genericpath.py, line 18, in exists [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] os.stat(path) [Sat Jun 08 20:32:44 2013] [error] [client 79.103.41.173] UnicodeEncodeError: 'ascii' codec can't encode characters in position 34-37: ordinal not in range(128) -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On 08/06/2013 17:53, Νικόλαος Κούρας wrote: Sorry for th delay guys, was busy with other thigns today and i am still reading your resposes, still ahvent rewad them all just Cameron's: Here is what i have now following Cameron's advices: # # Collect filenames of the path directory as bytes path = b'/home/nikos/public_html/data/apps/' filenames_bytes = os.listdir( path ) for filename_bytes in filenames_bytes: try: filename = filename_bytes.decode('utf-8) except UnicodeDecodeError: # Since its not a utf8 bytestring then its for sure a greek bytestring # Prepare arguments for rename to happen utf8_filename = filename_bytes.encode('utf-8') greek_filename = filename_bytes.encode('iso-8859-7') utf8_path = path + utf8_filename greek_path = path + greek_filename # Rename current filename from greek bytes -- utf8 bytes os.rename( greek_path, utf8_path ) == I know this is wrong though. Yet you did it anyway! Since filename_bytes is the current filename encoded as utf8 or greek-iso then i cannot just *encode* what is already encoded by doing this: utf8_filename = filename_bytes.encode('utf-8') greek_filename = filename_bytes.encode('iso-8859-7') Try reading and understanding the code I originally posted. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
At the Terminal prompt type: python -c help('modules') If Pygame is not somewhere in the output then Pygame is not yet installed. If it is not installed then type: pip install --upgrade pygame -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On 8/6/2013 5:49 πμ, Cameron Simpson wrote: On 07Jun2013 04:53, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= nikos.gr...@gmail.com wrote: | Τη Παρασκευή, 7 Ιουνίου 2013 11:53:04 π.μ. UTC+3, ο χρήστης Cameron Simpson έγραψε: | | | errors='replace' mean dont break in case or error? | | | Yes. The result will be correct for correct iso-8859-7 and slightly mangled | | for something that would not decode smoothly. | | | How can it be correct? We have encoded out string in utf-8 and then | | we tried to decode it as greek-iso? How can this possibly be | | correct? | | If it is a valid iso-8859-7 sequence (which might cover everything, | since I expect it is an 8-bit 1:1 mapping from bytes values to a | set of codepoints, just like iso-8859-1) then it may decode to the | wrong characters, but the reverse process (characters encoded as | bytes) should produce the original bytes. With a mapping like this, | errors='replace' may mean nothing; there will be no errors because | the only Unicode characters in play are all from iso-8859-7 to start | with. Of course another string may not be safe. | | Visually, the names will be garbage. And if you go: |mv '999-EΟΟΞ�-ΟΞΏΟ-ΞΞ·ΟΞΏΟ.mp3' '999-Eυχή-του-Ιησού.mp3' | while using the iso-8859-7 locale, the wrong thing will occur | (assuming it even works, though I think it should because all these | characters are represented in iso-8859-7, yes?) | | All the rest you i understood only the above quotes its still unclear to me. | I cant see to understand it. | | Do you mean that utf-8, latin-iso, greek-iso and ASCII have the 1st 0-127 codepoints similar? Yes. It is certainly true for utf-8 and latin-iso and ASCII. I expect it to be so for greek-iso, but have not checked. They're all essentially the ASCII set plus a range of other character codepoints for the upper values. The 8-bit sets iso-8859-1 (which I take you to mean by latin-iso) and iso-8859-7 (which I take you to mean by greek-iso) are single byte mapping with the top half mapped to characters commonly used in a particular region. Unicode has a much greater range, but the UTF-8 encoding of Unicode deliberately has the bottom 0-127 identical to ASCII, and higher values represented by multibyte sequences commences with at least the first byte in the 128-255 range. In this way pure ASCII files are already in UTF-8 (and, in fact, work just fine for the iso-8859-x encodings as well). Hold on! In the beginning there was ASCII with 0-127 values and then there was Unicode with 0-127 of ASCII's + i dont know how much many more? Now ASCIII needs 1 byte to store a single character while Unicode needs 2 bytes to store a character and that is because it has 256 characters to store 2^8bits ? Is this correct? Now UTF-8, latin-iso, greek-iso e.t.c are WAYS of storing characters into the hard drive? Because in some post i have read that 'UTF-8 encoding of Unicode'. Can you please explain to me whats the difference of ASCII-Unicode themselves aand then of them compared to 'Charsets' . I'm still confused about this. Is it like we said in C++: ' int a', a variable with name 'a' of type integer. 'char a', a variable with name 'a' of type char So taken form above example(the closest i could think of), the way i understand them is: A 'string' can be of (unicode's or ascii's) type and that type needs a way (thats a charset) to store this string into the hdd as a sequense of bytes? -- Webhost http://superhost.gr Weblog http://psariastonafro.wordpress.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
On Saturday, June 8, 2013 6:58:53 PM UTC+1, ccl...@bluewin.ch wrote: At the Terminal prompt type: python -c help('modules') If Pygame is not somewhere in the output then Pygame is not yet installed. If it is not installed then type: pip install --upgrade pygame python -c help('modules') made an error. pip install --upgrade pygame made an error too. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
On Saturday, June 8, 2013 7:05:49 PM UTC+1, Eam onn wrote: On Saturday, June 8, 2013 6:58:53 PM UTC+1, ccl...@bluewin.ch wrote: At the Terminal prompt type: python -c help('modules') If Pygame is not somewhere in the output then Pygame is not yet installed. If it is not installed then type: pip install --upgrade pygame python -c help('modules') made an error. pip install --upgrade pygame made an error too. Wait, the python -c help('modules') worked after spamming it a few times. Pygame was listed but it won't do anything when I type in 'import pygame' I still get the error :( -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with serial port interface
Ok, thanks for your reply. But i have another problem: i hadn't always the hardware needed for the tests. Before i've used a terminal and com0com to simulate a serial input: if i want to simulate a transmission every 5ms how can i do? I need a program or a code that i'm sure about its correctness. Another question: may i have some problems (for example timings) to simulate with the same pc a serial transmission? Any suggestion? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On Sat, 08 Jun 2013 21:01:23 +0300, Νικόλαος Κούρας wrote: In the beginning there was ASCII with 0-127 values No, there were encoding systems that existed before ASCII, such as EBCDIC. But we can ignore those, and just start with ASCII. and then there was Unicode with 0-127 of ASCII's + i dont know how much many more? No, you have missed the utter chaos of dozens and dozens of Windows codepages and charsets. We still have to live with the pain of that. But now we have Unicode, with 0x10 (decimal 1114111) code points. You can consider a code point to be the same as a character, at least for now. Now ASCIII needs 1 byte to store a single character ASCII actually needs 7 bits to store a character. Since computers are optimized to work with bytes, not bits, normally ASCII characters are stored in a single byte, with one bit wasted. while Unicode needs 2 bytes to store a character No. Since there are 0x10 different Unicode characters (really code points, but ignore the difference) two bytes is not enough. Unicode needs 21 bits to store a character. Since that is more than 2 bytes, but less than 3, there are a few different ways for Unicode to be stored in memory, including: Wide Unicode uses four bytes per character. Why four instead of three? Because computers are more efficient when working with chunks of memory that is a multiple of four. Narrow Unicode uses two bytes per character. Since two bytes is only enough for about 65,000 characters, not 1,000,000+, the rest of the characters are stored as pairs of two-byte surrogates. and that is because it has 256 characters to store 2^8bits ? Correct. Now UTF-8, latin-iso, greek-iso e.t.c are WAYS of storing characters into the hard drive? Your computer cannot carve a tiny little A into the hard drive when it stores that letter in a file. It has to write some bytes. So you need to know: - what byte, or bytes, represents the letter A? - what byte, or bytes, represents the letter B? - what byte, or bytes, represents the letter λ? and so on. This set of rules, byte means letter , is called an encoding. If you don't know what encoding to use, you cannot tell what the byte means. Because in some post i have read that 'UTF-8 encoding of Unicode'. Can you please explain to me whats the difference of ASCII-Unicode themselves aand then of them compared to 'Charsets' . I'm still confused about this. A charset is an ordered set of characters. For example, ASCII has 127 characters, starting with NUL: NUL ... A B C D E ... Z [ \ ] ^ ... a b c ... z ... where NULL is at position 0, 'A' is at position 65, 'B' at position 66, and so on. Latin-1 is similar, except there are 256 positions. Greek ISO-8859-7 is also similar, also 256 positions, but the characters are different. And so on, with dozens of charsets. And then there is Unicode, which includes *every* character is all of those dozens of charsets. It has 1114111 positions (most are currently unfilled). An encoding is simply a program that takes a character and returns a byte, or visa versa. For instance, the ASCII encoding will take character 'A'. That is found at position 65, which is 0x41 in hexadecimal, so the ASCII encoding turns character 'A' into byte 0x41, and visa versa. Is it like we said in C++: ' int a', a variable with name 'a' of type integer. 'char a', a variable with name 'a' of type char So taken form above example(the closest i could think of), the way i understand them is: A 'string' can be of (unicode's or ascii's) type and that type needs a way (thats a charset) to store this string into the hdd as a sequense of bytes? Correct. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
On 8 Jun 2013 19:19, Eam onn letsplaysf...@gmail.com wrote: Wait, the python -c help('modules') worked after spamming it a few times. Pygame was listed but it won't do anything when I type in 'import pygame' I still get the error :( Try to always say what your error was. Do you have pip installed? Pygame AFAIK is a c extension so it requires a working compiler. I think you need to have one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On Sun, Jun 9, 2013 at 4:01 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Hold on! In the beginning there was ASCII with 0-127 values and then there was Unicode with 0-127 of ASCII's + i dont know how much many more? Now ASCIII needs 1 byte to store a single character while Unicode needs 2 bytes to store a character and that is because it has 256 characters to store 2^8bits ? Is this correct? No. Let me start from the beginning. Computers don't work with characters, or strings, natively. They work with numbers. To be specific, they work with bits; and it's only by convention that we can work with anything larger. For instance, there's a VERY common convention around the PC world that a set of bits can be interpreted as a signed integer; if the highest bit is set, it's negative. There are also standards for floating-point (IEEE 754), and so on. ASCII is a character set. It defines a mapping of numbers to characters - for instance, @ is 64, SOH is 1, $ is 36, etcetera, etcetera. There are 128 such mappings. Since they all fit inside a 7-bit number, there's a trivial way to represent ASCII characters in a PC's 8-bit byte: you just leave the high bit clear and use the other seven. There have been various schemes for using the eighth bit - serial ports with parity, WordStar (I think) marking the ends of words, and most notably, Extended ASCII schemes that give you another whole set of 128 characters. And that was the beginning of Code Pages, because nobody could agree on what those extra 128 should be. Norwegians used Norwegian, the Greeks were taught their Greek, Arabians created themselves an Arabian codepage with the speed of summer lightning, and Hebrews allocated from 255 down to 128, which is absolutely frightening. But I digress. There were a variety of multi-byte schemes devised at various times, but we'll ignore all of them and jump straight to Unicode. With Unicode, there's (theoretically) no need to use any other system ever again, because whatever character you want, it'll exist in Unicode. In theory, of course; there are debates over that. Now, Unicode currently has defined an address space of roughly 20 bits, and in a throwback to the first programming I ever did, it's a segmented system: sixteen or seventeen planes of 65,536 characters each. (Fortunately the planes are identified by low numbers, not high numbers, and there's no stupidity of overlapping planes the way the 8086 did with memory!) The highest planes are special (plane 14 has a few special-purpose characters, planes 15 and 16 are for private use), and most of the middle ones have no characters assigned to them, so for the most part, you'll see characters from the first three planes. So what do we now have? A mapping of characters to code points, which are numbers. (I'm leaving aside the issues of combining characters and such for the moment.) But computers don't work with numbers, they work with bits. Somehow we have to store those bits in memory. There are a good few ways to do that; one is to note that every Unicode character can be represented inside 32 bits, so we can use the standard integer scheme safely. (Since they fit inside 31 bits, we don't even need to care if it's signed or unsigned.) That's called UTF-32 or UCS-4, and it's a great way to handle the full Unicode range in a manner that makes a Texan look agoraphobic. Wide builds of Python up to 3.2 did this. Or you can try to store them in 16-bit numbers, but then you have to worry about the ones that don't fit in 16 bits, because it's really hard to squeeze 20 bits of information into 16 bits of storage. UTF-16 is one way to do this; special numbers mean grab another number. It has its issues, but is (in my opinion, unfortunately) fairly prevalent. Narrow builds of Python up to 3.2 did this. Finally, you can use a more complicated scheme that uses anywhere from 1 to 4 bytes for each character, by carefully encoding information into the top bit - if it's set, you have a multi-byte character. That's how UTF-8 works, and is probably the most prevalent disk/network encoding. All of the UTF-X systems are called UCS Transformation Formats (UCS meaning Universal Character Set, roughly Unicode). They are mappings from Unicode numbers to bytes. Between Unicode and UTF-X, you have a mapping from character to byte sequence. Now UTF-8, latin-iso, greek-iso e.t.c are WAYS of storing characters into the hard drive? The ISO standard 8859 specifies a number of ASCII-compatible encodings, referred to as ISO-8859-1 through ISO-8859-16. You've been working with ISO-8859-1, also called Latin-1, and ISO-8859-7, which has your Greek characters in it. These are all ways of translating characters into numbers; and since they all fit within 8 bits, they're most commonly represented on PCs with single bytes. So taken form above example(the closest i could think of), the way i understand them is: A 'string' can be of (unicode's or ascii's) type and that type needs a
Re: Installing PyGame?
Type: python -V (That was a capitol V) What version of python is running? Type: python3 -V (That was a capitol V) What version of python is running? Type: python -c 'import pygame' What is the exact error message? Type: python Your prompt should change to something like: Type: import pygame What is the exact error message? -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
Τη Σάββατο, 8 Ιουνίου 2013 10:01:57 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: ASCII actually needs 7 bits to store a character. Since computers are optimized to work with bytes, not bits, normally ASCII characters are stored in a single byte, with one bit wasted. So ASCII and Unicode are 2 Encoding Systems currently in use. How should i imagine them, visualize them? Like tables 'A' = 65, 'B' = 66 and so on? But if i do then that would be the visualization of a 'charset' not of an encoding system. What the diffrence of an encoding system and of a charset? ebcdic - ascii - unicode = al of them are encoding systems greek-iso - latin-iso - utf8 - utf16 = all of them are charsets. What are these differences? i cant imagine them all, i can only imagine charsets not encodign systems. Why python interprets by default all given strings as unicode and not ascii? because the former supports many positions while ascii only 127 positions , hence can interpet only 127 different characters? Narrow Unicode uses two bytes per character. Since two bytes is only enough for about 65,000 characters, not 1,000,000+, the rest of the characters are stored as pairs of two-byte surrogates. surrogates literal means a replacemnt? Latin-1 is similar, except there are 256 positions. Greek ISO-8859-7 is also similar, also 256 positions, but the characters are different. And so on, with dozens of charsets. Latin has to display english chars(capital, small) + numbers + symbols. that would be 127 why 256? greek = all of the above plus greek chars, no? And then there is Unicode, which includes *every* character is all of those dozens of charsets. It has 1114111 positions (most are currently unfilled). Shouldt the positions that Unicode has to use equal to the summary of all available characters of all the languages of the worlds plus numbers and special chars? why 1.000.000+ why the need for so many positions? Narrow Unicode format (2 byted) can cover all ofmthe worlds symbols. An encoding is simply a program that takes a character and returns a byte, or visa versa. For instance, the ASCII encoding will take character 'A'. That is found at position 65, which is 0x41 in hexadecimal, so the ASCII encoding turns character 'A' into byte 0x41, and visa versa. Why you say ASCII turn a character into HEX format and not as in binary format? Isnt the latter the way bytes are stored into hdd, like 01010010101 etc? Are they stored as hex instead or you just said so to avoid printing 0s and 1s? -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
On 06/08/2013 10:56 AM, Νικόλαος Κούρας wrote: its very tedious to always triming everything for me and i know it is for you to ead it assuc. Damn google groups, why is it behaving as such? Dont the programmers know about it? Most of us on the list don't use google groups. A number of us use plain old e-mail to post to the list. If you set up folders and rules in your e-mail client (or labels and filter in Gmail), then messages can go into their own folder. Any way what did you say and i havent understand you correctly? What path do you want me to show to you? He means that you should configure apache to use the real path on your file system, not the symlink. IE if www is just a symlink to public_html, reconfigure apache to not use www at all and use public_html. That way you can avoid these kinds of errors. What does this error means anyway? It means that Apache is unable to find your cgi script. It's turning the url into a file path, but it can't find the file path. Sometimes Apache is configured to not follow symlinks. It's confusing too because you have two apaches installed. The system default one and the one that comes with cPanel. -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
Sorry for displaying my code so many times, i know i ahve exhaust you but hti is the last thinkg i am gonna ask from you in this thread. We are very close to have this working. # # Collect directory and its filenames as bytes path = b'/home/nikos/public_html/data/apps/' files = os.listdir( path ) for filename in files: # Compute 'path/to/filename' filepath_bytes = path + filename for encoding in ('utf-8', 'iso-8859-7', 'latin-1'): try: filepath = filepath_bytes.decode( encoding ) except UnicodeDecodeError: continue # Rename to something valid in UTF-8 if encoding != 'utf-8': os.rename( filepath_bytes, filepath.encode('utf-8') ) assert os.path.exists( filepath ) break else: # This only runs if we never reached the break raise ValueError( 'unable to clean filename %r' % filepath_bytes ) # # Collect filenames of the path dir as strings filenames = os.listdir( '/home/nikos/public_html/data/apps/' ) # Load'em for filename in filenames: try: # Check the presence of a file against the database and insert if it doesn't exist cur.execute('''SELECT url FROM files WHERE url = %s''', (filename,) ) data = cur.fetchone() if not data: # First time for file; primary key is automatic, hit is defaulted print( iam here, filename + '\n' ) cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, %s, %s)''', (filename, host, lastvisit) ) except pymysql.ProgrammingError as e: print( repr(e) ) # # Collect filenames of the path dir as strings filenames = os.listdir( '/home/nikos/public_html/data/apps/' ) filepaths = () # Build a set of 'path/to/filename' based on the objects of path dir for filename in filenames: filepaths.add( filename ) # Delete spurious cur.execute('''SELECT url FROM files''') data = cur.fetchall() # Check database's filenames against path's filenames for rec in data: if rec not in filepaths: cur.execute('''DELETE FROM files WHERE url = %s''', rec ) = [Sun Jun 09 00:16:14 2013] [error] [client 79.103.41.173] Original exception was: [Sun Jun 09 00:16:14 2013] [error] [client 79.103.41.173] Traceback (most recent call last): [Sun Jun 09 00:16:14 2013] [error] [client 79.103.41.173] File /home/nikos/public_html/cgi-bin/files.py, line 78, in module [Sun Jun 09 00:16:14 2013] [error] [client 79.103.41.173] assert os.path.exists( filepath ) [Sun Jun 09 00:16:14 2013] [error] [client 79.103.41.173] File /usr/local/lib/python3.3/genericpath.py, line 18, in exists [Sun Jun 09 00:16:14 2013] [error] [client 79.103.41.173] os.stat(path) [Sun Jun 09 00:16:14 2013] [error] [client 79.103.41.173] UnicodeEncodeError: 'ascii' codec can't encode characters in position 34-37: ordinal not in range(128) == Asserts what to make sure the the path/to/file afetr the rename exists but why are we still get those unicodeencodeerrors? -- http://mail.python.org/mailman/listinfo/python-list
Re-using copyrighted code
Hello, I have written a small utility to locate errors in regular expressions that I want to upload to PyPI. Before I do that, I would like to learn a litte more about the legal aspects of open-source software. What would be a good introductory reading? Plus, I have one very specific question: In my package, I use modified code from sre_parse.py, which is part of the Python release. That file has the following header: # # Secret Labs' Regular Expression Engine # # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # See the sre.py file for information on usage and redistribution. # The referenced information is missing in the version of sre.py that comes with current versions of Python, but I found it in the archive http://effbot.org/media/downloads/sre-2.2.1.zip. It reads: # # Secret Labs' Regular Expression Engine # # re-compatible interface for the sre matching engine # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (i...@pythonware.com). # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # Now, how am I supposed to deal with that? Ask Secret Labs for some kind of permission? Leave it as it is and add my own copyright line? Malte -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
Τη Κυριακή, 9 Ιουνίου 2013 12:17:16 π.μ. UTC+3, ο χρήστης Michael Torrie έγραψε: What does this error means anyway? It means that Apache is unable to find your cgi script. It's turning the url into a file path, but it can't find the file path. Sometimes Apache is configured to not follow symlinks. Why every other python cgi script of mine that i run via browser doesnt produce this kind of error and only 'koukos.py' does? It's confusing too because you have two apaches installed. The system default one and the one that comes with cPanel. Hi Michael, indeed they are too. I wonder why cPanel deosnt use the default apache that came with the system and isntead complied its own. anyway httpd.conf seems correct == root@nikos [~]# cat /usr/local/apache/conf/httpd.conf | grep 'www' # system refer to the documentation at: http://www.cpanel.net/support/docs/ea/ea3/customdirectives.html # # system refer to the documentation at: http://www.cpanel.net/support/docs/ea/ea3/customdirectives.html # ServerAlias www.varsa.gr ServerAlias www.parking-byzantio.gr ServerAlias www.cafebar-idea.gr ServerAlias www.dauwin.gr ServerAlias www.leonidasgkelos.com ServerAlias www.mythosweb.gr ServerAlias www.superhost.gr ServerAlias www.panostech.gr ServerAlias www.pdimou.gr ServerAlias www.radio-klepsydra.com ServerAlias www.cravendot.gr ServerAlias www.ypsilandio.gr ServerAlias www.oliveoils.mythosweb.gr ServerAlias www.zimotirio.pdimou.gr root@nikos [~]# cat /usr/local/apache/conf/httpd.conf | grep 'public_html' UserDir public_html DocumentRoot /home/akis/public_html ScriptAlias /cgi-bin/ /home/akis/public_html/cgi-bin/ DocumentRoot /home/byzantio/public_html ScriptAlias /cgi-bin/ /home/byzantio/public_html/cgi-bin/ DocumentRoot /home/cafebar/public_html ScriptAlias /cgi-bin/ /home/cafebar/public_html/cgi-bin/ DocumentRoot /home/dauwin/public_html ScriptAlias /cgi-bin/ /home/dauwin/public_html/cgi-bin/ DocumentRoot /home/gkelos/public_html ScriptAlias /cgi-bin/ /home/gkelos/public_html/cgi-bin/ DocumentRoot /home/mythos/public_html ScriptAlias /cgi-bin/ /home/mythos/public_html/cgi-bin/ DocumentRoot /home/nikos/public_html ScriptAlias /cgi-bin/ /home/nikos/public_html/cgi-bin/ DocumentRoot /home/panos/public_html ScriptAlias /cgi-bin/ /home/panos/public_html/cgi-bin/ DocumentRoot /home/pdimou/public_html ScriptAlias /cgi-bin/ /home/pdimou/public_html/cgi-bin/ DocumentRoot /home/radio/public_html ScriptAlias /cgi-bin/ /home/radio/public_html/cgi-bin/ DocumentRoot /home/tasos/public_html ScriptAlias /cgi-bin/ /home/tasos/public_html/cgi-bin/ DocumentRoot /home/ypsiland/public_html ScriptAlias /cgi-bin/ /home/ypsiland/public_html/cgi-bin/ DocumentRoot /home/mythos/public_html/oliveoils ScriptAlias /cgi-bin/ /home/mythos/public_html/oliveoils/cgi-bin/ DocumentRoot /home/pdimou/public_html/zimotirio ScriptAlias /cgi-bin/ /home/pdimou/public_html/zimotirio/cgi-bin/ root@nikos [~]# === Why every other python cgi script of mines doesnt prodice this error and only 'koukos.py' does? -- http://mail.python.org/mailman/listinfo/python-list
Re: Re-using copyrighted code
On 2013.06.08 16:31, Malte Forkel wrote: Hello, I have written a small utility to locate errors in regular expressions that I want to upload to PyPI. Before I do that, I would like to learn a litte more about the legal aspects of open-source software. What would be a good introductory reading? The exact license terms. We might be able to help if you tell us which part(s) of the license you don't understand. There are some nice articles on many of the more common licenses on Wikipedia as well if you want a broader understanding. Open-source only implies that the source code is available. What one is allowed to actually do with the code will vary by project/author. Now, how am I supposed to deal with that? Ask Secret Labs for some kind of permission? Leave it as it is and add my own copyright line? If you can't find the license, I'd suggest sending an email to that address asking for a copy. -- CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On Sun, Jun 9, 2013 at 7:21 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Sorry for displaying my code so many times, i know i ahve exhaust you but hti is the last thinkg i am gonna ask from you in this thread. We are very close to have this working. You need to spend more time reading and less time frantically jumping around. Go read my post on Unicode; it answers several of the questions you posted in response to Steven's. And please, don't use this list as your substitute for source control. Don't keep posting your code. Most of us are ignoring it already. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Re-using copyrighted code
On Sat, Jun 8, 2013 at 2:31 PM, Malte Forkel malte.for...@berlin.de wrote: Hello, I have written a small utility to locate errors in regular expressions that I want to upload to PyPI. Before I do that, I would like to learn a litte more about the legal aspects of open-source software. What would be a good introductory reading? Plus, I have one very specific question: In my package, I use modified code from sre_parse.py, which is part of the Python release. That file has the following header: # # Secret Labs' Regular Expression Engine # # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # See the sre.py file for information on usage and redistribution. # The referenced information is missing in the version of sre.py that comes with current versions of Python, but I found it in the archive http://effbot.org/media/downloads/sre-2.2.1.zip. It reads: # # Secret Labs' Regular Expression Engine # # re-compatible interface for the sre matching engine # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (i...@pythonware.com). # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # Now, how am I supposed to deal with that? Ask Secret Labs for some kind of permission? Leave it as it is and add my own copyright line? Malte You can find the license terms for all versions of Python at http://docs.python.org/3/license.html I'm not a lawyer, but it looks like you just need to include the copyright statement. I'm not sure why the sre stuff is still licensed under the 1.6 license. Did no one get permission to distribute it under the PSF license, or did no one bother to rewrite the comment in the file? -- http://mail.python.org/mailman/listinfo/python-list
Re: Re-using copyrighted code
On Sun, Jun 9, 2013 at 7:31 AM, Malte Forkel malte.for...@berlin.de wrote: # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (i...@pythonware.com). I presume that's referring to this: http://www.handle.net/python_licenses/python1.6_9-5-00.html http://www.python.org/download/releases/1.6/license_faq/ This is looking like a hairy mess. I would recommend seeking an alternative to this code that's under a simpler license. One unfortunate consequence of license proliferation is that it's harder for code to be reused. For your own code, please use one of the better-known licenses - MIT, GPL, etc - as it will make life ever so much easier for the next person! Alternatively, since this is something that's still in current Python releases (at least, that's how I understand your opening paragraphs), this could be something to take up with the Python dev/legal team. You may be able to use it under the terms of the modern Python license: http://docs.python.org/3.3/license.html But before you publish, I'd look for an authoritative answer from someone in the PSF (which may involve a source-file edit to update the license annotation). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
On Sun, Jun 9, 2013 at 2:56 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Τη Σάββατο, 8 Ιουνίου 2013 7:03:57 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: On Sun, Jun 9, 2013 at 1:36 AM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote: Well, www as symlink to public_html is always a symlink to any system i have used so its something defaulted. It's most certainly not the default, it's definitely not universal and that has nothing to do with what I said. Use the exact same path, it reduces confusion. Also, I think it's time to mention again: Get yourself off Google Groups, or start trimming out the stupid double spacing! It's getting extremely annoying. its very tedious to always triming everything for me and i know it is for you to ead it assuc. Then get off Google Groups. There are alternatives. If you can't be bothered tidying up your posts before you click send, then get software that doesn't force you to. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On 08Jun2013 14:14, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= nikos.gr...@gmail.com wrote: | Τη Σάββατο, 8 Ιουνίου 2013 10:01:57 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: | ASCII actually needs 7 bits to store a character. Since computers are | optimized to work with bytes, not bits, normally ASCII characters are | stored in a single byte, with one bit wasted. | | So ASCII and Unicode are 2 Encoding Systems currently in use. | How should i imagine them, visualize them? | Like tables 'A' = 65, 'B' = 66 and so on? Yes, that works. | But if i do then that would be the visualization of a 'charset' not of an encoding system. | What the diffrence of an encoding system and of a charset? And encoding system is the method or transcribing these values to bytes and back again. | ebcdic - ascii - unicode = al of them are encoding systems | greek-iso - latin-iso - utf8 - utf16 = all of them are charsets. No. EBCDIC and ASCII and Unicode and Greek-ISO (iso-8859-7) are all character sets. (1:1 mappings of characters to numbers/ordinals). And encoding is a way of writing these values to bytes. Decoding reads bytes and emits character values. Because all of EBCDIC, ASCII and the iso-8859-x characters sets fit in the range 0-255, they are usually transcribed (encoded) directly, one byte per ordinal. Unicode is much larger. It cannot be transcribed (encoded) as one bytes to one value. There are several ways of transcribing Unicode. UTF-8 is a popular and usually compact form, using one byte for values below 128 and and multiple bytes for higher values. | Why python interprets by default all given strings as unicode and | not ascii? because the former supports many positions while ascii | only 127 positions , hence can interpet only 127 different characters? Yes. [...] | Latin-1 is similar, except there are 256 positions. Greek ISO-8859-7 is | also similar, also 256 positions, but the characters are different. And | so on, with dozens of charsets. | | Latin has to display english chars(capital, small) + numbers + symbols. that would be 127 why 256? ASCII runs up to 127. Essentially English, numerals, control codes and various symbols. The iso-8859-x sets run to 255, and the upper 128 values map to characters popular in various regions. | greek = all of the above plus greek chars, no? So iso-8859-7 included the Greek characters. | And then there is Unicode, which includes *every* character is all of | those dozens of charsets. It has 1114111 positions (most are currently | unfilled). | | Shouldt the positions that Unicode has to use equal to the summary | of all available characters of all the languages of the worlds plus | numbers and special chars? why 1.000.000+ why the need for so many | positions? Narrow Unicode format (2 byted) can cover all ofmthe | worlds symbols. 2 bytes is not enough. Chinese alone has more glyphs than that. | An encoding is simply a program that takes a character and returns a | byte, or visa versa. For instance, the ASCII encoding will take character | 'A'. That is found at position 65, which is 0x41 in hexadecimal, so the | ASCII encoding turns character 'A' into byte 0x41, and visa versa. | | Why you say ASCII turn a character into HEX format and not as in binary format? Steven didn't say that. He said position 65. People often write bytes in hex (eg 0x41) because a byte always fits in a 2-character hex (16 x 16) and because often these values have binary-based subranges, and hex makes that more obvious. For example, 'A' is 0x41. 'a' is 0x61. So you can look at the hex code and almost visually know if you're dealing with upper or lower case, etc. | Isnt the latter the way bytes are stored into hdd, like 01010010101 etc? | Are they stored as hex instead or you just said so to avoid printing 0s and 1s? They're stored as bits at the gate level. But writing hex codes _in_ _text_ is more compact, and more readable for humans. Cheers, -- Cameron Simpson c...@zip.com.au A lot of people don't know the difference between a violin and a viola, so I'll tell you. A viola burns longer. - Victor Borge -- http://mail.python.org/mailman/listinfo/python-list
Re: Re-using copyrighted code
On 2013.06.08 17:09, Benjamin Kaplan wrote: On Sat, Jun 8, 2013 at 2:31 PM, Malte Forkel malte.for...@berlin.de wrote: # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (i...@pythonware.com). # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # Now, how am I supposed to deal with that? Ask Secret Labs for some kind of permission? Leave it as it is and add my own copyright line? Malte You can find the license terms for all versions of Python at http://docs.python.org/3/license.html I'm not a lawyer, but it looks like you just need to include the copyright statement. I misread that bit, having forgotten that Python was not always under the PSF. To the OP: this is a pretty permissive license, but, as noted in the FAQ that Chris linked, there could be a problem if you wish to license your work under the GPL since the CNRI license specifies a jurisdiction. -- CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PyGame?
Eam onn: ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found. Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper This is saying that the version of Python you are using is a different architecture to the installed pygame library. This could be because you are using a 64-bit version of Python with a 32-bit library or vice-versa. Or you have a PowerPC library and Python is compiled for Intel processors. In Terminal, you can find the architecture of files with otool -vh followed by the file name. So try (on one line) otool -vh /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so And the same with Python, first finding where Python is with whereis python Then post all of the output text, not just your interpretation. Neil -- http://mail.python.org/mailman/listinfo/python-list
Re: Re-using copyrighted code
I can't tell you as a lawyer, but I can tell you that regarding code for non-commercial use, the only supportable case is requiring fair-credit assignment. If reading the original license (which you are obligated to do if you re-use and re-distribute the code), it stipulates that you must re-share accordingly, then you should, otherwise there's very little case that could be brought about if the code was put into a published, open-source project, whatever the license. mark On Sat, Jun 8, 2013 at 2:31 PM, Malte Forkel malte.for...@berlin.de wrote: Hello, I have written a small utility to locate errors in regular expressions that I want to upload to PyPI. Before I do that, I would like to learn a litte more about the legal aspects of open-source software. What would be a good introductory reading? Plus, I have one very specific question: In my package, I use modified code from sre_parse.py, which is part of the Python release. That file has the following header: # # Secret Labs' Regular Expression Engine # # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # See the sre.py file for information on usage and redistribution. # The referenced information is missing in the version of sre.py that comes with current versions of Python, but I found it in the archive http://effbot.org/media/downloads/sre-2.2.1.zip. It reads: # # Secret Labs' Regular Expression Engine # # re-compatible interface for the sre matching engine # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (i...@pythonware.com). # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # Now, how am I supposed to deal with that? Ask Secret Labs for some kind of permission? Leave it as it is and add my own copyright line? Malte -- http://mail.python.org/mailman/listinfo/python-list -- MarkJ Tacoma, Washington -- http://mail.python.org/mailman/listinfo/python-list
Re: Re-using copyrighted code
On Sat, 08 Jun 2013 23:31:10 +0200, Malte Forkel wrote: Hello, I have written a small utility to locate errors in regular expressions that I want to upload to PyPI. Before I do that, I would like to learn a litte more about the legal aspects of open-source software. What would be a good introductory reading? *shrug* I don't know of any good introductory reading for software licences. But have you tried googling for information about open source software licences, copyright, infringement, fair use, etc.? You can also start here: http://opensource.org/licenses/ http://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq http://shop.oreilly.com/product/9780596005818.do Plus, I have one very specific question: In my package, I use modified code from sre_parse.py, which is part of the Python release. That file has the following header: # # Secret Labs' Regular Expression Engine # # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # See the sre.py file for information on usage and redistribution. # The referenced information is missing in the version of sre.py that comes with current versions of Python, That's a bug then. It should be reported to the bug tracker. but I found it in the archive http://effbot.org/media/downloads/sre-2.2.1.zip. It reads: # # Secret Labs' Regular Expression Engine # # re-compatible interface for the sre matching engine # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (i...@pythonware.com). # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # Now, how am I supposed to deal with that? Ask Secret Labs for some kind of permission? Leave it as it is and add my own copyright line? Does Secret Labs even still exist? Try contacting them and see if they respond. I am not a lawyer, and I don't mean to imply that you should ignore or pay no attention to the existing licence, but I wouldn't sweat this too much. I expect that since the code is published under an open source licence, the intent is to allow you to re-use the code (provided you too use a compatible open source licence). That being the case, so long as you too keep the same intent, you won't get into trouble for minor licencing errors. The worst that may happen is that you'll be told to change your licence to match what it should be. (That's the beauty of the FOSS community -- so long as everyone works in good faith, minor errors in licencing are treated as bugs to be fixed, not infringements to pursue for profit.) Give credit to where you are copying the code from, and use a licence that is compatible. Don't try to give away rights that they don't give away, don't try to hold rights that they give away, and you're already 90% of the way there. And of course, it goes without saying, if in doubt, consult a lawyer with experience in software licensing and copyright, especially open source licensing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Listing modules from all installed packages
Hi, I'm trying to write a function that programmatically obtains and returns the exact location of all first-level modules for all installed packages. For example, if the packages named 'django' and 'django-debug-toolbar' are installed, I'd like this function to return something like: installed_modules() /Users/my_user/.virtualenvs/my_venv/lib/python2.6/site-packages/django /Users/my_user/.virtualenvs/my_venv/src/debug_toolbar That is, this function needs to consider all installed packages, including those that have been installed in edit mode (i.e. in the src/ folder). Note also that the main module for the 'django-debug-toolbar' is in fact named 'debug_toolbar'. So far the closest I've been to retrieving the list of first-level modules is as follows: import os import pkg_resources import setuptools pkgs = set() for dist in pkg_resources.working_set: if os.path.isdir(dist.location): for pkg in setuptools.find_packages(dist.location): if '.' not in pkg: pkgs.add(pkg) The idea is then to loop through that list of modules, import them and get their exact locations by fetching their __file__ attribute values. However, this feels very hackish and I don't think it's actually quite correct either. I'm sure there must be a better way. If possible I'd also like to avoid having to use setuptools. Do you have any tips on how to achieve this? Many thanks! Julien -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
On 9/6/2013 1:32 πμ, Cameron Simpson wrote: On 08Jun2013 14:14, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= nikos.gr...@gmail.com wrote: | Τη Σάββατο, 8 Ιουνίου 2013 10:01:57 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: | ASCII actually needs 7 bits to store a character. Since computers are | optimized to work with bytes, not bits, normally ASCII characters are | stored in a single byte, with one bit wasted. | | So ASCII and Unicode are 2 Encoding Systems currently in use. | How should i imagine them, visualize them? | Like tables 'A' = 65, 'B' = 66 and so on? Yes, that works. | But if i do then that would be the visualization of a 'charset' not of an encoding system. | What the diffrence of an encoding system and of a charset? And encoding system is the method or transcribing these values to bytes and back again. So we have: ( 'A' mapped to the value of '65' ) = encoding process(i.e. uf-8) = bytes bytes = decoding process(i.e. utf-8) = ( '65' mapped to character 'A' ) Why does every character in a character set needs to be associated with a numeric value? I mean couldn't we just have characters sets that wouldn't have numeric associations like: 'A' = encoding process(i.e. uf-8) = bytes bytes = decoding process(i.e. utf-8) = character 'A' EBCDIC and ASCII and Unicode and Greek-ISO (iso-8859-7) are all character sets. (1:1 mappings of characters to numbers/ordinals). And encoding is a way of writing these values to bytes. Decoding reads bytes and emits character values. Because all of EBCDIC, ASCII and the iso-8859-x characters sets fit in the range 0-255, they are usually transcribed (encoded) directly, one byte per ordinal. Unicode is much larger. It cannot be transcribed (encoded) as one bytes to one value. There are several ways of transcribing Unicode. UTF-8 is a popular and usually compact form, using one byte for values below 128 and and multiple bytes for higher values. An ordinal = ordered numbers like 7,8,910 and so on? Since 1 byte can hold up to 256 chars, why not utf-8 use 1-byte for values up to 256? UTF-8 and UTF-16 and UTF-32 I though the number beside of UTF- was to declare how many bits the character set was using to store a character into the hdd, no? Narrow Unicode uses two bytes per character. Since two bytes is only enough for about 65,000 characters, not 1,000,000+, the rest of the characters are stored as pairs of two-byte surrogates. Can you please explain this line the rest of thecharacters are stored as pairs of two-byte surrogates more easily for me to understand it? I'm still having troubl understanding what a surrogate is. Again, thank you very much for explaining the encodings to me, they were giving me trouble for years in all of my scripts. And one last thing. When locale to linux system is set to utf-8 that would mean that the linux applications, should try to encode string into hdd by using system's default encoding to utf-8 nad read them back from bytes by also using utf-8. Is that correct? -- Webhost http://superhost.gr Weblog http://psariastonafro.wordpress.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing filenames from Greeklish = Greek (subprocess complain)
Τη Σάββατο, 8 Ιουνίου 2013 9:47:53 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: Fortunately, Python lets us hide away pretty much all those details, just as it lets us hide away the details of what makes up a list, a dictionary, or an integer. You can safely assume that the string foo is a string of three characters, which you can work with as characters. The chr() and ord() functions let you switch between characters and numbers, and str.encode() and bytes.decode() let you switch between characters and byte sequences. Once you get your head around the differences between those three, it all works fairly neatly. I'm trying too! So, chr('A') would give me the mapping of this char, the number 65 while ord(65) would output the char 'A' likewise. and str.encode() and bytes.decode() let you switch between characters and byte sequences. Once What would happen if we we try to re-encode bytes on the disk? like trying: s = νίκος utf8_bytes = s.encode('utf-8') greek_bytes = utf_bytes.encode('iso-8869-7') Can we re-encode twice or as many times we want and then decode back respectively lke? utf8_bytes = greek_bytes.decode('iso-8859-7') s = utf8_bytes.decoce('utf-8') Is somethign like that totally crazy? And also is there a deiffrence between encoding and compressing ? Isnt the latter useing some form of encoding to take a string or bytes to make hold less space on disk? -- http://mail.python.org/mailman/listinfo/python-list
RE: Listing modules from all installed packages
print '\n'.join([re.findall(from '(.*)',str(v))[0] for k,v in sys.modules.items() if str(v).find('from')-1]) Date: Sat, 8 Jun 2013 21:30:48 -0700 Subject: Listing modules from all installed packages From: jpha...@gmail.com To: python-list@python.org Hi, I'm trying to write a function that programmatically obtains and returns the exact location of all first-level modules for all installed packages. For example, if the packages named 'django' and 'django-debug-toolbar' are installed, I'd like this function to return something like: installed_modules() /Users/my_user/.virtualenvs/my_venv/lib/python2.6/site-packages/django /Users/my_user/.virtualenvs/my_venv/src/debug_toolbar That is, this function needs to consider all installed packages, including those that have been installed in edit mode (i.e. in the src/ folder). Note also that the main module for the 'django-debug-toolbar' is in fact named 'debug_toolbar'. So far the closest I've been to retrieving the list of first-level modules is as follows: import os import pkg_resources import setuptools pkgs = set() for dist in pkg_resources.working_set: if os.path.isdir(dist.location): for pkg in setuptools.find_packages(dist.location): if '.' not in pkg: pkgs.add(pkg) The idea is then to loop through that list of modules, import them and get their exact locations by fetching their __file__ attribute values. However, this feels very hackish and I don't think it's actually quite correct either. I'm sure there must be a better way. If possible I'd also like to avoid having to use setuptools. Do you have any tips on how to achieve this? Many thanks! Julien -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Errin when executing a cgi script that sets a cookie in the browser
Trying yum install dos2unix and root@nikos [/home/nikos/www/cgi-bin]# dos2unix koukos.py dos2unix: converting file koukos.py to UNIX format ... Then browsed to the page again in Chrome it worked as expected :-) -- http://mail.python.org/mailman/listinfo/python-list
[issue17947] Code, test, and doc review for PEP-0435 Enum
Ethan Furman added the comment: Hopefully the final bit of code, plus docs. Code changes: _names_ are reserved Doc changes (different from the PEP): examples of AutoEnum, UniqueEnum, and OrderedEnum -- Added file: http://bugs.python.org/file30504/pep-0435.08.stoneleaf.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Changes by Ethan Furman et...@stoneleaf.us: Removed file: http://bugs.python.org/file30504/pep-0435.08.stoneleaf.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Changes by Ethan Furman et...@stoneleaf.us: Added file: http://bugs.python.org/file30505/pep-0435.08.stoneleaf.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Changes by Ethan Furman et...@stoneleaf.us: Removed file: http://bugs.python.org/file30505/pep-0435.08.stoneleaf.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Ethan Furman added the comment: Apologies for the noise -- was having trouble getting the correct patch attached. :/ -- Added file: http://bugs.python.org/file30506/pep-0435.09.stoneleaf.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18111] Add a default argument to min max
Changes by Phil Connell pconn...@gmail.com: -- nosy: +pconnell ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18111 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18112] PEP 442 implementation
Changes by Phil Connell pconn...@gmail.com: -- nosy: +isoschiz, pconnell ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18112 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18129] Fatal Python error: Cannot recover from stack overflow.
Changes by Phil Connell pconn...@gmail.com: -- nosy: +pconnell ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18129 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16715] Get rid of IOError. Use OSError instead
koobs added the comment: Commit to 3.3 broke at least my FreeBSD buildbot: http://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.0%20dtrace%203.3/builds/641/steps/test/logs/stdio Also setting +Version: Python 3.3 on this. -- nosy: +koobs versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16715 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15528] Better support for finalization with weakrefs
Łukasz Langa added the comment: Your patch leaks references with subinterpreters, which was exposed by functools.singledispatch using weakref. While the actual bug is in atexit (which doesn't properly unregister on subinterpreter termination), now all uses of weakref leak. Context: http://mail.python.org/pipermail/python-dev/2013-June/126755.html PJE suggests importing atexit and registering finalize only when it's actually used. I guess this would be the easiest workaround. -- assignee: - sbt nosy: +lukasz.langa resolution: fixed - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15528 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16715] Get rid of IOError. Use OSError instead
Terry J. Reedy added the comment: I don't think so. The idle test, test_idle, passed. The patch did not even affect any of the three idle files that it currently tests. Just because a commit triggers a test does not mean that it is the cause of any failure that happens. The log says the failure was in test_subprocess. ''' FAIL: test_wait_timeout (test.test_subprocess.ProcessTestCaseNoPoll) -- Traceback (most recent call last): File /usr/home/buildbot/python/3.3.koobs-freebsd/build/Lib/test/test_subprocess.py, line 953, in test_wait_timeout p.wait(timeout=0.0001) AssertionError: TimeoutExpired not raised ''' As I interpret the traceback, this did not fail is the re-run. I did not set 3.3, nor reopen, because this patch is primarily part of a new issue, #18151. I cross-referenced this one so that if anyone else thought of backporting some of the mega patch, this backport would be recorded here. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16715 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18111] Add a default argument to min max
Changes by Serhiy Storchaka storch...@gmail.com: -- stage: - patch review versions: -Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18111 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16715] Get rid of IOError. Use OSError instead
koobs added the comment: Apologies for the noise Terry, rebuilding passes. Unsetting versions: 3.3 Is the failure on the build I reported worth opening an issue for? -- versions: -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16715 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17343] Add a version of str.split which returns an iterator
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17343 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7796] No way to find out if an object is an instance of a namedtuple
Changes by Eric Snow ericsnowcurren...@gmail.com: -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7796 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18143] ssl.get_default_verify_paths()
Antoine Pitrou added the comment: Your raw parameter is one too many IMO. You should find a way to present all relevant information in a single API call. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15528] Better support for finalization with weakrefs
Roundup Robot added the comment: New changeset d6ad9d7468f7 by Richard Oudkerk in branch 'default': Issue #15528: Delay importing atexit until weakref.finalize() used. http://hg.python.org/cpython/rev/d6ad9d7468f7 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15528 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Ethan Furman added the comment: So, which is better? To have a @unique class decorator as part of the module, or to have a UniqueEnum recipe in the docs? A decorator is immediately usable, but requires remembering an extra line of code. An example requires being put into a local utility module, but also serves as a guide to customising Enums. (Took be about five tries to get it right. :/ ) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17375] Add docstrings to methods in the threading module
Changes by Eli Bendersky eli...@gmail.com: -- nosy: -eli.bendersky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17375 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1772673] Replacing char* with const char*
Changes by Eli Bendersky eli...@gmail.com: -- nosy: -eli.bendersky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1772673 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Eli Bendersky added the comment: Nick prudently moved the unique discussion to its own issue - 18042. Let's get the initial implementation docs committed first (without unique in the implementation, although it's fine to have it as an example in the docs for now), close this issue, and then discuss in 18042 whether unique should be part of the stdlib-provided API or not. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Ethan Furman added the comment: Good idea, thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17947] Code, test, and doc review for PEP-0435 Enum
Eli Bendersky added the comment: I sent a fresh review - nothing major; it's very near commit readiness now. Additional changes can be done after the initial commit. We have time until 3.4 beta (November 2013) to tweak stuff (and the documentation whenever...) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18042] Provide enum.unique class decorator
Barry A. Warsaw added the comment: +1 for the decorator! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18042 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18042] Provide enum.unique class decorator
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18042 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18143] ssl.get_default_verify_paths()
Christian Heimes added the comment: How about a single return value: DefaultVerifyPaths = collections.namedtuple(DefaultVerifyPaths, cafile capath openssl_cafile_env openssl_cafile openssl_capath_env openssl_capath) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15528] Better support for finalization with weakrefs
Richard Oudkerk added the comment: PJE suggests importing atexit and registering finalize only when it's actually used. I guess this would be the easiest workaround. Done. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15528 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8902] add datetime.time.now() for consistency
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8902 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18159] ConfigParser getters not available on SectionProxy
João Bernardo added the comment: Overriding __getattr__ doesn't look like the best solution Another idea would be to allow the proxy class to be selectable, but this would require the user to do much more coding for this simple thing... I believe a proxy should be dynamic enough to avoid having to duplicate every function definition. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18159 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18113] Memory leak in curses.panel
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18113 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18110] Nested set comprehensions in class scope fail
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18110 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18119] urllib.FancyURLopener does not treat URL fragments correctly
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti, orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18119 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18156] Add an 'attr' attribute to AttributeError
Changes by Ezio Melotti ezio.melo...@gmail.com: -- keywords: +easy nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18156 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18152] Idle: add 2.7 backport script
Ezio Melotti added the comment: 'Import' is as easy to use as Graft and as far as I know, the result when successful is the same. I use import while importing patches from the tracker, but once I committed on 2.x it's easier to just graft instead of importing again (importing often requires you to generate a new patch and possibly you have to commit manually again after the import). I know I 'should' learn to use kdiff3 effectively, but it seldom works right for me, That's what learning it is supposed to avoid :) and the live repository is the wrong place to learn by failure. As long as you check the result before pushing there shouldn't be any problems. If the merge goes wrong you can always rollback and try again (or try a different approach). You can also use hg diff -c tip to see the diff of the last commit. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14015] surrogateescape largely missing from documentation
Changes by A.M. Kuchling li...@amk.ca: -- nosy: +akuchling ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14015 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17134] Use Windows' certificate store for CA certs
Christian Heimes added the comment: New patch with fixed doc string and indention. http://msdn.microsoft.com/en-us/library/windows/desktop/aa377189%28v=vs.85%29.aspx explains how encoding type shall be interpreted. I haven't seen PKCS#7 certs on my Windows system, though. Instead of a flag I could also return a string: CERTIFICATE for X509_ASN_ENCODING cert, X509 CRL for X509_ASN_ENCODING CRL or PKCS7 for PKCS#7 encoded certs. -- Added file: http://bugs.python.org/file30507/enumcertstore3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17134 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18143] ssl.get_default_verify_paths()
Antoine Pitrou added the comment: How about a single return value: DefaultVerifyPaths = collections.namedtuple(DefaultVerifyPaths, cafile capath openssl_cafile_env openssl_cafile openssl_capath_env openssl_capath) Sounds good. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14797] Deprecate imp.find_module()/load_module()
Thomas Heller added the comment: The modulefinder usage is directly exposed in its API as the return value of a find_module method, which makes removal a pain. Adding Thomas Heller to see what he has to say. Some months ago, I have started to implement a brand-new modulefinder, which is based on importlib. It has a different API, but the (barely) documented API functions remain the same or could be made compatible. The advantage against the current modulefinder is that it finds modules in zipfiles, for example in zipped eggs. IMO it is not yet ready for inclusion into Python 3.4, but given the plans for the first alpha release in August I will hopefully find time to work on it a little bit more. If someone wants to read the code, or try it out: Modulefinder: http://code.google.com/p/ctypes-stuff/source/browse/trunk/mf/mf4.py Test: http://code.google.com/p/ctypes-stuff/source/browse/trunk/mf/maketest.py Thomas -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14797 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18168] plistlib output self-sorted dictionary
Mher Movsisyan added the comment: I think this is not a bug. plistlib api accepts dict (not OrderedDict) and sorted output is a valid output. plistlib sorts dictionaries to be consistent with Apple's tools. property list format [1] uses CFDictionary [2] with CFString keys. CFDictionary is unordered and the plist example in the format [1] is unordered too. But plutil [3] command sorts dictionaries. It is easy to observe by self-converting plist files with plutil -convert xml1 test.plist command. 1. https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/plist.5.html 2. http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFDictionaryRef/Reference/reference.html 3. https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/plutil.1.html -- nosy: +mher.movsisyan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18168 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7796] No way to find out if an object is an instance of a namedtuple
Eric Snow added the comment: It may not enough, but the use of namedtuples (vs. plain tuples) with functools.singledispatch() would be messier without a NamedTuple ABC (or other base type). Of course, when would you want to dispatch specifically on namedtuple? I can think of a few relatively weak uses, but not enough to justify the cost of establishing a common base class for namedtuple. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7796 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18168] plistlib output self-sorted dictionary
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: +hynek, ned.deily, ronaldoussoren ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18168 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10652] test___all_ + test_tcl fails (Windows installed binary)
Changes by Ezio Melotti ezio.melo...@gmail.com: -- versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10652 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18169] struct.pack() behaves strangely for 'L' on 64bit Linux
New submission from Roman Zeyde: Reproduction: Python 2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3] on linux2 Type help, copyright, credits or license for more information. import struct struct.pack('!L', 0x01020304) '\x01\x02\x03\x04' struct.pack('L', 0x01020304) '\x01\x02\x03\x04' struct.pack('L', 0x01020304) '\x04\x03\x02\x01' struct.pack('L', 0x01020304) '\x04\x03\x02\x01\x00\x00\x00\x00' ### WAT??? ### As far as I see at the source code (http://hg.python.org/releasing/2.7.4/file/9290822f2280/Modules/_struct.c#l703), sizeof(long) is used as the size of 'L', which is equal to 8 at 64bit Linux... The problem is that the results of packing with 'L' returns 8 bytes, instead of 4 - as was expected from the documentation... -- components: Interpreter Core messages: 190817 nosy: Roman.Zeyde priority: normal severity: normal status: open title: struct.pack() behaves strangely for 'L' on 64bit Linux type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18169 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18041] mention issues with code churn in the devguide
Ezio Melotti added the comment: I’ve actually seen two contrary kinds of advice and the best approach is most of the times something in between. Doing minor cleanups while touching the code is fine, but if most of the changes are cleanups then it gets distracting. In that case it's better to do the cleanups in a separate commit (either before or after). Regarding rewrapping paragraphs in the docs the situation is a bit different. There are 3 options: 1) change and rewrap in the same commit; 2) change but avoid rewrapping so that the changes are easier to detect; 3) like 2, but then add the rewrapping in a separate commit; 3) is overkill IMHO, and I don't think I've seen it used very often. 2) makes the diff more readable, but leaves the code unwrapped making it less readable for everyone else (and I would argue that reading code happens more often than reading diffs). 1) makes the diff less readable, but leaves wrapped code and it's IMHO the best compromise, and thus what I usually do. However, I think that the actual problem pointed out in the linked issue is about mass changes, rather than cleanups while touching code for other reasons. Even for that it depends on the case: how many files/lines are affected, what benefits are brought by the change, how complex are the changes, how likely is to introduce new bugs while doing them and so on. A couple of generic guidelines could be added to the devguide, but there's no hard rule for this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18041 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com