Re: Issue with Python module downloads from Library for a beginner Python coder.
Diverting replies to [email protected], a better place for all this. It looks like the error is in graphics.py, not in your file. Your line: from graphics import * is syntacticly correct. Something has mangled the line breaks in your traceback, which here appears as: When I write a different line - (from import graphics *), this is the output: from graphics import *Traceback (most recent call last): File "", line 1, in from graphics import * File "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line 1 Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32 ^SyntaxError: invalid syntax To me it appears that the syntax error in in graphics.py at line 1. I'd normally expect such a traceback to look more like this: File "", line 1, in from graphics import * File "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line 1 Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32 ^SyntaxError: invalid syntax In particular, the "^" would point to the place in the code where Python _noticed_ the syntax error. Is it possible that graphics.py contains that "Python 3.8.5 " text? So the traceback I've invented above says that _your_ import failed, but that was because of a failure in the file you were trying to import. BTW, it looks to me like your Python programmes (graphics.py and whatever other file you might be making) are inside the Python install. Normally you'd keep these elsewhere, for example in a folder such as: C:\Users\sarvesh\my-programmes Cheers, Cameron Simpson On 02Aug2020 06:36, Sarvesh Poddar wrote: >I am currently using Python 3.8.5 with IDLE environment that comes >pre-installed with the Python application. I am using the book "An >Introduction to computer science" by John Zelle as my reference. >The problem I am facing is "There is a python program named "graphics.py" that >is used as reference in the book and I downloaded the python file from >internet (link to the file - >https://mcsp.wartburg.edu/zelle/python/graphics.py). I have kept this module >in (C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32) and this is >were my Python files also lie in C drive. The problem is that I am not able to >import graphics.py file and when I try to do that following is the error I >receive, >Traceback (most recent call last): > File "", line 1, in import graphics > File >"C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line >1 > Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 >bit (Intel)] on win32 ^SyntaxError: invalid syntax > I have installed, uninstalled and then re-installed Python 3.8.5 multiple >times but the problem remains. I did a thorough internet search and most of >them suggested using sys path and following is the result, > >import sys>>> sys.path['', >'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\idlelib', > >'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs', >'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib', >'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32', >'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages'] >When I write a different line - (from import graphics *), this is the output: >from graphics import *Traceback (most recent call last): File >"", line 1, in from graphics import * File >"C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", >line 1 Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) >[MSC v.1926 32 bit (Intel)] on win32 ^SyntaxError: invalid >syntax -- https://mail.python.org/mailman/listinfo/python-list
Re: Pygobject style question
On 01Aug2020 13:32, Chris Green wrote: >Having (after lots of help from here, thank you) finally converted my >Python 2, gtk 2 program to Python 3 and pygobject gtk 3 I'm left with >a couple of what might be called style questions. > >I guess it's mostly down to what feels right to me but there may be >good reasons for choosing one way over another and, if so, I'd like to >know what they are. > >So, my original code had:- >... >self.buffer = gtk.TextBuffer() >self.view = gtk.TextView(self.buffer) > >This doesn't work in gtk+ 3 (or at least I don't think it does, the >converter script changed it) and there seem to be several ways of >doing it now:- > >self.buffer = Gtk.TextBuffer() >self.view = Gtk.TextView(buffer = self.buffer) I like this first one. It is least verbose, and it makes the buffer before it makes the view, which I prefer. If they are all legal and all correct and equivalent, go with the one which is easiest to read. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: questions re: calendar module
On Sat, Aug 1, 2020 at 11:33 PM dn via Python-list wrote: > > On 02/08/2020 12:24, o1bigtenor wrote: > > On Sat, Aug 1, 2020 at 6:29 PM dn via Python-list > > wrote: > >> On 01/08/2020 23:36, o1bigtenor wrote: > >>> On Sat, Aug 1, 2020 at 1:29 AM dn via Python-list > >>> mailto:[email protected]>> wrote: > >>> On 31/07/2020 02:52, o1bigtenor wrote: > >>> > I regularly work in planning through multiple years at once. > ... > > >>> calendar starting > >>> from a date that is 3 years in time frame. > >> ... > >> > >>> I would like to show something like 2024 through the end of 2028. > ... > > It is very disappointing - - - -suggests that thinking outside the space of > > one year is somehow deprecated. Frustrated when what you do demands > > that you think in longer periods of time (and yet have to function within > > the week as well). > > I agree - says he who tactically changes his 'events calendar' every > half-year, to ensure that there is more than a six-month planning > horizon. Sister-in-Law has just this morning blocked-out dates for > family gatherings ("you are expected to attend!") for not just > Christmas/December, but into Jan, Feb, and Easter holidays (Uni > vacation) next year; because U.David is but a mere-male and needs lots > of 'extra help'... > (and because she knows 'the system', and has something similar at home!) > (LOL) something like that except what I'm working with also needs the to the day planning as well as the long term stuff. Did some 'counting' here. there are from 8 to 14 discrete event times for a group within a 'period' (presently a year but that may change) and there are multiple groups. The event timing (spacing) is mostly similar. There is also a need for multi-event (think year) planning as well. I could see a busy theater organisation doing a similar kind of planning. > > >> There are other helper functions. Also, we are invited to sub-class. > > > > Hmm - - - will have to investigate that. > > I'm thinking that the month function/method might be a better way to go > (than year-at-a-time). > > For visualisation (per next para), have you tried computing a month in > the REPL and then str.split()-ting the output into separate week-strings? > > > >> Might it be possible to generate multiple year (or month) groups, split > >> them by line, and then reassemble line-by-line to produce the width and > >> temporal length required? > > > > Likely work well if the months were considered as discrete blocks. > > Thinking that one could have something like > > > > January 20xx February 20xx > >Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa > > 1 1 2 3455 > > 12 > > 2 6 78 910 11 12 6 3 45 6 > > 7 89 > > 313 14 15 16 17 18 19 710 11 12 13 14 15 16 > > 420 21 22 23 24 25 26 8 > > 527 28 29 30 31 > > > > It is very useful for me to have the week numbers included. Have > > learned some fascinating things (some months have 6 weeks in > > them!) and the joys of formating (grin!). > >> > >> What do you think? > > I'm no expert with the calendar module, having used it as many times as > (probably only) once before! > > However, skim-reading that page of the docs, I'd say that using the > class to do the formatting is better than 'reinventing the wheel', and > thus the question becomes: could the 'standard output' be post-processed > into the form required? > > The outline above (ignoring month/year and day headings) is basically: > > weekNR gap weekNR month> ... > > as far across the page/screen as there is space/per the requirements. > > Given that a seems to be a fixed-length string, then > you could indeed employ format() or f-strings with formatting. > > The fact that some months have fewer, or more, weeks to include, is > largely irrelevant. The solution is a standard "merge" algorithm. (us > 'silver surfers' cut our teeth on sorting, searching, and merging as the > three pillars of "batch processing"). The differences become very relevant for formatting. A month that has 4 weeks takes a different amount of vertical space than a month that has 6 weeks. > > To print across the page/screen, we divide the available number of > character-columns by the number of columns a single month's data > requires (plus inter-month spacing) and this gives the maximum number of > months the can be displayed 'across'. > > Dividing that number into the number of months within the period, will > give the number of month-rows required to 'do the job'. > > A month-row could be defined as: 'as many lines as it takes to display > every week of the month' (plus vertical separation/spacing). > > So, now the challenge is to print each output line, combining > (laterally) all of the relevant data/dates, in such a manner that after > e
Re: questions re: calendar module
On 2020-08-02 at 06:26:10 -0500, o1bigtenor wrote: > On Sat, Aug 1, 2020 at 11:33 PM dn via Python-list > wrote: > > The fact that some months have fewer, or more, weeks to include, is > > largely irrelevant. The solution is a standard "merge" algorithm. (us > > 'silver surfers' cut our teeth on sorting, searching, and merging as the > > three pillars of "batch processing"). > > The differences become very relevant for formatting. A month that has > 4 weeks takes a different amount of vertical space than a month that > has 6 weeks. Back in high school, we wrote a FORTRAN program to multiply matrixes, which wasn't too bad, because our FORTRAN library came with a matrix multiplier. The real problem was formatting the output. In FORTRAN. With crude "graphics" (made from plus signs, minus signs, and upper case "I"s) for the matrix brackets. And the multiplication and equality operators were supposed to be vertically centered in a horizontally oriented equation. Don't forget, matrix multiplication usually involves three differently shaped matrixes. The equation with the green check mark on https://www.mathsisfun.com/algebra/matrix-multiplying.html is a reasonable facsimile of what our output was supposed to look like. -- https://mail.python.org/mailman/listinfo/python-list
Re: questions re: calendar module
On 8/2/20 7:26 AM, o1bigtenor wrote: > The differences become very relevant for formatting. A month that has > 4 weeks takes a different amount of vertical space than a month that > has 6 weeks. The only month that has only 4 weeks would be Febuary, on non-lead years, that starts on Sunday (or whatever you consider the first day of your week). Yes, the 5 to 6 variation can cause formatting problems, especially since the 6 week months are rare enough (only 30 days months beginning on the last day of the week, or 31 day months beginning on the last 2 days, so around 1 in 5 or so) that you may want to trim them out when possible. I would likely just build the formatter to start by assuming 6 week months, and then near the end, after stacking the side by side months, see if it can be trimmed out (easier to remove at the end then add if needed) -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
Re: questions re: calendar module
Richard Damon wrote:
> I would likely just build the formatter to start by assuming 6 week
> months, and then near the end, after stacking the side by side months,
> see if it can be trimmed out (easier to remove at the end then add if
> needed)
If you like some itertools gymnastics: you can format square
boxes of text with two nested zip_longest():
import itertools
def gen_lines(blurbs, columncount, columnwidth):
first = True
for row in itertools.zip_longest(
*[iter(blurbs)] * columncount,
fillvalue=""
):
if first:
first = False
else:
yield ""
for columns in itertools.zip_longest(
*[blurb for blurb in row],
fillvalue=""
):
yield " ".join(
column.ljust(columnwidth) for column in columns
).rstrip()
BLURBS = [
"aaa\\naaa",
"\nbb\nbbb\nbb\nb",
"ccc",
"ddd\nddd"
]
BLURBS = [blurb.splitlines() for blurb in BLURBS]
for line in gen_lines(BLURBS, 2, 10):
print(line)
print("\n")
for line in gen_lines(BLURBS, 3, 10):
print(line)
print("\n")
As calendar provides formatted months with TextCalendar.formatmonth()
you can easily feed that to gen_lines():
import calendar
def monthrange(start, stop):
y, m = start
start = y * 12 + m - 1
y, m = stop
stop = y * 12 + m - 1
for ym0 in range(start, stop):
y, m0 = divmod(ym0, 12)
yield y, m+1
tc = calendar.TextCalendar()
months = (
tc.formatmonth(*month).splitlines() for month in
monthrange((2020, 10), (2021, 3))
)
for line in gen_lines(months, 3, 21):
print(line)
However, I found reusing the building blocks from calendar to add week
indices harder than expected. I ended up using brute force and am not
really satisfied with the result. You can have a look:
$ cat print_cal.py
#!/usr/bin/python3
"""Print a calendar with an arbitrary number of months in parallel columns.
"""
import calendar
import datetime
import functools
import itertools
SEP_WIDTH = 4
def get_weeknumber(year, month, day=1):
"""Week of year for date (year, month, day).
"""
return datetime.date(year, month, day).isocalendar()[1]
class MyTextCalendar(calendar.TextCalendar):
"""Tweak TextCalendar to prepend weeks with week number.
"""
month_width = 24
def weeknumber(self, year, month, day=1):
"""Week of year or calendar-specific week index for a given date.
"""
return get_weeknumber(year, month, max(day, 1))
def formatmonthname(self, theyear, themonth, width, withyear=True):
return " " + super().formatmonthname(
theyear, themonth, width, withyear=withyear
)
def formatweekheader(self, width):
return " " + super().formatweekheader(width)
def formatweek(self, theweek, width):
week, theweek = theweek
return "%2d " % week + ' '.join(
self.formatday(d, wd, width) for (d, wd) in theweek
)
def monthdays2calendar(self, year, month):
return [
(self.weeknumber(year, month, week[0][0]), week)
for week in super().monthdays2calendar(year, month)
]
class MyIndexedTextCalendar(MyTextCalendar):
"""Replace week number with an index.
"""
def __init__(self, firstweekday=0):
super().__init__(firstweekday)
self.weekindices = itertools.count(1)
@functools.lru_cache(maxsize=1)
def get_index(self, weeknumber):
"""Convert the week number into an index.
"""
return next(self.weekindices)
def weeknumber(self, year, month, day=1):
return self.get_index(super().weeknumber(year, month, day))
def monthindex(year, month):
"""Convert year, month to a single integer.
>>> monthindex(2020, 3)
24242
>>> t = 2021, 7
>>> t == monthtuple(monthindex(*t))
True
"""
return 12 * year + month - 1
def monthtuple(index):
"""Inverse of monthindex().
"""
year, month0 = divmod(index, 12)
return year, month0 + 1
def yearmonth(year_month):
"""Convert -mm to a (year, month) tuple.
>>> yearmonth("2020-03")
(2020, 3)
"""
return tuple(map(int, year_month.split("-")))
def months(first, last):
"""Closed interval of months.
>>> list(months((2020, 3), (2020, 5)))
[(2020, 3), (2020, 4), (2020, 5)]
"""
for monthnum in range(monthindex(*first), monthindex(*last)+1):
yield monthtuple(monthnum)
def dump_calendar(first, last, months_per_row, cal=MyTextCalendar()):
"""Print calendar from `first` month to and including `last` month.
>>> dump_calendar((2020, 11), (2021, 1), 2)
November 2020 December 2020
Mo Tu We Th Fr Sa SuMo Tu We Th Fr Sa Su
441 49 1 2 3 4 5 6
45 2 3 4 5 6 7 8 50 7 8 9 10 11 12 13
46 9 10 11 12 13 14 15 51 14
Re: Issue with Python module downloads from Library for a beginner Python coder.
Do you have tkinter installed? The graphics.py module needs it to run. On Sat, Aug 1, 2020 at 11:36 PM Sarvesh Poddar via Python-list < [email protected]> wrote: > Hi, > I am currently using Python 3.8.5 with IDLE environment that comes > pre-installed with the Python application. I am using the book "An > Introduction to computer science" by John Zelle as my reference. > The problem I am facing is "There is a python program named "graphics.py" > that is used as reference in the book and I downloaded the python file from > internet (link to the file - > https://mcsp.wartburg.edu/zelle/python/graphics.py). I have kept this > module in (C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32) and > this is were my Python files also lie in C drive. The problem is that I am > not able to import graphics.py file and when I try to do that following is > the error I receive, > Traceback (most recent call last): > File "", line 1, in import graphics > File > "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", > line 1 > Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 > 32 bit (Intel)] on win32 ^SyntaxError: invalid syntax > I have installed, uninstalled and then re-installed Python 3.8.5 multiple > times but the problem remains. I did a thorough internet search and most of > them suggested using sys path and following is the result, > > import sys>>> sys.path['', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\idlelib', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages'] > When I write a different line - (from import graphics *), this is the > output: > from graphics import *Traceback (most recent call last): File > "", line 1, in from graphics import * File > "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", > line 1Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC > v.1926 32 bit (Intel)] on win32 ^SyntaxError: invalid syntax > Please do let me know if I am missing out something very basic. > Thanks and I look forward.On Saturday, 1 August, 2020, 07:54:19 am > IST, boB Stepp wrote: > > On Thu, Jul 30, 2020 at 9:24 AM Sarvesh Poddar via Python-list > wrote: > > > I re-installed Python in my Windows system as the earlier one was not > able to import modules... > > You do not provide much detail to diagnose what your problem(s) > is(are). By the "earlier one" is it the same version as the one you > re-installed? Were you able to run IDLE with the "earlier one"? By > not being able to import modules do you mean modules from Python's > standard library? Or do you mean installing third party libraries > using pip? > > > ...But now I am not able to open IDLE after multiple tries. > > Have you looked in your start menu in the list of installed programs > for Python? If it is there did you expand it and see if there is an > entry for IDLE? How have you been trying (unsuccessfully) to open > IDLE? > > > -- > boB > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: [email protected] WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list
Re: Non IDE development strategy - what do others do that's fairly simple?
Cameron Simpson wrote: [snip fantastic explanation] Cameron, thanks for that long and detailed explanation. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: Issue with Python module downloads from Library for a beginner Python coder.
On 8/2/2020 2:36 AM, Sarvesh Poddar via Python-list wrote: [I downloaded] https://mcsp.wartburg.edu/zelle/python/graphics.py) I have unmangled the traceback and added explanations. Traceback (most recent call last): File "", line 1, in import graphics You typed this in IDLE Shell in response to the >>> prompt. File "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line 1 This says that you put the file in the same directory as python.exe. It should better be in ".../Lib/site-packages" or in a directory in "/Users/". None the less, the import worked. Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32 ^ SyntaxError: invalid syntax This says that the first line of graphics.py begins with "Python 3.8.5..." This is the startup message printed by python.exe when run in interactive mode, and by IDLE's interactive Shell. It is text, not python code. It is not the first line of the file at that link (I checked). Look at the file on your disk and check its first line. You may have to put '%appdata%' in the directory box if the /User//appdata directory is hidden on your machine. I have installed, uninstalled and then re-installed Python 3.8.5 multiple times but the problem remains. I did a thorough internet search and most of them suggested using sys path and following is the result, This suggestion is for when the import fails because the module is not found. In your case, it was found and the import process started. import sys>>> sys.path['', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\idlelib', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32', 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages'] When I write a different line - (from import graphics *), this is the output: from graphics import *Traceback (most recent call last): File "", line 1, in from graphics import * File "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line 1 Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32 ^SyntaxError: invalid syntax Same bad first line, same error. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Downloading Python
On 8/1/20, MRAB wrote: > On 2020-08-01 21:58, Barry wrote: >> On 31-7-2020 22:10, Tanmay Shah wrote: >>> >>> After downloading Python 3.8.5 IDLE, an error message popped up, >>> saying the code execution cannot proceed because python38.dll was >>> not found. What should I do in order to use the Python interpreter? >> >> I have never had to reboot windows when installing python. >> Was I lucky? > > No. I've never had a problem with it either. I don't know what "[a]fter downloading Python 3.8.5 IDLE" means to the OP. For a successful installation of Python 3.8 using an "executable" or "web-based" installer from python.org [1], the file "python38.dll" will be installed in the same directory as python.exe and will thus always be found. [1] https://www.python.org/downloads/release/python-385 -- https://mail.python.org/mailman/listinfo/python-list
Re: questions re: calendar module
On 8/2/20 12:58 PM, Dennis Lee Bieber wrote: > Yet follows what most /print/ calendars contain (though some companies > put the last four months of the current year in a 4-up page, before doing > one month per page for the new year). "Daily planner" journals also tend to > cover just one year, from Jan 1 to Dec 31. Actually, now many calendars are 15 or 16 months, starting in September or October and go through the following December (maybe with a planning calendar page giving a compressed view of the next 4 or 12 months of the following year. There also are 'Academic' calendars that might start in July or August and go to maybe the following September -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
Re: Downloading Python
It's quite possible you have a version mismatch. Try installing python 3.8 first. BtW, before the would you like to check what version python command reports. Sorry for top post. I am sending from my phone and bottom post pretty confusing here. On Mon, Aug 3, 2020, 00:56 Eryk Sun wrote: > On 8/1/20, MRAB wrote: > > On 2020-08-01 21:58, Barry wrote: > >> On 31-7-2020 22:10, Tanmay Shah wrote: > >>> > >>> After downloading Python 3.8.5 IDLE, an error message popped up, > >>> saying the code execution cannot proceed because python38.dll was > >>> not found. What should I do in order to use the Python interpreter? > >> > >> I have never had to reboot windows when installing python. > >> Was I lucky? > > > > No. I've never had a problem with it either. > > I don't know what "[a]fter downloading Python 3.8.5 IDLE" means to the > OP. For a successful installation of Python 3.8 using an "executable" > or "web-based" installer from python.org [1], the file "python38.dll" > will be installed in the same directory as python.exe and will thus > always be found. > > [1] https://www.python.org/downloads/release/python-385 > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: questions re: calendar module
On Sun, Aug 2, 2020 at 2:28 PM Richard Damon wrote: > > On 8/2/20 12:58 PM, Dennis Lee Bieber wrote: > > Yet follows what most /print/ calendars contain (though some companies > > put the last four months of the current year in a 4-up page, before doing > > one month per page for the new year). "Daily planner" journals also tend to > > cover just one year, from Jan 1 to Dec 31. > > Actually, now many calendars are 15 or 16 months, starting in September > or October and go through the following December (maybe with a planning > calendar page giving a compressed view of the next 4 or 12 months of the > following year. > > There also are 'Academic' calendars that might start in July or August > and go to maybe the following September > Hmm - - - - one of the problems with slicing and dicing on quotes - - - - stuff gets lost. I had asked for at least 2.5 years worth of calendar - - - - preferable even more. A previous iteration of this project which I am using (until either I can find or make better) is at present sitting with some 60 months of time showing. Sorry - - - - even 18 months - - - - well its like stepping into a nuclear bomb argument with a water pistol. Regards -- https://mail.python.org/mailman/listinfo/python-list
Re: questions re: calendar module
On Sun, Aug 2, 2020 at 2:08 PM Dennis Lee Bieber wrote: > > On Sat, 1 Aug 2020 19:24:41 -0500, o1bigtenor > declaimed the following: > > > > >It is very disappointing - - - -suggests that thinking outside the space of > >one year is somehow deprecated. Frustrated when what you do demands > >that you think in longer periods of time (and yet have to function within > >the week as well). > > Yet follows what most /print/ calendars contain (though some companies > put the last four months of the current year in a 4-up page, before doing > one month per page for the new year). "Daily planner" journals also tend to > cover just one year, from Jan 1 to Dec 31. > > If you are willing to view the calendar in a browser, using > calendar.HTMLCalendar() may be the fastest way toward what you intend. You > could start, perhaps, with generating full year calendars (setting the > width to 12 months), and then package them as rows into an outer table > (granted, you won't get week numbers this way, but it may be a starting > point). > -=-=-=- I understand that what I'm trying to do isn't 'normal'. I do understand that most businesses only work with any detail in one year at a time. I got it That doesn't work for my situation. I tried to do this planning using 'typical software'. I about went crazy when I was trying to work looking back at one year, working in the present year and needing to drop details into the next year. (I need to work more than one year forward as well!) I found some very old software (cal), from the days of Unix V, with its update that is itself (ncal) over 10 years old. This project started when I found that I could get cal to display a LARGE amount of months except I was limited to a 80 column display. I was moaning to a friendof mine one time looking into how I could change the display from an 80 column limit to some at least 160 if not 192 columns. One day he surprised me by sending me code which got this idea started. When he found out that week numbers were very useful - - - - they were included. He died about 3 months ago without ever finishing the project. He liked to write in Perl albeit was comfortable in lots of other languages. I had talked to him about learning Python. So this project morphed from being in Perl (5) to being in Python. This existing code already allows me to display lots of months at a time with enough months width so that my terminal is 'full'. What's not there is the possibility of specifying a starting point to this calendar. At present the calendar only works from today (both backward and forward). There are also a few small display things I would like to tweak but the bulk of the idea works very well. Maybe I should be learning Perl (7) instead so I could just extend his work but Python seems to have more other things that it 'works' on so even though this makes for more work I have chosen this direction. HTH -- https://mail.python.org/mailman/listinfo/python-list
Re: questions re: calendar module
On 8/2/20 5:38 PM, o1bigtenor wrote: > On Sun, Aug 2, 2020 at 2:08 PM Dennis Lee Bieber > wrote: >> On Sat, 1 Aug 2020 19:24:41 -0500, o1bigtenor >> declaimed the following: >> >>> It is very disappointing - - - -suggests that thinking outside the space of >>> one year is somehow deprecated. Frustrated when what you do demands >>> that you think in longer periods of time (and yet have to function within >>> the week as well). >> Yet follows what most /print/ calendars contain (though some >> companies >> put the last four months of the current year in a 4-up page, before doing >> one month per page for the new year). "Daily planner" journals also tend to >> cover just one year, from Jan 1 to Dec 31. >> >> If you are willing to view the calendar in a browser, using >> calendar.HTMLCalendar() may be the fastest way toward what you intend. You >> could start, perhaps, with generating full year calendars (setting the >> width to 12 months), and then package them as rows into an outer table >> (granted, you won't get week numbers this way, but it may be a starting >> point). >> -=-=-=- > I understand that what I'm trying to do isn't 'normal'. > I do understand that most businesses only work with any detail in one year > at a time. > > I got it > > That doesn't work for my situation. > > I tried to do this planning using 'typical software'. I about went > crazy when I was > trying to work looking back at one year, working in the present year > and needing > to drop details into the next year. (I need to work more than one year forward > as well!) > > I found some very old software (cal), from the days of Unix V, with its update > that is itself (ncal) over 10 years old. > > This project started when I found that I could get cal to display a > LARGE amount > of months except I was limited to a 80 column display. I was moaning > to a friendof mine one time looking into how I could change the display from > an > 80 column limit to some at least 160 if not 192 columns. One day he surprised > me by sending me code which got this idea started. When he found out that > week numbers were very useful - - - - they were included. He died about 3 > months ago without ever finishing the project. > > He liked to write in Perl albeit was comfortable in lots of other languages. > I had talked to him about learning Python. > So this project morphed from being in Perl (5) to being in Python. > > This existing code already allows me to display lots of months at a time > with enough months width so that my terminal is 'full'. What's not there is > the possibility of specifying a starting point to this calendar. At present > the calendar only works from today (both backward and forward). There > are also a few small display things I would like to tweak but the bulk of > the idea works very well. > > Maybe I should be learning Perl (7) instead so I could just extend his > work but Python seems to have more other things that it 'works' on so > even though this makes for more work I have chosen this direction. > > HTH If you don't need to produce these often, then the fastest method may be to just build up on a spread sheet, probably less than a half hour of work if you are at all familiar with what you are doing. The second method would be to write a program to do this. Maybe use the 'canned' routine as a base for the program, but accept that your actual desired output is unusual enough it won't be something you can get with a single call. Maybe accept you can't get exactly what you want, so be willing to accept something close. Maybe the chart goes from January of your start year to December of the final year if the library likes doing a full year at a time. -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
Python running in the Command Prompt Window questions
When I double click on a .py file, it executes at the command prompt with black background and small white font. Is there python code to change the font size and background color? === FootNote: Would it be ironic if Popeye’s chicken was fried in Olive Oil? -- https://mail.python.org/mailman/listinfo/python-list
Re: Issue with Python module downloads from Library for a beginner Python coder.
Hello Dennis, Sorry for my copy-paste error and thanks for highlighting the same. I will make sure that from next time I will maintain the line breaks. I tried opening it in CMD and it did open with the skewed triangle figure although I am still not able to use it in my IDLE environment. Unfortunately, I am not able to move ahead with my Python classes because of this, as it specifically asks to import the module before proceeding. I saved the file in tkinter folder now and receive the same problem, >>> import graphicsTraceback (most recent call last): File "", line >>> 1, in import graphicsModuleNotFoundError: No module named >>> 'graphics' Location of the file - C:\Program Files (x86)\Lib\tkinter Didn't work out. On Monday, 3 August, 2020, 12:47:26 am IST, Dennis Lee Bieber wrote: On Sun, 2 Aug 2020 06:36:28 + (UTC), Sarvesh Poddar via Python-list declaimed the following: > Hi, >I am currently using Python 3.8.5 with IDLE environment that comes >pre-installed with the Python application. I am using the book "An >Introduction to computer science" by John Zelle as my reference. >The problem I am facing is "There is a python program named "graphics.py" that >is used as reference in the book and I downloaded the python file from >internet (link to the file - >https://mcsp.wartburg.edu/zelle/python/graphics.py). I have kept this module >in (C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32) and this is >were my Python files also lie in C drive. The problem is that I am not able to >import graphics.py file and when I try to do that following is the error I >receive, >Traceback (most recent call last): > File "", line 1, in import graphics > File >"C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line >1 > Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 >bit (Intel)] on win32 ^SyntaxError: invalid syntax > I have installed, uninstalled and then re-installed Python 3.8.5 multiple >times but the problem remains. I did a thorough internet search and most of >them suggested using sys path and following is the result, > In future, you might want to ensure your cut&paste and/or posting client, maintains line breaks -- many of your pastes seem to "unwrap" stuff... >When I write a different line - (from import graphics *), this is the output: >from graphics import *Traceback (most recent call last): File "", >line 1, in from graphics import * File >"C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line >1 Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 >bit (Intel)] on win32 ^SyntaxError: invalid syntax ... such as the above, which appears to have turned something like 7 lines of output into one long string/paragraph. My only suggestion is to drop OUT of IDLE or whatever, and open a Windows command shell... and try running a script from that shell. I note that this library makes use of Tkinter -- which is also used by IDLE. The two uses may be causing complications. Going to a command shell avoids that. -=-=- C:\Users\Wulfraed\Downloads>type testgraphics.py import graphics print(dir(graphics)) C:\Users\Wulfraed\Downloads>python testgraphics.py ['BAD_OPTION', 'Circle', 'DEFAULT_CONFIG', 'Entry', 'GraphWin', 'GraphicsError', 'GraphicsObject', 'Image', 'Line', 'OBJ_ALREADY_DRAWN', 'Oval', 'Point', 'Polygon', 'Rectangle', 'Text', 'Transform', 'UNSUPPORTED_METHOD', '_BBox', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__', '_root', '_update_lasttime', 'color_rgb', 'os', 'sys', 'test', 'time', 'tk', 'update'] C:\Users\Wulfraed\Downloads> -=-=- Heck... from the command shell, navigate to the directory in which you saved graphics.py and enter -=-=- C:\Users\Wulfraed\Downloads>python graphics.py -=-=- On my system, that pops up a small window with skewed triangle, some text, and a grey input field. -- Wulfraed Dennis Lee Bieber AF6VN [email protected] http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: (Issue resolved!) Issue with Python module downloads from Library for a beginner Python coder.
Hi terry, I am so happy to mention that your suggestion worked! I moved the file from Tkinter to Lib and I am suddenly able to import the file. Thanks you so much @Bob, @Arjun, @Cameron for your suggestions. I can finally move forward. I hope to contribute to this community in future after gaining enough experience on the Python subject. Looking forward! On Monday, 3 August, 2020, 12:51:28 am IST, Terry Reedy wrote: On 8/2/2020 2:36 AM, Sarvesh Poddar via Python-list wrote: [I downloaded] https://mcsp.wartburg.edu/zelle/python/graphics.py) I have unmangled the traceback and added explanations. > Traceback (most recent call last): > File "", line 1, in > import graphics You typed this in IDLE Shell in response to the >>> prompt. > File >"C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", line >1 This says that you put the file in the same directory as python.exe. It should better be in ".../Lib/site-packages" or in a directory in "/Users/". None the less, the import worked. > Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 >bit (Intel)] on win32 > ^ > SyntaxError: invalid syntax This says that the first line of graphics.py begins with "Python 3.8.5..." This is the startup message printed by python.exe when run in interactive mode, and by IDLE's interactive Shell. It is text, not python code. It is not the first line of the file at that link (I checked). Look at the file on your disk and check its first line. You may have to put '%appdata%' in the directory box if the /User//appdata directory is hidden on your machine. > I have installed, uninstalled and then re-installed Python 3.8.5 multiple >times but the problem remains. > I did a thorough internet search and most of them suggested using sys path > and following is the result, This suggestion is for when the import fails because the module is not found. In your case, it was found and the import process started. > import sys>>> sys.path['', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\idlelib', > > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32', > 'C:\\Users\\sarvesh\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages'] > When I write a different line - (from import graphics *), this is the output: > from graphics import *Traceback (most recent call last): File "", > line 1, in from graphics import * File > "C:\Users\sarvesh\AppData\Local\Programs\Python\Python38-32\graphics.py", > line 1 Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC > v.1926 32 bit (Intel)] on win32 ^SyntaxError: invalid syntax Same bad first line, same error. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python running in the Command Prompt Window questions
On 03/08/2020 13:52, Steve wrote: When I double click on a .py file, it executes at the command prompt with black background and small white font. Is there python code to change the font size and background color? Ctrl-Shift-+ ? === FootNote: Would it be ironic if Popeye’s chicken was fried in Olive Oil? The irony was that the marketing drive behind Popeye eating spinach was based upon research that was in-error by at least a factor of ten. -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
