Re: Code Snippets

2017-11-02 Thread Rhodri James
On 01/11/17 18:57, Stefan Ram wrote: Ned Batchelder writes: You should not optimize for the shortest time to paste a line of code. You should take time and care writing your code, so that it reads best and runs best.  If you needed another os function, would you have two __import__("os") in y

Re: Code Snippets

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 08:02 am, Ben Bacarisse wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> Wolfgang Maier writes: >>>If you're worried bout having things on separate lines, you could write: >>>import os; os.getcwd() >>>,etc., which is actually saving a few characters :) >> >> Yes, b

Re: Code Snippets

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 05:57 am, Stefan Ram wrote: > I also have heard that there was a module cache, so I > was hoping that a second import of the same module might > not be such an effort for the implementation. There is: sys.modules. Although `import spam` is cheap when spam is in the cache, its

Re: Code Snippets

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 04:25 am, Stefan Ram wrote: > I started to collect some code snippets: [...] > __import__( "random" ).random() > > And so on. You get the idea. > > However, reportedly, all those snippets are anti-patterns > because they use »__import_

Re: Code Snippets

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 8:02 AM, Ben Bacarisse wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> Wolfgang Maier writes: >>>If you're worried bout having things on separate lines, you could write: >>>import os; os.getcwd() >>>,etc., which is actually saving a few characters :) >> >> Yes,

Re: Code Snippets

2017-11-01 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Wolfgang Maier writes: >>If you're worried bout having things on separate lines, you could write: >>import os; os.getcwd() >>,etc., which is actually saving a few characters :) > > Yes, but there still is the risk of the identifier »os« > already

Re: Code Snippets

2017-11-01 Thread Irmen de Jong
On 11/01/2017 06:25 PM, Stefan Ram wrote: > import random > ... > random.random() > > Now, the user has to cut the import, paste it to the top > of his code, then go back to the list of snippets, find > the same snippet again, copy the expression, go to his code, > then find the point whe

Re: Code Snippets

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 7:17 AM, Stefan Ram wrote: > Wolfgang Maier writes: >>If you're worried bout having things on separate lines, you could write: >>import os; os.getcwd() >>,etc., which is actually saving a few characters :) > > Yes, but there still is the risk of the identifier »os« > al

Re: Code Snippets

2017-11-01 Thread Wolfgang Maier
On 01.11.2017 18:25, Stefan Ram wrote: I started to collect some code snippets: Sleep one second __import__( "time" ).sleep( 1 ) Get current directory __import__( "os" ).getcwd() Get a random number __import__( "random" ).random() And so on.

Re: Code Snippets

2017-11-01 Thread Ned Batchelder
On 11/1/17 1:25 PM, Stefan Ram wrote: I started to collect some code snippets: Sleep one second __import__( "time" ).sleep( 1 ) Get current directory __import__( "os" ).getcwd() Get a random number __import__( "random" ).random() And so on.

Re: Code Snippets

2017-11-01 Thread Neil Cerutti
On 2017-11-01, Stefan Ram wrote: > I started to collect some code snippets: > > Sleep one second > > __import__( "time" ).sleep( 1 ) > > What I'm supposed to do instead, I guess, is: > > Sleep one second > > import time > ... > tim

Re: posting code snippets

2014-03-02 Thread Gene Heskett
On Sunday 02 March 2014 07:05:06 Alister did opine: > On Sun, 02 Mar 2014 09:16:35 +1100, Chris Angelico wrote: > > On Sat, Mar 1, 2014 at 1:31 AM, Grant Edwards > > > > > > wrote: > >> You drag out the lab scope, logic analyzer, spectrum analyzer, sweep > >> generator, strip plotter, and the ma

Re: posting code snippets

2014-03-02 Thread Alister
On Sun, 02 Mar 2014 09:16:35 +1100, Chris Angelico wrote: > On Sat, Mar 1, 2014 at 1:31 AM, Grant Edwards > wrote: >> You drag out the lab scope, logic analyzer, spectrum analyzer, sweep >> generator, strip plotter, and the machine that goes "ping". You start >> to get everything set up to nail

Re: posting code snippets

2014-03-01 Thread Gregory Ewing
Grant Edwards wrote: You drag out the lab scope, logic analyzer, spectrum analyzer, sweep generator, strip plotter, and the machine that goes "ping". You start to get everything set up to nail that problem securely to the dissecting board. Long before you actually get to that point, the proble

Re: posting code snippets

2014-03-01 Thread Chris Angelico
On Sat, Mar 1, 2014 at 1:31 AM, Grant Edwards wrote: > You drag out the lab scope, logic analyzer, spectrum analyzer, sweep > generator, strip plotter, and the machine that goes "ping". You start > to get everything set up to nail that problem securely to the > dissecting board. Long before you

Re: posting code snippets

2014-03-01 Thread Gene Heskett
On Saturday 01 March 2014 16:52:44 Grant Edwards did opine: > On 2014-02-28, Chris Angelico wrote: > > The problem does have to believe that the rubber duck/teddy > > bear/figurine is an expert, though. I've had my siblings or parents > > come to me with problems and, without saying a word or tou

