PyCon PL 2015 - Został niecały tydzień dla Call for Proposals
Cześć Polska Społeczności Pythona! Jakiś czas temu uruchomiono PyCon PL 2015 - Call for Proposals, czyli nabór na propozycje prelekcji, warsztatów, paneli dyskusyjnych oraz innych aktywności konferencyjnych. Zaakceptowani prowadzący, którzy spełnią warunki Call for Proposals, otrzymają darmowy bilet na konferencję. Termin zgłoszeń mija z dniem 15 lipca 2015. PyCon PL 2015 to ósma edycja największej konferencji pythonowej w Europie Środkowo-Wschodniej. W ubiegłym roku wzięło w niej udział ponad 500 osób. Na tegorocznej edycji organizatorzy spodziewają się nawet 700 uczestników! Konferencja integruje środowiska programistów Pythona, naukowców oraz biznesu, wykorzystujące ten język we własnych projektach. Stałym elementem wydarzenia są ciekawe wystąpienia, w tym prelekcje specjalnych gości zza granicy, warsztaty, "piorunujące wystąpienia" oraz inne atrakcje wpasowujące się w luźny, weekendowy klimat wydarzenia. PyCon PL 2015 odbędzie się w dniach od 15 do 18 października 2015 r. w czterogwiazdkowym gigancie "Ossa Congress & Spa" w miejscowości Ossa. Zachęcam Was do wystąpienia przed międzynarodową społecznością, do dzielenia się wiedzą i nabytym doświadczeniem. W tym celu wystarczy zgłosić propozycję wystąpienia w specjalnym formularzu Call for Proposals (http://goo.gl/forms/kh4kBkVF9G). Wyboru wystąpień dokona Komitet Programowy PyCon PL 2015, w skład w którego wchodzą przedstawiciele lokalnych, polskich środowisk Pythona. Więcej informacji: http://pl.pycon.org/2015/, https://www.facebook.com/PyConPL -- https://mail.python.org/mailman/listinfo/python-list
PyCon PL 2015 - Call for Proposal is waiting for you
Python Hackers, PyCon PL 2015 is pleased to announce that its Call for Proposals will be closed soon! We encourage you all to come and share experience with a varied audience of ethusiastic Pythonistas that the conference attracts each year. Talks and workshops from all Python-related areas are welcome, both in Polish and English. The deadline for proposals is July 15th, 2015. You can submit yours by filling in this form: http://goo.gl/forms/kh4kBkVF9G PyCon PL is renowed for its unique atmosphere, owed to accomodating all participants in the same hotel, which helds the conference. It fosters superb networking opportunities as well as a great fun in the evenings. This year we invite you to a comfortable four-star hotel in the middle of beautiful and green area, located 60km from Warsaw. We will arrange inexpensive bus transport from Warsaw to the hotel for those who need it. More information on Call for Proposals and the conference itself can be found on its website. Hope to meet you in Poland this autumn! Feel free to meet us on: http://pl.pycon.org/2015/ https://www.facebook.com/PyConPL -- https://mail.python.org/mailman/listinfo/python-list
Re: merits of Lisp vs Python
Paul Rubin wrote: > > > a[i] = b[n] > > > (setf (aref a i) (aref b n)) > > Well, there's some similar way to look up elements in a Lisp > hashtable, but I've forgotten the keyword for it (oops, cognitive > inefficiency, having to remember separately.) Python uses the same > syntax for both. That's true, Lisp would benefit from _standard_ homogenuous polymorphic accessor functions to list-like objects and/or low-level (macro-like) syntactic sugar. Yes, you can easily make (a i) act like (aref a i) but it is not done by default. Legacy reasons? Graham has interesting things to say about this issue: http://www.paulgraham.com/ilc03.html Most of my programs are also written in Python, however, I would say that in many cases "a[i] = b[n]" is an artefact of programming habits from C, which has no language support for list comprehension, iterators, etc. I tend to avoid such constructs; usually there is a more natural way to do the same and it's just too easy to get the indices wrong. Piotr -- http://mail.python.org/mailman/listinfo/python-list
readline() - problem
Hi! I'm a new user of python, and have problem. I have a plain ascii file: 11..1 12..1 11..1 I want to create a new file which contains only lines with '1' on 15th position. I've tried this: import string f=open('/test/test.asc','r') o=open('/test/out.asc','w') for line in f: s= f.readline() if s[15]=='1' : o.write(s) o.close() f.close() Why it doesn't work ('s' contains ' ' )? piotr -- http://mail.python.org/mailman/listinfo/python-list
Re: readline() - problem
On 2 Pa , 13:39, Ben Finney <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > import string > > Why import 'string' if you're not using it? > > > f=open('/test/test.asc','r') > > o=open('/test/out.asc','w') > > for line in f: > > s= f.readline() > > Your line object is already bound to the 'line' name in each > iteration. You need to use that, not attempt to read yet another line > each time. > Of course, it helped. Many thanks for all. piotr -- http://mail.python.org/mailman/listinfo/python-list
template engine
Hi, I'm looking for a template engine that can give me names of required variables in parse time. Calculation of a value for a specific variable name could be possibly done in specified callback function. For example: $title #if user hello $user/name #else hello guest #endif for above document engine should call my function first giving an argument "title", then second time with argument "user", and optionally if result for user was not empty call function again with argument "user/name" then engine should replace specific placeholders with results of my callback function obviously this is just example syntax, I hope you catch the idea that would be nice if engine could work with non HTML documents. thanks in advance for your help, and sorry for my English :) //peter -- http://mail.python.org/mailman/listinfo/python-list
Re: template engine
On Sat, 13 Jan 2007 16:42:16 -0200, Jorge Godoy wrote: > Take a look at Kid (http://www.kid-templating.org/) and Genshi > (http://genshi.edgewall.org/). I've already done a short look at kid, but to be honest I don't like it's XML/Python syntax. I strongly prefer idea from SimpleTAL or HTMLTemplates where HTML and Python code are separated. But syntax is for me not so important like functionality so maybe I have to get back and look at kid again :) any other engines? :) thanks //peter -- http://mail.python.org/mailman/listinfo/python-list
Why is pylaucher in Python 3.3 being installed in Windows folder?
Why is pylauncher in Python 3.3 being installed in Windows folder and not in Program Files folder? Installing into Windows folder was maybe acceptable 10 years ago but not now... -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is pylaucher in Python 3.3 being installed in Windows folder?
On Oct 4, 6:30 am, Chris Rebert wrote: > Presumably because Program Files isn't part of the > $PATH.http://superuser.com/questions/124239/what-is-the-default-path-enviro... > Contrast (from the PEP): "However, the Windows directory is always on the > path." I guess that's the reason indeed. > Now, as for why the launcher must be on the $PATH…*shrugs* Now, the question is why not put pylauncher together with python.exe now, when 3.3 has an option to add Python's folder to the PATH? In case there are more than one Python installed this would mean changing pylauncher when changing active Python (via PATH modification). Maybe that's undesired? If so then installing to Program Files and adding its folder to PATH the same way Python's folder is added would be much better than installing into Windows folder. -- http://mail.python.org/mailman/listinfo/python-list
DLLs folder on Windows
Hi! I'm curious how dlls from the DLLs folder on Windows are being loaded? As they are not placed in the same folder where python.exe resides I guess they must be loaded by giving the path explicitly but I'm not sure. I'm asking because there's no DLLs folder being created when creating virtualenv and I suspect it should be. This is a followup to my question "Why doesn't virtualenv create DLLs folder?" (http://stackoverflow.com/q/6657541/95735) and to the virtualenv's issue 87 - "Problems creating virtualenv on Windows when Python is not installed for all users." (https://github.com/pypa/virtualenv/issues/87). Regards, Piotr Dobrogost ps. This was originaly posted to python-devel see http://thread.gmane.org/gmane.comp.python.devel/136821 -- http://mail.python.org/mailman/listinfo/python-list
Re: Abandoning Python
I'm sorry, I wanted to send the message below to the list and instead I sent it to just one user. Piotr Dnia 23-05-2011 o 10:29:24 Piotr Kamiński napisał(a): Dnia 23-05-2011 o 00:58:55 Brendan Simon (eTRIX) napisał(a): ... Take a look at Cobra. http://cobra-language.com/docs/python/ http://cobra-language.com/ It is similar to Python, but with a quite a few nice extras and few improved things (eg. no "self", no ":", ...) Possible negatives are: * Requires either .NET or Mono frameworks. * lack of 3rd party libraries ?? Cheers, Brendan. One more piece of information and a link: "...It supports both static and dynamic typing..." http://en.wikipedia.org/wiki/Cobra_(programming_language_from_Cobra_Language_LLC) HTH, Piotr -- http://mail.python.org/mailman/listinfo/python-list
Why is there no natural syntax for accessing attributes with names not being valid identifiers?
Hi! I find global getattr() function awkward when reading code. What is the reason there's no "natural" syntax allowing to access attributes with names not being valid Python identifiers in a similar way to other attributes? Something along the line of my_object.'valid-attribute-name-but-not-valid-identifier'? Regards, Piotr Dobrogost -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Tuesday, December 3, 2013 7:03:41 PM UTC+1, rand...@fastmail.us wrote: > On Tue, Dec 3, 2013, at 12:14, Piotr Dobrogost wrote: > > > Hi! > > > I find global getattr() function awkward when reading code. > > What is the reason there's no "natural" syntax allowing to access > > attributes with names not being valid Python identifiers in a similar way > > to other attributes? > > Something along the line of > > my_object.'valid-attribute-name-but-not-valid-identifier'? > > The getattr function is meant for when your attribute name is in a > variable. Being able to use strings that aren't valid identifiers is a > side effect. Why do you say it's a side effect? Could you elaborate? I see nothing odd in passing literal (string literal in this case) as a value of function's argument. > Why are you designing classes with attributes that aren't > valid identifiers? Attribute access syntax being very concise is very often preferred to dict's interface. That's why various containers expose their elements as attributes. In my case I'm using in-house web form library which provides FieldSet class holding objects of type Field or other FieldSets. This nesting leads to names of the form 'outer_fieldset-inner_fieldset-third_field' which are not valid identifiers due to minus sign. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Tuesday, December 3, 2013 6:31:58 PM UTC+1, Ethan Furman wrote: > > When would you have attribute names that are not valid identifiers? > See my answer to rand's post. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Wednesday, December 4, 2013 6:45:05 AM UTC+1, Tim Roberts wrote: > > It is not "very concise". It is slightly more concise. > > x = obj.value1 > x = dct['value1'] > > You have saved 3 keystrokes. Actually only 1 as you should have compared these: x = obj.'value-1' x = dct['value-1'] Unless we compare with what we have now, which gives 9 (without space) or 10 (with space): x = obj.'value-1' x = getattr(obj, 'value-1') > That is not a significant enough savings to create new syntax. Well, 9 characters is probably significant enough saving to create new syntax but saving these characters is only a side effect and is not the most important aspect of this proposal which leads us to the next point. > Remember the Python philosophy that there ought to be one way to do it. Funny you use this argument against my idea as this idea comes from following this rule whereas getattr goes against it. Using dot is the main syntax to access attributes. Following this, the syntax I'm proposing is much more in line with this primary syntax than getattr is. If there ought to be only one way to access attributes then it should be dot notation. Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Wednesday, December 4, 2013 2:06:44 AM UTC+1, Tim Chase wrote: > > I think random832 is saying that the designed purpose of setattr() > was to dynamically set attributes by name, so they could later be > accessed the traditional way; not designed from the ground-up to > support non-identifier names. But because of the getattr/setattr > machinery (dict key/value pairs), it doesn't prevent you from having > non-identifiers as names as long as you use only the getattr/setattr > method of accessing them. Right. If there's already a way to have attributes with these "non-standard" names (which is a good thing) then for uniformity with dot access to attributes with "standard" names there should be a variant of dot access allowing to access these "non-standard" named attributes, too. Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Wednesday, December 4, 2013 2:23:24 PM UTC+1, Roy Smith wrote: > In article <17gt99hg615jfm7bdid26185884d2pf...@4ax.com>, > > Tim Roberts <> wrote: > > > Piotr Dobrogost <> wrote: > > > >Attribute access syntax being very concise is very often preferred > > >to dict's interface. > > > It is not "very concise". It is slightly more concise. > > > x = obj.value1 > > x = dct['value1'] > > > You have saved 3 keystrokes. That is not a significant enough savings to > > create new syntax. Remember the Python philosophy that there ought to be > > one way to do it. > > I'll trade typing [ ' ' ] for . any day. Easier to type, easier to > read. It's not just the character count, it's that you need to move > your fingers off the home row (or, at the very least, a big stretch with > your pinkie) to reach the brackets. I suppose that depends on your > particular keyboard layout and typing style/skill. Very true. Just a remark it's actually trading getattr(o,'x') for o.'x' (saving of 11 keystrokes - don't forget shifts :)) as attribute is quite a different beast then key in a dictionary so comparing this to dict's interface is comparing apples to oranges. Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Wednesday, December 4, 2013 10:41:49 PM UTC+1, Neil Cerutti wrote: > > not something to do commonly. Your proposed syntax leaves the > distinction between valid and invalid identifiers a problem the > programmer has to deal with. It doesn't unify access to > attributes the way the getattr and setattr do. Taking into account that obj.'x' would be equivalent to obj.x any attribute can be accessed with the new syntax. I don't see how this is not unified access compared to using getattr instead dot... Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Tuesday, December 3, 2013 6:48:38 PM UTC+1, Dave Angel wrote: > On Tue, 3 Dec 2013 09:14:49 -0800 (PST), Piotr Dobrogost > > wrote: > > > What is the reason there's no "natural" syntax allowing to access > > attributes with names not being valid Python identifiers in a similar > > way to other attributes? > > There is. Just use a dictionary. Object's attributes and dictionary's keys are quite different things. What about descriptors? Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Wednesday, December 4, 2013 10:41:49 PM UTC+1, Neil Cerutti wrote: > On 2013-12-04, Piotr Dobrogost <> wrote: > > > Right. If there's already a way to have attributes with these > > "non-standard" names (which is a good thing) > > At best its a neutral thing. You can use dict for the same > purpose with very little effort and no(?) loss of efficiency. As much as many people in this topic would like to put equal sign between attributes and dictionary's keys they are not the same thing. AFAIK descriptor protocol works only with attributes, right? Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Wednesday, December 4, 2013 11:11:56 PM UTC+1, Terry Reedy wrote: > > The discussion of enlarging the scope of 'identifier' is not relevant as > you are not proposing that. In particular, you are not asking that > obj.value-1 get the 'value-1' attribute of obj. Right. > The discussion of keystrokes is also a side-track. To great degree, yes. Having said that I find extra 11 keystrokes needed to access some attributes to be a freaking big and unjustifiable number. > What you are proposing, I believe, is a new grammatical category: > attribute-name := identifier or string-literal. This would break the > symmetry of the grammatical form identifier '.' identifier and change it > to the asymmetrical identifier '.' attribute-name, and that is the Nice description. > To put it another way, how does 'obj' get the non-standard attribute > 'value-1', when obj is a module or class? The workaround given above for > module attributes will not work for classes. I'm not sure I see your point. Do you mean that being inside class declaration there's no name that referrs to the current namespace (the way __globals__ refer to module's namespace) thus we can't use proposed syntax to access non-standard attributes from this namespace? > > >> Remember the Python philosophy that there ought to be one way to do > >> it. > > > Funny you use this argument against my idea as this idea comes from > > following this rule whereas getattr goes against it. > > Not really. As others have pointed out, getattr is the preferred way to > get the value of an attribute when you have an object with attributes > and a run-time-only reference to the name in a string variable. Yes, and I think it's very unfortunate in itself. Attribute access is fundamental operation and it's not accident that "operator" for this action is very concise in many languages being one char only. Having to switch to global function to access attribute in case its name is known only at run time is very awkward both when writing and reading code. > It would also be the case that "obj.'value' is obj.value", so the > proposal *would* add duplication. This is not a big deal and that's what you get when someone had already decided that in expression a.b, b is treated literally. Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Thursday, December 5, 2013 12:09:52 AM UTC+1, Ethan Furman wrote: > Perhaps you should look > at different ways of spelling your identifiers? Why can't you use an > underscore instead of a hyphen? So that underscore could be left for use inside fields' names? However I think we could use some unique Unicode character for this instead hyphen as long as Python allows any alphanumeric Unicode character inside identifiers which I think it does... Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?
On Friday, December 6, 2013 3:07:51 PM UTC+1, Neil Cerutti wrote: > On 2013-12-04, Piotr Dobrogost > > wrote: > > > On Wednesday, December 4, 2013 10:41:49 PM UTC+1, Neil Cerutti > > wrote: > > >> not something to do commonly. Your proposed syntax leaves the > >> distinction between valid and invalid identifiers a problem > >> the programmer has to deal with. It doesn't unify access to > > >> attributes the way the getattr and setattr do. > > > > > > Taking into account that obj.'x' would be equivalent to obj.x > > any attribute can be accessed with the new syntax. I don't see > > how this is not unified access compared to using getattr > > instead dot... > > I thought of that argument later the next day. Your proposal does > unify access if the old obj.x syntax is removed. As long as obj.x is a very concise way to get attribute named 'x' from object obj it's somehow odd that identifier x is treated not like identifier but like string literal 'x'. If it were treated like an identifier then we would get attribute with name being value of x instead attribute named 'x'. Making it possible to use string literals in the form obj.'x' as proposed this would make getattr basically needless as long as we use only variable not expression to denote attribute's name. This is just casual remark. Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Cross-platform way to get default directory for binary files like console scripts?
Hi! Is there cross-platform way to get default directory for binary files (console scripts for instance) the same way one can use sys.executable to get path to the Python's interpreter in cross-platform way? Context: There's Python script which runs various tools like pip using subprocess and we would like to make sure we run tools that accompany Python's interpreter used to run this script. Please note that the script may be run from within virtualenv which had not been activated - ./venv/bin/python our_script.py Regards, Piotr Dobrogost -- https://mail.python.org/mailman/listinfo/python-list
Re: Cross-platform way to get default directory for binary files like console scripts?
On Thursday, February 20, 2014 4:22:53 PM UTC+1, Oscar Benjamin wrote: > > I'm not sure if I understand the question. Are you trying to find > where a script would go if it had been installed as a result of > 'python setup.py install' or 'pip install ...'? > Yes. > If so there are > different places it could go depending not only on the system but also > how the packages were installed (e.g. --user). Right. > You can find the default location in this roundabout way: > > (...) > > In [5]: c.install_scripts > Out[5]: '/usr/local/bin' I think this is pretty much what I'm after, thanks. I'm wondering if there's some API to get this info as what you showed is really roundabout way to achieve the goal... Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Cross-platform way to get default directory for binary files like console scripts?
On Thursday, February 20, 2014 4:42:54 PM UTC+1, Ned Batchelder wrote: > > As roundabout and advanced as that code is, it doesn't give the right > answer for me. It returns None. Indeed. I tried on Linux and got None both inside and outside virtualenv :( Regards, Piotr -- https://mail.python.org/mailman/listinfo/python-list
Re: Cross-platform way to get default directory for binary files like console scripts?
On Thursday, February 20, 2014 4:34:25 PM UTC+1, Piotr Dobrogost wrote: > > I'm wondering if there's some API to get this info as what you showed is > really roundabout way to achieve the goal... Turns out there is API for this - see thread on distutils-sig mailing list at https://mail.python.org/pipermail/distutils-sig/2014-February/023867.html Regards, Piotr Dobrogost -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Basic asyncio usage
Hi, I have posted the same question to python-tutor list *, but I'm trying my luck here as advised. I'm trying to get more familiar with asyncio library. Using python 3.4, I wrote simple echo server (see attachement for the code). I know that instead of using bare bone send/recv I could use some of the helper functions, but I want to start with the basics. Using attached code, I can connect from multiple sources, but echo won't work for all clients. Also, please look at the `sendall` mehtod - I have to manually remove write callback, otherwise it will be called all the time. Any tips on solving this problem? * https://mail.python.org/pipermail/tutor/2014-March/100679.html import asyncio import socket import time loop = asyncio.get_event_loop() class Client: def __init__(self, conn): self.conn = conn self.conn.setblocking(False) def recv(self, size): "wrap `recv` method with future" future = asyncio.Future() def _recv(): try: future.set_result(self.conn.recv(size)) except Exception as exc: future.set_exception(exc) loop.add_reader(self.conn, _recv) return future def sendall(self, data): "wrap `sendall` method with future" future = asyncio.Future() def _sendall(): try: # XXX manually remove, because otherwise it will be called # forever loop.remove_writer(self.conn) future.set_result(self.conn.sendall(data)) except Exception as exc: future.set_exception(exc) loop.add_writer(self.conn, _sendall) return future def close(self): self.conn.close() def accept(sock): future = asyncio.Future() def _accept_client(): conn, addr = sock.accept() future.set_result((Client(conn), addr)) loop.add_reader(sock, _accept_client) return future def handle_client(conn, addr): print("Client connected: {}".format(addr)) while True: data = yield from conn.recv(1024) if data.strip() == b'quit': conn.close() print("Client disconnected: {}".format(addr)) return yield from conn.sendall(data) @asyncio.coroutine def test(): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(False) sock.bind(('localhost', 12345)) sock.listen(1) while True: conn, addr = yield from accept(sock) asyncio.Task(handle_client(conn, addr)) def main(): loop.run_until_complete(test()) loop.close() if __name__ == "__main__": main() -- https://mail.python.org/mailman/listinfo/python-list
Why is str(None) == 'None' and not an empty string?
Hi! Having repr(None) == 'None' is sure the right thing but why does str(None) == 'None'? Wouldn't it be more correct if it was an empty string? Regards Piotr Dobrogost -- http://mail.python.org/mailman/listinfo/python-list
Convert Python 3 ResourceWarnings into exception
Hi! Recently A. Jesse Jiryu Davis asked at Stackoverflow (http://stackoverflow.com/q/24717027/95735) if there is "a way to force a Python 3 unittest to fail, rather than simply print a warning to stderr, if it causes any ResourceWarning?" Daniel Harding, in the accepted answer, states it's not possible. Is it really the case? For sake of context, here I believe is the place, where PyErr_WriteUnraisable is being called in this case – http://hg.python.org/cpython/annotate/c0e311e010fc/Modules/socketmodule.c#l3857 -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert Python 3 ResourceWarnings into exception
Terry Reedy udel.edu> writes: > > python -W error ... > "Raise an exception instead of printing a warning message." > > You can also turn this on with the warnings module. Assuming that this > works for ResourceWarning, which is should, please correct the SO record. Thanks for taking time to answer. Please notice that OP already tried warnings.simplefilter(action='error', category=ResourceWarning) with no luck. Also, in the answer, Daniel states the following: "The ResourceWarning is indeed being generated during garbage collection, and Python prints a message because it doesn't have a way to raise an exception at that point." If it were true that would have been rather unfortunate as I guess most ResourceWarnings are being generated during garbage collection. In that case to let users get hold on such warnings there would need to be created new mechanism for gathering warnings (not based on exceptions as a mean of transport). -- https://mail.python.org/mailman/listinfo/python-list
backporting PEP 3134 "Exception Chaining and Embedded Tracebacks" to Python 2.7
Hi! What is a chance of backporting PEP 3134 "Exception Chaining and Embedded Tracebacks" to Python 2.7? Regards, Piotr Dobrogost -- http://mail.python.org/mailman/listinfo/python-list
SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page.
Hi! I'd like to bring your attention to the question titled "Use HTTP/1.1 with SimpleHTTPRequestHandler" at http://stackoverflow.com/q/15839718/95735 which reads; "When I use HTTP/1.1 with SimpleHTTPRequestHandler, loading a page that pulls in other resources will hang after the second resource." and there's a tiny test showing the problem. It's hard to believe that SimpleHTTPServer doesn't handle such a simple task, does it? If I checked correctly code is stuck in handle_one_request() method at line 370 of server.py (http://hg.python.org/cpython/file/d9893d13c628/Lib/http/server.py#l370) but I can't see what's wrong. Any ideas? Best regards, Piotr Dobrogost -- http://mail.python.org/mailman/listinfo/python-list
Re: SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page.
On Saturday, April 13, 2013 12:21:33 AM UTC+2, Terry Jan Reedy wrote: > I find the doc slightly confusing. The SO code uses BaseHTTPServer. The > doc says "Usually, this module isn’t used directly," On the other hand, > SimpleHTTPServer only defines a request handler and not a server itself. Thanks for taking time to reply. Well, I've seen presentations where BaseHTTPServer is a recommended way of running simple, ad-hoc web server. In addition the documentation of http.server module in Python 3.3 (which contains implementation of the same HTTPServer class as found in BaseHTTPServer module in Python 2.x) does not contain the statement you cited which I take to mean it can safely be used directly. As Python 3.3.1 exhibits the same behavior let's focus on the following Python 3 version of the code from the original question: from http.server import SimpleHTTPRequestHandler from http.server import HTTPServer class MyRequestHandler(SimpleHTTPRequestHandler): #protocol_version = "HTTP/1.0" # works protocol_version = "HTTP/1.1" # hangs server = HTTPServer(("localhost", 7080), MyRequestHandler) server.serve_forever() > What does 'hang' mean? Does the page get displayed? If so, > server.serve_forever is supposes to 'hang'. I increased the number of resources to 7 to be able to detect possible patterns. The page and some of the resources are being displayed almost instantly. However browser waits for the requests to get remaining resources to finish and so those resources naturally are not being displayed. When browser waits the code is stuck at the line I showed in my original post. What's interesting is that after some time the request to get the second resource (in case there are only 2 on the page) finishes. However the time spent waiting for the second resource is ridiculously long compared to time spend waiting for the first resource. For example in one of my tests Firebug showed waiting time for the first resource to be 4ms whereas the waiting time for the second resource to be 1m 55s. > The SO post says > > class MyRequestHandler(SimpleHTTPRequestHandler): > #protocol_version = "HTTP/1.0" # works > protocol_version = "HTTP/1.1" # hangs > > so this should be some sort of clue. The code says > > 569 # The version of the HTTP protocol we support. > 570 # Set this to HTTP/1.1 to enable automatic keepalive > 571 protocol_version = "HTTP/1.0" Sure, in version 1.1 of http the connection is not closed by default unless 'Connection: Close' header was sent in request. Firefox sends all requests with 'Connection: keep-alive' header. I don't really know how to debug this... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python pdb bug, followed by bug in bugs.python.org
On Thursday, April 11, 2013 5:12:53 PM UTC+2, donald...@gmail.com wrote: > > I just submitted a bug report on the pdb issue. It would be nice of you to share the link to this issue. -- http://mail.python.org/mailman/listinfo/python-list
is a wiki engine based on a cvs/svn a good idea?
I'm planning to wite a fully featured wiki in Python in one of frameworks. I've seen some notes about wiki/documentation management scripts that use SVN as a data storage/versioning. I've been using SVN a bit but I don't know if it's a good idea to use it in a wiki engine. Pro: versioning / diffs, Cons: you need your own svn/cvs repository, can pyLucene or Xapwrap index this? -- http://mail.python.org/mailman/listinfo/python-list
Python, GUI, and GTK+
Hi, I'm new at GUI programming. I've heard about Gazpacho but I couldn't find any tutorial about it on Internet (even on the gazpacho page). Becouse of that fact, I've installed Glaze, but there's probably no tutorials for python too. Can anyone point me an introdutory tutorial on how to implement a very simple application in GTK+ based on a XML file? -- http://mail.python.org/mailman/listinfo/python-list
converting binary data
I have a game file described here: http://iesdp.gibberlings3.net/ieformats/itm_v1.htm and I'm trying to read all the data: plik = open('bow08.itm', 'rb') try: tekst = plik.read() finally: plik.close() # char array - works print tekst[0x0004:0x0004+4] # resref - works print tekst[0x003a:0x003a+8] #dword - binary something, doesn't work print tekst[0x004c:0x004c+4]##The dword and many other variables are binary code and I don't know how to convert them into "normal" data. NearInfinity, app written in Java converts dword and friends in this way: ##public static int convertInt(byte buffer[], int offset) { int value = 0; for (int i = 3; i >= 0; i--) value = (value << 8) | (buffer[offset + i] & 0xFF); return value; } ##How to pythonize this code, or make something in python to read the data from Baldurs Gate files ? :) -- http://mail.python.org/mailman/listinfo/python-list
testing with coverage.py problem
Hi there. I've spent few hours and found nothing, so here's my question: How can i run tests wrote by myself on a module, using coverage.py ? Let's assume i have a module mymod.py which i want to test with tests from file mytest.py (i.e. class inherited from unittest.TestCase). How to do that with coverage.py? Where i should put the code that runs the tests? -- Regards Piotr Hrebieniuk -- http://mail.python.org/mailman/listinfo/python-list
Re: Does anybody know how to install PythonMagick?
python imaging library is more advanced and up to date :) try using this one. -- http://mail.python.org/mailman/listinfo/python-list
the official way of printing unicode strings
Hello, in Python (contrary to Perl, for instance) there is one way to do common tasks. Could somebody explain me what is the official python way of printing unicode strings? I tried to do this such way: s = u"Stanisław Lem" print u.encode('utf-8') This works, but is very cumbersome. Then I tried to do this that way: s = u"Stanisław Lem" print u This breaks when I redirect the output of my program to some file, like that: $ example.py > log Then I tried to do this that way: sys.stdout = codecs.getwriter("utf-8")(sys.__stdout__) s = u"Stanisław Lem" print u This works but is even more combersome. So, my question is: what is the official, recommended Python way? -- http://mail.python.org/mailman/listinfo/python-list
Re: the official way of printing unicode strings
Marc 'BlackJack' Rintsch wrote: > I'd make that first line: > sys.stdout = codecs.getwriter('utf-8')(sys.stdout) > > Why is it even more cumbersome to execute that line *once* instead > encoding at every ``print`` statement? Oh, maybe it's not cumbersome, but a little bit strange - but sure, I can get used to it. My main problem is that when I use some language I want to use it the way it is supposed to be used. Usually doing like that saves many problems. Especially in Python, where there is one official way to do any elementary task. And I just want to know what is the normal, official way of printing unicode strings. I mean, the question is not "how can I print the unicode string" but "how the creators of the language suppose me to print the unicode string". I couldn't find an answer to this question in docs, so I hope somebody here knows it. So, is it _the_ python way of printing unicode? -- http://mail.python.org/mailman/listinfo/python-list
I want to release the GIL
Hello, I have such program: import time import thread def f(): global lock while True: lock.acquire() print thread.get_ident() time.sleep(1) lock.release() lock=thread.allocate_lock() thread.start_new_thread(f,()) thread.start_new_thread(f,()) time.sleep(60) As you can see, I start two threads. Each one works in an infinite loop. Inside that loop it acquires lock, prints its own id, sleeps a bit and then releases lock. When I run it, I notice that only one thread works and the other one never has a chance to run. I guess it is because the thread don't have a chance to release the GIL - after it releases the lock, it almost immediately (in the very next bytecode command) reacquires it. I know I can put "time.sleep(0.01)" command after between release and reacquire, but it doesn't seem elegant - why should I make my program sleep instead of work? Is there any simple way to release the GIL? Like: lock.release() thread.release_gil() ? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: I want to release the GIL
Thanks for answers. But what about my main question? Is it possible to release GIL without sleeping? I know that in this example situation I can achieve my goals without that - I can just move sleep outside of locked block. But I just want to know it for future - can I just do something like thread.gil_release()? -- http://mail.python.org/mailman/listinfo/python-list
Re: Workflow engine?
Grzegorz Staniak pisze: Hi, In a couple of weeks I'm starting a medium-size project (using a web framework) involving a workflow implementation. Are you aware of any open source workflow engines/libraries that I could base the project on? Google returns hist for GoFlow (Django only, from what I can tell), itools.workflow, spiff (AFAIK tied to a CMS), but not much else. I don't think I'll have enough time to get acquinted with Plone and its offer of products. Has anyone here tried any such code? What would you recommend? There are some packages for zope on pypi: Products.DCWorkflow - zope2, cmf hurry.workflow and some extensions - zope3 zope.wfmc - zope3 (not many dependencies on zope3) -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing objects in relational database
[EMAIL PROTECTED] pisze: I don't know if you'd label it 'elegant', but as far as I'm concerned, storing serialized objects as blobs in a relational database is mostly non-sense. If I use a relational database, it's because it is a *relational* database. If you want an OODB, then we have the ZODB, Durus and a couple others. It is sometimes convenient to store objects in mature relational database backend (reliability, stability, support, tools, replication, etc.). See latst efforts with RelStorage backend for ZODB (http://wiki.zope.org/ZODB/RelStorage) - it stores pickled Python objects in Oracle, PostgreSQL or MySQL) -- http://mail.python.org/mailman/listinfo/python-list
variable scope in list comprehensions
Hello, there is something I don't understand about list comprehensions. I understand how does this work: print [[y for x in range(8)] for y in range(8)] However I don't understand why this one works: print [[y for y in range(8)] for y in range(8)] In this second example I have one loop nested in another. Both loops uses the same variable - y. How is it that those loops do not conflict with each other? For a moment I thought that maybe list comprehension has its own scope, but it doesn't seem to be so: print [[y for y in range(8)] for y in range(8)] print y Does anybody understand it? -- http://mail.python.org/mailman/listinfo/python-list
Re: variable scope in list comprehensions
Duncan Booth wrote: > For the OP, in some languages (e.g. C) 'for' loops typically calculate > the value of the loop control variable based on some expression > involving the previous value. Python isn't like that. In Python the data > used to compute the next value is stored internally: you cannot access > it directly. Great! Now everything is clear. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
functools's partial and update_wrapper does not work together
Hello! I wanted to use a decorator to wrap partially applied function like this: from functools import * def never_throw(f): @wraps(f) def wrapper(*args, **kwargs): try: return f(*args, **kwargs) except: pass return wrapper def foo(i): raise ValueError(str(i) + " is too little") never_throw(partial(foo, 3)) However this fails with an exception saying AttributeError: 'functools.partial' object has no attribute '__module__'. How can I use generic wrapper (never_throw) around partials? Thank you, Piotr -- http://mail.python.org/mailman/listinfo/python-list
Re: functools's partial and update_wrapper does not work together
> If not already done by someone else, it might be worth filling a ticket > - generic decorators should work with any callable, not only with > functions (well, IMHO at least). you're right. it's already there http://bugs.python.org/issue3445 regards! -- http://mail.python.org/mailman/listinfo/python-list
how can I use a callable object as a method
Hello, I would like to use a callable object as a method of a class. So, when I have such normal class: class f: version = 17 def a(self): return self.version f1 = f() print f1.a() I want to change it to something like that: class add: def __call__(self, another_self): return another_self.version class f: version = 17 a = add() f1 = f() print f1.a() However, the second version does not work. I think I understand why. That's because "a" inside f1 is not a function (but an object). So f1.a is not a method. So when I do f1.a(), the implicit argument self is not passed. Q1: Am I right? Is this the problem? Q2: What can I do to make it work? -- http://mail.python.org/mailman/listinfo/python-list
Re: how can I use a callable object as a method
Hrvoje Niksic wrote: >> However, the second version does not work. I think I understand >> why. That's because "a" inside f1 is not a function (but an object). > > An object that defines __call__ is perfectly usable as a function. > Your problem is that it doesn't know how to convert itself to a > method, so that f1.a() knows how to pass f1 as another_self to > add.__call__. To do that, add needs to be a bit smarter: A! Now it works, thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list
is hk_classes python interface good?
Ive found hk_classes a C++/Python library/module for accesing databases. It works nice for me but I wonder if someone used hk_classes in a project, is this module good, etc. -- http://mail.python.org/mailman/listinfo/python-list
creating website script in Myghty
I'm learning Myghty from few weeks and now I'm making a simple forum script ;) and I have problem finding few things in python that I need: - how to strip all HTML tags leaving the text / strip all code (python/other) from a string? - how to highlight a python/html/other code (result in HTML code)? -- http://mail.python.org/mailman/listinfo/python-list
MyghtyBoard 0.0.1
MyghtyBoard 0.0.1 alfa have been released. It's a forum script written in python/myghty/hk_classes. Download: http://sourceforge.net/project/showfiles.php?group_id=163611&package_id=185021&release_id=404570 Few old screens: http://www.fotosik.pl/pokaz_obrazek/q0pq9tc1i6aphwc4.html http://www.fotosik.pl/pokaz_obrazek/4xdrt560ove5i0gf.html http://www.fotosik.pl/pokaz_obrazek/tf2tqifsog43eiuv.html Requirements: - Python :) - Myghty - http://www.myghty.org/ - hk_classes python module - http://hk-classes.sourceforge.net/tiki-page.php?pageName=Description - MySQL database Installation howto is in the readme. All comments and suggestions are welcome. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] RuPy 2007 - Python & Ruby Conference
RuPy 2007 Python & Ruby Conference Poznan, Poland April 7-8, 2007 RuPy is a Python & Ruby conference. It will be held at Adam Mickiewicz University, in Poznan, Poland, so it is relatively accessible from both the East and the West of Europe. The philosophy of RuPy is to put together Python & Ruby experts with young programmers and to provide a good communication channel for East-West exchange of prospective ideas. -- Call For Participation -- We would like to invite you to join us for two days of Python & Ruby fun. We are looking for speakers willing to share their knowledge and experience, talk about new solutions and show new developments. Potential presenters should submit an abstract to: rupy-talks at wmid.amu.edu dot pl by November, 31th 2006 for consideration. If you have any special presentation needs, let us know. For more details check our site: http://rupy.wmid.amu.edu.pl Best regards, -- Jakub P. Nowak -- http://mail.python.org/mailman/listinfo/python-list
IPv6 in python
Hello, How to make python support IPv6? I tried to do: ./configure --enable-ipv6 make make install and I didn't get any error. However, IPv6 doesn't seem to be working yet. then I tried ./configure --enable-ipv6=yes and I got a lot of parse errors (many pages similar to this below) In file included from /root/Piotr/Python-2.5.1/Modules/_tkinter.c:67: /usr/include/tk.h:581: parse error before "Bool" /usr/include/tk.h:583: parse error before "event" /usr/include/tk.h:584: parse error before "root" /usr/include/tk.h:585: parse error before "subwindow" /usr/include/tk.h:586: parse error before "time" /usr/include/tk.h:586: `time' redeclared as different kind of symbol /usr/include/time.h:184: previous declaration of `time' /usr/include/tk.h:591: parse error before "same_screen" /usr/include/tk.h:597: parse error before "Bool" /usr/include/tk.h:599: parse error before "window" /usr/include/tk.h:601: parse error before "XActivateEven How to make it work? Thank you in advance, Piotr -- http://mail.python.org/mailman/listinfo/python-list
enabling IPv6 in python
Hello, How to make python support IPv6? I have IPv6 running on my host (interfaces have ipv6 addresses assigned) I tried to do: ./configure --enable-ipv6 make make install and I didn't get any error. However, IPv6 didn't work. then I tried ./configure --enable-ipv6=yes and I got a lot of parse errors (many pages of errors similar to the ones below) In file included from /root/Piotr/Python-2.5.1/Modules/_tkinter.c:67: /usr/include/tk.h:581: parse error before "Bool" /usr/include/tk.h:583: parse error before "event" /usr/include/tk.h:584: parse error before "root" /usr/include/tk.h:585: parse error before "subwindow" /usr/include/tk.h:586: parse error before "time" /usr/include/tk.h:586: `time' redeclared as different kind of symbol /usr/include/time.h:184: previous declaration of `time' /usr/include/tk.h:591: parse error before "same_screen" /usr/include/tk.h:597: parse error before "Bool" /usr/include/tk.h:599: parse error before "window" /usr/include/tk.h:601: parse error before "XActivateEven How to make it work? Thank you in advance, Piotr -- http://mail.python.org/mailman/listinfo/python-list
cgi subprocess, cannot get output
Hello, In the following cgi program, I cannot get subprocess output. I print the header, flush stdout to prepare it to new content, but variable 'o' is always empty. Could somebody help me with that? def main(): print "Content-type: text/html\n\n" sys.stdout.flush() if form.has_key('sentence'): input = form['sentence'].value o = Popen(['./tinki', input], stdout=PIPE).communicate()[0] result = cgi.escape(o) results['xmlfile'] = result results['sentence'] = input content['output'] = (output % results) print template % content Best regards, -- Jakub P. Nowak -- http://mail.python.org/mailman/listinfo/python-list
Re: cgi subprocess, cannot get output
Dnia 26.04.2006 James Stroud <[EMAIL PROTECTED]> napisa³/a: } Jakub Piotr Nowak wrote: }> Hello, }> }> In the following cgi program, I cannot get subprocess output. }> I print the header, flush stdout to prepare it to new content, }> but variable 'o' is always empty. }> }> Could somebody help me with that? }> }> [...mniam...] }> }> Best regards, } } What kind of script is tinki? I had a bitch of a problem like this with } perl and ended up just writing to a file. No idea why I couldn't get the } stdout. Tinki is a natural language parser. It takes a sentence as a command line argument and prints xml file to stdout. Thanks for the hint, I will try... Best regards, -- Jakub P. Nowak -- http://mail.python.org/mailman/listinfo/python-list