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
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
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,
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__«.
Correct. Nearly all dunder
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()
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
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
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 :)
>
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. You get the idea.
However,
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. You get the idea.
However,
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
> ...
> time.sleep( 1 )
>
> Get current
11 matches
Mail list logo