Re: posting code snippets

2014-03-01 Thread Grant Edwards
On 2014-02-28, Chris Angelico wrote: > The problem does have to believe that the rubber duck/teddy > bear/figurine is an expert, though. I've had my siblings or parents > come to me with problems and, without saying a word or touching the > computer or anything, I've solved them. The problem itse

Re: posting code snippets

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 9:15 AM, Ben Finney wrote: > Since you'll be posting the code in-line, make sure it's short. Since > it'll be short, make sure it's complete — we should need nothing else to > run the code and expect to see the same behaviour you're seeing. > > Since you'll be making it sho

Re: posting code snippets

2014-02-27 Thread Dave Angel
"Mark H. Harris" Wrote in message: > my isp withdrew the post service (nntp) from their server at end of 2011... > and I didn't notice till now! ha! So, I'm not using seamonkey any > longer... using google groups/ and that has been a fit to get used to, but > I'm making progress. > >

Re: posting code snippets

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 4:15:16 PM UTC-6, Ben Finney wrote: > > Post your code in-line with your message. This is for the sake of the > people whose time you're requesting, and of later readers who will find > the thread when searching the archives -- URLs to snippets are likely to > be in

Re: posting code snippets

2014-02-27 Thread Ben Finney
"Mark H. Harris" writes: >Its been too long... can't remember... are there rules here about >posting code snippets, or length considerations, and so forth? Post your code in-line with your message. This is for the sake of the people whose time you're requesting

Re: posting code snippets

2014-02-27 Thread Tim Chase
On 2014-02-27 04:13, Mark H. Harris wrote: > are there rules here about posting code snippets, or length > considerations, and so forth? Seems like there was a place to share > code snips outside of the message area? This is the internet, so you're welcome to post code as you p

Re: posting code snippets

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 9:01:50 AM UTC-6, Jerry Hill wrote: > -- > > Jerry Thanks guys, perfect. 'preciate it! -- https://mail.python.org/mailman/listinfo/python-list

Re: posting code snippets

2014-02-27 Thread Jerry Hill
On Thu, Feb 27, 2014 at 7:13 AM, Mark H. Harris wrote: > hi folks, >Its been too long... can't remember... are there rules here about posting > code snippets, or length considerations, and so forth? Chris' advice about just posting your code inline with your message is go

Re: posting code snippets

2014-02-27 Thread Chris Angelico
On Thu, Feb 27, 2014 at 11:13 PM, Mark H. Harris wrote: > hi folks, >Its been too long... can't remember... are there rules here about posting > code snippets, or length considerations, and so forth? >Seems like there was a place to share code snips outside of the mess

posting code snippets

2014-02-27 Thread Mark H. Harris
hi folks, Its been too long... can't remember... are there rules here about posting code snippets, or length considerations, and so forth? Seems like there was a place to share code snips outside of the message area? A related question, is there a python repository for uplo

Re: Review Python site with useful code snippets

2011-10-31 Thread DevPlayer
When visitors visit your site to post their code; often such posts ask for username and email address; consider adding additional fields to generate some Python documenting feature like Sphinx or epydoc. and let your site inject the docstring (module string) into the snippet; primarily, author, u

Re: Review Python site with useful code snippets

2011-10-30 Thread Mehrzad Irani
Considering that the site is going to grow over time, putting the snippets in a drop-down menu isn't a wise idea in my opinion. Snippets on a separate page like activestate python would make it more convenient. Nice initiative, and would be very helpful when it grows over time. -- http://mail.

Re: Review Python site with useful code snippets

2011-10-29 Thread Jason Friedman
te is: > > http://www.pythonsnippet.com > > If you have anything to contribute or comment, please post it on the > site or email me directly. Great sentiment, but there is already http://code.activestate.com/, http://code.google.com/p/python-code-snippets/ and http://stackoverflo

Review Python site with useful code snippets

2011-10-26 Thread Chris Hall
I am looking to get reviews, comments, code snippet suggestions, and feature requests for my site. I intend to grow out this site with all kinds of real world code examples to learn from and use in everyday coding. The site is: http://www.pythonsnippet.com If you have anything to contribute or co

Getting indented code snippets into blogger

2007-09-18 Thread Paddy
I got tired of Bloggers inadequate comment editor so wrote this for transforming code snippets: = ''' blogspace.py Turns leading spaces into HTML   tokens which shows as correct indentation on Blogger comment fields (and maybe other blogs). Donald. '

Re: Wikicodia - The code snippets wiki

2007-07-28 Thread Tina I
Wikicodia Admin wrote: > Dears, > > Wikicodia is a wiki based project for sharing code snippets. We're > collecting large number of code snippets for all code-based > programming languages, scripts, shells and consoles. We wish you could > help us. We're still BETA.

Wikicodia - The code snippets wiki

2007-07-27 Thread Wikicodia Admin
Dears, Wikicodia is a wiki based project for sharing code snippets. We're collecting large number of code snippets for all code-based programming languages, scripts, shells and consoles. We wish you could help us. We're still BETA. Your suggestions, ideas and criticisms are very welco