Run Windows commands from Python console

2017-09-03 Thread g . morkvenas
Hello, I run Python console in Windows. Can I run cmd prompt commands there? If I run command dir I have: >>> dir What does it means? If i trying to create file I have error: >>> type NUL > hh.txt File "", line 1 type NUL > hh.txt ^ SyntaxError: invalid syntax What means

Re: Run Windows commands from Python console

2017-09-03 Thread Rick Johnson
On Sunday, September 3, 2017 at 7:57:14 AM UTC-5, g.mor...@gmail.com wrote: > Hello, > > I run Python console in Windows. Can I run cmd prompt commands there? > > If I run command dir I have: > > >>> dir > > > What does it means? It means that the expression `dir` (in python's universe) is a

ANN: psutil 5.3.0 with full unicode support is out

2017-09-03 Thread Giampaolo Rodola'
Hello all, I'm glad to announce the release of psutil 5.3.0: https://github.com/giampaolo/psutil A blogpost describing the main changes is available here: http://grodola.blogspot.com/2017/09/psutil-530-with-full-unicode-support-is.html About = psutil (process and system utilities) is a cross-

Re: Run Windows commands from Python console

2017-09-03 Thread eryk sun
On Sun, Sep 3, 2017 at 7:56 AM, wrote: > > I run Python console in Windows. Can I run cmd prompt commands > there? Python doesn't know the first thing about CMD's "batch" language. Also, Python's shell (i.e. REPL) is not a system administration shell that implicitly runs external commands. You n

How to get status of Autoplay video from browser

2017-09-03 Thread kabalida16
Hi , I have a URL where Video will start playing after launch (autoplay video) eg:https://techcrunch.com/ Another script will pause the video as soon as it detects a Video is playing. Now I need to verif the video is paused successfully or not. HOw to get the status of video? I am using

Re: ANN: psutil 5.3.0 with full unicode support is out

2017-09-03 Thread eryk sun
On Sun, Sep 3, 2017 at 9:58 AM, Giampaolo Rodola' wrote: > > - #1040: all strings are encoded by using OS fs encoding. > - #1040: the following Windows APIs on Python 2 now return a string instead > of > unicode: > - Process.memory_maps().path > - WindowsService.bin_path() > - WindowsServi

Re: Case-insensitive string equality

2017-09-03 Thread Steve D'Aprano
On Sun, 3 Sep 2017 05:17 pm, Stephan Houben wrote: > Generally speaking, the more you learn about case normalization, > the more attractive case sensitivity looks Just because something is hard doesn't mean its not worth doing. And just because you can't please all the people all the time doesn'

Re: A question on modification of a list via a function invocation

2017-09-03 Thread Stephan Houben
Op 2017-08-17, Rustom Mody schreef : > On Thursday, August 17, 2017 at 6:49:19 AM UTC+5:30, Mok-Kong Shen wrote: >> Am 17.08.2017 um 02:41 schrieb Steve D'Aprano: >> > By reference and by value are not the only two conventions. >> > >> > Perhaps if you go back to the 1950s you might be able to arg

Have do_nothing as default action for dictionary?

2017-09-03 Thread Christopher Reimer via Python-list
Greetings, I was playing around this piece of example code (written from memory). def filter_text(key, value):     def do_nothing(text): return text     return {'this': call_this,   'that': call_that,   'what': do_nothing }[key](value) Is

Re: Case-insensitive string equality

2017-09-03 Thread Pavol Lisy
On 9/3/17, Steve D'Aprano wrote: > On Sun, 3 Sep 2017 05:17 pm, Stephan Houben wrote: > >> Generally speaking, the more you learn about case normalization, >> the more attractive case sensitivity looks > > Just because something is hard doesn't mean its not worth doing. > > And just because you ca

Re: Have do_nothing as default action for dictionary?

2017-09-03 Thread Chris Angelico
On Mon, Sep 4, 2017 at 5:31 AM, Christopher Reimer via Python-list wrote: > Greetings, > > I was playing around this piece of example code (written from memory). > > > def filter_text(key, value): > > def do_nothing(text): return text > > return {'this': call_this, > > 't

Re: Have do_nothing as default action for dictionary?

2017-09-03 Thread Peter Otten
Christopher Reimer via Python-list wrote: > Greetings, > > I was playing around this piece of example code (written from memory). > > > def filter_text(key, value): > > def do_nothing(text): return text > > return {'this': call_this, > > 'that': call_that, > > 'what': do_nothing > > }

Re: Have do_nothing as default action for dictionary?

2017-09-03 Thread Peter Otten
Christopher Reimer via Python-list wrote: > Greetings, > > I was playing around this piece of example code (written from memory). > > > def filter_text(key, value): > > def do_nothing(text): return text > > return {'this': call_this, > > 'that': call_that, > > 'what': do_nothing > > }

Re: Run Windows commands from Python console

2017-09-03 Thread Terry Reedy
On 9/3/2017 11:17 AM, eryk sun wrote: On Sun, Sep 3, 2017 at 7:56 AM, wrote: What means line below: File "", line 1 I don't have any file. Indeed, on Windows you cannot create a file named "". Python uses this fake name for the code object it compiles when reading from stdin (i.e. the f

testfixtures 5.2.0 released!

2017-09-03 Thread Chris Withers
Hi All, I'm pleased to announce the release of testfixtures 5.2.0 featuring the following: * test_datetime and test_time now accept a [1]datetime instance during instantiation to set the initial value. * test_date now accepts a [2]date instance during instantiation to

python multiprocessing question

2017-09-03 Thread Xristos Xristoou
hello i have create a 4 function using python(f1,f2,f3,f4) and i have 4 cores in my system. def f1() ... ... def f2() ... ... def f3() ... ... def f4() ... .

Re: Case-insensitive string equality

2017-09-03 Thread Gregory Ewing
Stefan Ram wrote: But of course, actually the rules of orthography require "Maße" or "Masse" and do not allow "MASSE" or "MASZE", just as in English, "English" has to be written "English" and not "english" or "ENGLISH". While "english" is wrong in English, there's no rule against usin

Re: Case-insensitive string equality

2017-09-03 Thread Steve D'Aprano
On Mon, 4 Sep 2017 09:10 am, Gregory Ewing wrote: > Stefan Ram wrote: >> But of >> course, actually the rules of orthography require "Maße" or >> "Masse" and do not allow "MASSE" or "MASZE", just as in >> English, "English" has to be written "English" and not >> "english" or "ENGLISH". >

Re: A question on modification of a list via a function invocation

2017-09-03 Thread Steve D'Aprano
On Mon, 4 Sep 2017 04:15 am, Stephan Houben wrote: > Needless to say, according to the definition in Plotkin's paper, Python > is "call-by-value". According to Plotkin's definition, when you pass a value like a 100MB string: "This is a long string of text..." # continues on for millions more ch

Re: A question on modification of a list via a function invocation

2017-09-03 Thread Chris Angelico
On Mon, Sep 4, 2017 at 12:05 PM, Steve D'Aprano wrote: > On Mon, 4 Sep 2017 04:15 am, Stephan Houben wrote: > >> Needless to say, according to the definition in Plotkin's paper, Python >> is "call-by-value". > > According to Plotkin's definition, when you pass a value like a 100MB string: > > "Thi

Capital ß [was Re: Case-insensitive string equality]

2017-09-03 Thread Steve D'Aprano
On Sat, 2 Sep 2017 01:48 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>[1] I believe that the German government has now officially recognised the >>uppercase form of ß. > > [skip to the last paragraph for some "ß" content, > unless you want to read details about German spelling rules.] >

Re: A question on modification of a list via a function invocation

2017-09-03 Thread Steve D'Aprano
On Mon, 4 Sep 2017 12:20 pm, Chris Angelico wrote: > This is another proof that you can't divide everything into "pass by > value" vs "pass by reference", unless you mess around with "passing a > reference by value" or other shenanigans. In C, a string is not an > entity; it's simply an array of c

Re: A question on modification of a list via a function invocation

2017-09-03 Thread Rustom Mody
On Monday, September 4, 2017 at 7:50:22 AM UTC+5:30, Chris Angelico wrote: > On Mon, Sep 4, 2017 at 12:05 PM, Steve D'Aprano wrote: > > On Mon, 4 Sep 2017 04:15 am, Stephan Houben wrote: > > > >> Needless to say, according to the definition in Plotkin's paper, Python > >> is "call-by-value". > > >

Re: meaning of [ ]

2017-09-03 Thread Rustom Mody
On Sunday, September 3, 2017 at 5:10:13 PM UTC+5:30, Rick Johnson wrote: > Andrej Viktorovich wrote: > > I suppose p becomes array of strings but what [] means in this statement? > > Generally, it's an inline form of writing a loop that returns a list. There > are other types as well. Tsk tsk th

Re: ANN: psutil 5.3.0 with full unicode support is out

2017-09-03 Thread Giampaolo Rodola'
Hello Eryk, it is true that the most correct way to represent strings in Python 2 is by dealing with Unicode but it is also true that the most common scenario in both the stdlib and most third party libs is to return and deal with str (bytes) instead, so this is why I decided to do the same in psut

Re: ANN: psutil 5.3.0 with full unicode support is out

2017-09-03 Thread eryk sun
On Sun, Sep 3, 2017 at 11:09 PM, Giampaolo Rodola' wrote: > > This is an example which filters processes with a funky name which works > with both Python 2 > and 3: > > import psutil, sys > > PY3 = sys.version_info[0] == 2 > LOOKFOR = u"ƒőő.exe" > for proc in psutil.process_iter(at

Re: Case-insensitive string equality

2017-09-03 Thread Stephan Houben
Op 2017-09-02, Pavol Lisy schreef : > But problem is that if somebody like to have stable API it has to be > changed to "do what the Unicode consortium said (at X.Y. )" :/ It is even more exciting. Presumably a reason to have case-insentivity is to be compatible with existing popular case-inse

Re: tkinter keypress events are a mess for numpad keys

2017-09-03 Thread Stephan Houben
Op 2017-08-29, Irmen de Jong schreef : > I'll have a look at https://www.tcl.tk/man/tcl8.6/TkCmd/keysyms.htm > but I don't have high hopes because I already tried empirically to > figure out the distinguishing attributes of the keypress event object, > on various platforms (Mac OS, Linux, Windows)

meaning of [ ]

2017-09-03 Thread Andrej Viktorovich
Hello, Trying to understand command: [p for p in sys.path] It prints array of paths. I suppose p becomes array of strings but what [] means in this statement? -- https://mail.python.org/mailman/listinfo/python-list

Re: meaning of [ ]

2017-09-03 Thread Peter Otten
Andrej Viktorovich wrote: > Hello, > > Trying to understand command: > [p for p in sys.path] > > It prints array of paths. I suppose p becomes array of strings but what [] > means in this statement? This is called "list comprehension", and paths = [p for p in sys.path if "foo" in p] is roughl

Re: tkinter keypress events are a mess for numpad keys

2017-09-03 Thread Rick Johnson
Irmen de Jong wrote: > Using tkinter in python3, I was trying to intercept > individual keypresses (and releases) of keys on the numeric > keypad. I want to use this as a simple joystick simulation. > While you can bind the event, actually doing > something sensible with it in a cross platform way

Re: meaning of [ ]

2017-09-03 Thread Rick Johnson
Andrej Viktorovich wrote: > I suppose p becomes array of strings but what [] means in this statement? Generally, it's an inline form of writing a loop that returns a list. There are other types as well. https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions -- https://mail.p

Re: Python... feeding an instance as an argument into a new instance.

2017-09-03 Thread Chris Roberts
On Saturday, September 2, 2017 at 6:34:59 PM UTC-4, Chris Roberts wrote: > Perhaps someone here could help me to get this into perspective. > Somehow when we start to feed an instance as the argument in a new instance. > my head explodes.. > in this case... > a = Foo() > b = Bar(a) > So... > a

Re: Case-insensitive string equality

2017-09-03 Thread Chris Angelico
On Sun, Sep 3, 2017 at 5:17 PM, Stephan Houben wrote: > Generally speaking, the more you learn about case normalization, > the more attractive case sensitivity looks ;-) Absolutely agreed. My general recommendation is to have two vastly different concepts: "equality matching" and "searching". Equ

Re: Python... feeding an instance as an argument into a new instance.

2017-09-03 Thread Rick Johnson
On Saturday, September 2, 2017 at 7:45:14 PM UTC-5, Steve D'Aprano wrote: > On Sun, 3 Sep 2017 08:34 am, Chris Roberts wrote: > > > Perhaps someone here could help me to get this into > > perspective. Somehow when we start to feed an instance as > > the argument in a new instance. my head explodes