Re: This is a test
Please don't send a test message to the public list which was read by thousands of people. thanks. On Fri, Jan 8, 2021 at 5:26 AM Craig Hatch wrote: > I have added you to the EMAIL list, so when I have questions. > > Just learn for fun. > > > Craig Hatch > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Remove duplicate values from dictionary without removing key
I want to replace duplicate values with empty "" in my dictionary. Here is my original dictionary. items = [ {'client': 'xyz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 100}, {'client': 'xyz','name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': 100}, {'client': 'xyz','name': "Alexander Lukashenko", 'rating': 3.1, 'total': 100}, {'client': 'xyz', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': 100}, {'client': 'udz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 150}, {'client': 'udz', 'name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': 100}, {'client': 'udz', 'name': "Alexander Lukashenko", 'rating': 3.1, 'total': 150}, {'client': 'udz', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': 150} ] Now I want to create another dict with like this items = [ {'client': 'xyz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 100}, {'client': '','name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': ''}, {'client': '','name': "Alexander Lukashenko", 'rating': 3.1, 'total': ''}, {'client': '', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': ''}, {'client': 'udz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 150}, {'client': '', 'name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': ''}, {'client': '', 'name': "Alexander Lukashenko", 'rating': 3.1, 'total': ''}, {'client': '', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': ''} ] Would you please help me how I can do this? and if this is not the right place to ask this question then please help me where I can ask this? I had tried stackoverflow but that not worked. -- https://mail.python.org/mailman/listinfo/python-list
better handling of "pinned" modules?
Hi, I don't know if this makes more sense here or on "python-ideas" (or elsewhere?) but I'll try this first: I am starting to encounter more and more instances of packages requiring older, pinned, versions of modules, and this is occasionally actually starting to cause conflicts. It seems that the "official" way to handle this is through virtual environments, but this is not ideal for my workflow, which usually involves a lot of exploratory analysis -- I don't know which packages I'll need before I start (and, in any event, there's no guarantee I won't need conflicting packages). Are there any good workarounds, or proposals for actual solutions so that multiple versions of a package can be installed? I understand that this is not trivial. Where would the "pinning" happen? It could be in the source code, so that it would somehow happen in the `import` statement (e.g., by explicitly renaming the package in question to include a version number, or less likely, by a new `import` syntax)? Or it could happen in the structure of the way modules are stored so that, for example, any imports that happen within a specific package egg would be directed to a specific version stored within the egg or in some other known location? Is this an issue worth tackling? Or do we just have to rely on package developers to keep up with their dependencies? Yours, Andrew -- https://mail.python.org/mailman/listinfo/python-list
Re: better handling of "pinned" modules?
On Sat, Jan 9, 2021 at 5:18 AM Andrew Jaffe wrote: > > Hi, > > I don't know if this makes more sense here or on "python-ideas" (or > elsewhere?) but I'll try this first: > > I am starting to encounter more and more instances of packages requiring > older, pinned, versions of modules, and this is occasionally actually > starting to cause conflicts. > The first thing to do is to see if those packages ACTUALLY need older versions of those dependencies. There's a good chance they don't. To avoid creating this sort of problem, don't depend on a highly specific version of things; just depend on a minimum version, and if there's a problem (ONLY if there's a problem), a maximum version. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove duplicate values from dictionary without removing key
On 2021-01-08 09:56, Umar Draz wrote: I want to replace duplicate values with empty "" in my dictionary. Here is my original dictionary. items = [ {'client': 'xyz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 100}, {'client': 'xyz','name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': 100}, {'client': 'xyz','name': "Alexander Lukashenko", 'rating': 3.1, 'total': 100}, {'client': 'xyz', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': 100}, {'client': 'udz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 150}, {'client': 'udz', 'name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': 100}, {'client': 'udz', 'name': "Alexander Lukashenko", 'rating': 3.1, 'total': 150}, {'client': 'udz', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': 150} ] Now I want to create another dict with like this items = [ {'client': 'xyz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 100}, {'client': '','name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': ''}, {'client': '','name': "Alexander Lukashenko", 'rating': 3.1, 'total': ''}, {'client': '', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': ''}, {'client': 'udz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 150}, {'client': '', 'name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': ''}, {'client': '', 'name': "Alexander Lukashenko", 'rating': 3.1, 'total': ''}, {'client': '', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': ''} ] Would you please help me how I can do this? and if this is not the right place to ask this question then please help me where I can ask this? I had tried stackoverflow but that not worked. Iterate through the list of dicts. If you've seen the client before, then set the appropriate value or values in the dict to ''. You can use a set to remember which clients you've already seen. -- https://mail.python.org/mailman/listinfo/python-list
asyncio project code review
Good day everyone. I have new asyncio project which use aiohttp connector and asyncio protocols/transports for tunneling packets through Tor Network cleanly. Project called aiotor: https://github.com/torpyorg/aiotor If someone with experience in asyncio field can make code review I will be appreciated for any comments. I prepared pull request to make it convenient to review and comment on the code: https://github.com/torpyorg/aiotor/pull/1 -- https://mail.python.org/mailman/listinfo/python-list
Asyncio project code review
Good day for everyone. I have new asyncio project which use aiohttp connector and asyncio protocols/transports for tunneling packets through Tor Network cleanly. Project called aiotor: https://github.com/torpyorg/aiotor If someone with experience in asyncio field can make code review I will be appreciated for any comments. I prepared pull request to make it convenient to review and comment on the code: https://github.com/torpyorg/aiotor/pull/1 Thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list
tkinter: creating/attaching menubar to top level window
I'm using Chapter 9 in Mark Roseman's "Modern Tkinter for Busy Python Developers" to learn how to write a top level menu. MWE code is attached. Python3 tells me there's invalid syntax on line 42: self.['menu'] = menubar # attach it to the top level window ^ yet that's the syntax he prints on page 84 (and has in the book's code supplement). Why am I getting an invalid syntax error here? TIA, Rich #!/usr/bin/env python3 # main file to start application. from os import environ import sys import pdb from datetime import datetime import tkinter as tk from tkinter import ttk from tkinter import Menu from tkinter import filedialog from tkinter import messagebox from tkinter.font import nametofont from functools import partial import model as m import views as v import controller as c class Application(tk.Tk): """ Application root window """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # the top level frame holding menu, status bar, etc. self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.geometry('800x600') self.title("Frame title") self.resizable(width=True, height=True) datestring = datetime.today().strftime("%Y-%m-%d") # status bar self.status = tk.StringVar() self.statusbar = ttk.Label(self, textvariable=self.status) self.statusbar.grid(sticky="we", row=3, padx=10) # toplevel window menu menubar = Menu(self) # create a Menu widget self.['menu'] = menubar # attach it to the top level window """ Add menus to menubar """ self.menu_file = Menu(menubar, tearoff=0) self.menu_view = Menu(menubar, tearoff=0) self.menu_add = Menu(menubar, tearoff=0) self.menu_edit = Menu(menubar, tearoff=0) self.menu_report = Menu(menubar, tearoff=0) self.menu_help = Menu(menubar, tearoff=0) """ Add menu items to menus """ menubar.add_cascade(menu_file, label='File') menubar.add_cascade(menu_view, label='View') menubar.add_cascade(menu_add, label='Add') menubar.add_cascade(menu_edit, label='Edit') menubar.add_cascade(menu_report, label='Report') menubar.add_cascade(menu_help, label='Help') if __name__ == "__main__": app = Application() app.mainloop() -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: creating/attaching menubar to top level window
Am 08.01.21 um 22:47 schrieb Rich Shepard: I'm using Chapter 9 in Mark Roseman's "Modern Tkinter for Busy Python Developers" to learn how to write a top level menu. MWE code is attached. Python3 tells me there's invalid syntax on line 42: self.['menu'] = menubar # attach it to the top level window ^ yet that's the syntax he prints on page 84 (and has in the book's code supplement). It is a simple typo, remove the dot. self['menu'] = menubar It will then stop at the add_cascade, fix it like this: menubar.add_cascade(menu=self.menu_file, label='File') and then it works, Why am I getting an invalid syntax error here? Because the dot would indicate the access of an attribute. but no name follows. What it does here, instead, is indexing - the correct line is similar to setting a dict entry. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: creating/attaching menubar to top level window
On 1/8/21 4:47 PM, Rich Shepard wrote: > I'm using Chapter 9 in Mark Roseman's "Modern Tkinter for Busy Python > Developers" to learn how to write a top level menu. MWE code is attached. > > Python3 tells me there's invalid syntax on line 42: > self.['menu'] = menubar # attach it to the top level window > ^ > yet that's the syntax he prints on page 84 (and has in the book's code > supplement). > > Why am I getting an invalid syntax error here? > > TIA, > > Rich Because it is the wrong syntax. It could be either: self.menu = menubar or self['menu'] = menubar -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
Re: dayofyear is not great when going into a new year
Den 2021-01-05 skrev Stefan Ram : > Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?= writes: >>I have had some Python fun with COVID-19 data. I have done >>some curve fitting and to make that easier I have transformed >>date to day of year. Come end of 2020 and beginning of 2021 >>and this idea falls on its face. > > import datetime > > continuous_day_of_the_year = \ > ( datetime.date.today() - datetime.date( 2020, 1, 1 )).days > > Thanks guys, you got me on the right track. After some further meandering I did something close to what Stefan suggest above. I added a column to my Pandas data frame and populated it with content of date column - datetime(2020, 1, 1) "regardless of what you have been told, recreational use of mathematics is harmless" I hope that is true for recreational programming as well :-) /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: dayofyear is not great when going into a new year
On 9/01/21 11:17 am, Martin Schöön wrote: "regardless of what you have been told, recreational use of mathematics is harmless" I hope that is true for recreational programming as well :-) Mostly harmless, but it can be addictive! -- Greg -- https://mail.python.org/mailman/listinfo/python-list
learning python building 2nd app, need advices
Hi, This is a python app I was working on, can you help making it a beautiful looking app like bleachbit or ccleaner? The whole code below (what it does: it lists all folders and files from a specified path and tells some infos like size in mb or gb... and export it to a csv file for further processing maybe with customized dashboard...the listing should will also be used to rename multiple files to help ordering and finding files because current renaming tools are difficult to use I find...) For now it just gives infos about folders and files and rename. Maybe a backup tool would be nice, please advise. But the code is opposiite to bullet proof and if could be more bullet proof, it would be a way to start and continue the messy code #!/usr/bin/env python3 # -*- coding: utf-8 -*- import locale import os import csv from tkinter import messagebox as msg try: from tkinter import * import ttk except: import tkinter as tk #GUI package from tkinter import ttk def fx_BasicListing(): #argx mode = 1 pour basic listing #argx mode = 2 pour adv listing # "txt" pour type enreg csv txt/csv # tree.delete(*tree.get_children()) fx_browseFoldersZ(1) return def fx_AdvancedListing(): #argx mode = 1 pour basic listing #argx mode = 2 pour adv listing # fx_browseFoldersZ(2,"txt") # tree.destroy() #tree.delete(*tree.get_children()) fx_browseFoldersZ(2) return def fx_browseFoldersZ(argy): #argx mode = 1 pour basic listing #argx mode = 2 pour adv listing # "txt" pour type enreg csv txt/csv tree.delete(*tree.get_children()) fx_browseFolders(argy,"txt") ### ### ### def fx_writeCSV(*arr): csv_file_title = 'csv_1_baselisting.csv' # csv path entry box CSV_FILE = vcsv_path.get() if not os.path.exists(CSV_FILE): os.makedirs(CSV_FILE) CSV_FILE += csv_file_title print('%s' % CSV_FILE) with open(CSV_FILE,'w', newline ='\n') as f: write = csv.writer(f, doublequote=True, delimiter=';') for row in arr: write.writerows(row) def fx_writeCSV_str(txt_str): csv_file_title = 'csvtxt_1_baselisting.csv' # csv path entry box CSV_FILE = vcsv_path.get() if not os.path.exists(CSV_FILE): os.makedirs(CSV_FILE) CSV_FILE += csv_file_title print('%s' % CSV_FILE) with open(CSV_FILE,'w') as f: f.write(txt_str) # fx_LoadCSV(CSV_FILE) with open(CSV_FILE, 'r') as f: reader = csv.DictReader(f, delimiter=';') for row in reader: col1 = row['Path'] col2 = row['Folder-file'] col3 = row['Size in Byte'] col4 = row['Size in Kb'] col5 = row['Size in Mb'] col6 = row['Size in Gb'] col7 = row['type'] tree.insert('', 'end', values=(col1, col2, col3, col4, col5, col6,col7)) return ### ### def fx_chkPath(xzPath): isxFile = os.path.isfile(xzPath) isxDir = os.path.isdir(xzPath) print("DOSSIER OUI",isxDir) if isxDir: return elif not isxDir: msg.showwarning("Folder path", "WD Path entered not found") return ### ### ### def fx_browseFolders(argz, tycsv): tree.delete(*tree.get_children()) # /// /// /// csv_txt = "" csv_contents = "" counterPath = 0 size = 0 f_size = 0 f_vscale = 0 # /// /// /// # path WD Lpath = vtxt_path.get() print('%s' % Lpath) # include files vvchkboxF = vchkboxF.get() # print("include files:::", vchkboxF.get()) # include modification date print(vchkboxD.get()) # include creation date print(vchkboxC.get()) # scale f_vscale = int(var_scale.get()) print(f_vscale) # path WD 2 if Lpath.endswith(os.path.sep): Lpath = Lpath[:-1] # isFile = os.path.isfile(Lpath) # print("fichier?",isFile) fx_chkPath(Lpath) counterPath = Lpath.count(os.path.sep) csv_contents = "Path;Folder-file;Size in Byte;Size in Kb;Size in Mb;Size in Gb;type\n" csv_txt = csv_contents # csv_contents # 1-FOLDER PATH # 2-FILENAME # 3-FOLDER PATH FULL # 4-Size in Byte # 5-Size in Kb # 6-Size in Mb # 7-Size in Gb # 8-type\n ### BASIC LISTING # if argz == 1: print("basic listing") fi
Re: learning python building 2nd app, need advices
any way to attach a file because I loose indentation? -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: creating/attaching menubar to top level window [RESOLVED]
On Fri, 8 Jan 2021, Christian Gollwitzer wrote: It is a simple typo, remove the dot. self['menu'] = menubar It will then stop at the add_cascade, fix it like this: Christian, Well, I totally missed that because I'm used to adding a period after each self. Your fresh eyes saw what I kept missing, menubar.add_cascade(menu=self.menu_file, label='File') I was going to add the 'self' there when I found what stopped the processing before it. Many thanks. Stay well and carpe weekend, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: creating/attaching menubar to top level window
On Fri, 8 Jan 2021, Richard Damon wrote: It could be either: self.menu = menubar or self['menu'] = menubar Got it, Richard. Removed the period after 'self'. Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: learning python building 2nd app, need advices
And something important to this app, is about listing files, how to avoid listing small application files parts .ini and binary files so if it's an application it would tell the size of of the folder of this application and not list the content or make it optionnal? -- https://mail.python.org/mailman/listinfo/python-list
Re: learning python building 2nd app, need advices
On 9/01/21 12:10 pm, pascal z wrote: any way to attach a file because I loose indentation? Indentation usually makes it through here if you indent with spaces rather than tabs. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: learning python building 2nd app, need advices
On 1/8/21 6:10 PM, pascal z via Python-list wrote: > any way to attach a file because I loose indentation? Don't post via googlegroups, it thinks the world is HTML, which treats spaces in a funny matter. -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove duplicate values from dictionary without removing key
On 1/8/2021 2:56 AM, Umar Draz wrote: I want to replace duplicate values with empty "" in my dictionary. Here is my original dictionary. items = [ {'client': 'xyz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 100}, {'client': 'xyz','name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': 100}, {'client': 'xyz','name': "Alexander Lukashenko", 'rating': 3.1, 'total': 100}, {'client': 'xyz', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': 100}, {'client': 'udz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 150}, {'client': 'udz', 'name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': 100}, {'client': 'udz', 'name': "Alexander Lukashenko", 'rating': 3.1, 'total': 150}, {'client': 'udz', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': 150} ] Now I want to create another dict with like this items = [ {'client': 'xyz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 100}, {'client': '','name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': ''}, {'client': '','name': "Alexander Lukashenko", 'rating': 3.1, 'total': ''}, {'client': '', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': ''}, {'client': 'udz', 'name': "Ilir Meta", 'rating': 0.06, 'total': 150}, {'client': '', 'name': "Abdelmadjid Tebboune", 'rating': 4.0, 'total': ''}, {'client': '', 'name': "Alexander Lukashenko", 'rating': 3.1, 'total': ''}, {'client': '', 'name': "Miguel Díaz-Canel", 'rating': 0.32, 'total': ''} ] Would you please help me how I can do this? and if this is not the right place to ask this question then please help me where I can ask this? I had tried stackoverflow but that not worked. items isn't a dictionary; as MRAB mentioned, it's a list of dictionaries. Each dictionary in items looks like a database record with fields (client, name, rating, and total). When you say you want to replace duplicate client fields by "", it almost looks like you're getting ready to print a report that looks something like this: xyz Ilir Meta 0.06 100 Abdelmadjid Tebboune 4.00 100 Alexander Lukashenko 3.10 ... where the report will look better when duplicate client values aren't printed. If that's the case, there are almost certainly better ways to do it. Changing values in items might have unforeseen consequences, since once duplicate client fields have been wiped out, there's no way to retrieve items[1]["client"] without looking at items[0]. And if the list of items is ever reordered, some of the client fields will be lost for good. I hope this helps. Louis -- https://mail.python.org/mailman/listinfo/python-list
Re: better handling of "pinned" modules?
On 08/01/2021 18:21, Chris Angelico wrote: On Sat, Jan 9, 2021 at 5:18 AM Andrew Jaffe wrote: Hi, I don't know if this makes more sense here or on "python-ideas" (or elsewhere?) but I'll try this first: I am starting to encounter more and more instances of packages requiring older, pinned, versions of modules, and this is occasionally actually starting to cause conflicts. The first thing to do is to see if those packages ACTUALLY need older versions of those dependencies. There's a good chance they don't. To avoid creating this sort of problem, don't depend on a highly specific version of things; just depend on a minimum version, and if there's a problem (ONLY if there's a problem), a maximum version. Well, sure. But there's still the "aesthetic" problem that `pip[3] check` reports a problem in such a case, and the real (albeit correctable) problem that `pip[3] install --upgrade` will occasionally automatically downgrade required packages. So perhaps my original query about whether there could be a way to actually solve this problem is still potentially interesting/useful. AndrewJ ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: dayofyear is not great when going into a new year
Am 05.01.21 um 23:56 schrieb Eli the Bearded: Elijah -- also finds "week starts on Monday" to be oddball about ISO-8601 In Europe, the week starts on Monday - hence, Saturday and Sunday are the last days of the week or the "weekend". Starting on Sunday is weird for us, because then the weekend is split into the first and last day of the week (?) - even if, historically, the week was the time from Sunday to Sunday. Christian -- https://mail.python.org/mailman/listinfo/python-list