Html Parsing stuff
Ok i get the basics of this and i have been doing some successful parsings and using regular expressions to find html tags. I have tried to find an img tag and write that image to a file. I have had no success. It says it has successfully wrote the image to the file with a try... except statement but when i try to open this it says that the image has like no been saved correctly or is damaged. This was just reading the src attribute of the tag and trying to save that link to a .jpg(the extension of the image). Ok so i looked deeper and added a forward slash to the url and then added the image src attribute to it. I then opened that link with the urllib.urlopen() and then read the contents and saved it to the file again. I still got the same result as before. Is there a function in beautiful soup or the urllib module that i can use to save and image. This is just a problem i am sorting out not a whole application so the code is small. Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Confused with Functions and decorators
On Saturday, July 19, 2014 8:44:25 PM UTC+8, Wojciech Giel wrote: > On 19/07/14 12:40, Jerry lu wrote: > > > oh yeah i forgot about the decorators. Um say that you wanted to decorate a > > function with the outer() func you would just put @outer on top of it? And > > this is the same as passing another func into the outer func? > > yes. > > syntax was added because with very long function definitions it was > > dificult to track reassignment to the name when it followed definition > > of the function. decorators is just abbreviation. > > > > >>> def outer(f): > > ... def inner(*args, **kwargs): > > ... print("inner function") > > ... return f(*args, **kwargs) > > ... return inner > > ... > > >>> @outer > > ... def myfunc(x): > > ... print("Myfunc", x) > > ... > > >>> myfunc("test") > > inner function > > Myfunc test > > > > it is exactly equivalent to: > > > > >>> def outer(f): > > ... def inner(*args, **kwargs): > > ... print("inner function") > > ... return f(*args, **kwargs) > > ... return inner > > ... > > >>> def myfunc(x): > > ... print("Myfunc", x) > > ... > > >>> myfunc = outer(myfunc) > > >>> myfunc("test") > > inner function > > Myfunc test > > > > cheers > > Wojciech > > > > > > and also with the first example you say x is in the scope when is was > > created can you define x in the outer func and refer to it in the inner > > func? > > check nonlocal. Uhn, a local object inside a function can be passed back in Python. Of course, a local function is treated as an object in Python,and the GC is built-in. -- https://mail.python.org/mailman/listinfo/python-list
Re: Confused with Functions and decorators
On Mon, 21 Jul 2014 00:30:00 -0700, CHIN Dihedral wrote: > Uhn, a local object inside a function can be passed back in Python. > > Of course, a local function is treated as an object in Python,and the GC > is built-in. Sigh, the Dihedral bot is not what it used to be... -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
2014-07-21 4:30 GMT+02:00 Tim Chase : > On 2014-07-20 19:06, Rick Johnson wrote: >> >> STEPS TO REPRODUCE BUG 1: "Attack of the clones!" >> >> >> 1. Open the IDLE application >> 2. Maximize the window that appears >> 3. Go to the "File Menu" and choose the "Open" command >> >> Now repeat step 3 at least one more time, but feel free to >> keep opening new dialogs until your fingers bleed and/or >> eyes pop out. > > In the versions of IDLE that I have here (2.7.3 and 3.2.3), both > prevent me from repeating step #3 multiple times. Not on 2.7.6 and 3.4 on Linux Mint either -- Regards, Martin S -- https://mail.python.org/mailman/listinfo/python-list
Re: Idle's Shell: prompts and indents (was ...) Idle users please read
On 7/20/2014 11:34 PM, Chris Angelico wrote: On Mon, Jul 21, 2014 at 1:28 PM, Terry Reedy wrote: A few users have noticed (and complained) that setting sys.ps1 and sys.ps2 *in the batch mode user process* has no effect. The Idle doc should better explain why this is and should be. User code should not affect the operation of Idle. Idle is separately configured through dialogs. As I understand it, setting them has *absolutely* no effect, currently, right? As far as I know, setting sys.ps1 and sys.ps2 have no effect in any batch mode program. This has nothing to do with Idle. There's no situation in which it would be useful to set them? In that case, it might be useful to put some magic in there (although I'm not sure it's possible; can't use @property at top level in a module) that gives a notification - pointing users to the dialog. In general, Idle should execute user code the same way that the interpreter does, subject to the limitations of the different execution environment. No idea how you'd go about it, but telling someone when what s/he does is useless can be helpful. What needs better documentation is what the execution environment is, and how the shell is different from a line-buffered console. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Html Parsing stuff
dont worry it has been solved -- https://mail.python.org/mailman/listinfo/python-list
Re: OT: usenet reader software
On 2014-07-21, Paul Rudin wrote: > Sturla Molden writes: > >> wrote: >> >>> That doesn't address the problem at all! :-) You still need a news >>> reader. >> >> The problem was that Thunderbird does not support killfiles when used as a >> newsreader. Leafnode adds filtering capabilities which Thunderbird >> (supposedly) does not have. >> > > There are plenty of non-Thunderbird news clients... But relatively few GUI clients on Linux... which was what I was looking for. -- https://mail.python.org/mailman/listinfo/python-list
Re: Idle's Shell: prompts and indents (was ...) Idle users please read
On Mon, Jul 21, 2014 at 7:00 PM, Terry Reedy wrote: > In general, Idle should execute user code the same way that the interpreter > does, subject to the limitations of the different execution environment. Agreed, but I think the setting of prompts is a "different execution environment" case. It's a fundamental difference between batch mode and interactive, and Idle uses batch mode to implement interactive mode. So something like: >>> sys.ps1="Python> " "Setting sys.ps1 has no effect in Idle; see the Options menu." >>> It might not be possible, but if it is, it wouldn't break any actual viable use-cases. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 2014-07-21, Chris Angelico wrote: > You call it a bug because you can't think of any way it could be > beneficial. That's the wrong way of looking at it. Something isn't a > bug because you find it annoying; it's a bug because it fails to > implement the programmer's intentions and/or the docs/specification. I was always taught that it's a "bug" is when a program doesn't do what a reasonable user expects -- that it's got nothing to do with the programmer's intent. -- Grant Edwards grant.b.edwardsYow! I'm RELIGIOUS!! at I love a man with gmail.coma HAIRPIECE!! Equip me with MISSILES!! -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
No intent to pollute this thread. But really interested in the invalid@invalid.invalid mailing address. And,,, obviously, I cannot send to invalid@invalid.invalid, so How does you(he) make this? 2014-07-21 22:27 GMT+08:00 Grant Edwards : > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. > > -- > -- > https://mail.python.org/mailman/listinfo/python-list -- 吾輩は猫である。ホームーページはhttp://introo.me。 -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On Tue, Jul 22, 2014 at 12:27 AM, Grant Edwards wrote: > On 2014-07-21, Chris Angelico wrote: > >> You call it a bug because you can't think of any way it could be >> beneficial. That's the wrong way of looking at it. Something isn't a >> bug because you find it annoying; it's a bug because it fails to >> implement the programmer's intentions and/or the docs/specification. > > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. There are many definitions of the word, and sometimes they disagree. (That's why it's common to have an "issue tracker" rather than a "bug tracker"; often the "is this a bug report or a feature request" question doesn't even matter. In theory, version x.y.? releases should have bug fixes but not feature additions, but sometimes some bug fix might potentially break code, so it's deferred till the next x.? release. Or a feature addition is allowed to be backported, because it's Idle, not the core language.) But even using that definition, I would not say that one single person saying "this can't possibly be useful" is enough to define something as a bug. Take, for instance, the behaviour of Windows's cmd.exe editing keys: enter three commands, then up-arrow three times and hit enter, then press down, enter, down, enter. You'll repeat the three commands. In other interfaces (eg GNU readline), you'd do the same job by pressing up, up, up, enter each time. Personally, I find the cmd.exe behaviour extremely surprising, especially when I've been working with some very similar commands (imagine: ./configure some_bunch_of_args; make; some_command_to_test; rm -rf *; git checkout HEAD - then repeat with a different set of configure arguments), and I end up "stuck half way up command history", wondering why I'm not seeing what I wanted. Can be extremely awkward. But even so, I don't call this a bug. It's entirely possible that it is one - some internal state that isn't being reset correctly - as I don't have docs or the programmer's intention to compare against. However, I can't honestly call it a bug based on just my own use-cases. I personally find it useless and unhelpful, but that doesn't make it a bug any more than a colourblind person would find a colour-based UI phenomenon a bug. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On Tue, Jul 22, 2014 at 12:40 AM, Shiyao Ma wrote: > No intent to pollute this thread. > > But really interested in the invalid@invalid.invalid mailing address. > And,,, obviously, I cannot send to invalid@invalid.invalid, so > > How does you(he) make this? When you send email, you have to have a valid envelope-from address, which can be found in the headers. But the From: address doesn't technically have to be valid. And if the email you received actually came from the news<->mail gateway, then it's even less significant; the address used is simply whatever Grant chose to key into his newsreader, which in this case is a marker saying "Please don't email me, just follow-up to the group" :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 2014-07-21, Shiyao Ma wrote: > But really interested in the invalid@invalid.invalid mailing address. > And,,, obviously, I cannot send to invalid@invalid.invalid, so > > How does you(he) make this? Some usenet clients, such as slrn which it looks like Grant is using according to the message header, support using different addresses for 'From:' and 'Reply-To:', and the comments in the default .slrnrc config file recommend using some form of 'invalid' in your 'From:' address to cut down on spam. Looks like Grant took that quite literally ;) Not sure if it really matters... probably can't hurt... Monte -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 21/07/2014 15:27, Grant Edwards wrote: On 2014-07-21, Chris Angelico wrote: You call it a bug because you can't think of any way it could be beneficial. That's the wrong way of looking at it. Something isn't a bug because you find it annoying; it's a bug because it fails to implement the programmer's intentions and/or the docs/specification. I was always taught that it's a "bug" is when a program doesn't do what a reasonable user expects -- that it's got nothing to do with the programmer's intent. As in my entire career I've never come across a "reasonable user" then by that definition there are no bugs. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On Tue, Jul 22, 2014 at 1:19 AM, Mark Lawrence wrote: > On 21/07/2014 15:27, Grant Edwards wrote: >> >> On 2014-07-21, Chris Angelico wrote: >> >>> You call it a bug because you can't think of any way it could be >>> beneficial. That's the wrong way of looking at it. Something isn't a >>> bug because you find it annoying; it's a bug because it fails to >>> implement the programmer's intentions and/or the docs/specification. >> >> >> I was always taught that it's a "bug" is when a program doesn't do >> what a reasonable user expects -- that it's got nothing to do with the >> programmer's intent. >> > > As in my entire career I've never come across a "reasonable user" then by > that definition there are no bugs. Absence of evidence is not the same as evidence of absence. It may be that there is a single platinum "reasonable user", kept at the International Bureau of Bugs, that we may all look on it and know what the SI Standard User is. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and IDEs [was Re: Python 3 is killing Python]
On Sunday, July 20, 2014 9:53:02 AM UTC+8, C.D. Reimer wrote: > On 7/19/2014 6:23 PM, Steven D'Aprano wrote: > > > I haven't used Python on Windows much, but when I did use it, I found > > > the standard Python interactive interpreter running under cmd.exe to > > > be bare- bones but usable for testing short snippets. If I recall > > > correctly, it is missing any sort of command history or line editing > > > other than backspace, which I guess it would have been painful to use > > > for extensive interactive work, but when I started using Python on > > > Linux the interactive interpreter had no readline support either so it > > > was just like old times :-) > > > > Windows PowerShell supports very basic Linux commands and has a command > > history. I'm always typing "ls" for a directory listing when I'm on a > > Windows machine. The regular command line would throw a DOS fit. > > PowerShell lets me get away with it. > > > > http://en.wikipedia.org/wiki/Windows_PowerShell#Comparison_of_cmdlets_with_similar_commands > > > > I prefer working on my vintage 2006 Black MacBook. Alas, the CPU fan is > > dying and MacBook shuts down after 15 minutes. I'm surprised at how well > > I was able to set up a equivalent programming environment on Windows. > > > > Chris Reimer Well, Python could be used as a scripting language for routine jobs in various Oses. But Python has been designed to be a cross-platform high-level general purpose programming language from the birth. One can be sure that the investing in most of the programming concepts and skills in Python 2.XX is still valid in Python 3.XX. Forget those non-investing imitators' flase spamming claims. -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
Chris Angelico writes: > Take, for instance, the behaviour of Windows's cmd.exe > editing keys: enter three commands, then up-arrow three times and hit > enter, then press down, enter, down, enter. You'll repeat the three > commands. In other interfaces (eg GNU readline), you'd do the same job > by pressing up, up, up, enter each time. Personally, I find the > cmd.exe behaviour extremely surprising, especially when I've been > working with some very similar commands (imagine: ./configure > some_bunch_of_args; make; some_command_to_test; rm -rf *; git checkout > HEAD - then repeat with a different set of configure arguments), and I > end up "stuck half way up command history", wondering why I'm not > seeing what I wanted. Can be extremely awkward. But even so, I don't > call this a bug. Granted, the readline library exposes a "operate-and-get-next" function, by default bound to \C-o, with the same behaviour as the cmd.exe one. I find it very handy in the scenario you picted. So again, "feature" and "bug" may be effectively subjective :-) ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On Tue, Jul 22, 2014 at 1:57 AM, Lele Gaifax wrote: > Granted, the readline library exposes a "operate-and-get-next" function, > by default bound to \C-o, with the same behaviour as the cmd.exe > one. I find it very handy in the scenario you picted. So again, > "feature" and "bug" may be effectively subjective :-) I've never used it, but from the name, I would take it to be equivalent to "enter, down-arrow" in the above scenario. As a single action, that's less surprising and just as useful. The problem isn't when you consciously want the feature - it's when you DON'T want it and get this unexpected state. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Network/multi-user program
So... this is a fairly general / hypothetical question, and I'm more looking for direction than specifics - though it may be useful as well. I need to create a particular application for administering a sporting event. 95% (and this may be understating the case) of the 'users' would likely be single-machine, single user scenarios. For those exceptions (which are important enough that I'm concerned over them) there would be one person 'administering' the event and a small number of others (probably <5, no more than 10) doing basic data entry - competitor registration and later entering scores. Before (setting up event), in between (squadding competitors based on classification, equipment, available positions on relays, etc.) and taking care of final reports for awards, etc. would be done only from the main program. The end-users are likely not tech-saavy, and most likely running Windows or maybe a Mac. Being able to do the data entry from a tablet would be nice but by no means necessary. Installation needs to be as stone-simple as possible - running from a pre-configured USB stick or a browser would be ideal. Use would be over small wired or wi-fi LAN enviroment - no exposure to Internet. Given that the vast majority of the 'work' is going to be done on one computer by one user, but wanting to retain the flexibility/ability to later have addtional 'clients' connect for data entry purposes... I'm trying to decide what would be a better option: create a stand-alone GUI desktop app and figure out how to create a separate 'client' program that can connect and perform basic CRUD operations, or start out with some sort of web framework and have everything literally run from the 'server' via a browser-based interface. The scope of the project in terms of users appears to be small enough that using something like sqlite would be feasible (the data entry clients would not be working on the same records), and the small development web servers that most projects like web2py, flask, django come with should (maybe?) be able to carry the (minimal) load as well. Having to throw html/css/js plus browser compatibility issues on top of everything else starts making the project look a whole lot bigger than I'm comfortable with... but on the other hand I have no idea how to go about connecting a client app to a running GUI program either. The whole project is fairly ambitious for my current skill level (basically small addressbook/task-list type apps) but I figured I'd have to stretch/grow a bit either way I go. So I guess I'm asking for advice or simplified examples of how to go about connecting a client desktop app to a parent/master desktop app, so I can get some idea of how big of a task I'm looking at here, and whether that would be more or less difficult than trying to do the equivalent job using a web framework. Thanks, Monte -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
On Tue, Jul 22, 2014 at 2:07 AM, Monte Milanuk wrote: > So I guess I'm asking for advice or simplified examples of how to > go about connecting a client desktop app to a parent/master desktop app, > so I can get some idea of how big of a task I'm looking at here, and > whether that would be more or less difficult than trying to do the > equivalent job using a web framework. Easier way: Don't have a "master desktop app", but instead have a master database. Since you're posting this to python-list, I'll assume you currently intend writing this in Python; you can make a really simple transition from single-user-single-desktop to a networked system, although of course you'll want to think in terms of multiple users from the start. All you need to do is pick a database engine at the top of the script. As a general rule, I would say that it's okay to have more complicated installation instructions for a more demanding job, so you can have the single-user setup done with SQLite3 (no need to install a database and worry about passwords), but for the multi-user setup, they have to install (say) PostgreSQL on a single central server, and then possibly key in some authentication on each client (or even maybe not, depending on how much you trust the LAN - you did say there's no internet exposure). This is going to be comparable difficulty to setting up a centralized web server, but with the advantage that you can short-cut the whole thing when it's to be used on only one computer (not really possible with a browser-based system). Your UI would, obviously, be absolutely the same for both scenarios - it'd be all the same code, doing exactly the same things. (Obviously you'd have to make sure your SQL isn't specific to either engine, but that's easy enough. You won't warp your code much around that.) The only difference would be if you have to worry about update conflicts and other inherently multi-user issues, but ultimately there's no difference between the multi-user scenario where nobody else happens to be doing anything, and the dedicated single-user scenario. So, how big a task is it? If you're already familiar with the Python databasing API, and at least broadly familiar with a multi-user DBMS like PostgreSQL, and especially if you already know the important aspects of coping with simultaneous users, then this will be pretty easy - much easier than working it into a web browser. (And you'd need to worry about the issues of simultaneous users anyway. There's really no difference on that.) In terms of setup complexity for your users, it's *possible* that you could develop a low-performance web server that would be easier to deploy. You'd just need to either embed an HTTP server in your Python script, or use a framework that includes one; and if you make it single-threaded (ie all requests are serialized), you could use SQLite for the database back-end. In contrast, I'm suggesting a central database, which has to be installed and configured (most databases won't, by default, accept connections from anyone but localhost), which at very least will require a bit more chugging (you can automate all or at least most of it, but it'll still take time to install). The advantages are that you can trust your code (because it's all the same everywhere), and yet you have an extremely light single-user mode, plus your UI is flexible - you're not restricted to a web browser, you can build an actual application with whatever UI you like. And, in fact, you could have several different UIs, if you wanted to, because it's the database that's king. Maybe it'd be helpful to have a really REALLY cut-down UI for the basic data entry, with no clutter from the admin functions. It'd all work fine. (And you could add that later, without breaking anything.) It is, of course, possible to write a desktop application that can be remotely scripted for data entry. But I don't think it's necessary. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
Monte Milanuk writes: > I need to create a particular application for administering a sporting > event. 95% (and this may be understating the case) of the 'users' would > likely be single-machine, single user scenarios. For those exceptions > (which are important enough that I'm concerned over them) there would be > one person 'administering' the event and a small number of others > (probably <5, no more than 10) doing basic data entry - competitor > registration and later entering scores. Before (setting up event), in > between (squadding competitors based on classification, equipment, > available positions on relays, etc.) and taking care of final reports > for awards, etc. would be done only from the main program. The > end-users are likely not tech-saavy, and most likely running Windows or > maybe a Mac. Being able to do the data entry from a tablet would be > nice but by no means necessary. Installation needs to be as > stone-simple as possible - running from a pre-configured USB stick or a > browser would be ideal. Use would be over small wired or wi-fi LAN > enviroment - no exposure to Internet. I developed SoL[1] with almost the same goal, to manage Carrom tournaments. It started many years ago as a Windows only desktop application, but evolved into a much nicer and fun-to-develop web application, based on Python on the backend (using Pyramid and SQLAlchemy, with a SQLite database) and ExtJS on the frontend. That basically means that the backend may be installed with little effort on any Python-supported OS, and the frontend runs on most modern browsers. I manage small events with a single notebook and a low cost printer, without network connection, while major events with a network connection may be managed online. You can try it out at http://sol3.arstecnica.it/, using guest/guest as username/password. Hope this helps, ciao, lele. [1] https://pypi.python.org/pypi/SoL -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
RE: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
> -Original Message- > From: Python-list [mailto:python-list-bounces+michael.coll- > barth=verizonwireless@python.org] On Behalf Of Grant Edwards > Sent: Monday, July 21, 2014 10:27 AM > To: python-list@python.org > Subject: Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! > > On 2014-07-21, Chris Angelico wrote: > > > You call it a bug because you can't think of any way it could be > > beneficial. That's the wrong way of looking at it. Something isn't a > > bug because you find it annoying; it's a bug because it fails to > > implement the programmer's intentions and/or the docs/specification. > > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. > > -- I have to agree with Chris. A bug is what you call something that happens contrary to design or intent. Only. I build a program, regardless of the platform, with my intent, not yours. When it blows up or doesn't do what I want, then it's a bug and it's a bug even if there are no users for my program. Something that happens contrary to user expectations is an annoyance to that user. You might want to get your money back from those that taught you otherwise. BTW, there ain't no such thing as a 'reasonable' user. That's what they call an oxymoron. -- https://mail.python.org/mailman/listinfo/python-list
Installing Python 2.6.2 on Ubuntu 12.1
Question: How to install Python manually and make sure that all the necessary modules and .so files get built (eg: _sha256.so, zlib.so) Details: I am trying to install Python2.6.2 version manually, installation goes through fine, but later installing setuptools fails due to _sha256 Module not found. These are the steps I did for manually installing python in my private folder: 1. ./configure --help 2. ./configure --prefix=/home/brd/priv_env 3. make; make install The installation went through successfully, however I noticed that some of the _*.so files did not get built under lib/python2.6/lib-dynload/ folder (eg _sha256.so) , which is likely the reason why my setuptools install failed due to the error: " File "/home/cisco/priv_env/lib/python2.6/hashlib.py", line 138, in sha224 = __get_builtin_constructor('sha224') File "/home/cisco/priv_env/lib/python2.6/hashlib.py", line 66, in __get_builtin_constructor import _sha256 ImportError: No module named _sha256" Note that I have the necessary libraries installed on this machine eg: libzlib.so, libssl.so /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libssl3.so /usr/lib/x86_64-linux/gnu/libz.so.1 Another note, is that the standard python installation on this system (Python 2.7.3), does not have this problem, and has all the modules and .so files built. Sincere Regards, Behzad -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 2014-07-21, Shiyao Ma wrote: > No intent to pollute this thread. > > But really interested in the invalid@invalid.invalid mailing address. > And,,, obviously, I cannot send to invalid@invalid.invalid, so FWIW, my real e-mail address is at the bottom of every post. > How does you(he) make this? I execute the following slang code via my slrn startup file: username = "grant.b.edwards"; host = "gmail.com"; -- Grant Edwards grant.b.edwardsYow! Does someone from at PEORIA have a SHORTER gmail.comATTENTION span than me? -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 2014-07-21, Chris Angelico wrote: > On Tue, Jul 22, 2014 at 12:40 AM, Shiyao Ma wrote: >> No intent to pollute this thread. >> >> But really interested in the invalid@invalid.invalid mailing address. >> And,,, obviously, I cannot send to invalid@invalid.invalid, so >> >> How does you(he) make this? > > When you send email, you have to have a valid envelope-from address, > which can be found in the headers. But the From: address doesn't > technically have to be valid. Note that a lot of mail servers and/or spam filters will think it's spam if it isn't. > And if the email you received actually came from the news<->mail > gateway, It did. > then it's even less significant; the address used is simply whatever > Grant chose to key into his newsreader, which in this case is a > marker saying "Please don't email me, just follow-up to the group" :) If people really do want to e-mail me, that's fine. What I'm trying to avoid is people who e-mail my without knowing they're doing so because that's the default setting for whatever broken-by-design email client, web-UI, or newsreading they happen to be using. If people conciously want to e-mail me, all they can by using the address in my sig. -- Grant Edwards grant.b.edwardsYow! Wait ... is this a FUN at THING or the END of LIFE in gmail.comPetticoat Junction?? -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 2014-07-21, Mark Lawrence wrote: > On 21/07/2014 15:27, Grant Edwards wrote: >> On 2014-07-21, Chris Angelico wrote: >> >>> You call it a bug because you can't think of any way it could be >>> beneficial. That's the wrong way of looking at it. Something isn't a >>> bug because you find it annoying; it's a bug because it fails to >>> implement the programmer's intentions and/or the docs/specification. >> >> I was always taught that it's a "bug" is when a program doesn't do >> what a reasonable user expects -- that it's got nothing to do with the >> programmer's intent. > > As in my entire career I've never come across a "reasonable user" then > by that definition there are no bugs. Well done! -- Grant Edwards grant.b.edwardsYow! Hello. Just walk at along and try NOT to think gmail.comabout your INTESTINES being almost FORTY YARDS LONG!! -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On Mon, 21 Jul 2014 17:57:22 +0200, Lele Gaifax wrote: > Chris Angelico writes: > >> Take, for instance, the behaviour of Windows's cmd.exe editing keys: >> enter three commands, then up-arrow three times and hit enter, then >> press down, enter, down, enter. You'll repeat the three commands. In >> other interfaces (eg GNU readline), you'd do the same job by pressing >> up, up, up, enter each time. Personally, I find the cmd.exe behaviour >> extremely surprising, especially when I've been working with some very >> similar commands (imagine: ./configure some_bunch_of_args; make; >> some_command_to_test; rm -rf *; git checkout HEAD - then repeat with a >> different set of configure arguments), and I end up "stuck half way up >> command history", wondering why I'm not seeing what I wanted. Can be >> extremely awkward. But even so, I don't call this a bug. > > Granted, the readline library exposes a "operate-and-get-next" function, > by default bound to \C-o, with the same behaviour as the cmd.exe one. I > find it very handy in the scenario you picted. So again, "feature" and > "bug" may be effectively subjective :-) Have you actually got that working in Python with the readline module? I've tried and tried and cannot get it to work. Any hints gratefully appreciated. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 2014-07-21, Grant Edwards wrote: > On 2014-07-21, Shiyao Ma wrote: >> No intent to pollute this thread. >> >> But really interested in the invalid@invalid.invalid mailing address. >> And,,, obviously, I cannot send to invalid@invalid.invalid, so > > FWIW, my real e-mail address is at the bottom of every post. > >> How does you(he) make this? > > I execute the following slang code via my slrn startup file: > > username = "grant.b.edwards"; > host = "gmail.com"; Oops, I cut and pasted the wrong code: variable username = "invalid"; variable host="invalid.invalid"; set_string_variable("hostname", host); set_string_variable("username", username); -- Grant Edwards grant.b.edwardsYow! Was my SOY LOAF left at out in th'RAIN? It tastes gmail.comREAL GOOD!! -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
Steven D'Aprano writes: >> Granted, the readline library exposes a "operate-and-get-next" function, >> by default bound to \C-o, with the same behaviour as the cmd.exe one. I >> find it very handy in the scenario you picted. So again, "feature" and >> "bug" may be effectively subjective :-) > > Have you actually got that working in Python with the readline module? > I've tried and tried and cannot get it to work. Any hints gratefully > appreciated. I was pretty sure it worked when I revamped the readline support[1], many years ago, but effectively I'm not able to do it now, and I find this https://github.com/ipython/ipython/issues/41 where Chet Ramey says it's something that bash injects into the library... and that it should be easy to implement by the calling application. So I guess my memory is faulty. ciao, lele. [1] http://ftp.vim.org/languages/python/python/contrib-09-Dec-1999/System/Pyrl.README -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On Tue, Jul 22, 2014 at 2:55 AM, Grant Edwards wrote: > On 2014-07-21, Chris Angelico wrote: >> >> When you send email, you have to have a valid envelope-from address, >> which can be found in the headers. But the From: address doesn't >> technically have to be valid. > > Note that a lot of mail servers and/or spam filters will think it's > spam if it isn't. Yes, which is why I said "technically". Most often, a difference between envelope-from and From: header is because of a resending, like when Mailman sends mail on behalf of someone else; the From is still a valid address, but it's not the same one as the envelope-from (which will be the list-bounces address). That said, though, I've often telnetted to a mail server and done something like this: """ helo mail from: rcpt to: data From: me To: me Subject: Test Test! . quit """ Generally that sort of thing gets through. Sometimes it lands in a spam box, but more often it doesn't. I don't remember it ever getting rejected, other than for issues of relaying (which usually come from typoing the recipient domain). ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
On 2014-07-21, Chris Angelico wrote: > On Tue, Jul 22, 2014 at 2:07 AM, Monte Milanuk wrote: >> So I guess I'm asking for advice or simplified examples of how to >> go about connecting a client desktop app to a parent/master desktop app, >> so I can get some idea of how big of a task I'm looking at here, and >> whether that would be more or less difficult than trying to do the >> equivalent job using a web framework. > > Easier way: Don't have a "master desktop app", but instead have a > master database. Since you're posting this to python-list, I'll assume > you currently intend writing this in Python; you can make a really > simple transition from single-user-single-desktop to a networked > system, although of course you'll want to think in terms of multiple > users from the start. So... if everybody is using the same application to access the same database, how would you prevent say, a data entry user from accidentally breaking something above their pay-grade? Set up some sort of role-based privilege system to limit them to write access for some portions and read-only for others? Thanks, Monte -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
On 2014-07-21, Lele Gaifax wrote: > I manage small events with a single notebook and a low cost printer, > without network connection, while major events with a network connection > may be managed online. > > You can try it out at http://sol3.arstecnica.it/, using guest/guest as > username/password. Wow. I have no idea how the game/events run, but that is a very nice looking program! How hard was it to migrate from a desktop app to what you have now? Would you recommend this route for someone starting out? Monte -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
On Tue, Jul 22, 2014 at 4:16 AM, Monte Milanuk wrote: > On 2014-07-21, Chris Angelico wrote: >> On Tue, Jul 22, 2014 at 2:07 AM, Monte Milanuk wrote: >>> So I guess I'm asking for advice or simplified examples of how to >>> go about connecting a client desktop app to a parent/master desktop app, >>> so I can get some idea of how big of a task I'm looking at here, and >>> whether that would be more or less difficult than trying to do the >>> equivalent job using a web framework. >> >> Easier way: Don't have a "master desktop app", but instead have a >> master database. Since you're posting this to python-list, I'll assume >> you currently intend writing this in Python; you can make a really >> simple transition from single-user-single-desktop to a networked >> system, although of course you'll want to think in terms of multiple >> users from the start. > > So... if everybody is using the same application to access the same > database, how would you prevent say, a data entry user from accidentally > breaking something above their pay-grade? Set up some sort of > role-based privilege system to limit them to write access for some > portions and read-only for others? That would be one way, yes. The first question you'd need to ask is: How do you know who's data-entry and who's admins? As soon as you solve that (probably with some sort of login), you tie the access level to that. If you need absolute security, you would have the user enter a login and password which would actually be the database credentials. Then you grant exact rights in the database manager, permitting ONLY what that user is allowed to do. It's then utterly impossible, even for someone who knows Python and SQL, to do damage. But more likely, what you really want is a cut-down UI that simplifies things: if the user is data-entry level, you take away all the admin-type options. It might be possible to fiddle around in internals and gain elevated access, but that's not an issue in many environments. In any case, these are issues you'd need to figure out regardless of the development model. Ultimately, you could treat the entire computer, network, database, etc as a black box, and just look at two entities: the human, and the UI s/he is using. All permissions issues can be explained at that level. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Idle's Shell: prompts and indents (was ...) Idle users please read
On 7/21/2014 6:56 AM, Chris Angelico wrote: On Mon, Jul 21, 2014 at 7:00 PM, Terry Reedy wrote: In general, Idle should execute user code the same way that the interpreter does, subject to the limitations of the different execution environment. Agreed, but I think the setting of prompts is a "different execution environment" case. It's a fundamental difference between batch mode and interactive, and Idle uses batch mode to implement interactive mode. So something like: sys.ps1="Python> " "Setting sys.ps1 has no effect in Idle; see the Options menu." It might not be possible, but if it is, it wouldn't break any actual viable use-cases. It would be a lot of work for close to 0 gain. It could not work consistent without special-casing sys assignments. Consider >>> prompt1 = 'Me>' >>> setps1 = sys.ps1 >>> setps1(prompt1) ;-(. Idle cannot exactly imitate the interactive interpreter (II) because it does not execute code in exactly the same way. For instance, http://bugs.python.org/issue21997 reported that fact that the sequence >>>def dodebug(): pdb.set_trace() >>>dodebug() behaves differently in Idle and II. Not knowing the details of Idle (currently only available in the code), the OP claimed that this is an Idle bug. It turns out that running dodebug indirectly >>> def run_code(code): exec(code, globals()) >>> run('dodebug()') *in the II* behaves like Idle. The above is essentially how Idle runs code. (The difference is that it substitutes a custom namespace designed to look like the globals() of a main modules, include having __name__ == '__main__'.) Well, at least I know now, so I know how to review claims that Idle is buggy when it acts a bit differently than the II. The exec abstraction has a few tiny leaks if one looks hard enough, such as with the debugger. Using inspect to look at the frame stack would also show a difference. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Idle's Shell: prompts and indents (was ...) Idle users please read
On Tue, Jul 22, 2014 at 4:30 AM, Terry Reedy wrote: > It would be a lot of work for close to 0 gain. It could not work consistent > without special-casing sys assignments. The latter doesn't much matter (this is just a theory to help people realize what they've done, not an actual preventative - it's like if someone types "quit" and it comes back with a custom repr that tells them about quit() or EOF), but the former is the important bit here. Not a big deal, not worth a huge amount of effort. At best, this is something to docket away as "here's another thing that we could do if we had an equivalent for @property at module-level", nothing more. (Because with that, it would be pretty easy.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Event loop documentation error
I was reading https://docs.python.org/3/library/asyncio-eventloop.html#example-set-signal-handlers-for-sigint-and-sigterm and wanted to test the example, however, I am getting this error when I run the code; Traceback (most recent call last): File "C:/Users/gorki/Documents/Python Scripts/as-io.py", line 14, in loop.add_signal_handler(SIGINT, partial(ask_exit, "SIGINT")) File "C:\Python34\lib\asyncio\events.py", line 329, in add_signal_handler raise NotImplementedError NotImplementedError I was wondering if there is something I am doing wrong, or is this behaviour platform specific (I am on windows 7). I wanted to ask in the list before I file a bug report. -- http://ysar.net/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Event loop documentation error
On Tue, Jul 22, 2014 at 4:38 AM, Yaşar Arabacı wrote: > Traceback (most recent call last): > File "C:/Users/gorki/Documents/Python Scripts/as-io.py", line 14, in > > loop.add_signal_handler(SIGINT, partial(ask_exit, "SIGINT")) > File "C:\Python34\lib\asyncio\events.py", line 329, in add_signal_handler > raise NotImplementedError > NotImplementedError > > I was wondering if there is something I am doing wrong, or is this > behaviour platform specific (I am on windows 7). I wanted to ask in > the list before I file a bug report. SIGINT is a Unix signal. There is an equivalent for Windows, but it wouldn't at all surprise me if trying to hook signals raises NotImplementedError. See if there's a different way to hook Ctrl-C on Windows; if not, you may want to word your report as a feature request. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Event loop documentation error
-- Forwarded message -- From: Yaşar Arabacı Date: 2014-07-21 21:54 GMT+03:00 Subject: Re: Event loop documentation error To: Chris Angelico 2014-07-21 21:45 GMT+03:00 Chris Angelico : > SIGINT is a Unix signal. There is an equivalent for Windows, but it > wouldn't at all surprise me if trying to hook signals raises > NotImplementedError. See if there's a different way to hook Ctrl-C on > Windows; if not, you may want to word your report as a feature > request. > > ChrisA After reading the next page of the documentation, I realized that "add_signal_handler() and remove_signal_handler() are not supported" on Windows. Moreover, dev3.5 version of the docs are also saying that they are not supported, so I think they are not planning to supports those features on Windows anytime soon. In that case, should I make a bug report on docs that it should be mentioned on example that this feature is not supported on Windows. As for the feature request, I think there is a good reason that they didn't include it already. I will try to look into it, before making a feature request. -- http://ysar.net/ -- http://ysar.net/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Event loop documentation error
On Tue, Jul 22, 2014 at 4:55 AM, Yaşar Arabacı wrote: > After reading the next page of the documentation, I realized that > "add_signal_handler() and remove_signal_handler() are not supported" > on Windows. Moreover, dev3.5 version of the docs are also saying that > they are not supported, so I think they are not planning to supports > those features on Windows anytime soon. If I had to guess, I would say that the reason there's no Windows Ctrl-C handler would simply be that nobody's yet volunteered to write one. So you might be in a position to add what you want to 3.5 :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Event loop documentation error
On 21/07/2014 20:00, Chris Angelico wrote: On Tue, Jul 22, 2014 at 4:55 AM, Yaşar Arabacı wrote: After reading the next page of the documentation, I realized that "add_signal_handler() and remove_signal_handler() are not supported" on Windows. Moreover, dev3.5 version of the docs are also saying that they are not supported, so I think they are not planning to supports those features on Windows anytime soon. If I had to guess, I would say that the reason there's no Windows Ctrl-C handler would simply be that nobody's yet volunteered to write one. So you might be in a position to add what you want to 3.5 :) ChrisA I'd check the bug tracker before doing anything. It's perfectly possible that somebody has already done this but the patch hasn't been reviewed yet. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Event loop documentation error
On Tue, Jul 22, 2014 at 5:15 AM, Mark Lawrence wrote: > On 21/07/2014 20:00, Chris Angelico wrote: >> >> On Tue, Jul 22, 2014 at 4:55 AM, Yaşar Arabacı >> wrote: >>> >>> After reading the next page of the documentation, I realized that >>> "add_signal_handler() and remove_signal_handler() are not supported" >>> on Windows. Moreover, dev3.5 version of the docs are also saying that >>> they are not supported, so I think they are not planning to supports >>> those features on Windows anytime soon. >> >> >> If I had to guess, I would say that the reason there's no Windows >> Ctrl-C handler would simply be that nobody's yet volunteered to write >> one. So you might be in a position to add what you want to 3.5 :) >> >> ChrisA >> > > I'd check the bug tracker before doing anything. It's perfectly possible > that somebody has already done this but the patch hasn't been reviewed yet. Or that, yes. My point is, I doubt there's a strong philosophical reason for there to be a lack of support, but merely that it hasn't been done yet. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!
On 7/21/2014 10:27 AM, Grant Edwards wrote: On 2014-07-21, Chris Angelico wrote: You call it a bug because you can't think of any way it could be beneficial. That's the wrong way of looking at it. Something isn't a bug because you find it annoying; it's a bug because it fails to implement the programmer's intentions and/or the docs/specification. I was always taught that it's a "bug" is when a program doesn't do what a reasonable user expects -- that it's got nothing to do with the programmer's intent. For the Python issue tracker at bugs.python.org, one definition of a behavior ('bug') issue, one that might lead to a patch in maintenance releases of current versions, is a discrepancy between doc claim and code behavior. Discrepancies can be fixed by changing either doc or code to match the other, depending on which is considered to be wrong. Of course, sometime the doc is absent, partial, ambiguous, or confusing. People (such as Rick) proposing enhancements often consider matching code and doc to be buggy by design. But this is different type of issue. For Idle, the doc briefly specifies behavior at a high, user level. File / open should 'open an existing file'. A text box for entry of a path would minimally suffice. The current open file dialog adds the option of filling in the box by clicking around the directory tree. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
How to extract digit from a number?
Hi, I see the following example on line, but it does not work. I do not know what is wrong. Could you correct it for me? Thanks, I'm not sure what [1, 1, 0, 0, 0, 0, ...] has to do with 128, but if you want the base 10 digits: >>> a = 1234 >>> [int(d) for d in str(a)] >>> [1, 2, 3, 4] -- https://mail.python.org/mailman/listinfo/python-list
Re: How to extract digit from a number?
On 2014-07-21 13:14, fl wrote: > I see the following example on line, but it does not work. I do not > know what is wrong. Could you correct it for me? > > I'm not sure what [1, 1, 0, 0, 0, 0, ...] has to do with 128, but > if you want the base 10 digits: > > >>> a = 1234 > >>> [int(d) for d in str(a)] > >>> [1, 2, 3, 4] You don't specify *what* is wrong or what constitutes "does not work". If you provide an example of what you *do* want, folks here can help you get closer to the code you need to do what you intend. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: How to extract digit from a number?
On Monday, July 21, 2014 4:26:25 PM UTC-4, Tim Chase wrote: > On 2014-07-21 13:14, fl wrote: > You don't specify *what* is wrong or what constitutes "does not > work". If you provide an example of what you *do* want, folks here > can help you get closer to the code you need to do what you intend. > > -tkc The original source input is: >>> a = 1234 >>> [int(d) for d in str(a)] He hopes the output is: >>> [1, 2, 3, 4] In fact, I get the output is: >>> a = 1234 >>> [int(d) for d in str(a)] Traceback (most recent call last): File "", line 1, in TypeError: 'str' object is not callable BTW, I just add input: >>> import string The error is still there. Why does it say :"TypeError: 'str' object is not callable"? -- https://mail.python.org/mailman/listinfo/python-list
How to use string constant?
Hi, I learn string constant on Python tutorial at: https://docs.python.org/2/library/string.html Although it gives explanation, it does not show me any example usage. Could you give me an example on using these options? string.digits string.ascii_letters Thanks, -- https://mail.python.org/mailman/listinfo/python-list
Re: How to extract digit from a number?
In article , fl wrote: > >>> a = 1234 > >>> [int(d) for d in str(a)] > Traceback (most recent call last): > File "", line 1, in > TypeError: 'str' object is not callable This looks like you've overwritten str with an *instance* of a string. When a python interpreter starts up, there are certain pre-defined symbols. For example, 'str' is bound to the string class. But, there's nothing to prevent you from re-defining it. Here's an example which produces the same result you got: - $ python Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> str = "foo" >>> a = 1234 >>> [int(d) for d in str(a)] Traceback (most recent call last): File "", line 1, in TypeError: 'str' object is not callable - -- https://mail.python.org/mailman/listinfo/python-list
Re: How to extract digit from a number?
On 2014-07-21 13:42, fl wrote: > The original source input is: > >>> a = 1234 > >>> [int(d) for d in str(a)] > > He hopes the output is: > >>> [1, 2, 3, 4] > > In fact, I get the output is: > > >>> a = 1234 > >>> [int(d) for d in str(a)] > Traceback (most recent call last): > File "", line 1, in > TypeError: 'str' object is not callable This sounds suspiciously like you have shadowed the str() function. You might search your code for something like str = "test" which shadows the built-in str() function. The code you have works at the command-line as long as you haven't shadowed the previously-existing str() function: $ python Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 1234 >>> [int(d) for d in str(a)] [1, 2, 3, 4] -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
Monte Milanuk writes: > On 2014-07-21, Lele Gaifax wrote: >> I manage small events with a single notebook and a low cost printer, >> without network connection, while major events with a network connection >> may be managed online. >> >> You can try it out at http://sol3.arstecnica.it/, using guest/guest as >> username/password. > > Wow. I have no idea how the game/events run, but that is a very nice > looking program! Thank you! > How hard was it to migrate from a desktop app to what you have now? Well, basically I rewrote everything, there's nothing in common. The original application was written in Delphi, using Paradox tables, no i18n, no multiuser, no PDF printouts... On the other hand, with Python is far easier to get something working, and databasing with SQLAlchemy is a pleasure. On the frontend, ExtJS is impressive, even if it has its own drawbacks. > Would you recommend this route for someone starting out? Yes, absolutely. You learn something that you can reuse over and over. Do not hesitate to ask for further hints. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Re: Event loop documentation error
On 7/21/2014 2:38 PM, Yaşar Arabacı wrote: I was reading https://docs.python.org/3/library/asyncio-eventloop.html#example-set-signal-handlers-for-sigint-and-sigterm and wanted to test the example, With 3.4.0, 3.4.1, or 3.5.0a0 in the repository (available to view at hg.python.org, I believe)? Asyncio is patched at least once a week You can access the latest version of the 3.5 docs online (see the box in upper left corner) also to check how the example is written today. however, I am getting this error when I run the code; Traceback (most recent call last): File "C:/Users/gorki/Documents/Python Scripts/as-io.py", line 14, in loop.add_signal_handler(SIGINT, partial(ask_exit, "SIGINT")) File "C:\Python34\lib\asyncio\events.py", line 329, in add_signal_handler raise NotImplementedError NotImplementedError I was wondering if there is something I am doing wrong, or is this behaviour platform specific (I am on windows 7). I wanted to ask in the list before I file a bug report. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: How to use string constant?
On 7/21/2014 4:46 PM, fl wrote: Hi, I learn string constant on Python tutorial at: https://docs.python.org/2/library/string.html Although it gives explanation, it does not show me any example usage. Could you give me an example on using these options? string.digits string.ascii_letters >>> import string >>> 'a' in string.ascii_letters True >>> 'a' in string.digits False -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
asyncip application hangs
I am trying to grasp how asyncio works today. Based on the examples that I found on the docs, I write a simple program like this; import asyncio import urllib.request import urllib.parse @asyncio.coroutine def print_status_code(url_q): while True: url = yield from url_q.get() print('URL recieved from q:', url) if url is None: return url = urllib.parse.urlsplit(url) reader, writer = yield from asyncio.open_connection(url.hostname, 80) query = ('GET {url.path} HTTP/1.0\r\n' 'Host: {url.hostname}\r\n' '\r\n').format(url=url) writer.write(query.encode('latin-1')) line = yield from reader.readline() code = line.decode('latin1').split()[0] print("(%s) %s", code, url.path) if __name__ == "__main__": from bs4 import BeautifulSoup as bs sitemap = urllib.request.urlopen('http://ysar.net/sitemap.xml').read() soup = bs(sitemap) print('soup created') tasks = [] num_coroutines = 10 q = asyncio.Queue() for i in range(num_coroutines): # start 10 tasks tasks.append(asyncio.Task(print_status_code(q))) for loc in soup.find_all('loc'): q.put(loc.string) for i in range(num_coroutines): # Put poison pil. q.put(None) loop = asyncio.get_event_loop() loop.run_until_complete(asyncio.wait(tasks)) This program is supposed to give me status codes for web pages that are found on my sitemap.xml file. But program hangs as Tasks wait for getting something out of the Queue. I think it has something to do with how I am using asyncio.Queue, but I couldn't figure out what am I doing wrong here. Can anyone help me with that? -- http://ysar.net/ -- https://mail.python.org/mailman/listinfo/python-list
Re: asyncip application hangs
2014-07-22 1:19 GMT+03:00 Yaşar Arabacı : > This program is supposed to give me status codes for web pages that > are found on my sitemap.xml file. But program hangs as Tasks wait for > getting something out of the Queue. I think it has something to do > with how I am using asyncio.Queue, but I couldn't figure out what am I > doing wrong here. Can anyone help me with that? Ok, I figured out what was wrong with my code. Since asyncio.Queue.put() is a coroutine, I should have wrapped those with asyncio.Task in order for them to start executing. Therefore, this works; q = asyncio.Queue() loop = asyncio.get_event_loop() for i in range(num_coroutines): # start 10 tasks tasks.append(asyncio.Task(print_status_code(q))) for loc in soup.find_all('loc'): asyncio.Task(q.put(loc.string)) for i in range(num_coroutines): # Put poison pil. asyncio.Task(q.put(None)) print("%i items in queue" % q.qsize()) loop.run_until_complete(asyncio.wait(tasks)) -- http://ysar.net/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
On 2014-07-21, Lele Gaifax wrote: > Monte Milanuk writes: >> How hard was it to migrate from a desktop app to what you have now? > > Well, basically I rewrote everything, there's nothing in common. The > original application was written in Delphi, using Paradox tables, no > i18n, no multiuser, no PDF printouts... On the other hand, with Python > is far easier to get something working, and databasing with SQLAlchemy > is a pleasure. On the frontend, ExtJS is impressive, even if it has its > own drawbacks. Any hints/opinions on what those drawbacks might be? I know literally almost nothing about JS. I worked thru a short generic tutorial a couple years ago, but nothing like these libraries I see people talking about now like jquery, angular, ext, and so on. Hence my hesitation at adding another learning curve on top of python and the various libraries needed for this first 'real' project. Monte -- https://mail.python.org/mailman/listinfo/python-list
A Pythonista Meets JavaScript™ (was: Network/multi-user program)
Monte Milanuk writes: > I know literally almost nothing about JS. At the Melbourne Python Users's Group this year, I gave a presentation http://vimeo.com/album/2855296/video/93691338> on my initial learnings of JavaScript™ (and ECMAScript) from a Python programmer's perspective. Hope that's useful to anyone interested in the intersection of these languages and their cultures. -- \ “If consumers even know there's a DRM, what it is, and how it | `\ works, we've already failed.” —Peter Lee, Disney corporation, | _o__) 2005 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
In article , Monte Milanuk wrote: > Any hints/opinions on what those drawbacks might be? I know literally > almost nothing about JS. I worked thru a short generic tutorial a couple > years ago, but nothing like these libraries I see people talking about > now like jquery, angular, ext, and so on. Hence my hesitation at adding > another learning curve on top of python and the various libraries needed > for this first 'real' project. In the beginning, there was javascript. It was used to do cutesy little things like animated U/I elements and perform certain actions when your browser detected events like clicking on a button or moving the mouse cursor over an image. But, javascript is a real (if bletcherous) programming language. It's got functions and variables and loops and if statements and classes (OK, it doesn't really have classes, but it has things that we can pretend are classes, if we squint hard). It can talk to the network and generate HTML on the fly. So, people started building a whole new kind of web site. Instead of having an application running on the server which spits out HTML and CSS, and little bits of javascript to tweak those, we've got a full-blown javascript application running in the browser. That application is retrieving data from the server, doing useful things with it, and totally managing the HTML that you see rendered in your browser window. Things like jquery and (even more so) angular, backbone, ember, etc, are frameworks which make it easier to write these applications, in much the same way frameworks like django make it easier to write server-side web applications in Python. The truly sucky part of this picture is that javascript is a horrible language, but you have no choice. It's the only thing that runs in browsers. On the server side, if you don't like Python, you can write your app in Java, or Go, or Ruby, or a host of other languages (even javascript, if you want). On the client side, no so much. -- https://mail.python.org/mailman/listinfo/python-list
async, on-demand lazy rendering for jinja2 possible?
Hi all, Been reading @igrigorik's posts https://www.igvita.com/archives/ I found that flush response as early as possible is crucial for a website performance. I wanna make Time To First Byte (TTTFB) happen as early as possible with a Jinja2 site, Suppose a typical Jinja2 template: {{ site_title }} {% for item in items %} item {% endfor %} Let's presume site_title is static and known in view function from the start, I wanna flush everything before to the client as early as possible, then items was a query from db, it's kinda slower, let's flush the everything below later in a second TCP packet. This looks like impossible at the moment. I searched the Jinja2 docs, the closest thing I've found is the streaming template API jinja2.Template('Hello {{ name }}!').stream(name='foo') Which still requires all variables to be ready before rendering. Is there a way to stream partial template results with partial template variables? This would be great help making faster websites. Other template engine than Jinja2 is welcome as long as it's in python! Thanks in advance! -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing Python 2.6.2 on Ubuntu 12.1
Greetings, > The installation went through successfully, however I > noticed that some of the _*.so files did not get built under > lib/python2.6/lib-dynload/ folder (eg _sha256.so) , which is likely the reason > why my setuptools install failed due to the error: I believe you need the developer libraries for that (including the C header files). IIRC "sudo apt-get build-dep python" should install all the required packages. HTH, -- Miki -- https://mail.python.org/mailman/listinfo/python-list
Unicode, stdout, and stderr
Hi all This is not important, but I would appreciate it if someone could explain the following, run from cmd.exe on Windows Server 2003 - C:\>python Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (In tel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = '\u2119' >>> x # this uses stderr '\u2119' >>> print(x) # this uses stdout Traceback (most recent call last): File "", line 1, in File "C:\Python34\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in position 0: character maps to >>> It seems that there is a difference between writing to stdout and writing to stderr. My questions are - 1. What is the difference? 2. Is there an easy way to get stdout to behave the same as stderr? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
Monte Milanuk writes: > On 2014-07-21, Lele Gaifax wrote: >> Monte Milanuk writes: >>> How hard was it to migrate from a desktop app to what you have now? >> >> Well, basically I rewrote everything, there's nothing in common. The >> original application was written in Delphi, using Paradox tables, no >> i18n, no multiuser, no PDF printouts... On the other hand, with Python >> is far easier to get something working, and databasing with SQLAlchemy >> is a pleasure. On the frontend, ExtJS is impressive, even if it has its >> own drawbacks. > > Any hints/opinions on what those drawbacks might be? I know literally > almost nothing about JS. I worked thru a short generic tutorial a couple > years ago, but nothing like these libraries I see people talking about > now like jquery, angular, ext, and so on. Hence my hesitation at adding > another learning curve on top of python and the various libraries needed > for this first 'real' project. I completely agree with Roy on the language itself, it has several tricky parts that require some training to learn how to avoid, "defects" that are inherent to language and to the syntax, that no framework or library can really eliminate. There is a very good book by Douglas Crockford, "JS: the good parts" that I recommend reading. On the framework, ExtJS is the one I know better and its quite good and powerful: it has a dual license, GPL for free software projects and a commercial version, very good documentation and a lot of users. My main complaint is about their (Sencha's) release policy which frankly sucks, on both sides (free and commercial): they do not have a clear roadmap, you report bugs in a forum and from then on you cannot know if and when the bug gets fixed, or even released. They do not promise any kind of backward compatibility, and several times they irremediably broke the internal implementation of a few widgets I used from one minor version to the next and eventually released a proper fix only for the commercial version. They assert to have an extensive suite of unit and functional tests, but sometime I have the doubt they do not run it as often as one would expect :-) On the other hand, it has good and extensive examples, so the learning curve is not so steep (I'm clearly biased here, but I introduced several young developers to that environment and that's what they said too). Anyway, don't be scared: start on the Python side, laying down the foundations of the application, the database model, the main business logic, unit and functional tests, and so on. Any kind of frontend, be it a traditional desktop application or a web based one will build on that. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Re: Network/multi-user program
> > almost nothing about JS. I worked thru a short generic tutorial a couple > Please check Pyjs and Python with flash in http://pyjs.org/examples/Space.html for the front end part of GUI under a browser. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode, stdout, and stderr
"Frank Millman" writes: > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit > (In > tel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. x = '\u2119' x # this uses stderr > '\u2119' print(x) # this uses stdout > Traceback (most recent call last): > File "", line 1, in > File "C:\Python34\lib\encodings\cp437.py", line 19, in encode > return codecs.charmap_encode(input,self.errors,encoding_map)[0] > UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in > position > 0: character maps to No, both statements actually emit noise on the standard output, but the former prints the *repr* of the string, the latter tries to encode it to CP437, which you console seems to be using. One approach could be changing the "code page" (that is, the encoding) of the "terminal" (see the "chcp" command), to select one that actually have that glyph. But I'm really guessing here... ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Re: Top online steroid pharmacies - 2009 Best Site!
GET A GOOD LOOKING AND SEXY BODY HERE We are suppliers and whole sellers chemical supplements. BEFORE WE SUPPLY TO YOU MAKE SURE YOU ARE NOT UNDER 18. we supply chemical supplements such as HIGH QUALITY STEROID HORMONES, HGH ,SEX PILLS, HIGH QUALITY PAIN KILLERS, MEDICAL KUSH AND HIGH QUALITY KUSH, ACTIVIS PURPLE SYRUPS OF ALL CATEGORIES. we sell high quality KATAMIN, XANAX PILLS NEMBROTER and also some high quality weight loss products. Text or call us on (407)-4852249 Email: stuffstorehouse2014(AT)gmail.com We have agents located in the Germany , USA, Asia, and others.we sell high quality chemical supplements and at the best prices. we provide prescriptions to body builders and to those who are novice in the field, we do prescription for free. Text or call us on (407)-4852249 Email: stuffstorehouse2014(AT)gmail.com we also supply chemical supplements and also top quality powder and crystals such as -high quality 2ci and 2ce 2ci, 2CP 2CE ,2CB 2CD,FLY 2CC ,2CP 2CT21, 2CT4 Meo-crystal and powder 5-Meo-DMT 4-Aco-DMT 4-Ho-MIPT 5-Methylmethylone crystal and powder 5-Methylethylone 2-Methylbutylone 5-Methylbutylone Butylone Eutylone Pentylone -Grade(?.96) Mephedrone (2- methylamino 1-one also known as 4-methylmethcathinone(4-MMC).We are one of the top suppliers in wholesale and retail of mephedrone and Mephedrone crystal and powder methedrone Flephedrone Mathedrone Buphedrone Ethedrone Brephedrone Mdma and BK mdma crystals and powder methylone butylone NAPHYRONE MBDB Mdai 5-Methylmethylone crystal and powder 5-Methylethylone 2-Methylbutylone 5-Methylbutylone Butylone Eutylone Pentylone 4-MEC large and small crystals ( (RS)-1-(4-methylphenyl)- 2-methylaminopropan-1-one ). methamphetamine detrophetamine Ethcathinone Methoxetamine Dimethocaine Dimethylcathinone crystal and powder Diethylpropion Methcathinone Ethcathinone 3-MMC,3-MEC,3-EMC 3-EEC,4-EMC,4-EEC 3-MOMC,2-FMC,2-FEC,a-PVP 3-FMC,3-FEC,3-CMC, FPVP 3-BMC,N,N-DEMC,3,4-DMMC 4-MePPP,MOPPP, FPPP MPBP,MPHP,MDPPP, MDPBP Powder and crystals AM 2201 AM2202 am1220 am122 compliments of 2ci and 2ce 2ci, 2CP 2CE ,2CB 2CD,FLY 2CC ,2CP 2CT21, 2CT4 compliments of jwh- JWH-018 , JWH-250 JWH-018,JWH-073 JWH-200,JWH-250 JWH-240,jwh-350 compliments of Meo-crystal and powder 5-Meo-DMT 4-Aco-DMT 4-Ho-MIPT 4 Our quality is the best you can find around and we sell in small/large quantities with guaranteed discreet delivery in good time Shipping is done Via DHL TNT FedEx.Please Do Include Your Contact Number . All inquiries are welcomed at Text or call us on (407)-4852249 Email: stuffstorehouse2014(AT)gmail.com -- https://mail.python.org/mailman/listinfo/python-list