Re: Multi-threading with a simple timer?

2018-07-03 Thread David D
This works, but does not do exactly what I want. What I want to happen is : when the user enters in a correct answer, the program and threading stops. Any ideas on what I should change? import time from threading import Thread class Answer(Thread): def run(self): a=input("What

Re: Multi-threading with a simple timer?

2018-07-03 Thread David D
This works, but does not do exactly what I want. When the user enters in a correct answer, the program and threading stops. Any ideas on what I should change? import time from threading import Thread class Answer(Thread): def run(self): a=input("What is your answer:") if a=

Re: Multi-threading with a simple timer?

2018-07-03 Thread David D
I have some success with this. I am not sure if this would work longer term, as in restarting it, but so far so good. Any issue with this new code? import time from threading import Thread th=Thread() class Answer(Thread): def run(self): a=input("What is your answer:") if a

RE: Checking whether type is None

2018-07-24 Thread David Raymond
https://docs.python.org/3.7/library/constants.html "None The sole value of the type NoneType..." "x is None" and "type(x) is type(None)" are equivalent because of that. I think though that the better way to do the first tests would be to use isinstance https://docs.python.org/3.7/library/functi

RE: Python bug in ArcGIS - Urban Network analysis tool

2018-07-30 Thread David Raymond
A note that Arc may have installed its own version of Python, which it is using from within its own tools. For example, I've got a full Python installation in C:\Python27\ArcGIS10.2 which Arc installed on top of a preexisting installation in C:\Python27. So you may need to explicitly run it with

RE: Python Console Menu

2018-07-31 Thread David Raymond
Take a look at the subprocess module for how to "spawn new processes, connect to their input/output/error pipes, and obtain their return codes." https://docs.python.org/2/library/subprocess.html -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@p

RE: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-01 Thread David Raymond
A couple notes: -I think the Python interpreter actually sends its output to stderr, so to capture it you'd probably want it to go to the same place as stdout, so use stderr = subprocess.STDOUT -You're only reading 1 line out output for each thing, so if 1 command creates multiple lines of out

RE: How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

2018-08-15 Thread David Raymond
So what are you saying is an option vs an argument? Because I see no distinction whatsoever. When you run something you give it a bunch of strings. That's it. There is nothing magical about putting a dash in front of a letter, nothing magical about putting in a string that might possibly also b

RE: ignoring some default fields from SimpleJsonFormatter

2018-08-21 Thread David Raymond
https://docs.python.org/3.7/library/logging.html#logging.Logger.debug https://docs.python.org/3.7/library/logging.html#logging.Formatter.format Basically your Formatter string doesn't include %(anotherfield1)s in it anywhere, so that gets ignored. To have a variable number of those in there you

RE: Python Postgresql complete guide

2018-08-23 Thread David Raymond
Looks good. Having used psycopg2 a fair amount, here are some suggestions I have on extra things to cover or emphasize. -Postgres specific things like remembering to "set search_path to blargh, public;" etc as needed before querying. -An example case of cur.fetchone() returning None, or more

RE: How to sort over dictionaries

2018-08-29 Thread David Raymond
Well, that's a list of... somethings. So I'm assuming you mean sort a list of dictionaries? foo.sort(key = lambda x: time.strptime(x["date"], "%d-%m-%Y %H:%M")) with , reverse = True in the sort if you want it sorted in reverse -Original Message- From: Python-list [mailto:python-list

RE: How to sort over dictionaries

2018-08-30 Thread David Raymond
Remember to check what the res["date"] types actually are. If they're just text, then it looked like they were in M/D/Y format, which won't sort correctly as text, hence you might want to include using datetime.strptime() to turn them into sortable datetimes. -Original Message- From: P

RE: Why emumerated list is empty on 2nd round of print?

2018-09-06 Thread David Raymond
The actual "enumerate" object is really just holding a current index and a reference to the original list. So if you alter the original list while you're iterating through it you'll see the changes. If you want a full copy then you can just wrap it with list() Python 3.7.0 (v3.7.0:1bf9cc5093, J

RE: [SPAM] Type error: not enough arguments for format string

2018-09-19 Thread David Raymond
My first bet at the culprit is the space between the % and (message)s, they should be together like you have them for asctime. -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of synch1...@gmail.com Sent: Wednesday, Septemb

Re: [OT] master/slave debate in Python

2018-09-26 Thread David Palao
Hello, My opinion is that the terms "master/slave" describe well some situations. They could be seen by some people as offensive (although unfortunately sometimes true, even today) when applied to persons. But it is not offensive when applied to processes in a computer. They are not living entities

RE: [OT] master/slave debate in Python

2018-09-26 Thread David Raymond
...Think about how you treat your computers - you have the power to discard them if they do not work correctly, or even if you just want to get a newer one. You have the power to kick them across the room and nobody will arrest you. Maybe you don't do those things (I would hope you don't kick co

Windows file associations fix

2018-11-09 Thread David Raymond
Would some kind person be so good as to point me to instructions on how to fix Windows file associations and default programs for the various Python extensions (.py/.pyw/etc)? I know I've fixed this before after installing a new version, but didn't save the instructions, and apparently my search

Re: How to parameterize unittests

2016-04-14 Thread David Palao
2016-04-14 16:08 GMT+02:00 Antoon Pardon : > > I have a unittest for my avltree module. > > Now I want this unittest to also run on a subclass of avltree. > How can I organise this, so that I can largely reuse the > original TestCase? > > -- > Antoon Pardon > -- > https://mail.python.org/mailman/li

Re: Guido sees the light: PEP 8 updated

2016-04-18 Thread David Palao
2016-04-18 5:19 GMT+02:00 Steven D'Aprano : > On Mon, 18 Apr 2016 11:39 am, Rustom Mody wrote: > >> yes we can agree on this -- arbitrary line lengths are almost certainly >> unreadable. >> The problem then becomes so what is optimal? > > I really don't think it is a problem. We have about 400 year

How to read from serial port?

2016-04-26 Thread David Aldrich
sing Python 3.5. How would I fix this error please? Best regards David -- https://mail.python.org/mailman/listinfo/python-list

Re: String concatenation

2016-05-10 Thread David Palao
2016-05-10 9:54 GMT+02:00 Steven D'Aprano : > On Tuesday 10 May 2016 17:13, Paul Rubin wrote: > >> Steven D'Aprano writes: >>> Australia's naming laws almost certainly wouldn't allow such a name. >> >> https://en.wikipedia.org/wiki/Facebook_real- > name_policy_controversy#Vietnamese > > "Phuc Dat

Re: for / while else doesn't make sense

2016-05-19 Thread David Jardine
> no_such_thing() > > > > I think of the "else" as being paired with the "if" inside the loop. > > At run time, you execute a number of "if"s, one for each iteration > > around the loop. The "else" is what gets executed if none of the > > "if"s was true. In that sense, it's exactly the right keyword to > > use. > > Cheers, David -- https://mail.python.org/mailman/listinfo/python-list

Re: How to implement semaphores in python?

2016-06-07 Thread David Palao
Hi, Have you checked this https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Semaphore ? Best 2016-06-07 11:43 GMT+02:00 karthik jagilinki : > Hello All, > > I need some help with semaphore implementation between two programs in > python. I'd be glad if anyone can give me som

Re: passing dictionay as argument

2016-06-13 Thread David Navarro
id', > 'api_transaction_key', > ) > > result = authorize.Transaction.sale({'amount': 40.00,credit_card}) > > result.transaction_response.trans_id > > it returns following error: > > result = authorize.Transaction.sale({40.00,credit_card}) > TypeError: unhashable type: 'dict' > > Do I need to make changes in authorize.Transaction.sale() source code? > -- > https://mail.python.org/mailman/listinfo/python-list > -- David Navarro Estruch -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread David Rock
on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import netifaces >>> gws = netifaces.gateways() >>> gws {'default': {2: ('192.168.69.1', 'en0')}, 2: [('192.168.6

RE: Windows file associations fix

2018-11-13 Thread David Raymond
working happily now. Again, many thanks for the replies. -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of eryk sun Sent: Friday, November 09, 2018 6:43 PM To: Python Subject: Re: Windows file associations fix On 11/9/18

RE: Why do integers compare equal to booleans?

2018-11-16 Thread David Raymond
A boolean type didn't come about until version 2.3, and even now they still inherit from integers. Some links for you: https://docs.python.org/3.7/whatsnew/2.3.html#pep-285-a-boolean-type https://docs.python.org/3.7/library/stdtypes.html#boolean-values https://docs.python.org/3.7/reference/datam

Re: Generators, generator expressions, and loops

2018-11-18 Thread David Neil
Steve, On 17/11/18 03:52, Steve Keller wrote: I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or all powers of two, for example? In C it would be for (int i = 0; ; i++)

RE: Variable number of arguments

2018-12-17 Thread David Raymond
argparse works fine on 3.x https://docs.python.org/3.6/library/argparse.html You can't really have back to back _positional_ arguments with nargs = "+" as it won't be able to tell where you meant one group to end and the next to begin. You'd have to call it with switches like script.py -if inFi

RE: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread David Raymond
Agreeing with the other poster that it's probably not the best way to handle it. But for the sake of helping with subprocess: https://docs.python.org/3.7/library/subprocess.html#popen-objects Popen Objects don't have read() as the error says. That's on their .stdout and .stderr streams. So you'd

RE: How can I find the indices of an array with float values in python?

2019-01-10 Thread David Raymond
Maybe something along the lines of... indices = [i for i, val in enumerate(x) where 0 <= val <= 15000] -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of Madhavan Bomidi Sent: Thursday, January 10, 2019 12:05 PM To: python

RE: Pythonic Y2K

2019-01-18 Thread David Raymond
Which brings up the assumption that this whole A.D. thing is gonna stick around for more than a few millennia and isn't just a fad. Sloppy to just use positive for A.D. and negative for B.C. without a discrete unit for Age. What happens when Sauron is defeated and the Third Age is declared? Or i

RE: Pythonic Y2K

2019-01-18 Thread David Raymond
Reminds me of a similar problem that didn't get noticed until it did actually hit: In 2007 the first time a group of F-22's crossed the international date line every computer system in the aircraft crashed, losing comms, navigation, avionics, and a host of other systems. Fortunately their engine

time.strftime question on 0 as argument

2019-01-28 Thread David Raymond
https://docs.python.org/3.7/library/time.html#time.strftime In the docs there is "0 is a legal argument for any position in the time tuple; if it is normally illegal the value is forced to a correct one." and yet if given 0 for the year/first item in the tuple it raises a ValueError. Is that a

RE: Loop with else clause

2019-02-05 Thread David Raymond
As mentioned somewhere, "readability counts", so why not just go with exactly what you said... if len(nominees) > 0:#if a condition exists for nominee in nominees: #the loop should be executed print(nominee) else:#but if not

RE: timezones

2019-02-07 Thread David Raymond
I'd say if the documentation mentions it, but doesn't say why, then we're not gonna be able to do much better for you as far as "why" goes. http://pytz.sourceforge.net/ "Unfortunately using the tzinfo argument of the standard datetime constructors "does not work" with pytz for many timezones."

RE: more pythonic way

2019-02-11 Thread David Raymond
My non-expert vote is for if month is None: month = datetime.date.today().month Because you're checking for your default value, not whether the boolean version of what they did give you is True or False. It's explicit, it's not reliant on any __bool__() function implementations or overrides

RE: I cannot seem to write time/date to the file.

2019-02-12 Thread David Raymond
DateReading.write = (nowTimeDate2 + "\n") You're re-assigning the write method to be a string here. You want to call the method with the string as the argument. DateReading.write(nowTimeDate2 + "\n") -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomto

RE: Convert a list with wrong encoding to utf8

2019-02-14 Thread David Raymond
Next question is how did you _insert_ those names into the database previously? Are the names showing up ok using any other tool to look at them? The error might have been on insert and you're just seeing weird stuff now because of that. Maybe, where instead of giving it the text and letting the

RE: confusion with os.chmod() and follow_symlinks

2019-02-22 Thread David Raymond
Not sure, but the way I read it follow_symlinks = True is the default behavior of systems that don't allow you to set it, and being able to set it to False is the special bit. So "allowing follow_symlinks" means it "allows you to change it to whatever you want", not "allows it to be True" Under

RE: in a pickle

2019-03-06 Thread David Raymond
https://docs.python.org/3.7/library/pickle.html#pickling-class-instances includes 2 notes, which I think are the relevant ones: When a class instance is unpickled, its __init__() method is usually not invoked. The default behaviour first creates an uninitialized instance and then restores the s

RE: System Beep?

2019-03-08 Thread David Raymond
Windows has the built in winsound module that lets you set frequency and duration, not sure about other OS's. https://docs.python.org/3.7/library/winsound.html -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of Steve Sent

RE: System Beep?

2019-03-08 Thread David Raymond
I believe you added an extra D there. winsound, not winDsound -Original Message- From: Steve [mailto:Gronicus@SGA.Ninja] Sent: Friday, March 08, 2019 3:16 PM To: David Raymond; python-list@python.org Subject: RE: System Beep? = RESTART: C:\Gork\Med Insulin codes

RE: What is the difference between "ws.Messagebeep(1)" and "ws.Messagebeep(-1)" ?

2019-03-21 Thread David Raymond
I'm assuming by ws you mean winsound? Check the docs: https://docs.python.org/3.7/library/winsound.html winsound.MessageBeep(type=MB_OK) Call the underlying MessageBeep() function from the Platform API. This plays a sound as specified in the registry. The type argument specifies which s

RE: Losing words

2019-04-01 Thread David Raymond
https://docs.python.org/3.7/library/socket.html#socket.socket.send .send returns the number of bytes that it actually succeeded in sending. From the docs: "Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to a

RE: I want understand how this word wrap program playing on input

2019-04-04 Thread David Raymond
The function is constructing a list of the lines, which it will combine at the end. Answering the questions in reverse order: 3. Also why that `if` test is required there. The if statement is saying "I don't have room on my current line for the next word, so time to start a new line" 2. In the

RE: I want understand how this word wrap program playing on input

2019-04-04 Thread David Raymond
> Yep, spotted that too! :-) BTW, your fix also a bug: the last word on a > line won't be followed by a space (off-by-one). The easiest fix for that > is to add 1 to line_length initially, another little trick. > Or, equivalently, to reset current_line_length to -1, which is an elegant > hack. I

RE: break out of a program

2019-04-19 Thread David Raymond
The normal way of saying you want to exit the whole program is with sys.exit() https://docs.python.org/3.7/library/sys.html#sys.exit You can optionally give it the return code/exit status you want the interpreter to give to the OS when it exits. -Original Message- From: Python-list [ma

A newbie question about using tix

2019-04-30 Thread David Sumbler
but I just can't get it to work. If I run: from tkinter import * from tkinter.tix import FileSelectBox root = Tk() f = FileSelectBox(root) I get the following: Traceback (most recent call last): File "/home/david/bin/Gradient.py", line 4, in

Re: A newbie question about using tix

2019-05-01 Thread David Sumbler
On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: > On 2019-04-30 16:40, David Sumbler wrote: > > Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6 > > > > I am very new to tkinter. The simple program I am writing requires > > a > > user file to be selected before

tix.FileSelectBox causes crash: was A newbie question about using tix

2019-05-03 Thread David Sumbler
On Wed, 2019-05-01 at 19:11 +0100, MRAB wrote: > On 2019-05-01 17:44, David Sumbler wrote: > > > > On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: ... > > > For some reason, tix widgets don't work with normal tkinter > widgets, > > > so >

RE: PYTHONHASHSEED VALUE

2019-05-14 Thread David Raymond
What is the test case actually checking for, and why? One of the main aspects of a set is that it's unordered. So something checking to make sure the order of an unordered object is some static value seems like it's testing for the wrong thing. -Original Message- From: Python-list [ma

RE: More CPUs doen't equal more speed

2019-05-23 Thread David Raymond
You really need to give more info on what you're doing in doit() to know what's going on. Are you using subprocess, threading, multiprocessing, etc? Going off of what you've put there those nested for loops are being run in the 1 main thread. If doit() kicks off a program and doesn't wait for it

RE: Threading Keyboard Interrupt issue

2019-05-29 Thread David Raymond
That's a little weird, and my running it works slightly differently. Please paste exactly what you're running (no time import and true being lowercase for example means we couldn't copy and paste it and have it immediately run) In your script, the main thread hits y.start() which completes succe

problem about the installation

2019-06-17 Thread David Martin
Hello there! My computer windows is 8 and the operating system is 32-bit operating system, based upon x64 processor but I got a problem during installation, could you please assist me about this? I appreciate your efforts in advance. Thanks Yours sincerely YarDel Daudy

Re: Creating a Windows executable on a Linux system

2019-06-26 Thread David Sumbler
e only tried it with one file, which I wanted to send to my brother. I'm using Ubuntu 18.04, and the command: wine ~/.wine/drive_c/Python34/Scripts/pyinstaller.exe --onefile bin/GradientProfile_v2.py produces a file that my brother can run on his Windows 10 machine. David -- https://mail.

RE: Boolean comparison & PEP8

2019-07-29 Thread David Raymond
I think the other part of the discussion to be had here is: how do you name your booleans? As with other things, "x", and "greeting" aren't really the best names. "greeting" sounds like it should hold what the greeting _is_, not whether or not there _should be_ a greeting. If it were something

RE: Xml File Error

2019-07-30 Thread David Raymond
Is that the correct path to the file, without any typos? os.path.abspath and os.path.join don't do any checking on whether their resulting path exists. So if there is a typo or error in your path it doesn't get reported until you actually try and open it by running ElementTree.parse You can che

RE: Python/SQLite best practices

2019-08-05 Thread David Raymond
Not a full expert, but some notes: I believe the default Connection context manager is set up for the context to be a single transaction, with a commit on success or a rollback on a failure. As far as I know it does NOT close the connection on exiting the context manager. That only happens aut

RE: Python/SQLite best practices

2019-08-05 Thread David Raymond
"What's the advantage of this over letting the connection object do that for you? As the context manager exits, it will automatically either commit or roll back. If you want to guarantee closing _as well_, then you can do that, but you can at least use what already exists." After review I guess I

RE: Weird Python Bug

2019-09-13 Thread David Raymond
2 comments: First: Deleting from a list while you're iterating over it is a bad idea. Your first iteration gives nums[0] which is 72. But then you delete that and (in effect) everything moves up. So now the 4 is in the nums[0] slot. Your second iteration returns nums[1] which is now the 82 mean

RE: Exception

2019-09-24 Thread David Raymond
I believe the idea is that previously, if you were handling an exception, and your handling code caused its own exception, then you would get no info about the original exception. So all useful information about the original problem would get lost because of an oopsie in the handling code. So it

RE: Calculations and Variables

2019-10-31 Thread David Raymond
How are you getting any value at all? You are trying to do math on string values just like in your infinite loop question. This should raise TypeError: unsupported operand type(s) for /: 'str' and 'str' Also, tips are usually given as percentages. Here with a tip value of 9 you're saying that th

RE: How execute at least two python files at once when imported?

2019-11-06 Thread David Raymond
"Why is importing modules in parallel bad?" In general I'd say that "import foo" is supposed to be there because you want the classes, functions, variables etc. in foo to be available in your current program. A module should never run a whole bunch of time consuming stuff when it's imported. If

RE: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread David Raymond
Here is it rewritten using the proposal: ``` #Definition def myFoo (str1, str2, foo, str = " "): print( foo(str = str1), foo(str = str2) ) #Call myFoo ("hello", "world!"): str = list(str)[0].upper() + str[1:] return str ``` Are you looking for multi-line l

RE: How to delay until a next increment of time occurs ?

2019-11-13 Thread David Raymond
Maybe something along the lines of this? timeInterval = 0.0003 time.sleep(timeInterval - (time.perf_counter() % timeInterval)) -Original Message- From: Python-list On Behalf Of R.Wieser Sent: Wednesday, November 13, 2019 11:12 AM To: python-list@python.org Subject: Re: How to delay un

RE: How to delay until a next increment of time occurs ?

2019-11-13 Thread David Raymond
n.org Subject: Re: How to delay until a next increment of time occurs ? David, > timeInterval = 0.0003 > time.sleep(timeInterval - (time.perf_counter() % timeInterval)) Possibly: any reason for the performance counter modulo the interval ? Regards, Rudy Wieser -- https://mail.python.o

RE: threading

2019-12-04 Thread David Raymond
100 increments happen very fast, and means each thread will probably complete before the main thread has even started the next one. Bump that up to 1_000_000 or so and you'll probably trigger it. I did a test with a print(x) at the start of test() to see what the number was when each thread kic

Idiom for partial failures

2020-02-20 Thread David Wihl
e-ads-python [1] https://developers.google.com/google-ads/api/docs/start [2] https://developers.google.com/google-ads/api/docs/best-practices/partial-failures [3] https://github.com/googleads/google-ads-python/blob/master/examples/error_handling/handle_partial_failure.py Thanks! -David --

Re: Idiom for partial failures

2020-02-21 Thread David Wihl
Yes, the API has to support partial failures across all six supported languages. Not all operations need to be atomic and there is considerable efficiency in having multiple operations sent in a single request. Thanks, -David On Thu, Feb 20, 2020 at 6:07 PM Rob Gaddi wrote: > On 2/20/20 9:30

Re: [Python-ideas] Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-09 Thread David Mertz
This isn't a terrible use of the walrus operator either. if blue_20 := (color==BLUE and count==20) or red_5 := (color==RED and count%5==0) rotate_the_wheel() # Common to the two sub-conditions if blue_20: # First sub-condition set_signal() if red_5: # Second sub-condition

RE: Please solve this problem

2020-03-09 Thread David Raymond
> It was a problem and it was solved. > Check the second or third e-mail in the thread. > > Thank you. The first email was blank, The second email was from the same person and just said "Rply if solved" The third was a sarcastic reply to the blank emails with just: "Solved, answer is:" The fo

RE: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-19 Thread David Raymond
For dictionaries it'd even be more useful: d = { 'first_name': 'Frances', 'last_name': 'Allen', 'email': 'fal...@ibm.com' } fname, lname = d[['first_name', 'last_name']] Why not do this? import operator first_last = operator.itemgetter("first_name", "last_name"

RE: Multiprocessing queue sharing and python3.8

2020-04-06 Thread David Raymond
Attempting reply as much for my own understanding. Are you on Mac? I think this is the pertinent bit for you: Changed in version 3.8: On macOS, the spawn start method is now the default. The fork start method should be considered unsafe as it can lead to crashes of the subprocess. See bpo-33725.

RE: Multiprocessing queue sharing and python3.8

2020-04-06 Thread David Raymond
= mp.Pool(initializer = pool_init, initargs = (mp_comm_queue,)) ... -Original Message- From: David Raymond Sent: Monday, April 6, 2020 4:19 PM To: python-list@python.org Subject: RE: Multiprocessing queue sharing and python3.8 Attempting reply as much for my own understanding. Are you on

RE: Is there anything in the script which could cause it to not run its full course please?

2020-05-04 Thread David Raymond
Not necessarily the cause of your problem, but if you're going to compare dates it should be as objects, or as text as year-month-day. Here you're comparing dates as text in day-month-year format. So January first comes before May 4th 2020 "01-01-" < "04-05-2020" ... 04-05-2020 09:30:

RE: how to let argument be optional falling back to certain integer

2020-06-22 Thread David Raymond
> This is true. I have written 0 as false in C so many times. But > clearly for me times have changed... I now look at numbers as a thing > in their own special class not to be confused as truth-values. (So much > so that I fell for this.) But I confess I still think of numbers as all > TRUE

RE: Python Scripts

2020-07-21 Thread David Raymond
> im having problems when running python scripts > > When running the scripts it always closes immediately If you're running it in Windows, and running it by double clicking on a .py file, then it will pop up a console window while it's running, and then immediately close that window when the s

RE: Python Scripts

2020-07-21 Thread David Raymond
Remember to reply-all, so that python-list is included and can still see responses and offer help. If Python won't open them, then how do you know the scripts work? They work on someone else's computer you mean? Please provide the basics then so we can try to help out. What OS are you using? H

Proposal: SimpleNamespace "recursive" parameter

2020-08-13 Thread David Rashty
It would be nice if you could do this to create a "nested" SimpleNamespace: >>> d = {"_meta": {"fields": ({"name": "field0"}, {"name": "field1"})}} >>> sns = SimpleNamespace(**d) >>> print(sns._meta.fields[0].name) # This is what I wish you could do 'field0' SimpleNamespace does this though: >>>

RE: Final statement from Steering Council on politically-charged commit messages

2020-08-18 Thread David Raymond
> Do I agree with the PR, not exactly. However, I do think we as a community > should be accommodating to people > Whose use of the English language differs from the standard as long as the > meaning is clear. Remember that the problem isn't the change in wording of the PEP. That's all well and g

RE: Didn't understand the output of the following Python 3 code with reduce function?

2020-08-28 Thread David Raymond
All the numbers in the nums list don't matter and aren't used. Only the first number, and how many there are. https://docs.python.org/3.8/library/functools.html#functools.reduce Basically it's doing ADDS(1, 2) which returns 2 that 2 gets fed back into ADDS(2, 3) which returns 3 that 3 gets fed ba

RE: grouping and sorting within groups using another list

2020-09-02 Thread David Raymond
Would it be something as simple as: rows.sort(key = lambda x: (x[0], x[3], x[4], sort_list.index(x[6]))) -Original Message- From: Python-list On Behalf Of Larry Martell Sent: Wednesday, September 2, 2020 1:55 PM To: Python Subject: grouping and sorting within groups using another lis

RE: [RELEASE] Python 3.8.6 is now available

2020-09-29 Thread David Raymond
> Python 3.8.6 is the sixth maintenance release of Python 3.8. Go get it here: > https://www.python.org/downloads/release/python-386/ > Just a quick note that there still seem to be a few places on the website which are still showing 3.8.5

lmoments3 and scipy (again)

2020-10-13 Thread David Painter
48.3,46.6] >>> paras = distr.gpa.lmom_fit(data) Traceback (most recent call last): File "", line 1, in paras = distr.gpa.lmom_fit(data) File "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\distr.py", line 59, in lmom_fit

Re: lmoments3 and scipy (again)

2020-10-14 Thread David Painter
Thank you, Kyle and Dennis. The developer version from 17 months ago, which I hadn't spotted, has solved my immediate problem. It would be good to have it mainstreamed to prevent others having the same problem. David On Thu, 15 Oct 2020 at 09:07, Dennis Lee Bieber

RE: Are there Python ways to execute queries on PostgreSQL without getting data over?

2020-10-19 Thread David Raymond
> Are there Python ways to execute queries on PostgreSQL without getting data > over? > > Are there ways just to fire off PostgreSQL queries and not get data into > Python? > > Regards, > > David What is your use case for this? Normally when you do basic things

Re: Strange terminal behavior after quitting Tkinter application

2020-11-03 Thread David Burnette
On Wednesday, April 18, 2007 at 12:33:24 AM UTC-7, Chris wrote: > Hi, > I'm puzzled by some strange behavior when my Python/Tkinter > application quits (on linux): the terminal from which I started Python > is messed up. > If start up python, then import the code below, then start the program > wit

constant folding - why not more

2020-11-10 Thread David Kolovratník
Dear all, I would like to learn about constant folding optimisation in Python. It seems to be implemented in Python/ast_opt.c. In order to get impression I used python3 and dis module: $ python3 -V Python 3.7.3 Arithmetics expression is folded as expected: >>> dis.dis(compile('1 * 2', filename=

Re: tkinter global variable

2020-11-13 Thread David Kolovratník
o what do I need to do access the variable? How > >> do I return a value from that function? > >> > >> Thanks. > > > > The problem is that you are accessing the variable BEFORE the box has > > been put up and the user clicking on it. That doesn't happen until the > > mainloop() call. You need to delay the opening and reading of the file > > till the filedialog has been used and returned. > > > > Perhaps on_openfile could open and read the file. > > Ok. Then how do I access the content of the file from outside the > function? How can I access return value? > Thanks. What about def on_printfilename(): global pic try: print( f"C: {pic}" ) except NameError: print( f"C! pic not set yet" ) together with file_menu.add_command(label="Print filename", command=on_printfilename) Or move your print("B") block behind the mainloop(). David -- https://mail.python.org/mailman/listinfo/python-list

RE: primitive password cracker

2021-01-07 Thread David Raymond
I think you might want to check out itertools.product() https://docs.python.org/3.9/library/itertools.html#itertools.product import itertools import string passe = 'pass' for p in itertools.product(string.ascii_lowercase, repeat = 4): p = "".join(p) if p == passe: print("Found it:"

Re: primitive password cracker

2021-01-07 Thread David Kolovratník
its end. I stop here in order to leave space for Bischoop's deliberation. To sum up in order words, the clue is to stop thinking of inner loops for each letter and find a way to get the next combination. Best, David On Thu, Jan 07, 2021 at 04:52:56PM -, Bischoop wrote: > On 2021-01-0

Sniffing Text Files

2005-09-22 Thread David Pratt
less to delimited files. I have a couple of ideas on what I could do but I am interested in hearing from others on how they might handle something like this so I can determine the best approach to take. Many thanks. Regards, David -- http://mail.python.org/mailman/listinfo/python-list

Re: Sniffing Text Files

2005-09-23 Thread David Pratt
o the file. As it stands I am filtering mime types to the importing process to attempt to limit the possibilities. Regards, David On Friday, September 23, 2005, at 02:01 AM, Mike Meyer wrote: > David Pratt <[EMAIL PROTECTED]> writes: > >> Hi. I have files that I will b

Re: Sniffing Text Files

2005-09-23 Thread David Pratt
Hi Skip. Thank you for your reply. This is helpful and I am glad I put this to the list. There are some really good ideas that will help me come up with something good to use. Regards, David On Friday, September 23, 2005, at 11:14 AM, [EMAIL PROTECTED] wrote: > > David> I re

Re: Sniffing Text Files

2005-09-23 Thread David Pratt
Thanks Mike this is really great! Regards, David On Friday, September 23, 2005, at 11:55 AM, Mike Meyer wrote: > David Pratt <[EMAIL PROTECTED]> writes: >> Thanks Mike for your reply. I am not aware of libmagic and will look >> to see what it provides. > > and ...

Re: Sniffing Text Files

2005-09-26 Thread David Pratt
lines should probably be good enough to generate a decent scores for the type. Regards, David > def sniff(filename): > """Return one of "xml", "csv", "txt" or "tkn", or "???" > if it can't decide the file ty

Python Programming

2005-09-26 Thread David Edwards
o read and render the info using PIL instead, as well as allowing me to save the results in .ps, .eps, or .ai formats for use in other programs like Photoshop or Illustrator. If anyone has the skills, what would you charge? Thanks, David __ Do You Yah

Re: Vancouver Python and Zope: Next Meeting Oct 2nd

2005-09-26 Thread David Ascher
On 9/26/05, Casey Hawthorne <[EMAIL PROTECTED]> wrote: > Where is ActiveState? 580 Granville St, (corner of Dunsmuir). See http://maps.google.com/maps?q=580+Granville+St,+Vancouver+BC&spn=0.027339,0.057730&hl=en -- http://mail.python.org/mailman/listinfo/python-list

Cleveland Ohio Python Meeting

2005-09-28 Thread David Stanek
October 6 from 18:30-20:30 A presentation will be given on Django and I am sure that we will discuss web frameworks in general. Everyone is welcome. For more details take a look at http://www.clepy.org/meetings/2005_10_06_mtg_details David -- GPG keyID #6272EDAF on http://pgp.mit.edu Key

<    2   3   4   5   6   7   8   9   10   11   >