Using pycurl to obtain the download speed in real-time for a huge file.
Hi, I want to use pycurl to obtain the download speed in real-time for a huge file. Is this possible or not? Any hints on this issue? Regards -- .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. -- https://mail.python.org/mailman/listinfo/python-list
Remote/Pair-Programming in-the-cloud
Please recommend a Python-friendly, bandwidth-respectful, (but effective) system for pair-programming; where the 'pair' are geographically separate. Next week is the local PUG's next meeting (details below) billed as a "Python Hands-On Coding night". I shall be travelling, so can't attend in-person. The meeting organiser and I are investigating the possibility of offering remote 'support', enthusiastic at developing the prospect such extra flexibility may offer... The PUG will be meeting at the university. I will gain Internet access from another uni or through a café's wi-fi service. [I don't mind putting a bit of money into a good service, but $free for preference and F/LOSS for principle] I have surveyed various cloud-based services: - PythonAnywhere: Py3.6, used them in London (UK) perhaps one decade ago, team/"education" facility appears to work. Am checking with them... - PythonFiddle: doesn't seem to share - ShiftEdit: have been awaiting promised credentials-email all day... - CodeEnvy: Py3.5.1, doesn't seem to allow 'team' - IdeaOne: doesn't seem to share - UseTogether: off the air. - CodeAnywhere: 7-day trial free and tomorrow will be experimenting with: - AWS Cloud9: (apparently will run on a small, free, cloud-server) Then there is the possibility of installing a multi-user editor on my VPS or in an OpenStack PublicCloud instance: - Codiad: its need for PHP puts me off (haven't used/configured that language for >10yrs) and tomorrow will be reviewing: - Koding: (no longer offer their own server/services so looks-like I'll have to dredge-up my inner-SysAdmin - small children should look away now!) Do you have experience of such remote/shared/pair-programming facilities? Are you able to recommend software/a platform, please? *** Meeting ANN email/briefing: During these meetups, we pull out our own laptops and dig into coding something meaningful that works. We'll do a quick "round" at the start, where you can introduce yourself, your project, and any need for expertise you may have. People tend to wander around, checking out what others are using Python for, and giving ideas and tips where appropriate. Get ready to spend quality time on your own projects, on your own laptop, and catch up on what everyone else is doing. I'm going to be working on standing up a Python-based Solid Identity Platform (see https://www.infoq.com/news/2018/10/solid-identity-platform/) and you can work with us on your flashiest apps - which we will help you make perfect. *** (NB within the above quote, the "I" is the mtg organiser, not myself - although it does sound like an interesting topic...) -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Using pycurl to obtain the download speed in real-time for a huge file.
> On 2 Aug 2019, at 08:37, Hongyi Zhao wrote: > > Hi, > > I want to use pycurl to obtain the download speed in real-time for a huge > file. Is this possible or not? Yes > Any hints on this issue? Google for python pycurl progress Barry > > Regards > -- > .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 8/2/2019 5:10 AM, DL Neil wrote: Please recommend a Python-friendly, bandwidth-respectful, (but effective) system for pair-programming; where the 'pair' are geographically separate. 'geographically separate' could range from in the same room to a continent away, as long as two people have separate keyboards and screens. [I don't mind putting a bit of money into a good service, but $free for preference and F/LOSS for principle] IDLE is Python-friendly, free, and FOSS. I wonder how hard it would be to pair programming connectivity as an extension. A couple of questions: 1. Do the systems you have considered operate as an editor + satellite terminal or as synchronized peer editors. 2. Do two systems connect directly peer-to-peer or through a server? -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On Sat, Aug 3, 2019 at 6:34 AM Terry Reedy wrote: > > On 8/2/2019 5:10 AM, DL Neil wrote: > > Please recommend a Python-friendly, bandwidth-respectful, (but > > effective) system for pair-programming; where the 'pair' are > > geographically separate. > > 'geographically separate' could range from in the same room to a > continent away, as long as two people have separate keyboards and screens. Though there may be differences between LAN-optimized tools and internet-optimized ones. > > [I don't mind putting a bit of money into a good service, but $free for > > preference and F/LOSS for principle] > > > > IDLE is Python-friendly, free, and FOSS. I wonder how hard it would be > to pair programming connectivity as an extension. A couple of questions: > > 1. Do the systems you have considered operate as an editor + satellite > terminal or as synchronized peer editors. > > 2. Do two systems connect directly peer-to-peer or through a server? > Not the OP, but weighing in from personal experience: I've often pair programmed using just a video call service (with screen share). The biggest downside is that it has to share the full image of the screen, which means it has to aggressively compress the video in order to handle home-grade internet connections. (OTOH, that does mean that it's IDE-independent, and can showcase literally anything.) If IDLE were to grow a peer-to-peer pair programming feature, I could imagine it being a text-only connection with a single master and any number of slaves, where the slaves are showing a replica of the master's screen. IMO the slaves should not need any way to directly manipulate anything, though it may be of value to be able to highlight a block of text and have the master see that highlight (independently of the master's own text selection). Having everyone able to edit simultaneously creates technological problems, and then a social problem (when you start trampling over each other's code by mistake), and the solution to the social problem usually amounts to a semaphore system "okay, you go ahead and take over"; baking that semaphore into the technology (by having only a single master) would keep things way simpler. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 3/08/19 8:32 AM, Terry Reedy wrote: On 8/2/2019 5:10 AM, DL Neil wrote: Please recommend a Python-friendly, bandwidth-respectful, (but effective) system for pair-programming; where the 'pair' are geographically separate. 'geographically separate' could range from in the same room to a continent away, as long as two people have separate keyboards and screens. True! As long as the tech works... My experience has always been two sharing one PC, ie taking-it-in-turns to think or to type. Do you do it differently? [I don't mind putting a bit of money into a good service, but $free for preference and F/LOSS for principle] Intended to show the survey so-far (has he done his own 'homework'?), to save us from 'red herrings' but also to see if other approaches might exist. (such as your next thought...) IDLE is Python-friendly, free, and FOSS. I wonder how hard it would be to pair programming connectivity as an extension. A couple of questions: 1. Do the systems you have considered operate as an editor + satellite terminal or as synchronized peer editors. Always the former, the local devices are merely 'repeaters' (through a web browser) of what is happening on the server. This at both edit and run/test stages. 2. Do two systems connect directly peer-to-peer or through a server? Exclusively the latter (thus far in the investigation). -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to wrap a built-in function for the whole package?
functools.partial is a better option On Fri, Aug 2, 2019, 1:25 AM Cameron Simpson wrote: > On 31Jul2019 19:16, Jach Fong wrote: > >I get a package from Pypi. The package has many modules using built-in > open() function. I like to redefine all the open() there with the default > encoding 'utf-8', but not for code outside the package. Maybe I can put my > def statement at the beginning of every module of this package, but just > wondering is there a simple way of doing it? > > I would define something like this in the __init__.py file of the > package (or in some utils.py file in the package): > > def open8(path): > return open(path, encoding='utf-8') > > and just: > > from . import open8 > > and use "open8" throughout the code instead of "open"? > > What not alias "open"? Because I would want it evident that in this code > we're doing a slightly special flavour of open. By using a distinct name > I avoid confusion about the unusual semantics. > > Cheers, > Cameron Simpson > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 3/08/19 8:44 AM, Chris Angelico wrote: On Sat, Aug 3, 2019 at 6:34 AM Terry Reedy wrote: On 8/2/2019 5:10 AM, DL Neil wrote: Please recommend a Python-friendly, bandwidth-respectful, (but effective) system for pair-programming; where the 'pair' are geographically separate. 'geographically separate' could range from in the same room to a continent away, as long as two people have separate keyboards and screens. Though there may be differences between LAN-optimized tools and internet-optimized ones. Correct! Koding (on my ToDo list for today) no longer offers a web-based service but offers a download for Docker or Kubernetes (or ???). The communications lag has been my biggest concern since we opened the investigation... Not the OP, but weighing in from personal experience: I've often pair I'm hoping for more responses recounting personal experience, especially if it involves a stern warning for my sanity! (oops, too late!) programmed using just a video call service (with screen share). The TeamViewer, and similar? I didn't mention this earlier, perhaps being carried-away by my enthusiasm for 'there must be a better way'... biggest downside is that it has to share the full image of the screen, which means it has to aggressively compress the video in order to handle home-grade internet connections. (OTOH, that does mean that it's IDE-independent, and can showcase literally anything.) If IDLE were to grow a peer-to-peer pair programming feature, I could imagine it being a text-only connection with a single master and any number of slaves, where the slaves are showing a replica of the master's screen. IMO the slaves should not need any way to directly manipulate anything, though it may be of value to be able to highlight a block of text and have the master see that highlight (independently of the I have used VNC-type software to slave screens, either in pairs (tutorial - mine following a trainee's work) or in a 'class set' (using my screen as a 'projector'). It seemed both finicky and fragile and whilst working well on-the-LAN (ie in-class), was too slow and 'block-y' updating the screens when we used it for remote tutorials. (of course such [also] reveals that we didn't have very high-speed connections) During such, the VNC profiles were set so that trainees' I/O devices were 'locked' to prevent clashes. However, that need doesn't apply here and is actually contrary to the objectives... master's own text selection). Having everyone able to edit simultaneously creates technological problems, and then a social One of the encouraging features of many options (on list in earlier post) is the facility of "multiple cursors". At first this confused me, because many text editors allow one to declare "multiple cursors" in order to perform the same action at multiple locations throughout the same source-file. In the pair-programming context, "multiple cursors" means exactly what you say: each contributor is able to work (relatively) independently of the other, and the system keeps track of who-is-doing-what! ("IDE-independent"?) problem (when you start trampling over each other's code by mistake), and the solution to the social problem usually amounts to a semaphore system "okay, you go ahead and take over"; baking that semaphore into the technology (by having only a single master) would keep things way simpler. Which is why I assumed the need for Zoom or similar audio connection (A/V 'on top' likely to overwhelm a wi-fi link)? None seem to offer that, however some do provide a "chat" window. Yes, the "semaphore" is going to be my biggest concern on the night. When done in-person, a lot can be communicated non-verbally (and, perhaps particularly in this country: rather informally, eg even a nudge of the elbow = 'move out of the way and let me in/I got this'). I'm thinking that such will require a greater degree of formality and courtesy. Radio operators are used to the discipline of letting the other person finish talking... Contrarily, that might be handled by agreed rôles and 'separation of concerns':- Many of these services store the source code (etc) 'in the cloud', plus each contributor can share or have his/her own editor screen (your "IDE-independent", above). So, it would also be possible for one to be designing tests concurrently with the other writing code. However, perhaps we're getting away from 'traditional' pair programming, and into the area of 'just because the technology enables us do it, doesn't mean it's a good idea'! OTOH the whole point of this investigation is to see what's 'out there' and be open to whatever if might enable us to do... Thanks for your wisdom. -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Fwd: Re: PEP: add a `no` keyword as an alias for `not`
On Aug 1, 2019, at 13:38, Daniel Okey-Okoro wrote: > > > > not a strong enough justification for breaking any code that uses "no" in > > any other way. > > This is a very crucial point I didn't consider. > > > > What if we could lexically limit it to `if no {{everything else in the if > block}}`? > > I think that would sufficiently protect us from unintentionally breaking > people's code. There are some cases where a “contextual keyword” that’s usable as an identifier outside of a specific syntactic construct could avoid ambiguity, but this isn’t one of them, because the thing immediately after the `if` in an if statement can be–and often is—an identifier. For example: total = len(votes) yes, no, other = (len(part) for part in partition_votes(votes)) if no >= total//2: # etc. I even found an actual example of the equivalent in some C++ code I had on my hard drive: if (no == ask(…)) { // … } In Python, that would be: if no == ask(…): Also, even if that weren’t a problem, this would be very misleading syntax. If I can write `if no sales:` I’d expect to be able to write `if isopen and no sales:` or `0 if no sales else mean(sales)` or `skip = no sales` or any of the other things I can do with `not` and other operators rather than special syntax. Also, I could still write `if no sales and isopen:`, but it would do the wrong thing if `no` is special syntax that reverses the sense of the `if` rather than a normal operator that binds more tightly than `and`. -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Fwd: Re: PEP: add a `no` keyword as an alias for `not`
A truly marvellous aspect of Python is its world-wide spread! Many people use Python with greater ease than they speak or write English, despite Python appearing to be a sub-set of the English language! Native English-speakers often* have difficulty following negatively-worded sentences, eg "if there were no sales". (* coming from certain cultures/languages this evaluation changes to: "usually"!) We, of the computing world, must become familiar with Boolean Algebra; and thus learn to compose a Truth-Table matrix in our heads. Psychologically this suggests we first seek "logic", and only thereafter "meaning" - is this "normal" behavior? (humor, not question) We are all familiar with the injunction: do not to use "double negatives" in a sentence, eg "I can't get no satisfaction" or "A rolling stone don't gather no moss"; because it confuses people - regardless of their English-language facility. (even more than 'big words' such as "facility" have the potential to reduce understanding!) In fact, to continue analysing our own specific language-skills, when we double-up on something, eg a BASH switch like -vv, doesn't that mean 'don't just -v, but do it MORE-SO'? Thus, doubling your negatives would mean: 'even more negative', surely? Is that what "English" says though? NB repetition, in both a positive, or negative, sense; means "more" in many cultures, even good, old English: "hear, hear!". Accordingly, I feel for the OP. Personally I dislike reading, and recoil from writing: if not something_positive: On the other hand: if something_positive: pass else: process_the_negative whilst acceptable, probably doesn't look or read any better. Perhaps an answer is to use a "flag": no_sales_today = total_sales <= 0 if no_sales_today: fire_the_sales_manager() The descriptive variable-name IS 'negative', but the if-condition becomes (somewhat) positive, removes the comprehension-reducing "not", and the construct remains a simple if-then (ie no -else). (it also uses "no" in the flow-of-communication, per OP's suggested line-of-thought) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On Sat, Aug 3, 2019 at 7:30 AM DL Neil wrote: > > On 3/08/19 8:44 AM, Chris Angelico wrote: > > programmed using just a video call service (with screen share). The > > TeamViewer, and similar? > I didn't mention this earlier, perhaps being carried-away by my > enthusiasm for 'there must be a better way'... Google Hangouts, or a proprietary internal platform ("Owl") which does similar things but is better able to handle different bandwidth connections. > I have used VNC-type software to slave screens, either in pairs > (tutorial - mine following a trainee's work) or in a 'class set' (using > my screen as a 'projector'). It seemed both finicky and fragile and > whilst working well on-the-LAN (ie in-class), was too slow and 'block-y' > updating the screens when we used it for remote tutorials. (of course > such [also] reveals that we didn't have very high-speed connections) Yeah, that would be basically what I'm talking about. It works fairly well with a trainer/trainee model, as the trainer wants to be "hands off" most of the time anyway (better to talk the trainee through doing it than to grab the keyboard and do it yourself), and the "projector" model you describe is definitely that style. > > master's own text selection). Having everyone able to edit > > simultaneously creates technological problems, and then a social > > One of the encouraging features of many options (on list in earlier > post) is the facility of "multiple cursors". > > At first this confused me, because many text editors allow one to > declare "multiple cursors" in order to perform the same action at > multiple locations throughout the same source-file. In the > pair-programming context, "multiple cursors" means exactly what you say: > each contributor is able to work (relatively) independently of the > other, and the system keeps track of who-is-doing-what! ("IDE-independent"?) That would NOT be IDE-independent, as it requires help from the software itself (what I'm talking about is the way screenshare can jump across to your browser, a running app, etc, etc, and it's exactly the same as being inside the IDE). Multiple cursors is exactly what I meant when I referred to the technical problem and the social problem. The technical problem (there's only one ipt and every keystroke affects that point) can be solved with multiple cursors, but you're still left with the social problem (one person changes something up here, another changes something down there, and your changes affect each other - or, one is editing what another person tries to indent). So I'm actually quite happy with a blanket solution to the social problem by saying "only one person can edit at a time" - and forcing people to commit/push/pull to transfer the code to a new driver - and using that to avoid needing to go to the technical effort of multiple ipts. > Which is why I assumed the need for Zoom or similar audio connection > (A/V 'on top' likely to overwhelm a wi-fi link)? None seem to offer > that, however some do provide a "chat" window. Yes, some sort of audio link is HUGELY helpful, even if you do have multiple cursors. You can synchronize over it ("Okay, lemme try something") and just bounce ideas back and forth. If your software is replicating the display, you don't need video, and an audio connection is way lower bandwidth (also, a little latency can be handled - it's no big deal if you have 100ms or 250ms lag on the audio if you have snappy text updates). > Yes, the "semaphore" is going to be my biggest concern on the night. > When done in-person, a lot can be communicated non-verbally (and, > perhaps particularly in this country: rather informally, eg even a nudge > of the elbow = 'move out of the way and let me in/I got this'). "Move, I have a kit" is occasionally effective even when said by your opponents... or maybe that's exclusive to Counter-Strike... anyhow. > I'm thinking that such will require a greater degree of formality and > courtesy. Radio operators are used to the discipline of letting the > other person finish talking... Right. Works quite well IME. Basically, what I'd be interested in seeing is a multi-player game of Notepad++, in contrast to IRC. http://www.bash.org/?85514 ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 3/08/19 8:57 AM, Dennis Lee Bieber wrote: On Fri, 2 Aug 2019 21:10:32 +1200, DL Neil declaimed the following: - AWS Cloud9: (apparently will run on a small, free, cloud-server) Cloud9 is normally available on BeagleBone Black cards (though you'd have to open up your firewalls and maybe set up a DNS entry so others can connect to it). However, that appears to be an older version (v3.1.4056, 2017), not the Amazon Web Services version, and does not appear to have the collaboration features described at https://docs.c9.io/docs/share-a-workspace There's a great idea - put a BBB in the middle! Thanks wlfraed - will be checking the AWS version... (they claim it will even work on a 'free' server, which presumably means it would last for a whole year!) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 3/08/19 10:34 AM, Chris Angelico wrote: On Sat, Aug 3, 2019 at 7:30 AM DL Neil wrote: On 3/08/19 8:44 AM, Chris Angelico wrote: Google Hangouts, or a proprietary internal platform ("Owl") which does similar things but is better able to handle different bandwidth connections. Thanks. Will add to the mix... I have used VNC-type software to slave screens, either in pairs (tutorial - mine following a trainee's work) or in a 'class set' (using my screen as a 'projector'). It seemed both finicky and fragile and whilst working well on-the-LAN (ie in-class), was too slow and 'block-y' updating the screens when we used it for remote tutorials. (of course such [also] reveals that we didn't have very high-speed connections) Yeah, that would be basically what I'm talking about. It works fairly well with a trainer/trainee model, as the trainer wants to be "hands off" most of the time anyway (better to talk the trainee through doing it than to grab the keyboard and do it yourself), and the "projector" model you describe is definitely that style. Yes. I would prefer something with a more collaborative mode - helpful rather than 'taking (over) the lead'... master's own text selection). Having everyone able to edit simultaneously creates technological problems, and then a social One of the encouraging features of many options (on list in earlier post) is the facility of "multiple cursors". At first this confused me, because many text editors allow one to declare "multiple cursors" in order to perform the same action at multiple locations throughout the same source-file. In the pair-programming context, "multiple cursors" means exactly what you say: each contributor is able to work (relatively) independently of the other, and the system keeps track of who-is-doing-what! ("IDE-independent"?) That would NOT be IDE-independent, as it requires help from the software itself (what I'm talking about is the way screenshare can jump across to your browser, a running app, etc, etc, and it's exactly the same as being inside the IDE). Agreed - and just because two could work 'independently'... (a) certainly doesn't make it a 'good idea'! and (b) doesn't strike me as "pair programming", particularly not in the context of a PUG meeting - as you say... Multiple cursors is exactly what I meant when I referred to the technical problem and the social problem. The technical problem (there's only one ipt and every keystroke affects that point) can be solved with multiple cursors, but you're still left with the social problem (one person changes something up here, another changes something down there, and your changes affect each other - or, one is editing what another person tries to indent). So I'm actually quite happy with a blanket solution to the social problem by saying "only one person can edit at a time" - and forcing people to commit/push/pull to transfer the code to a new driver - and using that to avoid needing to go to the technical effort of multiple ipts. Which is why I assumed the need for Zoom or similar audio connection (A/V 'on top' likely to overwhelm a wi-fi link)? None seem to offer that, however some do provide a "chat" window. Yes, some sort of audio link is HUGELY helpful, even if you do have multiple cursors. You can synchronize over it ("Okay, lemme try something") and just bounce ideas back and forth. If your software is replicating the display, you don't need video, and an audio connection is way lower bandwidth (also, a little latency can be handled - it's no big deal if you have 100ms or 250ms lag on the audio if you have snappy text updates). Thanks for this assessment. Yes, the "semaphore" is going to be my biggest concern on the night. When done in-person, a lot can be communicated non-verbally (and, perhaps particularly in this country: rather informally, eg even a nudge of the elbow = 'move out of the way and let me in/I got this'). "Move, I have a kit" is occasionally effective even when said by your opponents... or maybe that's exclusive to Counter-Strike... anyhow. Sorry, not a gamer. However, during 'the real thing' I wouldn't have dared to say such a thing to my buddy! (mind you, he was the unit's armorer) Most of the time they pushed me down/towards the back. One of the advantages of carrying the radios! (needed to tell the airedales where to direct their fire, and which RDV we're using - please, please, please come to take us home... Forget games, try music: "I wanna go home" or "I want to get out of this place"!) Although as "nav" I did get to say "move out". Close enough? I'm thinking that such will require a greater degree of formality and courtesy. Radio operators are used to the discipline of letting the other person finish talking... Right. Works quite well IME. Basically, what I'd be interested in seeing is a multi-player game of Notepad++, in contrast to IRC. http://www.bash.org/?85514 With the ability to frag your pair-programmer when (
Re: Remote/Pair-Programming in-the-cloud
On Sat, Aug 3, 2019 at 9:40 AM DL Neil wrote: > > Basically, what I'd be interested in seeing is a multi-player game of > > Notepad++, in contrast to IRC. http://www.bash.org/?85514 > > With the ability to frag your pair-programmer when (s)he makes a > mistake? Remind me never to 'pair' with you! > Oh certainly not, I don't condone team-killing :) More seriously: I did build a very simple "multi-player notepad", which I've used with various people at various times. It's simplistic and nothing like what you actually need for this job, but the concept is similar; any time you make a change, everyone sees that change. The communication channel is plain text, and it's rendered on each side locally. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 03Aug2019 11:39, DL Neil wrote: On 3/08/19 10:34 AM, Chris Angelico wrote: On Sat, Aug 3, 2019 at 7:30 AM DL Neil wrote: On 3/08/19 8:44 AM, Chris Angelico wrote: Google Hangouts, or a proprietary internal platform ("Owl") which does similar things but is better able to handle different bandwidth connections. Thanks. Will add to the mix... appear.in can also screen share along with its video conferencing, and I imagine Zoom might do so also. But a screen share is "read only" for the other party. You could both screen share of course, but it doesn't solve the keep-the-code-in-sync issue. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to wrap a built-in function for the whole package?
Batuhan Taskaya於 2019年8月3日星期六 UTC+8上午5時27分49秒寫道: > functools.partial is a better option > > On Fri, Aug 2, 2019, 1:25 AM Cameron Simpson wrote: > > > On 31Jul2019 19:16, Jach Fong wrote: > > >I get a package from Pypi. The package has many modules using built-in > > open() function. I like to redefine all the open() there with the default > > encoding 'utf-8', but not for code outside the package. Maybe I can put my > > def statement at the beginning of every module of this package, but just > > wondering is there a simple way of doing it? > > > > I would define something like this in the __init__.py file of the > > package (or in some utils.py file in the package): > > > > def open8(path): > > return open(path, encoding='utf-8') > > > > and just: > > > > from . import open8 > > > > and use "open8" throughout the code instead of "open"? > > > > What not alias "open"? Because I would want it evident that in this code > > we're doing a slightly special flavour of open. By using a distinct name > > I avoid confusion about the unusual semantics. > > > > Cheers, > > Cameron Simpson > > -- > > https://mail.python.org/mailman/listinfo/python-list > > Totally agree:-) --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP: add a `no` keyword as an alias for `not`
On 8/1/2019 4:06 PM, Daniel Okey-Okoro wrote: I think that adding a `no` keyword as an alias for `not` would make for more readable, simple, pythonic code. I am 99.99% sure that this would not be accepted. However, the discussion of the not operator is worth at least a blog post. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 8/2/2019 4:52 PM, DL Neil wrote: On 3/08/19 8:32 AM, Terry Reedy wrote: On 8/2/2019 5:10 AM, DL Neil wrote: Please recommend a Python-friendly, bandwidth-respectful, (but effective) system for pair-programming; where the 'pair' are geographically separate. 'geographically separate' could range from in the same room to a continent away, as long as two people have separate keyboards and screens. True! As long as the tech works... My experience has always been two sharing one PC, ie taking-it-in-turns to think or to type. Do you do it differently? I currently work on my home machine, so my recent 'pair programming' has been limited to comments and now diff suggestions on Github PRs. So I need the comments on real use cases from you and Chris to even think about something for IDLE. IDLE is Python-friendly, free, and FOSS. I wonder how hard it would be to pair programming connectivity as an extension. This was an initially pie-in-the-sky idea that cannot solve your immediate problem. But I think now that something useful could be feasible sometime. 1. Do the systems you have considered operate as an editor + satellite terminal or as synchronized peer editors. Always the former, the local devices are merely 'repeaters' (through a web browser) of what is happening on the server. This at both edit and Good. Master-satellite would be much easier. We added line numbers to IDLE's editor last week, so verbal feedback from satellite to master should be sufficient for many purposes. IDLE already intercepts keypresses to do syntax coloring and smart indentation (after \n). It should not be too hard to also send through a socket anything sent to a tkinter/tk text widget. Making a text read-only is trivial. With a real editor as satellite, the locally configured font face, font size, and syntax highlight colors can be used. Transmitting highlighting as text would require the invention of a protocol to differentiate text from such meta information. run/test stages. Running code locally would 1. Save bandwidth. 2. Allow two users to do different things occasionally. 3. Reveal OS dependencies if on different systems. When patching IDLE, I would love to have my Macbook set as a satellite to check that code works on Mac as well as Windows. 4. Require encryption of some sort if over the public internet. Just because people download code from strangers over http is not a reason to encourage carelessness. I am pretty ignorant on what this would mean. 2. Do two systems connect directly peer-to-peer or through a server? Exclusively the latter (thus far in the investigation). The former would be the only option until someone (else) set up and supported a server. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 8/2/2019 4:44 PM, Chris Angelico wrote: in response to my enquiries Not the OP, but weighing in from personal experience: I've often pair programmed using just a video call service (with screen share). The biggest downside is that it has to share the full image of the screen, which means it has to aggressively compress the video in order to handle home-grade internet connections. (OTOH, that does mean that it's IDE-independent, and can showcase literally anything.) If IDLE were to grow a peer-to-peer pair programming feature, I could imagine it being a text-only connection with a single master and any number of slaves, where the slaves are showing a replica of the master's screen. IMO the slaves should not need any way to directly manipulate anything, though it may be of value to be able to highlight a block of text and have the master see that highlight (independently of the master's own text selection). Having everyone able to edit simultaneously creates technological problems, and then a social problem (when you start trampling over each other's code by mistake), and the solution to the social problem usually amounts to a semaphore system "okay, you go ahead and take over"; baking that semaphore into the technology (by having only a single master) would keep things way simpler. Thank you for the helpful response in a area where I lack experience. My response to Daniel includes my response to the above. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 3/08/19 11:50 AM, Cameron Simpson wrote: appear.in can also screen share along with its video conferencing, and I imagine Zoom might do so also. But a screen share is "read only" for the other party. You could both screen share of course, but it doesn't solve the keep-the-code-in-sync issue. Thanks Cameron. TBH I fear that the keep-the-code-in-sync issue is a bit of a 'red herring'. Do your pair-programming exercises ever involve both developing the same code-file at the same time? A simple screen-share solution has to be the MVP: - I can see the code someone wants to show/is requesting help for - we can talk through the question - but I can't 'take control', eg would have to ask the other person to scroll in order to show a piece of code 'somewhere else'. Perhaps this is good discipline? I am hoping we can 'do better'. One of the PythonAnywhere principals has come back to me (I first used this service at least a decade ago, starting when I met Harry (the testing goat) Roberts at a London PUG meeting - although I'm not sure whether the evening's topic was PA and 'testing' was mentioned, or perhaps the other way around! You know how these meetings go - and the serendipitous benefits that can be realised, although not designed/deliberate). PA's "education" services do not appear to have progressed very far (since), but at least they are happy for me to use the scheme. Yay! The other observation is that Py3.7 *IS* now available (contrary to previous msg). In PA, if I open a "console", it can be shared with all my (PA-defined) "students" as r/o. Better, is that anyone who cares to ask for help (registered as one of my students) can ask me to 'look over their shoulder'. As well as navigating the other person's source-files, I think I could initiate a test, or quick edit, in that mode. (if you'd like to give-it-a-whirl/have-a-go, they offer free accounts (with modest but quite functional facilities) and the registration process is not onerous - if we* can arrange an RDV, I'll be happy to try working as a pair...) * by "we" I mean any list-member, not just Cameron (whose suggestion heads this post) - I haven't had a chance to start evaluating the two apparently 'larger' systems, mentioned yesterday... So, the ambition for this next PUG coding-night, is to find something that offers more than the screen-share 'MVP', is well-rounded, and easy to learn/install/use on a casual basis. My hope, is that 'something' will offer services we might not have thought relevant/possible/useful, at first... (we can but dream) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On Fri, Aug 2, 2019 at 4:11 AM DL Neil wrote: > > Please recommend a Python-friendly, bandwidth-respectful, (but > effective) system for pair-programming; where the 'pair' are > geographically separate. > At work (not programming related) my department has just started using GoToMeeting. So far it has worked well. It can transmit audio and share one's screen. The host can choose to share with the remote person a particular application, his keyboard and mouse or the whole shebang. I don't know how bandwidth intensive it might be, but our intranet bandwidth is often less capable than what I have at home. Also I believe it is a paid service. boB -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 03Aug2019 16:51, DL Neil wrote: On 3/08/19 11:50 AM, Cameron Simpson wrote: appear.in can also screen share along with its video conferencing, and I imagine Zoom might do so also. But a screen share is "read only" for the other party. You could both screen share of course, but it doesn't solve the keep-the-code-in-sync issue. Thanks Cameron. TBH I fear that the keep-the-code-in-sync issue is a bit of a 'red herring'. Do your pair-programming exercises ever involve both developing the same code-file at the same time? My pair programming experience is pretty limited. If peering over someone's should is enough, you're good. If you ever swap roles (typing versus reviewing) I'd think it gets trickier. A simple screen-share solution has to be the MVP: - I can see the code someone wants to show/is requesting help for - we can talk through the question - but I can't 'take control', eg would have to ask the other person to scroll in order to show a piece of code 'somewhere else'. Perhaps this is good discipline? If you're teaching, then yes, sounds good to me. Student types, teacher observes. If it's two peers (regardless of relative expertise in the current problem) I'd imagine wanting to switch around occasionally. Like: Observer: what if we do blah-blah? Coder: not sure what you mean. Observer: types short example code, because it is easier than a precise verbal explaination. Coder: if ok, adapts the example to the actual problem. If you're mentoring/tutoring, you can put the typing in the associated text messaging system - I think most video conferency things let people message inside the conference? So you're not sharing a keyboard, but you can pass text/code around for copy/paste. One of the PythonAnywhere principals has come back to me [...] In PA, if I open a "console", it can be shared with all my (PA-defined) "students" as r/o. Better, is that anyone who cares to ask for help (registered as one of my students) can ask me to 'look over their shoulder'. As well as navigating the other person's source-files, I think I could initiate a test, or quick edit, in that mode. (if you'd like to give-it-a-whirl/have-a-go, they offer free accounts (with modest but quite functional facilities) and the registration process is not onerous - if we* can arrange an RDV, I'll be happy to try working as a pair...) Actually, I'd like that. But I'm in GMT+10. Guessing you're in GMT? We could take that off list. * by "we" I mean any list-member, not just Cameron (whose suggestion heads this post) My suggestions were merely "here're two more video conferencing services". Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 03Aug2019 08:52, DL Neil wrote: On 3/08/19 8:32 AM, Terry Reedy wrote: 2. Do two systems connect directly peer-to-peer or through a server? Exclusively the latter (thus far in the investigation). If one party is remote and both are behind a NAT (_very_ common in Australia, for example) then you always need an external intermediary. Even if that intermediary does no more than connect some sockets from each end together and blindly pass traffic. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 3/08/19 4:02 PM, Terry Reedy wrote: On 8/2/2019 4:52 PM, DL Neil wrote: On 3/08/19 8:32 AM, Terry Reedy wrote: On 8/2/2019 5:10 AM, DL Neil wrote: Please recommend a Python-friendly, bandwidth-respectful, (but effective) system for pair-programming; where the 'pair' are geographically separate. 'geographically separate' could range from in the same room to a continent away, as long as two people have separate keyboards and screens. True! As long as the tech works... My experience has always been two sharing one PC, ie taking-it-in-turns to think or to type. Do you do it differently? I currently work on my home machine, so my recent 'pair programming' has been limited to comments and now diff suggestions on Github PRs. So I need the comments on real use cases from you and Chris to even think about something for IDLE. Is that really "p-p" or more "code review"? What I had in-mind, and others may see it differently (and I will happily modify any contribution to whatever an individual PUG attendee might need!) is more-or-less the sort of practical question we see on the list/one hears in a dev-lab, all the time, eg 'why doesn't 'this' work?', or 'how do I...?" but with the advantage of the conversation taking-place in real-time. If the answer is trivial, that's it. Something more-involved however, may require a detailed look at the code, or 'sitting and watching' whilst the other starts to include some new 'suggestion' into their code-base. That takes us into the synergies offered by pair-programming... Use case: (possible examples) (The meeting organiser talked about a project involving Solid ID) - let's suggest the project hasn't started to-date. Perhaps he would download the code and start coding an enquiry against the API. Meantime I could be writing some Tests. - he starts work, but the API doesn't respond in the expected manner. He asks me to 'take a look', so I read the code, scroll around, ask 'why' or 'why not' questions, and within the conversation we decide an alternative approach The former, strikes me as a possible contribution to the PUG mtg, but the latter is more "pair programming" mode. In the case of Wednesday's PUG meeting, my personal goal is to offer encouragement. If that involves 'full' pair-programming I would like to be ready - if it involves more simplistic contribution, crest la vie - if we can find some new approach which 'shoots for the moon' then all my dreams will come true... IDLE is Python-friendly, free, and FOSS. I wonder how hard it would be to pair programming connectivity as an extension. This was an initially pie-in-the-sky idea that cannot solve your immediate problem. But I think now that something useful could be feasible sometime. (with all due apologies) I haven't touched Idle in years (probably v2.n - and n<5 at that). Can't remember if I did something which impacted the Idle environment, or if it was because I was doing a lot of web-work. Regardless, even after a quick scan of the v3.7 PSL docs, I don't know what I'm talking about! (as if that's anything new) 1. Do the systems you have considered operate as an editor + satellite terminal or as synchronized peer editors. Always the former, the local devices are merely 'repeaters' (through a web browser) of what is happening on the server. This at both edit and Good. Master-satellite would be much easier. We added line numbers to IDLE's editor last week, so verbal feedback from satellite to master should be sufficient for many purposes. Elsewhere in the thread there is much discussion of this. Regardless of the "we are all adults here" philosophy, my feeling (stuck-in-the-mud though it might be) is that one person/system has to have 'control', and the other, the 'pair' (or the 'tutor') is invited to see/do 'whatever'. However, r/o would be a show-stopping limitation. IDLE already intercepts keypresses to do syntax coloring and smart indentation (after \n). It should not be too hard to also send through a socket anything sent to a tkinter/tk text widget. Making a text read-only is trivial. Sounds like the sorts of things Linux's X-server does/did. With a real editor as satellite, the locally configured font face, font size, and syntax highlight colors can be used. Transmitting highlighting as text would require the invention of a protocol to differentiate text from such meta information. run/test stages. Yes, important to remember that the editor is only one tool, and that pair-programming may involve kicking-off a 'run' from the cmdLN or browsing a page from the web server (etc). Running code locally would 1. Save bandwidth. 2. Allow two users to do different things occasionally. 3. Reveal OS dependencies if on different systems. When patching IDLE, I would love to have my Macbook set as a satellite to check that code works on Mac as well as Windows. Good idea! Websites frequently use services which show h
Re: Remote/Pair-Programming in-the-cloud
On Sat, Aug 3, 2019 at 3:36 PM DL Neil wrote: > > On 3/08/19 4:02 PM, Terry Reedy wrote: > > I currently work on my home machine, so my recent 'pair programming' has > > been limited to comments and now diff suggestions on Github PRs. So I > > need the comments on real use cases from you and Chris to even think > > about something for IDLE. > > Is that really "p-p" or more "code review"? I'd say that, no, commenting on GitHub PRs is not "pair programming". It's a different form of collaboration. Pair programming specifically refers to two people working in realtime on one project. > > Good. Master-satellite would be much easier. We added line numbers to > > IDLE's editor last week, so verbal feedback from satellite to master > > should be sufficient for many purposes. > > Elsewhere in the thread there is much discussion of this. Regardless of > the "we are all adults here" philosophy, my feeling (stuck-in-the-mud > though it might be) is that one person/system has to have 'control', and > the other, the 'pair' (or the 'tutor') is invited to see/do 'whatever'. > However, r/o would be a show-stopping limitation. When pair programming involves training (tutor and student, or senior and junior programmer), forcing the more experienced person to stay hands-off is a very good thing; it forces the less experienced person to actually keyboard every change, and thus is more likely to understand what's going on. But when it's two peers, you'll often want to switch out who's in control. Depending on the architecture, this might be a simple matter of flipping a switch and changing who's master and who's on a read-only clone. > > 4. Require encryption of some sort if over the public internet. Just > > because people download code from strangers over http is not a reason to > > encourage carelessness. I am pretty ignorant on what this would mean. > > TLS? > TLS doesn't really solve this problem. If you have a single central server, TLS just tells you that you're talking to that server, without proving anything about who's on the other end. Even if you directly connect the two nodes, TLS wouldn't prove who that is, unless you get a dedicated certificate. What it *can* prove is that your data stream hasn't been tampered with en route, but the problem of receiving code from strangers is still an issue. Ultimately, pair programming depends on a measure of trust - you have to be confident that the person you're pairing with isn't going to be maliciously messing with your system. However, I think it would be an extremely useful feature if the output from running the program could also be replicated to the other client. Let's say you're developing a Python script that connects to a database (eg psycopg2 + PostgreSQL). To run that locally, you'd need your own replica of the database, and that often means having your own credentials (ie having the script able to choose which set of credentials to use), replicating the database schema, and possibly even getting a duplicate of the current table contents. Way WAY easier to just run it on one computer and copy the output. > >>> 2. Do two systems connect directly peer-to-peer or through a server? > >> Exclusively the latter (thus far in the investigation). > > > > The former would be the only option until someone (else) set up and > > supported a server. > > Except that when you think about it, were I viewing your screen, your > m/c would indeed be a "server"! We could lose potential by arguing > semantics (not my intention). In fact, we dealt with this point, above. There's a difference between the conceptual and the technical here. The NAT issue may mean that, for technical reasons, a broker is needed. > I'm thrilled at your interest, but am ignorant/uncertain that > pair-programming and Idle go together. To which you may say that perhaps > they should... In which case, I'd recommend taking a look at some of the > services (listed at the beginning of this thread) to first establish > 'virtue' and yes, I'll try to do a better job at roughing-out some > use-cases with you... I think Idle could be a very useful pair programming tool, but that doesn't mean it'd be the best option available. IMO it could be an extremely light-weight one, though. ChrisA -- https://mail.python.org/mailman/listinfo/python-list