Re: songbird's ngfp
flaskee wrote: ... > I look forward to seeing your game. > > Thanks! unfortunately the system needs a bit more complicated things to be installed for ngfp to also be installed. pkg-config and the cairo/pycairo stuff and a compiler... note, i have not had any chance to look into this further. some time ago i did see mention of wheels provided by the cairo/pycairo github project, but since it is still gardening season i've been a bit too busy to poke at this more to find out what has happened and how that might change the installation of ngfp. still, thank you again for trying and for the feedback. :) songbird -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a conflict of libraries here?
On 06Nov2020 09:36, Frank Millman wrote: >On 2020-11-06 9:25 AM, Steve wrote: >>In my program, I have the following lines of code: >> import datetime >> from datetime import timedelta >> >> from time import gmtime, strftime ##define strftime as time/date right >>now >>If I add the code: >> >> from datetime import datetime >> >>these new lines work: >> >>dt = datetime.fromisoformat(ItemDateTime) >> >>dt_string = dt.strftime(' at %H:%M on %A %d %B %Y') >> >>and will fail without that "datetime import datetime" line Right, because you're using the datetime _class_ to get the fromisoformat factory function. >>however; >> >> >>With that "datetime import datetime" line included, >> >>all of the lines of code throughout the program that contain >>"datetime.datetime" fail. >>These have been in use for over three years and there are at least a dozen >>of them. Yeah. because _those_ lines are using the name "datetime" as the module name. Just replace "datetime.datetime" throughout with "datetime". Your code will be more readable anyway. >>The error produced is: >> >> time1 = datetime.datetime.strptime(T1, date_format) >> >> AttributeError: type object 'datetime.datetime' has no attribute >>'datetime' That is because "datetime" is currently the class, not the module. >1. Remove the line 'from datetime import datetime'. > >2. Change dt = datetime.fromisoformat(ItemDateTime) to > dt = datetime.datetime.fromisoformat(ItemDateTime) > >Unless I have missed something, that should work. That will work, but produces verbose code. I prefer to import things _from_ the datetime module, letting me drop the 'datetime." module prefix across the code. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Incoming datas difficult to read "\r\n" and "\n"
I'm experimenting with irc bot. I've made it connecting, reading etc but everything is difficult to read. It's coming like one long string without breaking lines. How to mace it printing in new line after: \r\n or \n in data? -- b':weber.freenode.net 001 saaaki :Welcome to the freenode Internet Relay Chat Network saaaki\r\n:weber.freenode.net 002 saaaki :Your host is weber.freenode.net[162.213.39.42/6667], running version ircd-seven-1.1.9\r\n:weber.freenode.net 003 saaaki :This server was created Wed Dec 18 2019 at 21:37:52 UTC\r\n:weber.freenode.net 004 saaaki weber.freenode.net ircd-seven-1.1.9 DOQRSZaghilopsuwz CFILMPQSbcefgijklmnopqrstuvz bkloveqjfI\r\n:weber.freenode.net 005 saaaki CHANTYPES=# EXCEPTS INVEX CHANMODES=eIbq,k,flj,CFLMPQScgimnprstuz CHANLIMIT=#:120 PREFIX=(ov)@+ MAXLIST=bqeI:100 MODES=4 NETWORK=freenode STATUSMSG=@+ CALLERID=g CASEMAPPING=rfc1459 :are supported by this server\r\n:weber.freenode.net 005 saaaki CHARSET=ascii NICKLEN=16 CHANNELLEN=50 TOPICLEN=390 DEAF=D FNC TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,ACCEPT:,MONITOR: EXTBAN=$,ajrxz CLIENTVER=3.0 SAFELIST ELIST=CTU KNOCK :are supported by this server\r\n:weber.freenode.net 005 saaaki CP -- My code: -- while 1: time.sleep(2) data=s.recv(2040) print(data) if data.find(b"PING"): s.send(b"PONG :pingis") - -- https://mail.python.org/mailman/listinfo/python-list
Re: Incoming datas difficult to read "\r\n" and "\n"
On Fri, Nov 6, 2020 at 11:26 PM Bischoop wrote: > > > I'm experimenting with irc bot. I've made it connecting, reading etc but > everything is difficult to read. > > It's coming like one long string without breaking lines. > How to mace it printing in new line after: \r\n or \n in data? > -- > > b':weber.freenode.net 001 saaaki :Welcome to the freenode Internet Relay > Chat Network saaaki\r\n:weber.freenode.net 002 saaaki :Your host is > weber.freenode.net[162.213.39.42/6667], running version > ircd-seven-1.1.9\r\n:weber.freenode.net 003 saaaki :This server was > created Wed Dec 18 2019 at 21:37:52 UTC\r\n:weber.freenode.net 004 > saaaki weber.freenode.net ircd-seven-1.1.9 DOQRSZaghilopsuwz > CFILMPQSbcefgijklmnopqrstuvz bkloveqjfI\r\n:weber.freenode.net 005 > saaaki CHANTYPES=# EXCEPTS INVEX CHANMODES=eIbq,k,flj,CFLMPQScgimnprstuz > CHANLIMIT=#:120 PREFIX=(ov)@+ MAXLIST=bqeI:100 MODES=4 NETWORK=freenode > STATUSMSG=@+ CALLERID=g CASEMAPPING=rfc1459 :are supported by this > server\r\n:weber.freenode.net 005 saaaki CHARSET=ascii NICKLEN=16 > CHANNELLEN=50 TOPICLEN=390 DEAF=D FNC > TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,ACCEPT:,MONITOR: > EXTBAN=$,ajrxz CLIENTVER=3.0 SAFELIST ELIST=CTU KNOCK :are supported by > this server\r\n:weber.freenode.net 005 saaaki CP > -- > > My code: > -- > while 1: > time.sleep(2) > data=s.recv(2040) > print(data) > if data.find(b"PING"): > s.send(b"PONG :pingis") > You're currently dumping out the raw bytes. Not very interesting, and that's why it's not easy to read. I would recommend (a) decoding the bytes to text, and (b) splitting it on "\r\n", thus getting it line-by-line. What you may want to consider, though, is using an actual IRC library. It'll handle all kinds of details for you :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Incoming datas difficult to read "\r\n" and "\n"
On 2020-11-06, Chris Angelico wrote: > You're currently dumping out the raw bytes. Not very interesting, and > that's why it's not easy to read. I would recommend (a) decoding the > bytes to text, and (b) splitting it on "\r\n", thus getting it > line-by-line. > > What you may want to consider, though, is using an actual IRC library. > It'll handle all kinds of details for you :) > right I've changed the line to: print(data.decode('utf8')) and prints it now nice but not sure how to apply yet: print (string.splitlines( )) and PING PONG matter. -- https://mail.python.org/mailman/listinfo/python-list
Re: Incoming datas difficult to read "\r\n" and "\n"
On Fri, Nov 6, 2020 at 11:51 PM Bischoop wrote: > > On 2020-11-06, Chris Angelico wrote: > > > You're currently dumping out the raw bytes. Not very interesting, and > > that's why it's not easy to read. I would recommend (a) decoding the > > bytes to text, and (b) splitting it on "\r\n", thus getting it > > line-by-line. > > > > What you may want to consider, though, is using an actual IRC library. > > It'll handle all kinds of details for you :) > > > > right > > I've changed the line to: > print(data.decode('utf8')) > > and prints it now nice but not sure how to apply yet: > > print (string.splitlines( )) > > and PING PONG matter. Cool. You're going to have to iterate over the lines and process each one individually. IRC is a line-based protocol and every line has its own meaning. But, again, this is where an IRC library would help enormously; it'll do all of that parsing (including taking care of edge cases that you might not have thought of), and let you just handle the parts that are interesting, like responding to specific messages from people. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Incoming datas difficult to read "\r\n" and "\n"
On 2020-11-06, Chris Angelico wrote: > On Fri, Nov 6, 2020 at 11:51 PM Bischoop wrote: >> >> On 2020-11-06, Chris Angelico wrote: >> >> > You're currently dumping out the raw bytes. Not very interesting, and >> > that's why it's not easy to read. I would recommend (a) decoding the >> > bytes to text, and (b) splitting it on "\r\n", thus getting it >> > line-by-line. >> > >> > What you may want to consider, though, is using an actual IRC library. >> > It'll handle all kinds of details for you :) >> > >> >> right >> >> I've changed the line to: >> print(data.decode('utf8')) >> >> and prints it now nice but not sure how to apply yet: >> >> print (string.splitlines( )) >> >> and PING PONG matter. > > Cool. You're going to have to iterate over the lines and process each > one individually. IRC is a line-based protocol and every line has its > own meaning. But, again, this is where an IRC library would help > enormously; it'll do all of that parsing (including taking care of > edge cases that you might not have thought of), and let you just > handle the parts that are interesting, like responding to specific > messages from people. Yes, I know about irc libraries but I do it for educational purposes, when wrtiting it myself I do learn all the time new things. -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help test astral char display in tkinter Text (especially *nix)
Terry Reedy writes: > Perhaps half of the assigned chars in the first plane are printed > instead of being replaced with a narrow box. This includes emoticons > as foreground color outlines on background color. Maybe all of the > second plane of extended CJK chars are printed. The third plane is > unassigned and prints as unassigned boxes (with an X). I get the same as Menno Holscher (i.e. messages with "character is above the range blah blah") in Debian 10 with the system provided Python 3.7.3. Tcl and tk are 8.6.9. With Python 3.9.0 I get something like what you described above. Some chars print, lots of empty boxes too and lots of just empty space. No boxes with an X and no errors. -- https://mail.python.org/mailman/listinfo/python-list
I have no clue figuring out how to check dates in workholidays
Hi, Thank you for allowing me in this support mailing list. My experience with Python is short due to my new job. My boss told me that I need to create a code that checks yesterday's date. The conditions for returning none are that: - Yesterday happens to be a holiday, - Yesterday turns out to be a Saturday or a Sunday. For both reasons, it needs to return None. Now I have learned to scan a text file, and I have learned (ROUGHLY) the structure of what seems to scan for specific words in "Indented Comments". The file "gwd.py" that I have joined stands for getWorkingDate. It is the rough draft that I am creating. So what I wish is you to help me get a basic structure of what I need to edit and get gwd.py to scan cameroon.py; once everyday the gwd.py checks yesterday's date and if it fills the above conditions, it returns none. That is all. Please note that creating a separate file with the list of national holidays is ok but then I prefer using the holidays library because it evolves with the years, if you know what I mean. Please forgive my lack of proper expression as well as I have been going through Python for exactly five weeks only. Jean Jacques ECKEBIL -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a conflict of libraries here?
On Fri, 6 Nov 2020 02:25:25 -0500, Steve wrote: > In my program, I have the following lines of code: > import random > import re > import time > import datetime At this point, the name "datetime" points to a module. > from datetime import timedelta > from time import gmtime, strftime > import winsound as ws > import sys > [snip] > > from datetime import datetime By that, you have reassigned the name "datetime" to point to a class defined in the datetime module. [snip] > > AttributeError: type object 'datetime.datetime' has no attribute > 'datetime' Right, because the name "datetime" points to the class datetime in the module datetime. The class, unlike the module, has no "datetime" attribute. Apologies if you already knew this. I wasn't sure. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list
Questions about XML processing?
Hi everyone I am confronting some XML parsing challenges and would like to ask some questions to more knowledgeable Python users. Apparently there exists a group for such questions but that list (xml-sig) has apparently not received (or archived) posts since May 2018(!). I wonder if there are other list or forum for Python XML questions, or if this list would be fine for that. Thanks in advance /H. -- https://mail.python.org/mailman/listinfo/python-list
Re: Questions about XML processing?
On 11/6/2020 11:17 AM, Hernán De Angelis wrote: I am confronting some XML parsing challenges and would like to ask some questions to more knowledgeable Python users. Apparently there exists a group for such questions but that list (xml-sig) has apparently not received (or archived) posts since May 2018(!). I wonder if there are other list or forum for Python XML questions, or if this list would be fine for that. If you don't hear otherwise, try here. Or try stackoverflow.com and tag questions with python and xml. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Questions about XML processing?
Thank you Terry, Dan and Dieter for encouraging me to post here. I have already solved the problem albeit with a not so efficient solution. Perhaps, it is useful to present it here anyway in case some light can be added to this. My job is to parse a complicated XML (iso metadata) and pick up values of certain fields in certain conditions. This goes for the most part well. I am working with xml.etree.elementtree, which proved sufficient for the most part and the rest of the project. JSON is not an option within this project. The specific trouble was in this section, itself the child of a more complicated parent: (for simplicity tags are renamed and namespaces removed) Something Something else value 2020-11-06 Basically, I have to get what is in tagC/string but only if the value of tagC/note/title/string is "value". As you see, there are several tagC, all children of tagB, but tagC can have different meanings(!). And no, I have no control over how these XML fields are constructed. In principle it is easy to make a "findall" and get strings for tagC, using: elem.findall("./tagA/tagB/tagC/string") and then get the content and append in case there is more than one tagC/string like: "Something, Something else". However, the hard thing to do here is to get those only when tagC/note/title/string='value'. I was expecting to find a way of specifying a certain construction in square brackets, like [@string='value'] or [@/tagC/note/title/string='value'], as is usual in XML and possible in xml.etree. However this proved difficult (at least for me). So this is the "brute" solution I implemented: - find all children of tagA/tagB - check if /tagA/tagB/tagC/note/title/string has "value" - if yes find all tagA/tagB/tagC/string In quasi-Python: string = [] element0 = elem.findall("./tagA/tagB/") for element1 in element0: element2 = element1.find("./tagA/tagB/tagC/note/title/string") if element2.text == 'value' element3 = element1.findall("./tagA/tagB/tagC/string) for element4 in element3: string.append(element4.text) Crude, but works. As I wrote above, I was wishing that a bracketed clause of the type [@ ...] already in the first "findall" would do a more efficient job but alas my knowledge of xml is too rudimentary. Perhaps something to tinker on in the coming weeks. Have a nice weekend! On 2020-11-06 20:10, Terry Reedy wrote: On 11/6/2020 11:17 AM, Hernán De Angelis wrote: I am confronting some XML parsing challenges and would like to ask some questions to more knowledgeable Python users. Apparently there exists a group for such questions but that list (xml-sig) has apparently not received (or archived) posts since May 2018(!). I wonder if there are other list or forum for Python XML questions, or if this list would be fine for that. If you don't hear otherwise, try here. Or try stackoverflow.com and tag questions with python and xml. -- https://mail.python.org/mailman/listinfo/python-list
RE: Is there a conflict of libraries here?
"Right, because the name "datetime" points to the class datetime in the module datetime. The class, unlike the module, has no "datetime" attribute." Ok, how do I unpoint/repoint a "datetime" to let the two locations work? "Apologies if you already knew this. I wasn't sure." Absolutely did not know any of this. Libraries are a slow learning process for me Footnote Patient in the hospital: "What happens after I die?" Doctor: "We clean up the bed and bring in a new patient." -Original Message- From: Python-list On Behalf Of Peter Pearson Sent: Friday, November 6, 2020 10:36 AM To: python-list@python.org Subject: Re: Is there a conflict of libraries here? On Fri, 6 Nov 2020 02:25:25 -0500, Steve wrote: > In my program, I have the following lines of code: > import random > import re > import time > import datetime At this point, the name "datetime" points to a module. > from datetime import timedelta > from time import gmtime, strftime > import winsound as ws > import sys > [snip] > > from datetime import datetime By that, you have reassigned the name "datetime" to point to a class defined in the datetime module. [snip] > > AttributeError: type object 'datetime.datetime' has no attribute > 'datetime' Right, because the name "datetime" points to the class datetime in the module datetime. The class, unlike the module, has no "datetime" attribute. Apologies if you already knew this. I wasn't sure. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a conflict of libraries here?
On 11/6/20 3:05 PM, Steve wrote: "Right, because the name "datetime" points to the class datetime in the module datetime. The class, unlike the module, has no "datetime" attribute." Ok, how do I unpoint/repoint a "datetime" to let the two locations work? "Apologies if you already knew this. I wasn't sure." Absolutely did not know any of this. Libraries are a slow learning process for me The Python import command does some stuff behind the scenes, but from the programmer viewpoint, you're just manipulating names in namespaces - making a mapping of a name to the relevant object. import boo gives you a name 'boo' in the relevant namespace, which refers to the module object made for boo when it was imported (that's some of the behind the scenes stuff). A quick interactive sample showing this in action: >>> globals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': } >>> import sys >>> globals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': (built-in)>, 'sys': } here's the case you are running into: >>> import datetime >>> globals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': (built-in)>, 'datetime': '/usr/lib64/python3.8/datetime.py'>} >>> from datetime import datetime >>> globals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': (built-in)>, 'datetime': } If you want to import the datetime class and still have the full datetime module available, you can for example import as a different name - here's a sample of that: >>> import datetime as dt >>> from datetime import datetime >>> globals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': (built-in)>, 'dt': '/usr/lib64/python3.8/datetime.py'>, 'datetime': 'datetime.datetime'>} Does this make it clearer? -- https://mail.python.org/mailman/listinfo/python-list
Re: I have no clue figuring out how to check dates in workholidays
On 06Nov2020 08:41, J.J. E. wrote: >Thank you for allowing me in this support mailing list. Anyone may join. Welcome! >My experience with >Python is short due to my new job. My boss told me that I need to create a >code that checks yesterday's date. The conditions for returning none are >that: > - Yesterday happens to be a holiday, > - Yesterday turns out to be a Saturday or a Sunday. >For both reasons, it needs to return None. A remark: that is unusual. Normally this would be a "logical" test: is yesterday a workholiday or not, returning True or False accordingly. Returning None will "test" as false, but it is not a normal value for false situations. What does your function return when neither situation applies? >Now I have learned to scan a >text file, and I have learned (ROUGHLY) the structure of what seems to scan >for specific words in "Indented Comments". > >The file "gwd.py" that I have joined stands for getWorkingDate. This is a text only list, and the list software discards most, if not all, attachments. Your sample file is not present in the email I received. Please paste the contents of gwd.py directly into your email (which itself should be a _reply_ to this email or your original email). Then we can see your code. Thanks, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Python 3
Does anyone know how to turn a decimal number into duodecimal or if there is a function built-in for it? -- https://mail.python.org/mailman/listinfo/python-list