Re: Getting Directory of Command Line Entry Point For Packages
On 13/11/2021 10.51, Abdur-Rahmaan Janhangeer wrote: > Greetings list, > > Let's say i created a package named miaw > > miaw also has a cli command called miaw > > miaw prints files and folders in the directory it is called in > > except that when miaw is used, it prints the files and folders in > site-packages > > This is an analogy for a package i have. > > Well forgetting about the lines above, how do i get the path from > which miaw the command is called from? try: file_path = __file__ print( file_path ) and process file_path as-required. -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: The task is to invent names for things
On 27/10/2021 12.29, Stefan Ram wrote: > dn writes: >> On 27/10/2021 11.16, Stefan Ram wrote: >>> The Mental Game of Python - Raymond Hettinger (PyBay 2019) >>> | "The computer gives us words that do ### things. > ... >> Alternately, if your question was to identify the mumbled word, it is >> (seemed to me to be) "does". > > Thanks! > > Yes, my question was about the word at the place of the > "###". It does not even seem mumbled to me, but pronounced > with certainty and intention. That's why it makes me wonder. > As if there was a term "does things". That is a colloquialism: - my computer does things - my program[me] does stuff The "stuff" is something of a euphemism. In our profession, I would suggest it is used to avoid detail, eg as a 'signal' to a non-IT person that a more detailed answer would likely bore, or 'go over your head'. In PM-circles we identify the beginning and end of a project - the rest of the project plan 'stuff', is known as 'the miracle that happens in the middle'. Want more detail? Do we have more detail? What do I know? If a dog owner said: "my dog does things" it would again be a euphemism, but in this case employed to avoid saying something distasteful, ie that the puppy is not (yet) house-trained. That said, I suspect if you tried to use it in an English (language/literature) essay, the teacher/prof would take exception to such informality, and demand a 'better' noun! Believe it or not, my second trainee-discussion of the day included a question similarly-worded: 'why does the computer/interpreter/run-time do these things?'. Rather than 'literature', I taught this guy one of my favorite excursions into the world of poetry (the specific type of poetic stuff is "doggerel"): I really hate this dumb* machine, I wish that they would sell it. It never does quite what I want, but only what I tell it! * you might regard this word as a euphemism for another Upon which note, and your observation that I am no English-major, it's probably time we went to do things... -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: XML Considered Harmful
On 25/09/2021 11.00, Chris Angelico wrote: > Invented because there weren't enough markup languages, so we needed another? Anything You Can Do I Can Do Better https://www.youtube.com/watch?v=_UB1YAsPD6U -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Horrible abuse of __init_subclass__, or elegant hack?
Officially April-Fools Day is over (here), but... On 01/04/2021 19.25, Chris Angelico wrote: > On Thu, Apr 1, 2021 at 3:36 PM dn via Python-list > wrote: >> >> On 01/04/2021 13.54, Chris Angelico wrote: >>> Real and imaginary are the same thing, just rotated a quarter turn >> >> In which dimension(s)? > > Cartesian. Isn't this water you get out of the ground and then deliver using an horse-pulled vehicle? Without looking into the details/context: surely there's a more straightforward approach? >>> >>> Perhaps, but there are potentially a LOT of recipes, and I needed to >>> be able to cleanly edit those, even if the code at the top was a mess. >>> (The goal here is to map out production patterns in the game >>> "Satisfactory", for the curious. It's easy to add other things, like >>> computer manufacturing or bauxite processing, simply by adding more >>> recipes.) >>> >>> My original plan was basically pairwise tuple summing (deriving a set >>> of "oil in, water in, rubber out, fuel out" for each set of recipes, >>> where some might be zero), but it turned out that that wasn't flexible >>> enough, and it really needed more options than that. >> >> Which was where my mind was going*. Why not a dict of inputs, processes, >> and outputs**? Each dict having variable length, from None, and >> key:values assigned at declaration/init. In the case of process, the >> contained objects could be Python-functions. With "compact >> representation" (3.6+) the functions could also be relied upon to >> represent a 'production line' or pipeline of functions. > > Perhaps, but the key here is the input method. It wouldn't look nearly as > clean. Not sure about that. For example, is it immediately-obvious which of "Crude", "Residue", and "Plastic" are inputs; and which outputs? >>> I already have certificates from Rutledge's Asylum and MaayaInsane's >>> (unnamed) asylum, so that seems pretty likely. >> >> Noted you on the list of lauded alumni at the latter. > > Hmm, where do you see that list? I'm curious. Appeared to be some sort of 'leader board' for the game. Recognised your handle there. Think it was https://www.twitch.tv/maayainsane. Perhaps I was looking at the same time as you logged-in? Daren't disappear down that rabbit-hole again... >> When you left the former, did they allow you to keep the t-shirt, or did >> you have to buy your own memorabilia? >> (https://mysterious.americanmcgee.com/products/rutledge-asylum-mug) > > I beg your pardon? What is this "left"? I'm still there! Actually I > pay my membership on a monthly basis, and in return, my walls are > lavishly decorated in Alice art. Whereas us lateral-thinkers don't like the feeling of being fenced-in. >> The latter's treatment list sounds remarkably like .mil training. I know >> of plenty with that t-shirt - but can't think of a one sporting a mug... >> Should you have one, kindly bring it (with appropriate contents) come >> ANZAC Day at the end of this month... > > https://streamlabs.com/maayainsane/merch/1053635 > This is what I'd bring. They're the standard mugs that I offer to > guests. Well, I would if ever I had guests, but hermitism is a > thing... Is that the same as (anti-) club-ism (cue Groucho: https://www.goodreads.com/quotes/6517787-i-wouldn-t-want-to-belong-to-a-club-that-would) After suffering the RSA's ?quaint tradition of rum-in-milk (that BEFORE Dawn Parade, and thereafter marching on a less-than flat surface) I have learned to guard against the pre-dawn cold by heading for the Hot Chocolate counter - can't say the mugs look like that though. >> Magic, you ask? Well, maybe more "sinister". We did manage to find a >> loose floor-board, but a sad life-lesson was learned, when certain ones >> (un-named*) took it upon themselves to eat all of the contraband >> secreted there. > > Uh oh. How old was the contraband? Was between 'tuck days' (when we were allowed to acquire such goodies - once?twice per week). The theory being that we would all contribute, in anticipation of some later "midnight feast") - such gyre and gimble-ing being more Jabberwock than Alice! -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Application window geometry specifier
On 14/01/2021 15.25, boB Stepp wrote: > On Wed, Jan 13, 2021 at 7:28 PM Chris Angelico wrote: > >> I love how "I think" is allowed to trump decades of usability research. I'm just pleased that @Chris has found love! (not detracting from the point though) > Can you recommend a good reference for someone relatively new to GUI > programming that is based on such research? Book or web reference > would be fine. Most of my training-materials (certainly in this topic) are web-based - but the ideas are also common to Python. Nielsen-Norman Group do a lot of work in UX and offer a regular newsletter which is usually a good way to make the brain-cells work for their living: https://www.nngroup.com/ eg https://www.nngroup.com/articles/usability-101-introduction-to-usability/ A more applied view, courtesy of the New Zealand Government: https://www.digital.govt.nz/standards-and-guidance/nz-government-web-standards/web-usability-standard-1-3/ Some become confused between the two terms: Accessibility and Usability. Here's what the boss says: https://www.w3.org/WAI/fundamentals/accessibility-usability-inclusion/ This article clearly explains each and then offers a comparison. https://www.telerik.com/blogs/web-accessibility-vs-usability If you really want to dig-down, I know for-sure that IBM, Microsoft, Apple (and presumably others) have compiled style-guides about how various GUIs should work, starting from really basic matters such as when to use radio-buttons and when check-boxes. I can't tell you if the gtk, qt, or wx people offer something similar... -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Some problem in code execution in python
On 07/01/2021 22.44, Dario Dario wrote: > Sir, I am one of the user of your python program, that is after completion > of installation I got some statement like "you got code execution problem > ". I don't know how to rectify this problem.so please help me to rectify > this problem . > You send me the solution in this email ID itself . Welcome to the list, where Python users help each other. Please send more information: - which Operating System - which version of Python - from where Python was downloaded - copy-paste all of the error messages -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Winreg
On 31/07/2020 16:48, R Pasco wrote: Thanks for your extensive info. Its too bad this isn't published in the python winreg/_winreg modules' info. Ray Pasco Welcome to the world of documentation! Perhaps you have 'discovered' something, or maybe you're using the tool in an unusual way, or maybe the docs are too sketchy (I'm not a user of MS-Win, so can't comment). Regardless, the documentation team would welcome a contribution based upon this discussion and your learning... The best way to ensure you have learned something thoroughly is to explain it to others! -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a difference between python
On 6/04/20 10:35 AM, Malcolm Greene wrote: Is there a difference between the following 2 ways to launch a console-less script under Windows? python
Re: TypeError: unhashable type: 'list'
On 23/10/19 8:51 PM, joseph pareti wrote: I am experimnenting with this (reproducer) code: pattern_eur= ['Total amount'] mylines = []# Declare an empty list. with open ('tmp0.txt', 'rt') as myfile: # Open tmp.txt for reading text. for myline in myfile: # For each line in the file, mylines.append(myline.rstrip('\n')) # strip newline and add to list. for element in mylines: # For each element in the list, match_C = re.search(pattern_eur, element) if match_C: element = element + 2 print(element) -- the input file being: $ cat tmp0.txt line 0 line 1 Total amount 5.00 linex ... My intent is to locate the line containing "Total amount", skip the next line, then print the eur value. The program terminates as follows: ... Thanks for any insigths -- The first observation is that the two for loops are essentially identical, so why not condense? However, what is described may be calling for a solution called "a finite state machine": state 1: ignore unwanted data, until "Total amount" is found state 2: skip blank line state 3: grab the Euro value, and return to state 1 Being a simple-boy, I would avoid any reg-ex, because: myline[ :11 ] == "Total amount" is easier (and faster). Similarly, there is no need for rstrip-ping except at "state 3" (unless there are particular rules for the formatting of the total). Another thought is that the problem is being visualised as a series of lines and this may complicate things. If instead, a "buffer" or indeed the entire file, could be read at a time (which is current code, per first comment above), the string.find() method could be employed (replacing "state 1"), and then (implicit assumption about spacing here) "state 2" becomes a matter of moving a few characters 'along', before grabbing the total; rinse and repeat... Web-ref: https://en.wikipedia.org/wiki/Finite-state_machine -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Mouse control
On 7/10/19 4:11 AM, Alexander Vergun wrote: Hello all, I am coding a voice assistant under Python 3.7, Windows 7. I am using PYcharm and libraries such as PYSimpleGUI, mouse, keyboard etc. Everything works except for the mouse control and probably keyboard, the problem is following, when I run the script under PYcharm, the script can control mouse only within PYcharm editor, but when the other window is on the top, the script cannot control the mouse, and the same happens when the script runs under the Python console. There is only one way to make script control the mouse - I have to manually click on the window which was opened by the script only then the script controls the mouse. I tried to call win32gui.SetCapture without any effect. Of possible interest: python-catalin Catalin George Festila. Thursday, October 10, 2019 Python 3.7.4 : Testing the PyUSB python module. https://python-catalin.blogspot.com/2019/10/python-374-testing-pyusb-python-module.html (via PlanetPython) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Mouse control
On 7/10/19 4:11 AM, Alexander Vergun wrote: I am coding a voice assistant under Python 3.7, Windows 7. I am using PYcharm and libraries such as PYSimpleGUI, mouse, keyboard etc. Everything works except for the mouse control and probably keyboard, the problem is following, when I run the script under PYcharm, the script can control mouse only within PYcharm editor, but when the other window is on the top, the script cannot control the mouse, and the same happens when the script runs under the Python console. There is only one way to make script control the mouse - I have to manually click on the window which was opened by the script only then the script controls the mouse. I tried to call win32gui.SetCapture without any effect. Does anyone have an idea how to handle this? Thank you very much, Are you asking to be able to start a Python application in one window, which will control the mouse and keyboard in other concurrent applications' windows? I don't use MS-Windows, but don't think this is possible (under any OpSys). As you say "and probably keyboard": imagine typing and having the text appear in every open window/application? If you don't want that, how do you indicate which one should accept the input? Answer: "focus" = the 'target' for any typing is the application/window which currently has focus. Extending those thoughts to the mouse doesn't quite ring-true, because I'm currently in 'this' window writing an email message, yet the mouse will cheerfully scroll the window 'below'. Is that the sort of action you wish? In my experience, the Python application, including "mouse", only operates in "user space" and within the one window. If we can extend Python's power and dominion, I'll be interested to learn... Meantime, there are demo snippets which follow the mouse, printing its coordinates. Using one of those, what happens to the coordinates when the mouse is moved outside of the Python application's window? BTW you may like to take a look at PyAutoGUI, if only because it has been more recently updated. It may also help by bringing 'everything' under one import rather than the multiple packages (listed above): https://pypi.org/project/PyAutoGUI/ https://pyautogui.readthedocs.io/en/latest/mouse.html https://automatetheboringstuff.com/chapter18/ -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list