Nanpy 0.7 - Use your Arduino board with Python
Hi, Happy new year! :) New year, new release: Nanpy 0.7 is out with some changes: - Now we use the official version of edam's Arduino makefile (http://ed.am/dev/make/arduino-mk) - Added support to the CapacitiveSensor library (http://playground.arduino.cc//Main/CapacitiveSensor?from=Main.CapSense) and map function - Improvements on the communication speed and bugfixing We also have a repository with some projects made using Nanpy: https://github.com/nanpy/eggsamples ... if you have a project made with Nanpy and it's open source please let us know!! :) Enjoy Nanpy and discover its simplicity expecially using it with a RaspberryPi.. in the last MagPi issue I explain how to accomplish that: http://www.themagpi.com/ Remember that Nanpy is now an organization on Github! Join us and/or donate if you like it! https://github.com/nanpy WHAT IS NANPY Nanpy is a pure Python library that allows you communicating with an Arduino board connected via USB. Classes and methods used are really similar to the Arduino framework's ones, but simpler and with some additional features, so people who haven't worked with an Arduino can be easily introduced to his world.. The main purpose of Nanpy is making developers' life easier, giving them something simple and fast to use to create prototypes and scripts interacting with Arduino, saving time and making them concentrate on the problem. There are a lot of projects able to do something similar, using Python or other languages, but Nanpy can do more! Nanpy is easily extensible and can theoretically use every library Arduino supports, allowing you to create how many objects you want and without worrying about deallocation. Also, you can use Nanpy in parallel and concurrence programs. Nanpy is under heavy development but is growing fast and just supports the main methods of OneWire, Lcd, Tone, DallasTemperature, Stepper and Servo libraries. Just a word of warning: Raspberry Pi may not provide enough power to drive an Arduino, so you might need external power. UNDER THE WOOD With Nanpy you can write your Arduino programs using Python, communicating via serial port without sending hard-to-remember codesor limiting you to use only one object: when you create an object in Python it will be automatically created into your Arduino at runtime.. For example if you write something like Arduino.pinMode(13, Arduino.OUTPUT) Arduino.digitalWrite(13, Arduino.HIGH) or tone = Tone(13) or lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString(Hello World!) or ds = DallasTemperature(5) Nanpy creates the correct object into Arduino for you.. Also, you haven't to take care of deallocation, Nanpy deallocates objects into Arduino as soon as the correspondent Python objects get deleted. Look at the examples to see how simple it is.. (https://github.com/nanpy/nanpy/tree/master/examples) :) I tried running Nanpy on a Raspberry board and it works great!!(that's the result from one of my friends' Twitter account https://twitter.com/andreagrandi/status/251702684380434434 :) ). Also you can use it in other devices suppoting Python and serial communication, with Django, for creating prototypes faster etc.. because you use Python and you don't have to flash the firmware every time. Last but not least, firmware part of Nanpy is Python-indipendent, so you can write another implementation of Nanpy in any other language, for example Java, and see an Arduino controlled via Android (ok, in this case we should use Android USB Host API, writing our own driver, because Android doesn't provide anything to access device files). We will work on this in the future :) DONATE --- Do you like Nanpy? Contributions/suggestions/bug reporting/spreading the project/beers/coffee are accepted :) if you want to donate a coffee and be sure that we will work during the night, here's the link https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclickhosted_button_id=TDTPP5JHVJK8J Thanks for your attention! Best regards, =.4.S.= -- Andrea Stagi (@4ndreaSt4gi) - Software Engineer Job profile: http://linkedin.com/in/andreastagi Website: http://4spills.blogspot.it/ Github: http://github.com/astagi -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: pylint, was Re: pygame - importing GL - very bad...
Terry Reedy wrote: [a-z_][a-z0-9_]{2,30}$) - so I suppose it wants this name to end with an underscore ? No, it allows underscores. As I read that re, 'rx', etc, do match. They No, it's one leading letter or underscore [a-z_] plus at least two letters, underscores or digits [a-z0-9_]{2,30} -- http://mail.python.org/mailman/listinfo/python-list
Important questions about __future__
Does 'from __future__ import barry_as_FLUFL' do anything? Despite PEP 401, using print as a statement still raises a SyntaxError. Where is 'from __future__ import braces' implemented in CPython (it's not in __future__.py)? -- CPython 3.3.0 | Windows NT 6.2.9200.16461 -- http://mail.python.org/mailman/listinfo/python-list
Re: Important questions about __future__
On Thursday, 3 January 2013 15:13:44 UTC+5:30, Ramchandra Apte wrote: On Thursday, 3 January 2013 14:57:42 UTC+5:30, Andrew Berg wrote: Does 'from __future__ import barry_as_FLUFL' do anything? Despite PEP 401, using print as a statement still raises a SyntaxError. Where is 'from __future__ import braces' implemented in CPython (it's not in __future__.py)? -- CPython 3.3.0 | Windows NT 6.2.9200.16461 barry_as_FLUFL is probably simply a joke future statement (Barry is at the head of Python Development and would probably replace Guido in the future) (Guido is typically only active on python-ideas). from __future__ import braces is the Future statement (see http://docs.python.org/3/library/__future__.html) import __future__ simply imports __future__.py as a plain, ordinary module Link should have been http://docs.python.org/3/reference/simple_stmts.html#future --- Happy, new, joyful, etc new boring year. -- http://mail.python.org/mailman/listinfo/python-list
Re: Important questions about __future__
On Thursday, 3 January 2013 14:57:42 UTC+5:30, Andrew Berg wrote: Does 'from __future__ import barry_as_FLUFL' do anything? Despite PEP 401, using print as a statement still raises a SyntaxError. Where is 'from __future__ import braces' implemented in CPython (it's not in __future__.py)? -- CPython 3.3.0 | Windows NT 6.2.9200.16461 barry_as_FLUFL is probably simply a joke future statement (Barry is at the head of Python Development and would probably replace Guido in the future) (Guido is typically only active on python-ideas). from __future__ import braces is the Future statement (see http://docs.python.org/3/library/__future__.html) import __future__ simply imports __future__.py as a plain, ordinary module -- http://mail.python.org/mailman/listinfo/python-list
Re: New to python, do I need an IDE or is vim still good enough?
Wayne Werner wa...@waynewerner.com wrote: Yep. That's how I feel. I had used ViEmu in Visual Studio for coding in .NET at work - but I found that the buffers macros were more powerful. So now I do most of my programming in Vim, and only head to VS if I need autocomplete or some of it's auto-generation tools. Learning X different IDEs for different languages and uses can be confusing. So if you use Visual-Studio a lot there is Python Tools for VS [1]. A great but kinda slow extension to VS. Sticking to VS is also useful if one does Swig and need to debug your crashing .pyd modules. [1] http://pytools.codeplex.com/ --gv -- http://mail.python.org/mailman/listinfo/python-list
Re: Important questions about __future__
On Thu, Jan 3, 2013 at 2:27 AM, Andrew Berg bahamutzero8...@gmail.com wrote: Does 'from __future__ import barry_as_FLUFL' do anything? Despite PEP 401, using print as a statement still raises a SyntaxError. I think it only replaces the != operator with . Where is 'from __future__ import braces' implemented in CPython (it's not in __future__.py)? Python/future.c -- http://mail.python.org/mailman/listinfo/python-list
Re: Important questions about __future__
On Thu, 03 Jan 2013 03:27:42 -0600, Andrew Berg wrote: Does 'from __future__ import barry_as_FLUFL' do anything? Yes, it re-enables and disables != as not equal: py sys.version '3.3.0rc3 (default, Sep 27 2012, 18:44:58) \n[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)]' py 1 2 File stdin, line 1 1 2 ^ SyntaxError: invalid syntax py from __future__ import barry_as_FLUFL py 1 2 True Where is 'from __future__ import braces' implemented in CPython (it's not in __future__.py)? It's defined in the C source code for the CPython compiler. Look in future.c. http://hg.python.org/cpython/file/944e86223d1f/Python/future.c -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint, was Re: pygame - importing GL - very bad...
On 01/03/2013 03:55 AM, Ian Kelly wrote: On Wed, Jan 2, 2013 at 7:24 PM, someone newsbo...@gmail.com wrote: 3) self.rx / rself.ry / self.rz: Invalid name rx (should match [a-z_][a-z0-9_]{2,30}$) - so I suppose it wants this name to end with an underscore ? It wants the name to be at least 3 characters long. Uh, ok, thank you. I'll remember that. Doesn't this [ ... ] mean something optional? What does {2,30}$ mean? I think $ means that the {2,30} is something in the end of the sentence... -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint, was Re: pygame - importing GL - very bad...
On 01/03/2013 10:00 AM, Peter Otten wrote: Terry Reedy wrote: [a-z_][a-z0-9_]{2,30}$) - so I suppose it wants this name to end with an underscore ? No, it allows underscores. As I read that re, 'rx', etc, do match. They No, it's one leading letter or underscore [a-z_] plus at least two letters, underscores or digits [a-z0-9_]{2,30} Ah, [a-z0-9_]{2,30} means there should be at least two characters and maximum 30 characters here ? -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint, was Re: pygame - importing GL - very bad...
On Thu, Jan 3, 2013 at 10:19 PM, someone newsbo...@gmail.com wrote: Doesn't this [ ... ] mean something optional? What does {2,30}$ mean? I think $ means that the {2,30} is something in the end of the sentence... You can find regular expression primers all over the internet, but to answer these specific questions: [...] means any of the characters in the range; the $ means end of string; and {2,30} means at least two, and at most thirty, of the preceding character. So you have to have one from the first group, then 2-30 from the second, for a total of 3-31 characters in your names. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Regular expression syntax, was Re: pylint, was Re: pygame - importing GL - very bad...
someone wrote: On 01/03/2013 10:00 AM, Peter Otten wrote: Terry Reedy wrote: [a-z_][a-z0-9_]{2,30}$) - so I suppose it wants this name to end with [an underscore ? No, it allows underscores. As I read that re, 'rx', etc, do match. They No, it's one leading letter or underscore [a-z_] plus at least two letters, underscores or digits [a-z0-9_]{2,30} Ah, [a-z0-9_]{2,30} means there should be at least two characters and maximum 30 characters here ? Yes. See http://docs.python.org/2/library/re.html#regular-expression-syntax -- http://mail.python.org/mailman/listinfo/python-list
Re: Python printout
On Tuesday, 27 November 2012 15:00:29 UTC+5:30, Avrajit Chatterjee wrote: I have multiple list and want to invoke a single prinout which will give a print preview of all list in Grid format in a different pages. I have tried wx.lib.printout.PrintTable but it takes only one table at a time. Any clues how to achieve this? Didnt find any good way of doing it , hence printed all in a excel in background and used VBS win32 lib to print the excel sheet by selecting the print area. -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating interactive command-line Python app?
This is exactly what you want: https://cliff.readthedocs.org/en/latest/ Bob/Julius Flywheel On Wednesday, December 21, 2005 11:34:38 PM UTC+11, planetthoughtful wrote: Hello All, Newbie to Python, and I'm wondering if it's possible to create a Python console app that prompts for further input on the command line when run (in Windows XP, if that's important)? I've tried Googling, but the results are overwhelmingly about interactive Python environments (IPython etc etc), instead of how to achieve prompting at the command line when running your own Python app. Any help appreciated! Much warmth, planetthoughtful -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
Mitya Sirenef wrote: So, how many instances do you want to make.. what kind of different functionality / properties they will have? - mitya I am porting a modeling system I created using POV-Ray scene description language available at sourceforge at http://sourceforge.net/projects/kobldes/ The user can create as many marks as possible (limited by memory available). The difference between each mark are the parameters provided i.e. name, length, and position in the scene. If the user wishes to customize part of the program they must update the classes or create new ones before using it in the scene. File A in my previous illustrations can be considered the scene file. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On Wed, 02 Jan 2013 23:32:33 -0500 Kene Meniru kene.men...@illom.org wrote: This sounds so simple but being new to python I am finding it hard to get started. I want to create a module which I will call B. There will be other modules called C, D, etc, which will most likely be imported in B. Then I want the user to import B ONLY into another file I will call A in which commands such as the following will be entered: snap_size = 10 LinearMark(name) LinearMark.put(name, length, rotation, (x,y,z)) Sounds messy. The file A allows the user to enter commands that provide global variables as well as to use classes provided in modules C, D, OK, global variables is the clue that you need to rethink this. Try to stay away from global variables as much as possible except for maybe some simple setup variables within the same file. Consider something like this instead. In file B: class TopClass(object): def __init__(self, snap_size, var1 = None, var2 = None): self.snap_size = snap_size self.var1 = var1 if var2 is None: self.var2 = 7 self.var3 = GO self.var4 = Static string *add class methods here* In file A: class MyClass(TopClass): def __init__(self, var1): TopClass.__init__(self, 10, var1, 8) self.var3 = STOP x = MyClass(42) x.var4 = Not so static after all In this (untested) example you create your top class in B and then subclass it in A. Notice the different way of setting variables here. In MyClass we hard code snap_size to 10, we set var1 from the argument when we instantiate it, var2 is hard coded to 8 but could be left out if we wanted the default of 7, var3 is overwritten in MyClass and var4 is changed after the class is instantiated. Hope this gives you some ideas. -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
PyGreSQL 4.1 released
--- Release of PyGreSQL version 4.1 --- It has been a long time coming but PyGreSQL v4.1 has been released. It is available at: http://pygresql.org/files/PyGreSQL-4.1.tgz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection which will probably be updated shortly. Please refer to `changelog.txt changelog.html`_ for things that have changed in this version. Please refer to `readme.txt readme.html`_ for general information. This version has been built and unit tested on: - NetBSD - FreeBSD - openSUSE 12.2 - Windows 7 with both MinGW and Visual Studio - PostgreSQL 8.4, 9.0 and 9.2 32 and 64bit - Python 2.5, 2.6 and 2.7 32 and 64bit -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
D'Arcy J.M. Cain wrote: OK, global variables is the clue that you need to rethink this. Try to stay away from global variables as much as possible except for maybe some simple setup variables within the same file. Consider something like this instead. The global variable is not part of the LinearMark object. It will be used by ALL objects created. I understand the uneasiness with this so maybe I will make it a function so it will be set with something like: SnapSize(num) In file B: class TopClass(object): def __init__(self, snap_size, var1 = None, var2 = None): self.snap_size = snap_size self.var1 = var1 if var2 is None: self.var2 = 7 self.var3 = GO self.var4 = Static string *add class methods here* In file A: class MyClass(TopClass): def __init__(self, var1): TopClass.__init__(self, 10, var1, 8) self.var3 = STOP x = MyClass(42) x.var4 = Not so static after all As I mentioned, the file A can be considered a scene file. I do not want the user to have to create classes there. I apologize for the lack of code. I will soon have some python code so my future questions will have some examples. Thanks for the comments. -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame - importing GL - very bad...
On 13-01-02 08:53 PM, someone wrote: On 01/02/2013 10:57 PM, Michael Torrie wrote: On 01/01/2013 04:49 PM, someone wrote: On 01/01/2013 12:13 PM, Chris Angelico wrote: You could simply import OpenGL.GL as GL You're right - but I forgot to write that even though this maybe should/is recommended many places then I've seen a lot of opengl code on the internet and IMHO NOBODY does that and it'll be a lot slower to type that in front of all the opengl commands... So this solution is not something I like too... But I can see some other people came up with good solutions, which I didn't knew about.. Why is this solution not to your liking? Python has namespaces for a Because the amount of opengl-functions is HUGE, many people (at least on the internet) do as I and (IMHO) it takes up too much time to change a lot of code plus sometimes I grab/modify small code pieces from the internet and it makes my development SO MUCH faster just to make an exception here with star-import for opengl-commands. I'd agree on it being rather impractical/pointless/verbose to have every single OpenGL entry point and constant have an extra gl. or glu. or glut. added to the front. OpenGL/GLU/GLUT is already namespaced, but using C-style prefix namespacing (that is gl* glu* glut* and GL_*, GLU_*, GLUT_*), so adding Python style namespacing to the front of that makes it very verbose. OpenGL-using code is *littered* with OpenGL entry points and constants (and yes, I intend the slight slight), so that's going to make it rather annoying to work with. PyOpenGL's current approach is mostly attempting to maintain backward compatibility with the older revisions. wxPython actually rewrote its whole interface to go from * imports into namespaced lookups and then wrote a little migration tool that would attempt to rewrite your code for the new version. They also provided a transitional API so that code could mix-and-match the styles. For PyOpenGL that would look something like this: from OpenGL import gl, glu, glut gl.Rotate(...) gl.Clear(gl.COLOR_BUFFER_BIT) or, if you really needed PEP-8 compliance, and don't mind making the API look nothing like the original, we might even go to: from opengl import gl, glu, glut gl.rotate(...) gl.clear(gl.COLOR_BUFFER_BIT) Either of which would *also* make it possible for us to lazy-load the entry points and symbols (that would save quite a bit of ram). But I'm not actually likely to do this, as it makes it far more annoying to work with C-oriented references (and since PyOpenGL is primarily used by new OpenGL coders who need to lean heavily on references, that's a big deal). Currently you can often copy-and-paste C code into PyOpenGL and have it work properly as far as the OpenGL part is concerned (arrays and the like need to be rewritten, but that's not something I can control, really). People are already confused by the small variations from C OpenGL, making the API look entirely different wouldn't be a good direction to move, IMO. HTH, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint, was Re: pygame - importing GL - very bad...
On 13-01-02 09:48 PM, Terry Reedy wrote: ... 2) self.lightDone: Invalid name lightDone (should match [a-z_][a-z0-9_]{2,30}$) So I can now understand that pylint doesn't like my naming convention with a capital letter in the middle of the variable name, like: lightDone = a boolean value. I suppose pylint wants me to use (a little longer method) an underscore to separate words in long variable names... That is more conventional in the Python community (and is in pep 8, I believe) but still a choice. That seems like a improper error message from the tool. Invalid name does *not* properly describe that situation. The name is *not* Invalid in any sense of the word, and a checker that tells you it is is creating needless false-positives. An error checker should be saying something like: self.lightDone: Does not match PEP8 recommended style making it clear that this is *not* an error, it is a *style* related *warning*. HTH, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating interactive command-line Python app?
(original post from planetthoughtful didn't seem to arrive here, so replying to Bob's reply) Newbie to Python, and I'm wondering if it's possible to create a Python console app that prompts for further input on the command line when run (in Windows XP, if that's important)? While Bob's suggestion of cliff sounds interesting, Python also offers the cmd module[1] in the standard library which does most of what I've needed in the past. If you've got the readline library available, it also supports autocompletion and command-line history which is a nice bonus. -tkc [1] http://docs.python.org/2/library/cmd.html # py2.x http://docs.python.org/3/library/cmd.html # py3.x Docs should be about the same -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On Thu, 03 Jan 2013 09:06:55 -0500 Kene Meniru kene.men...@illom.org wrote: OK, global variables is the clue that you need to rethink this. Try to stay away from global variables as much as possible except for maybe some simple setup variables within the same file. Consider something like this instead. The global variable is not part of the LinearMark object. It will be used by ALL objects created. I understand the uneasiness with this so maybe I will make it a function so it will be set with something like: Applying to all objects in your file A is not an issue. See below. SnapSize(num) That doesn't make it any less global. As I mentioned, the file A can be considered a scene file. I do not I don't know what a scene file is. want the user to have to create classes there. I apologize for the But you expect them to write Python code? Classes are a very powerful part of Python and if super classes are written well they can be very simple to write. Perhaps you found my examples too complicated. That was so I could illustrate a number of methods. I wouldn't expect you to use all of them in your code. Here is a simpler example that may meet your requirements. File B: class TopClass(object): def __init__(self, snap_size): self.snap_size = snap_size def put(self, ... In file A: class MyClass(TopClass): def __init__(self): TopClass.__init__(self, 10) x = MyClass() x.put(... Now you have a new class where every instance uses a snap size of 10. Notice that this class in what you call the user's code is only three lines. That's pretty simple for your user. If you think that that is too complicated still then maybe the user shouldn't be writing any Python code and instead look at the various ways of parsing configuration files which they can write. -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating interactive command-line Python app?
On 01/03/2013 09:24 AM, Tim Chase wrote: (original post from planetthoughtful didn't seem to arrive here, so replying to Bob's reply) Newbie to Python, and I'm wondering if it's possible to create a Python console app that prompts for further input on the command line when run (in Windows XP, if that's important)? While Bob's suggestion of cliff sounds interesting, Python also offers the cmd module[1] in the standard library which does most of what I've needed in the past. If you've got the readline library available, it also supports autocompletion and command-line history which is a nice bonus. -tkc [1] http://docs.python.org/2/library/cmd.html # py2.x http://docs.python.org/3/library/cmd.html # py3.x Docs should be about the same The two replies in 2005 mentioned both raw_input and the cmd module (in case that's what he was implying). They were posted within 90 minutes of the original. http://python.6.n6.nabble.com/Creating-interactive-command-line-Python-app-td910404.html I assume that cliff is much more recent, and Bob wanted to update the thread after 7 years. http://pypi.python.org/pypi/cliff -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
building python from source
For those building python from source what are some tests you do to make sure the compilation and installation is up to standard. For instance here are some thing I do: Tk functionality sqlite module Python is compiled with shared object (important for wsgi) Proper preloading of python libraries (set the proper -rpath flag for gcc) Any others? The people who manage distributions what do they check with for regression tests? -- --- Get your facts first, then you can distort them as you please.-- -- http://mail.python.org/mailman/listinfo/python-list
Re: building python from source
Run the unittests. the test___all___.py test runner can be found under your python installation directory's lib/python-X.X/test/. *Matt Jones* On Thu, Jan 3, 2013 at 8:43 AM, Rita rmorgan...@gmail.com wrote: For those building python from source what are some tests you do to make sure the compilation and installation is up to standard. For instance here are some thing I do: Tk functionality sqlite module Python is compiled with shared object (important for wsgi) Proper preloading of python libraries (set the proper -rpath flag for gcc) Any others? The people who manage distributions what do they check with for regression tests? -- --- Get your facts first, then you can distort them as you please.-- -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
D'Arcy J.M. Cain wrote: As I mentioned, the file A can be considered a scene file. I do not I don't know what a scene file is. A scene file is applicable to programs like POV-Ray at www.povray.org. It is a file that is used to describe 3D objects such as box, sphere, polygon, etc. My program specializes this situation and allows the user to describe building components to be used in constructing houses. But you expect them to write Python code? ... Actually, I specifically do not want this. This is why in another thread (titled Parsing files in python) I was proposing developing a new language with python-PLY. After the comments here and in the PLY group, I decided it would be easier to just port the application I have now before thinking in this direction so that I am clear in my mind what I want to do with python. ... Here is a simpler example that may meet your requirements. File B: class TopClass(object): def __init__(self, snap_size): self.snap_size = snap_size def put(self, ... I understand where you are coming from and this is already being done but in modules C, D, etc, following my previous description. Module B will have the boundary classes which the user uses to interact with these other modules (C, D, etc.). In file A: class MyClass(TopClass): def __init__(self): TopClass.__init__(self, 10) x = MyClass() x.put(... Now you have a new class where every instance uses a snap size of 10. Notice that this class in what you call the user's code is only three lines. That's pretty simple for your user. If you can imagine creating hundreds of building components for each building described in the A, then you will understand that for any user (who just wants to make buildings and not program), it is not desirable to use this method. Think of LaTeX and using simple symbols to tell the computer how to lay out text. I want to do the same for architecture/building engineering. If you think that that is too complicated still then maybe the user shouldn't be writing any Python code and instead look at the various ways of parsing configuration files which they can write. Yes, I guess that is the main thing. I do not want users to have to write python code unless they are interested in customizing how the program behaves or perhaps a building component. In that case any of the other modules can be updated instead of A. Actually A will not be part of the packaged program. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGreSQL 4.1 released
On Thu, 03 Jan 2013 09:04:16 -0500, D'Arcy J.M. Cain wrote: --- Release of PyGreSQL version 4.1 --- It has been a long time coming but PyGreSQL v4.1 has been released. It is available at: http://pygresql.org/files/PyGreSQL-4.1.tgz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection which will probably be updated shortly. Please refer to `changelog.txt changelog.html`_ for things that have changed in this version. Please refer to `readme.txt readme.html`_ for general information. This version has been built and unit tested on: - NetBSD - FreeBSD - openSUSE 12.2 - Windows 7 with both MinGW and Visual Studio - PostgreSQL 8.4, 9.0 and 9.2 32 and 64bit - Python 2.5, 2.6 and 2.7 32 and 64bit Sounds good. Thanks for your efforts. Does it offer advantages oiver Psycopg2? -- http://mail.python.org/mailman/listinfo/python-list
running multiple django/bottle instances
I'm working on a quite complex web app that uses django and bottle (bottle for the API which is also restful). Before I came they started to use a staging server to be able to try out things properly before they get published, but now we would like to have the possibility to see multiple branches at a time. First we thought about multiple servers, but actually since bottle and django can be made to run on different ports, I thought why not running everything on one server on different ports? We also use elasticsearch and couchdb for the data, but these two don't change that much and can just be a single instance. So what would be really great could be staging_server/branch_x staging_server/branch_y and something keeps track of all the various branches tracked, and run or keeps running bottle/django on different ports for the different branches. Is there something in the wonderful python world which I could bend to my needs? I'll probably have to script something myself anyway, but any suggestions is welcome, since I don't have much experience with web stuff.. -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint, was Re: pygame - importing GL - very bad...
On 1/3/2013 9:19 AM, Mike C. Fletcher wrote: On 13-01-02 09:48 PM, Terry Reedy wrote: ... 2) self.lightDone: Invalid name lightDone (should match [a-z_][a-z0-9_]{2,30}$) So I can now understand that pylint doesn't like my naming convention with a capital letter in the middle of the variable name, like: lightDone = a boolean value. I suppose pylint wants me to use (a little longer method) an underscore to separate words in long variable names... That is more conventional in the Python community (and is in pep 8, I believe) but still a choice. That seems like a improper error message from the tool. Invalid name does *not* properly describe that situation. The name is *not* Invalid in any sense of the word, and a checker that tells you it is is creating needless false-positives. An error checker should be saying something like: self.lightDone: Does not match PEP8 recommended style making it clear that this is *not* an error, it is a *style* related *warning*. I quite agree. Wanting 3 chars for attribute names is not even PEP-8 style but pylint-author style. I was really surprised at that. In that case, 'Does not match pylint recommended style.' or even 'configured styles'. I have not used pylint or pychecker as of yet. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On Thu, 03 Jan 2013 09:59:04 -0500 Kene Meniru kene.men...@illom.org wrote: Yes, I guess that is the main thing. I do not want users to have to write python code unless they are interested in customizing how the That works too. It's just that you had users writing Python code but assumed that a three line subclass was beyond them. Not requiring them to write any Python code is a better option than the first one (global variables) that you proposed. That's all I am trying to say. program behaves or perhaps a building component. In that case any of the other modules can be updated instead of A. Actually A will not be part of the packaged program. Or A becomes the script that parses the config file and runs the other code. -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
D'Arcy J.M. Cain wrote: That works too. It's just that you had users writing Python code but assumed that a three line subclass was beyond them. Not requiring them to write any Python code is a better option than the first one (global variables) that you proposed. That's all I am trying to say. I understand. program behaves or perhaps a building component. In that case any of the other modules can be updated instead of A. Actually A will not be part of the packaged program. Or A becomes the script that parses the config file and runs the other code. Yes. To be more precise, later I will create A_Interface to provide the user with an interface for creating the contents of A. A_Interface will then parse A, calling B as required to create the artifact. I had wanted to jump into A_Interface using something like urwid or PyQt but it makes sense to work with A directly for now. Thanks for taking the time to understand. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGreSQL 4.1 released
On Thu, 3 Jan 2013 15:06:29 + (UTC) Walter Hurry walterhu...@lavabit.com wrote: Sounds good. Thanks for your efforts. I wasn't alone but I accept your thanks on behalf of the team. Does it offer advantages oiver Psycopg2? Well, it has two interfaces, the DB-API 2.0 and the Classic one. The classic one is basically the one PyGreSQL started life as before we had a standard interface. We kept it as it has some advantages over the portable one but offer both. As for other advantages, I prefer to hear those from people not involved with either project. -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On 01/03/2013 07:53 AM, Kene Meniru wrote: Mitya Sirenef wrote: So, how many instances do you want to make.. what kind of different functionality / properties they will have? - mitya I am porting a modeling system I created using POV-Ray scene description language available at sourceforge at http://sourceforge.net/projects/kobldes/ The user can create as many marks as possible (limited by memory available). The difference between each mark are the parameters provided i.e. name, length, and position in the scene. If the user wishes to customize part of the program they must update the classes or create new ones before using it in the scene. File A in my previous illustrations can be considered the scene file. I'm not familiar with POV-Ray. I want to note that with python standard style, class names look like this: ClassName, instances look like this: instance_name; it sounds like you want LMark to be an instance? Or you want instances in A to use class naming style? Second, is the LMark instance only used to perform one set of actions? If that's the case, you can have users instantiate it in A and the __init__ method will do the set of actions you need -- this will be just as easy for the user as the alternative. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating interactive command-line Python app?
On 01/03/13 08:41, Dave Angel wrote: The two replies in 2005 mentioned both raw_input and the cmd module (in case that's what he was implying). They were posted within 90 minutes of the original. Ah. 2005 would explain why my newsreader has purged them as ancient history :) Thanks for the clarification. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Missing something obvious with python-requests
Hello List: I seem to be missing something obvious in terms of using proxies with the requests module. I'm using requests 1.4 and Python 2.7. Have tried this on Centos 6 and Windows XP. Here's the sample code, right out of the manual: import requests proxies = { 'https': '192.168.24.25:8443', 'http': '192.168.24.25:8443', } a = requests.get('http://google.com/', proxies=proxies) When I look at the proxy log, I see a GET being performed -- when it should be a CONNECT. Does not matter if I try to get http or https google.com. Clearly I'm missing something fundamental here. But after two days of fiddling with the code and tracing through requests I'm still unclear as to why requests is not using the proxy information. Any help (or slap on the side of the head) appreciated. Thanks --Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
Mitya Sirenef wrote: I'm not familiar with POV-Ray. I want to note that with python standard style, class names look like this: ClassName, instances look like this: instance_name; it sounds like you want LMark to be an instance? Or you want instances in A to use class naming style? Think of A as an extension of the user interface. I want to make the user's life as easy as possible and in this case, part of that is to write as few text as possible. Using the abbreviated LMark is laziness on my part. I wanted to differentiate the boundary class LinearMark, which the user will type in A from the entity class LMark which will have the actual data about a linear mark object. LMark is actually called LinearMarkData. Second, is the LMark instance only used to perform one set of actions? If that's the case, you can have users instantiate it in A and the __init__ method will do the set of actions you need -- this will be just as easy for the user as the alternative. -m So far this is working for me. I am not sure if you mean something different. I have a command in A like: Site(New Site, borderNum) # Creates a building site object in B In B, the Site class (which is a subclass of the main class that coordinates the creation of the entire building) receives this call, processes the parameters with any required calculations and calls another class called SiteData (from module C) which generates the object called New Site with the number of boundaries provided. Site then stores SiteData in a dictionary provided in its super class. The super class coordinates the creation of the entire building so all objects can interact with the properties of the objects in the dictionary (of building components). So in effect no instantiation is performed in A. The user calls classes in B with the appropriate parameters to create the building components which are then created and stored for later access by other components. -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGreSQL 4.1 released
--- Release of PyGreSQL version 4.1 --- It has been a long time coming but PyGreSQL v4.1 has been released. It is available at: http://pygresql.org/files/PyGreSQL-4.1.tgz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection which will probably be updated shortly. Please refer to `changelog.txt changelog.html`_ for things that have changed in this version. Please refer to `readme.txt readme.html`_ for general information. This version has been built and unit tested on: - NetBSD - FreeBSD - openSUSE 12.2 - Windows 7 with both MinGW and Visual Studio - PostgreSQL 8.4, 9.0 and 9.2 32 and 64bit - Python 2.5, 2.6 and 2.7 32 and 64bit This is good news. The PyGreSQL team is doing a great job! Pass on my congrats :D -Modulok- -- http://mail.python.org/mailman/listinfo/python-list
Question on for loop
Dear Group, If I take a list like the following: fruits = ['banana', 'apple', 'mango'] for fruit in fruits: print 'Current fruit :', fruit Now, if I want variables like var1,var2,var3 be assigned to them, we may take, var1=banana, var2=apple, var3=mango but can we do something to assign the variables dynamically I was thinking of var_series=['var1','var2','var3'] for var in var_series: for fruit in fruits: print var,fruits If any one can kindly suggest. Regards, Subhabrata NB: Apology for some alignment mistakes,etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
On 2013-01-03 20:04, subhabangal...@gmail.com wrote: Dear Group, If I take a list like the following: fruits = ['banana', 'apple', 'mango'] for fruit in fruits: print 'Current fruit :', fruit Now, if I want variables like var1,var2,var3 be assigned to them, we may take, var1=banana, var2=apple, var3=mango but can we do something to assign the variables dynamically I was thinking of var_series=['var1','var2','var3'] for var in var_series: for fruit in fruits: print var,fruits If any one can kindly suggest. Regards, Subhabrata NB: Apology for some alignment mistakes,etc. Why would you want to do that? Creating names dynamically like that is a bad idea. Just keep them in a list, like they are already. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
subhabangal...@gmail.com wrote: Dear Group, If I take a list like the following: fruits = ['banana', 'apple', 'mango'] for fruit in fruits: print 'Current fruit :', fruit Now, if I want variables like var1,var2,var3 be assigned to them, we may take, var1=banana, var2=apple, var3=mango but can we do something to assign the variables dynamically I was thinking of var_series=['var1','var2','var3'] for var in var_series: for fruit in fruits: print var,fruits If any one can kindly suggest. For that problem you need another data structure -- a dictionary: lookup_fruits = {var1: banana, var2: apple, var3: mango} var_series = [var1, var2, var3] for var in var_series: ... print var, lookup_fruits[var] ... var1 banana var2 apple var3 mango -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
Yeah, this seems like a bad idea. What exactly are you trying to do here? Maybe using a dictionary is what you want? d = { 'first' : 'banana', 'second' : 'apple', 'third' : 'mango' } for key, value in d.items(): print key, value However I'm still not sure why you'd want to do this. *Matt Jones* On Thu, Jan 3, 2013 at 2:21 PM, MRAB pyt...@mrabarnett.plus.com wrote: On 2013-01-03 20:04, subhabangal...@gmail.com wrote: Dear Group, If I take a list like the following: fruits = ['banana', 'apple', 'mango'] for fruit in fruits: print 'Current fruit :', fruit Now, if I want variables like var1,var2,var3 be assigned to them, we may take, var1=banana, var2=apple, var3=mango but can we do something to assign the variables dynamically I was thinking of var_series=['var1','var2','**var3'] for var in var_series: for fruit in fruits: print var,fruits If any one can kindly suggest. Regards, Subhabrata NB: Apology for some alignment mistakes,etc. Why would you want to do that? Creating names dynamically like that is a bad idea. Just keep them in a list, like they are already. -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGreSQL 4.1 released
On Thu, 03 Jan 2013 13:07:40 -0500, D'Arcy J.M. Cain wrote: On Thu, 3 Jan 2013 15:06:29 + (UTC) Walter Hurry walterhu...@lavabit.com wrote: Sounds good. Thanks for your efforts. I wasn't alone but I accept your thanks on behalf of the team. Does it offer advantages oiver Psycopg2? 0 Well, it has two interfaces, the DB-API 2.0 and the Classic one. The classic one is basically the one PyGreSQL started life as before we had a standard interface. We kept it as it has some advantages over the portable one but offer both. As for other advantages, I prefer to hear those from people not involved with either project. 4.1 has just made it into the FreeBSD ports. I'll give it a try (thanks again, to you and your team). -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pypiserver 1.0.1 - minimal private pypi server
Hi, I've just uploaded pypiserver 1.0.1 to the python package index. pypiserver is a minimal PyPI compatible server. It can be used to serve a set of packages and eggs to easy_install or pip. pypiserver is easy to install (i.e. just 'pip install pypiserver'). It doesn't have any external dependencies. http://pypi.python.org/pypi/pypiserver/ should contain enough information to easily get you started running your own PyPI server in a few minutes. The code is available on github: https://github.com/schmir/pypiserver Changes in version 1.0.1 - make 'pypi-server -Ux' work on windows ('module' object has no attribute 'spawnlp', https://github.com/schmir/pypiserver/issues/26) - use absolute paths in hrefs for root view (https://github.com/schmir/pypiserver/issues/25) - add description of uploads to the documentation - make the test suite work on python 3 - make pypi-server-standalone work with python 2.5 -- Cheers Ralf -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On 01/03/2013 02:30 PM, Kene Meniru wrote: Mitya Sirenef wrote: I'm not familiar with POV-Ray. I want to note that with python standard style, class names look like this: ClassName, instances look like this: instance_name; it sounds like you want LMark to be an instance? Or you want instances in A to use class naming style? Think of A as an extension of the user interface. I want to make the user's life as easy as possible and in this case, part of that is to write as few text as possible. Using the abbreviated LMark is laziness on my part. I wanted to differentiate the boundary class LinearMark, which the user will type in A from the entity class LMark which will have the actual data about a linear mark object. LMark is actually called LinearMarkData. Second, is the LMark instance only used to perform one set of actions? If that's the case, you can have users instantiate it in A and the __init__ method will do the set of actions you need -- this will be just as easy for the user as the alternative. -m So far this is working for me. I am not sure if you mean something different. I have a command in A like: Site(New Site, borderNum) # Creates a building site object in B In B, the Site class (which is a subclass of the main class that coordinates the creation of the entire building) receives this call, processes the parameters with any required calculations and calls another class called SiteData (from module C) which generates the object called New Site with the number of boundaries provided. Site then stores SiteData in a dictionary provided in its super class. The super class coordinates the creation of the entire building so all objects can interact with the properties of the objects in the dictionary (of building components). So in effect no instantiation is performed in A. The user calls classes in B with the appropriate parameters to create the building components which are then created and stored for later access by other components. Ok but if the user creates two sites, how does he then manipulate them, if you are not binding instances in A? (e.g. you are not doing site1 = Site(New Site)). If the user only ever needs one site, that's fine. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing something obvious with python-requests
The shipped python library code does not work. See http://bugs.python.org/issue7291 for patches. Barry On 3 Jan 2013, at 18:53, Ray Cote rgac...@appropriatesolutions.com wrote: Hello List: I seem to be missing something obvious in terms of using proxies with the requests module. I'm using requests 1.4 and Python 2.7. Have tried this on Centos 6 and Windows XP. Here's the sample code, right out of the manual: import requests proxies = { 'https': '192.168.24.25:8443', 'http': '192.168.24.25:8443', } a = requests.get('http://google.com/', proxies=proxies) When I look at the proxy log, I see a GET being performed -- when it should be a CONNECT. Does not matter if I try to get http or https google.com. Clearly I'm missing something fundamental here. But after two days of fiddling with the code and tracing through requests I'm still unclear as to why requests is not using the proxy information. Any help (or slap on the side of the head) appreciated. Thanks --Ray -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
I'm interested to know why you're trying this as well. Is this something that would be helped by creating a class and then dynamically creating instances of that class? Something like... class Fruit: def __init__(self, name): self.name = name for fruit in ['banana', 'apple', 'mango']: varName = Fruit(fruit) # do stuff with varName On Thursday, January 3, 2013 2:04:03 PM UTC-6, subhaba...@gmail.com wrote: Dear Group, If I take a list like the following: fruits = ['banana', 'apple', 'mango'] for fruit in fruits: print 'Current fruit :', fruit Now, if I want variables like var1,var2,var3 be assigned to them, we may take, var1=banana, var2=apple, var3=mango but can we do something to assign the variables dynamically I was thinking of var_series=['var1','var2','var3'] for var in var_series: for fruit in fruits: print var,fruits If any one can kindly suggest. Regards, Subhabrata NB: Apology for some alignment mistakes,etc. -- http://mail.python.org/mailman/listinfo/python-list
Yet another attempt at a safe eval() call
I've written a small assembler in Python 2.[67], and it needs to evaluate integer-valued arithmetic expressions in the context of a symbol table that defines integer values for a set of names. The right thing is probably an expression parser/evaluator using ast, but it looked like that would take more code that the rest of the assembler combined, and I've got other higher-priority tasks to get back to. How badly am I deluding myself with the code below? def lessDangerousEval(expr): global symbolTable if 'import' in expr: raise ParseError(operand expressions are not allowed to contain the string 'import') globals = {'__builtins__': None} locals = symbolTable return eval(expr, globals, locals) I can guarantee that symbolTable is a dict that maps a set of string symbol names to integer values. -- Grant Edwards grant.b.edwardsYow! -- I have seen the at FUN -- gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
Mitya Sirenef wrote: Ok but if the user creates two sites, how does he then manipulate them, if you are not binding instances in A? (e.g. you are not doing site1 = Site(New Site)). If the user only ever needs one site, that's fine. -m There can only be one site for each building(s) so the super object that coordinates the creation of the entire building, will check and deal with this situation. This is where the building knowledge kicks in and is part of why I am designing it this way. That is with an overall coordinator that has the knowledge of all objects being created and provides the means for them to communicate with each other. So onces there is a site object in the dictionary, an attempt to add a new one will be caught and an error reported to the user. -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
Mitya Sirenef wrote: Ok but if the user creates two sites, how does he then manipulate them, if you are not binding instances in A? (e.g. you are not doing site1 = Site(New Site)). If the user only ever needs one site, that's fine. -m In case of situations where the user needs to manipulate an existing component like a side (wall) for a Space, this will be done using the name of the component to find it in the dictionary. So for example if user enters: LinearSide.put(Dining, (x,y,z)) # moves 'Dining' to x,y,z location The put function of the LinearSide boundary class finds Dining (which is an entity class called LinearSideData) in the dictionary and then allows this LinearSideData class to calculate its new location using the x,y,z values provided. -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple?
On 2 Jan 2013, at 08:01, Victor Hooi victorh...@gmail.com wrote: Hi, I'm using pysvn to checkout a specific revision based on date - pysvn will only accept a date in terms of seconds since the epoch. I'm attempting to use time.mktime() to convert a date (e.g. 2012-02-01) to seconds since epoch. According to the docs, mktime expects a 9-element tuple. My question is, how should I omit elements from this tuple? And what is the expected behaviour when I do that? For example, (zero-index), element 6 is the day of the week, and element 7 is the day in the year, out of 366 - if I specify the earlier elements, then I shouldn't really need to specify these. However, the docs don't seem to talk much about this. I just tried testing putting garbage numbers for element 6 and 7, whilst specifying the earlier elements: time.mktime((2012, 5, 5, 23, 59, 59, 23424234, 5234234 ,0 )) It seems to have no effect what numbers I set 6 and 7 to - is that because the earlier elements are set? How should I properly omit them? Is this all documented somewhere? What is the minimum I need to specify? And what happens to the fields I don't specify? See the python docs the tuple is fully documented. 6 and 7 are not needed to figure out the seconds so are ignored. Did you notice the parse_datetime.py that is in the pysvn Client Example? Its a rather over the top date and time parser I wrote a long long time ago. (Which is missing some imports, hmm I cannot have tested this for a long time). It can parse things like yesterday 10:34. Barry -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On 01/03/2013 07:08 PM, Kene Meniru wrote: LinearSide.put(Dining, (x,y,z)) # moves 'Dining' to x,y,z location The put function of the LinearSide boundary class finds Dining (which is an entity class called LinearSideData) in the dictionary and then allows this LinearSideData class to calculate its new location using the x,y,z values provided. That's what I thought, just wanted to confirm. However, if your objective to make it as easy for the user as possible, is it not easier to bind dining to a name and then do this?: dining.move(x, y, z) -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
Mitya Sirenef wrote: That's what I thought, just wanted to confirm. However, if your objective to make it as easy for the user as possible, is it not easier to bind dining to a name and then do this?: dining.move(x, y, z) Absolutely. I just found that out after replying to your comment! It actually decreases typing. Also discovered the module Logging. Interesting using python indeed :-) -- Kene :: kemen...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
On Jan 4, 6:04 am, subhabangal...@gmail.com wrote: but can we do something to assign the variables dynamically I was thinking of var_series=['var1','var2','var3'] for var in var_series: for fruit in fruits: print var,fruits Before trying to do this, write the next bit of code where you _use_ such variables. What do you do if there are no fruits? What do you do if there are 7000? You don't want variables to be optional, because otherwise you'll need to guard every usage with something like: if 'var2893' in locals(): ... Of course, you can also automate this, but why push values into a dictionary that exists for one purpose if you're not going to use it that way? If you need to deal with an unknown number of objects, use a list. If those objects have a name by which you can refer to them, use a dictionary. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On 01/03/2013 07:43 PM, Kene Meniru wrote: Mitya Sirenef wrote: That's what I thought, just wanted to confirm. However, if your objective to make it as easy for the user as possible, is it not easier to bind dining to a name and then do this?: dining.move(x, y, z) Absolutely. I just found that out after replying to your comment! It actually decreases typing. Also discovered the module Logging. Interesting using python indeed :-) I agree -- Python is really nice, I'm glad you seem to be enjoying it! -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another attempt at a safe eval() call
On 01/03/13 17:25, Grant Edwards wrote: def lessDangerousEval(expr): global symbolTable if 'import' in expr: raise ParseError(operand expressions are not allowed to contain the string 'import') globals = {'__builtins__': None} locals = symbolTable return eval(expr, globals, locals) I can guarantee that symbolTable is a dict that maps a set of string symbol names to integer values. For what definition of safe? Are CPython segfaults a problem? Blowing the stack? Do you aim to prevent exploitable things like system calls or network/file access? -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing something obvious with python-requests
Thank you. --Ray - Original Message - From: Barry Scott ba...@barrys-emacs.org To: Ray Cote rgac...@appropriatesolutions.com Cc: python-list@python.org Sent: Thursday, January 3, 2013 5:48:52 PM Subject: Re: Missing something obvious with python-requests The shipped python library code does not work. See http://bugs.python.org/issue7291 for patches. Barry On 3 Jan 2013, at 18:53, Ray Cote rgac...@appropriatesolutions.com wrote: Hello List: I seem to be missing something obvious in terms of using proxies with the requests module. I'm using requests 1.4 and Python 2.7. Have tried this on Centos 6 and Windows XP. Here's the sample code, right out of the manual: import requests proxies = { 'https': '192.168.24.25:8443', 'http': '192.168.24.25:8443', } a = requests.get('http://google.com/', proxies=proxies) When I look at the proxy log, I see a GET being performed -- when it should be a CONNECT. Does not matter if I try to get http or https google.com. Clearly I'm missing something fundamental here. But after two days of fiddling with the code and tracing through requests I'm still unclear as to why requests is not using the proxy information. Any help (or slap on the side of the head) appreciated. Thanks --Ray -- http://mail.python.org/mailman/listinfo/python-list -- Ray Cote, President Appropriate Solutions, Inc. We Build Software 603.924.6079 -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another attempt at a safe eval() call
On 2013-01-04, Tim Chase python.l...@tim.thechases.com wrote: On 01/03/13 17:25, Grant Edwards wrote: def lessDangerousEval(expr): global symbolTable if 'import' in expr: raise ParseError(operand expressions are not allowed to contain the string 'import') globals = {'__builtins__': None} locals = symbolTable return eval(expr, globals, locals) I can guarantee that symbolTable is a dict that maps a set of string symbol names to integer values. For what definition of safe? Are CPython segfaults a problem? Not by themselves, no. Blowing the stack? Not a problem either. I don't care if the program crashes. It's a pretty dumb assembler, and it gives up and exits after the first error anyway. Do you aim to prevent exploitable things like system calls or network/file access? Yes, that's mainly what I was wondering wondering about. -- Grant -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing something obvious with python-requests
On Fri, Jan 4, 2013 at 5:53 AM, Ray Cote rgac...@appropriatesolutions.com wrote: proxies = { 'https': '192.168.24.25:8443', 'http': '192.168.24.25:8443', } a = requests.get('http://google.com/', proxies=proxies) When I look at the proxy log, I see a GET being performed -- when it should be a CONNECT. Does not matter if I try to get http or https google.com. Not sure if it's related to your problem or not, but my understanding of a non-SSL request through a proxy is that it'll be a GET request (eg GET http://google.com/ HTTP/1.0). So the problem is only that it's still doing GET requests when it's an https query (which is where CONNECT is needed). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on for loop
On Thu, 03 Jan 2013 12:04:03 -0800, subhabangalore wrote: Dear Group, If I take a list like the following: fruits = ['banana', 'apple', 'mango'] for fruit in fruits: print 'Current fruit :', fruit Now, if I want variables like var1,var2,var3 be assigned to them, we may take, var1=banana, var2=apple, var3=mango but can we do something to assign the variables dynamically Easy as falling off a log. You can't write var1, var2 etc. but you can write it as var[0], var[1] etc. var = ['banana', 'apple', 'mango'] print var[0] # prints 'banana' print var[1] # prints 'apple' print var[2] # prints 'mango' Of course var is not a very good variable name. fruit or fruits would be better. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another attempt at a safe eval() call
On Thu, 03 Jan 2013 23:25:51 +, Grant Edwards wrote: I've written a small assembler in Python 2.[67], and it needs to evaluate integer-valued arithmetic expressions in the context of a symbol table that defines integer values for a set of names. The right thing is probably an expression parser/evaluator using ast, but it looked like that would take more code that the rest of the assembler combined, and I've got other higher-priority tasks to get back to. How badly am I deluding myself with the code below? Pretty badly, sorry. See trivial *cough* exploit below. def lessDangerousEval(expr): global symbolTable if 'import' in expr: raise ParseError(operand expressions are not allowed to contain the string 'import') globals = {'__builtins__': None} locals = symbolTable return eval(expr, globals, locals) I can guarantee that symbolTable is a dict that maps a set of string symbol names to integer values. Here's one exploit. I make no promises that it is the simplest such one. # get access to __import__ s = ([x for x in (1).__class__.__base__.__subclasses__() if x.__name__ == 'catch_warnings'][0]()._module .__builtins__['__imp' + 'ort__']) # use it to get access to any module we like t = s + ('os') # and then do bad things urscrewed = t + .system('echo u r pwned!') lessDangerousEval(urscrewed) At a minimum, I would recommend: * Do not allow any underscores in the expression being evaluated. Unless you absolutely need to support them for names, they can only lead to trouble. * If you must allow underscores, don't allow double underscores. Every restriction you apply makes it harder to exploit. * Since you're evaluating mathematical expressions, there's probably no need to allow quotation marks either. They too can only lead to trouble. * Likewise for dots, since this is *integer* maths. * Set as short as possible limit on the length of the string as you can bare; the shorter the limit, the shorter any exploit must be, and it is harder to write a short exploit than a long exploit. * But frankly, you should avoid eval, and write your own mini-integer arithmetic evaluator which avoids even the most remote possibility of exploit. So, here's my probably-not-safe-either safe eval: def probably_not_safe_eval(expr): if 'import' in expr.lower(): raise ParseError('import' prohibited) for c in '_\'.': if c in expr: raise ParseError('prohibited char %r' % c) if len(expr) 120: raise ParseError('expression too long') globals = {'__builtins__': None} locals = symbolTable return eval(expr, globals, locals) # fingers crossed! I can't think of any way to break out of these restrictions, but that may just mean I'm not smart enough. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another attempt at a safe eval() call
On Thu, Jan 3, 2013 at 3:25 PM, Grant Edwards invalid@invalid.invalid wrote: I've written a small assembler in Python 2.[67], and it needs to evaluate integer-valued arithmetic expressions in the context of a symbol table that defines integer values for a set of names. The right thing is probably an expression parser/evaluator using ast, but it looked like that would take more code that the rest of the assembler combined, and I've got other higher-priority tasks to get back to. How badly am I deluding myself with the code below? Given http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html and similar, I suspect the answer is a fair bit. def lessDangerousEval(expr): global symbolTable if 'import' in expr: raise ParseError(operand expressions are not allowed to contain the string 'import') globals = {'__builtins__': None} locals = symbolTable return eval(expr, globals, locals) I can guarantee that symbolTable is a dict that maps a set of string symbol names to integer values. Using the aformentioned article as a basis, I was able to get this doozy working, albeit under Python 3: $ python3 Python 3.3.0 (default, Nov 4 2012, 17:47:16) [GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.57))] on darwin Type help, copyright, credits or license for more information. expr = [klass for klass in ().__class__.__bases__[0].__subclasses__() if klass.__name__ == 'Codec'][0].encode.__globals__['__builtins__']['__im'+'port__']('os').remove eval(expr, {'__builtins__': None}, {}) built-in function remove Since the original attack was itself devised against Python 2.x, it's highly likely that similar convoluted attacks against 2.x remain possible, unless perhaps you were use a modified interpreter. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
[issue8952] Doc/c-api/arg.rst: fix documentation of number formats
Georg Brandl added the comment: It's still a valid bug. -- nosy: +georg.brandl resolution: fixed - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12939] Add new io.FileIO using the native Windows API
Марк Коренберг added the comment: Yes, re-writing windows IO to direct API, without intemediate layer is still needed. Please don't close bug. Maybe someone will implement this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12939 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14468] Update cloning guidelines in devguide
Ezio Melotti added the comment: The attached patch adds a couple of section about the single and multiple clones approaches. The patch is still incomplete, because the rest of the page should be adapted to the new content (in particular the old sections should be removed, and the whole structure revisited), but I wanted some early feedback about the ones I added. The idea is that contributors can use the single clone approach, and since they don't need to commit/merge, they don't need more instructions then the ones provided already in the setup.rst page. Committers are better off with multiple clones, and the best way to do it is IMHO with the share extension, so that's what I described. Ideally this section should be followed by a FAQ-like list that explains how to deal with conflicts, head merges, null merges, long-term features and similar. Some of these things are already there; some extra things are also there, and they should probably be moved or removed. -- Added file: http://bugs.python.org/file28540/issue14468.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16847] sha module broken
Roundup Robot added the comment: New changeset 944e86223d1f by Christian Heimes in branch '3.3': Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in http://hg.python.org/cpython/rev/944e86223d1f New changeset 4b42d7f288c5 by Christian Heimes in branch 'default': Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in http://hg.python.org/cpython/rev/4b42d7f288c5 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16847 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16847] sha module broken
Changes by Christian Heimes li...@cheimes.de: -- assignee: christian.heimes - resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16847 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16847] sha module broken
Ronald Oussoren added the comment: That's quick, thank :-). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16847 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14468] Update cloning guidelines in devguide
Chris Jerdonek added the comment: Content-wise the patch looks pretty good. I agree with the recommendations. A couple suggestions though: I would break up the 20 lines of command-line commands. Right now that chunk is a bit too long to grasp meaningfully. My suggestion would be to break it up into two sections with text in between: one for applying a patch to 2.x or 3.x, and the other for merging (forward-porting) from 3.x to 3.y, with a textual explanation of what the subsequent chunk of commands will do. I would also state (or link to) something about forward-porting from 3.x to 3.y and that 2.7 should be kept separate (both of which I think the current patch assumes knowledge of). I would also say (or link to) something about pushing all branches simultaneously. Lastly, might it be worth explicitly dividing the Mercurial stuff into separate sections for (1) everyone, and (2) committers? Putting the committer-specific stuff (e.g. instructions on merging and pushing changes) in a separate section will simplify things for the general contributor. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14468] Update cloning guidelines in devguide
Ezio Melotti added the comment: I would break up the 20 lines of command-line commands. I would have to find a compromise for this, because on one hand it's convenient to have all the commands in a single place (so it's easy to get an overview), but on the other hand that block includes several logically different operation (importing, grafting, merging) that would deserve their own FAQ. I would also state (or link to) something about forward-porting from 3.x to 3.y and that 2.7 should be kept separate (both of which I think the current patch assumes knowledge of). This is currently explained, but should be reorganized and integrated with my patch. I would also say (or link to) something about pushing all branches simultaneously. This happens automatically, so I don't think it deserves more than a short mention somewhere. Lastly, might it be worth explicitly dividing the Mercurial stuff into separate sections for (1) everyone, and (2) committers? ISTM that all the things that contributors need to know are already explained somewhere else in the devguide. This includes cloning, switching branches, and applying and generating patches. What I'm described here is mostly aimed to developers, since contributors don't have to commit/merging/grafting and dealing with all the related things. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12939] Add new io.FileIO using the native Windows API
Changes by Serhiy Storchaka storch...@gmail.com: -- components: +Windows nosy: +ezio.melotti stage: - needs patch type: - enhancement versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12939 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8821] Range check on unicode repr
Serhiy Storchaka added the comment: You can accept the patch. You can reject the patch. It doesn't matter. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8821 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16842] Allow to override a function signature for pydoc with a docstring
Serhiy Storchaka added the comment: Sorry, I mixed up the issues. For this issue I have not a patch yet. I wait for some suggestions and decisions first. See also related issue16638. -- stage: patch review - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16842 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16801] Preserve original representation for integers / floats in docstrings
Serhiy Storchaka added the comment: A subclass with a custom representation, as I suggested above, is even simpler and involves no change to inspect or docstring conventions. Agree, but this is a particular and cumbersome solution. I open new issue16842 for docstring conventions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16801 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16748] Make CPython test package discoverable
Serhiy Storchaka added the comment: See also test_functools, test_xml_etree, test_bisect, test_bz2, test_warnings, test_decimal, test_datetime, json_tests, test_io, test_concurrent_futures, and many, many other undiscoverable tests. -- stage: committed/rejected - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16748 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1584] Mac OS X: building with X11 Tkinter
Samuel John added the comment: Hello from Homebrew (Mac)! Indeed we also patch setup.py (but right now only for python2.7) and uncommented the detect_tkinter_darwin related lines to support linking against a Tkinter build with homebrew (optionally with X11 support). (Our patch: https://github.com/mxcl/homebrew/pull/16626/files#L0R270) I agree that an option to tell setup.py to use another Tk would be much appreciated. -- nosy: +samueljohn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15596] pickle: Faster serialization of Unicode strings
Serhiy Storchaka added the comment: Well, I take care of this. I have the own patch for raw_unicode_escape() optimization, but microbenchmarks don't show any speed up. Maybe your approach will be better. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15596 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16844] funcName in logging module for python 2.6
Vinay Sajip added the comment: You are apparently not using the logging in stdlib, but the older, standalone logging package intended to be used in versions of Python older than 2.3 - note the presence of site-packages/logging-0.4.9.6-py2.6.egg in the traceback. If you are using Python 2.6, you don't need the standalone logging-0.4.9.6, as the logging in the stdlib is more up to date (as you've discovered). -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16844 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16848] Mac OS X: python-config --ldflags and location of Python.framework
New submission from Samuel John: Some tools use `python-config --ldflags` to get the flags in order to link against the Python lib on OS X (for example gst-python from pygtk (2.x). For framework builds, `python-config --ldflags` returns (among few other): -u _PyMac_Error Python.framework/Versions/2.7/Python which is an incomplete path. This issue is almost a duplicate of http://bugs.python.org/issue3588 and the fix discussed there would work. However I report this for Python 2.7. We at Homebrew propose a very similar fix but I'd prefer the one in issue3588: LINKFORSHARED = -u _PyMac_Error -framework Python LDFLAGS += -F$(PYTHONFRAMEWORKPREFIX) -- components: Build messages: 178936 nosy: hynek, ned.deily, ronaldoussoren, samueljohn priority: normal severity: normal status: open title: Mac OS X: python-config --ldflags and location of Python.framework type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16848 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16848] Mac OS X: python-config --ldflags and location of Python.framework
Ronald Oussoren added the comment: Using '-framework Python' is suboptimal because this doesn't control which framework is used for linking (in particular, if you have both Python 2.7 and 3.3 installed '-framework Python' will link against the one installed last). For Python 3.3 I get: $ /Library/Frameworks/Python.framework/Versions/3.2/bin/python3-config --ldflags -L/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config-3.2m -ldl -framework CoreFoundation -lpython3.2m Simular output would also work for python 2.7 (but I don't have a patch right now) -- stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16848 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13094] Need Programming FAQ entry for the behavior of closures
R. David Murray added the comment: The FAQ (as in, this question gets asked again and again) is something like why do the lambdas I define in a loop all return the same result when the input value was different when each one was defined? The same applies to regular functions, but people almost never do that in a loop, so in that case they are more likely to think of the scoping issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16849] Element.{get, iter} doesn't handle keyword arguments when using _elementtree C accelerator.
New submission from Franck Michea: Documentation: - http://docs.python.org/3.3/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.get - http://docs.python.org/3.3/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.iter These two functions are documented with keyword arguments. Python implementation works correctly, but as of 3.3, _etreeelement module in C is hot-patching this module to enhance speed. C implementation only expects normal arguments for get and iter. This is what this patch fixes. First patch so: - I am not sure about the key string in kwlist array, I followed code above and it doesn't work without it, so I guess it's to for the normal arg. - I am not sure about how to test iter with this. tag argument is never used. - Included a test that shows the problem. Have a nice day, -- components: Library (Lib), XML files: etree.patch keywords: patch messages: 178939 nosy: kushou priority: normal severity: normal status: open title: Element.{get,iter} doesn't handle keyword arguments when using _elementtree C accelerator. type: behavior versions: Python 3.3 Added file: http://bugs.python.org/file28541/etree.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16846] relative import solution
R. David Murray added the comment: Could you give more information about what you see as the bug, here? I'm not understanding the problem because there doesn't appear to be enough context. What is your directory structure? Where is the import happening? -- components: +Interpreter Core -Windows nosy: +r.david.murray type: resource usage - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16846 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16281] TODO in tailmatch(): it does not support backward in all cases
Serhiy Storchaka added the comment: Shouldn't this be applied to 3.3? As for optimization, I made some benchmarks and didn't saw any significant difference. Usually this function used to check short ASCII heads and tails and any optimization will not be seen even under a microscope. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16281 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12105] open() does not able to set flags, such as O_CLOEXEC
Richard Oudkerk added the comment: Note that on Windows there is an O_NOINHERIT flag which almost corresponds to O_CLOEXEC on Linux. I don't think there is a need to use the win32 api. -- nosy: +sbt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12105 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12939] Add new io.FileIO using the native Windows API
Richard Oudkerk added the comment: A while ago I did write a PipeIO class which subclasses io.RawIOBase and works for overlapped pipe handles. (It was intended for multiprocessing and doing asynchronous IO with subprocess.) As it is it would not work with normal files because when you do overlapped IO on files you must manually track the file position. Yes, re-writing windows IO to direct API, without intemediate layer is still needed. What are the expected benefits? It would help feature #12105 to implement O_CLOEXEC flag using the lpSecurityAttributes argument. Isn't O_NOINHERIT the Windows equivalent of O_CLOEXEC? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12939 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16281] TODO in tailmatch(): it does not support backward in all cases
STINNER Victor added the comment: Shouldn't this be applied to 3.3? It's just a cleanup, it doesn't fix any real bug. I prefer to not pollute old versions with cleanup. As for optimization, I made some benchmarks and didn't saw any significant difference. Usually this function used to check short ASCII heads and tails and any optimization will not be seen even under a microscope. Ok, agreed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16281 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16846] relative import solution
Georg Brandl added the comment: David, the issue is that Python only allows relative imports within packages. The OP wants to have a.py and b.py in the same directory and then be able to said from . import b in the a module. This is a design decision and will not change without a PEP. -- nosy: +georg.brandl, ncoghlan resolution: - rejected status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16846 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16076] xml.etree.ElementTree.Element and xml.etree.ElementTree.TreeBuilder are no longer pickleable
Eli Bendersky added the comment: On Tue, Jan 1, 2013 at 2:56 PM, Daniel Shahaf rep...@bugs.python.orgwrote: Daniel Shahaf added the comment: Eli Bendersky wrote on Tue, Jan 01, 2013 at 15:54:00 +: Why did you change the class name, by the way, I don't think it's a valid change at least for 3.3 in terms of backwards compatibility. With unmodified tip of 3.4: import pickle, xml.etree.ElementTree as ET pickle.dumps(ET.Element('foo')) Traceback (most recent call last): File stdin, line 1, in module _pickle.PicklingError: Can't pickle class 'Element': attribute lookup builtins.Element failed I added the _elementtree to the tp_name in order to bypass the above error. Module-qualified names were in use elsewhere (including by _elementtree._element_iterator) so it seemed reasonable. I'll defer to you about compatibility implications of this change. I asked on pydev, but this is a key point to resolve. Can pickling/unpickling be made to work correctly without such (or similar) change at all? How will the unpickler know which module to load when it sees a pickled object of Element type? If this change is required (even if we choose to name it xml.etree.ElementTree.Element for Py compatibility to fix the pickling regression, we may find ourselves in a need to change it between 3.3 and 3.3.1 and I'm not sure if that's valid. I hope my question on pydev will be resolved conclusively. Danial, could you investigate if such a change is absolutely required to make pickling/unickling of Element work? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16076 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8952] Doc/c-api/arg.rst: fix documentation of number formats
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: -haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16748] Make CPython test package discoverable
Zachary Ware added the comment: Here's version 2 of the genericpath patch. Should I try to fix everything in one patch, or one patch per test module (or group of test modules like test_(generic|mac|nt|posix)path.py)? And if separate, should each one get its own issue, or just keep them all here? -- Added file: http://bugs.python.org/file28542/issue16748_genericpath.v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16748 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16835] Update PEP 399 to allow for test discovery
Zachary Ware added the comment: Thanks for the review, new patch attached. You're quite welcome. Is there anything I've missed in the process of reviewing itself? This is the first time I've reviewed a patch here... I did miss another nit in the prose, though; the tests methods in the first line isn't quite right, but I can't decide if it should be the test's methods (singular possessive), the tests' methods (plural possessive), or test methods (non-specific, non-possessive). Any of the three that better gets your point across makes me happy :) This should either have another newline inbetween or be reflowed. Either one paragraph or two makes sense to me, but I can't tell which way you actually meant I meant one and half :) I guess in HTML that would have been a br inside the p, but I don't think it really matters if it's rendered as a single paragraph. I see. As is works for me if it works for you, though I might lean towards rounding it up to 2 paragraphs :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16835 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16850] Atomic open + close-and-exec
New submission from STINNER Victor: Recent version on different operating systems support opening a file with close-on-exec flag set immediatly (atomic). This feature fixes a race condition when the process calls execv() between open() and fcntl() (to set the FD_CLOEXEC flag to the newly opened file). It would be nice to expose this feature in Python. The problem is the find a portable and safe way to expose the feature: neologix is against a best-effort function. For example, Linux kernel older than 2.6.22 simply ignores O_CLOEXEC flag (while the libc may expose it). The feature looks to be supported by at least: * Linux kernel = 2.6.23 * FreeBSD 8+ * Windows: _open(filename, _O_NOINHERIT). Is it supported by Windows XP and older versions? http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx See also: * Issue #12760 (closed): This issue added an x mode to open() to create a file in exclusive mode * Issue #12103: Document how to use open with os.O_CLOEXEC * Issue #12105: It was proposed to add an e mode to open() for O_CLOEXEC -- components: Interpreter Core messages: 178949 nosy: alexey-smirnov, amaury.forgeotdarc, haypo, neologix, sbt priority: normal severity: normal status: open title: Atomic open + close-and-exec versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15067] Clean up the sqlite3 docs
Changes by Zachary Ware zachary.w...@gmail.com: Removed file: http://bugs.python.org/file27829/sqlite3_cleanup_2.7.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15067 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15067] Clean up the sqlite3 docs
Changes by Zachary Ware zachary.w...@gmail.com: Removed file: http://bugs.python.org/file27830/sqlite3_cleanup_3.2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15067 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12105] open() does not able to set flags, such as O_CLOEXEC
STINNER Victor added the comment: Note that on Windows there is an O_NOINHERIT flag which almost corresponds to O_CLOEXEC on Linux. I don't think there is a need to use the win32 api. Ah yes. Because this issue is closed, I created the issue #16850 which is more specific to open + close-and-exec. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12105 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16848] Mac OS X: python-config --ldflags and location of Python.framework
Samuel John added the comment: Agreed. My patch, I did for Homebrew is to use the full path like so: PYTHONFRAMEWORKDIR= full/path/to/Frameworks/Python.framework instead of just `Python.framework`. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16848 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16850] Atomic open + close-and-exec
STINNER Victor added the comment: The problem is the find a portable and safe way to expose the feature A solution is to add a e mode to open() which would raise a NotImplementedError if the platform is not known to support this feature. For example, if the OS is linux, we would check if the kernel version is at least 2.6.23, otherwise an exception would be raised. The check (on the OS/version) would be done at the first call the function (if the e mode if used). We already have such behaviour on other functions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16850] Atomic open + close-and-exec
Christian Heimes added the comment: You could do both: use the O_CLOEXEC flag and do a fcntl() call on POSIX. In my opinion it's enough to document that the x flag may be affected by a race condition issue on some operation systems. -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12103] Document how to use open with os.O_CLOEXEC
STINNER Victor added the comment: x Open the file exclusively (like the O_EXCL flag of open(2)). If the file already exists, fopen() fails, and sets errno to EEXIST. This flag is ignored for fdopen(). Python 3.3 adds support for this mode: see issue #12760. e (since glibc 2.7) Open the file with the O_CLOEXEC flag. See open(2) for more information. I created the issue #16850 for this mode. -- Other modes seem to be very specific to some platforms. I don't think that it would be possible to expose them in a portable way using the open() function directly. Can we close this issue? I prefer to work on #16850 for the close-on-exec mode. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12103 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16836] configure script disables support for IPv6 on a system where IPv6 is disabled
Ralf Schmitt added the comment: Would you want to provide a patch for this? No, sorry. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16836 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com