api-ms-win-crt-runtime-l1-1-0.dll missing ?
I just have subscribed, so I send my message again as required. Sorry for not having pay attention. Thank you for your free product PYTHON I'd like to familiarize with, if possible. Environment: Windows 8.1 proc x64 I installed the version from the buton. After a succesfull installation, a system error occurs on the lounch of the program. I desinstalled this version from my PC. I installed the version for windows 64. After a succesfull installation, the same system error occurs on the lounch of the program: api-ms-win-crt-runtime-l1-1-0.dll is missing. Please would you let me know where I can get safely this .dll giving me the exact address because I'm a beginner ? Thank you. Best regards --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus -- https://mail.python.org/mailman/listinfo/python-list
Re: Python slang
On 6 August 2016 at 23:33, Ian Kelly wrote: > On Aug 6, 2016 2:10 PM, "Marco Sulla via Python-list" < > python-list@python.org> wrote: > > > Yes, I was thinking manly to SQL. That furthermore is NOT a > programming language. > > > Why not? It's claimed to be Turing complete. There's always something to learn. -- https://mail.python.org/mailman/listinfo/python-list
Python and 64bit Windows7
Hello: I am having problems when installing Python on a 64bit windows7 laptop. I am guessing that the problem is happening because of the 64bit architecture. Could you please take a look at the attached file that has screen shots of the problem I am facing? Could you tell me how I can fix these issues and get Python and PyCharm to work? I would appreciate your help. Regards James -- https://mail.python.org/mailman/listinfo/python-list
python 3.5.2 lounch: api-ms-win-crt-runtime-l1-1-0.dll is missing ?
Thank you for your free product PYTHON I'd like to familiarize with, if possible. Environment: Windows 8.1 proc x64 I installed the version from the buton. After a succesfull installation, a system error occurs on the lounch of the program. I desinstalled this version from my PC. I installed the version for windows 64. After a succesfull installation, the same system error occurs on the lounch of the program: api-ms-win-crt-runtime-l1-1-0.dll is missing. Please would you let me know where I can get safely this < api-ms-win-crt-runtime-l1-1-0.dll >. Please give me the exact address because I'm a beginner ? Thank you. Best regards --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus -- https://mail.python.org/mailman/listinfo/python-list
Re: Ned Batchelder: Loop Like A Native
On Sunday, August 7, 2016 at 2:26:48 AM UTC+1, Ned Batchelder wrote: > On Saturday, August 6, 2016 at 9:21:24 PM UTC-4, Lawrence D’Oliveiro wrote: > > On Sunday, August 7, 2016 at 11:36:06 AM UTC+12, Ned Batchelder wrote: > > > > > Didn't we already do this debate? > > > > I understand. You want to discuss loops, just not *those* sorts of loops... > > I didn't post this link here. I'm merely pointing out that your concern > about multiple ways to exit loops sounds like exactly what was discussed > here two months ago. Is there any reason to think there is new material > to discuss? > > --Ned. Thank you Ned for being far more diplomatic than I would have been. My round. When can you get over https://bearbeerfamily.co.uk/the-saxon-bear/ ? :) Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Cant download python libraries.
So i've downloaded python on a new laptop(Windows) and apparently i downloaded it in a wrong folder and now when i try to install a library i cant. I have tried both pip install and install setup.py but i cant make it work. It doesn't work if i just try to access python from cmd. I've tried to uninstall it but it still here. How can i fix that? -- https://mail.python.org/mailman/listinfo/python-list
api-ms-win-crt-runtime-l1-1-0.dll missing ?
Thank you for your free product PYTHON I'd like to familiarize with, if possible. Environment: Windows 8.1 proc x64 I installed the version from the buton. After a succesfull installation, a system error occurs on the lounch of the program. I desinstalled this version from my PC. I installed the version for windows 64. After a succesfull installation, the same system error occurs on the lounch of the program: api-ms-win-crt-runtime-l1-1-0.dll is missing. Please would you let me know where I can get safely this .dll giving me the exact address because I'm a beginner ? Thank you. Best regards --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and 64bit Windows7
On Sun, Aug 7, 2016 at 9:23 AM, James Santiago wrote: > Could you please take a look at the attached file that has screen shots of > the problem I am facing? No, because this is a text-only mailing list - your attachment got stripped. Can you transcribe the text of the error(s), please? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
RE: Python and 64bit Windows7
>I am having problems when installing Python on a 64bit windows7 laptop. >I am guessing that the problem is happening because of the 64bit architecture. >Could you please take a look at the attached file that has screen shots of the >problem I am facing? >Could you tell me how I can fix these issues and get Python and PyCharm to >work? Mailing list doesn't allow attachments so please post you error through writing it into text. This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt. -- https://mail.python.org/mailman/listinfo/python-list
Make sure you removed all debugging print statements error
Hello guys! I was answering a question on a piece of homework of mine. Sadly I can't answer it correctly due to the repetitive error being "Make sure you removed all debugging print statements." Hopefully one of you guys can help me solve this and also make me understand why I keep on getting this error. Piece of code: class Person(object): def __init__(self, name): self.name = name try: firstBlank = name.rindex(' ') self.lastName = name[firstBlank+1:] except: self.lastName = name self.age = None def getLastName(self): return self.lastName def setAge(self, age): self.age = age def getAge(self): if self.age == None: raise ValueError return self.age def __lt__(self, other): if self.lastName == other.lastName: return self.name < other.name return self.lastName < other.lastName def __str__(self): return self.name class USResident(Person): def __init__(self, name, status): self.name = name self.status = status def getStatus(self): return self.status # def getName(self): # return self.name a = USResident('Tim Beaver', 'citizen') print a.getStatus() # print(a.getName()) b = USResident('Tim Horton', 'non-resident') print b.getStatus() -- https://mail.python.org/mailman/listinfo/python-list
Re: Cant download python libraries.
On Mon, 8 Aug 2016 04:37 am, Panayiotis Mangafas wrote: > So i've downloaded python on a new laptop(Windows) and apparently i > downloaded it in a wrong folder and now when i try to install a library i > cant. I have tried both pip install and install setup.py but i cant make > it work. It doesn't work if i just try to access python from cmd. I've > tried to uninstall it but it still here. How can i fix that? You haven't given us enough information to answer your question. What do you mean, "it doesn't work"? Do you get an error message? Please copy and paste (NO SCREENSHOTS!) exactly what commands you type, and what errors you get. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: Make sure you removed all debugging print statements error
On Mon, 8 Aug 2016 10:20 pm, aaryanrevi...@gmail.com wrote: > Hello guys! I was answering a question on a piece of homework of mine. > Sadly I can't answer it correctly due to the repetitive error being "Make > sure you removed all debugging print statements." Hopefully one of you > guys can help me solve this and also make me understand why I keep on > getting this error. You haven't given us enough information to answer this question. What error do you get? What version of Python are you running? How are you running it? Please copy and paste (NO SCREENSHOTS!) the exact commands you use to run your code, and the actual error you get. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
A bioinformatics module similar to DEseq in R
Hi! is there a Python module equivalent\as similar as possible to 'DEseq' in R? It's just that my team's (many) scripts use it, and to start modifying them all to support some different bioinformatics module would be a nightmare. Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Make sure you removed all debugging print statements error
Am 08.08.16 um 14:20 schrieb aaryanrevi...@gmail.com:> Hello guys! I was answering a question on a piece of homework of mine. Sadly I can't answer it correctly due to the repetitive error being "Make sure you removed all debugging print statements." Hopefully one of you guys can help me solve this and also make me understand why I keep on getting this error. This seems to be specific to the system where you hand in the solutions; here we can only guess. Does it help to comment out all print staments in your code? I can only see 2 print statements at the end of the script. Christian -- https://mail.python.org/mailman/listinfo/python-list
Network protocols, sans I/O,(Hopefully) the future of network protocols in Python
This may be of interest to some of you http://www.snarky.ca/network-protocols-sans-i-o -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and 64bit Windows7
Hello: Thank you for your reply. Here are the steps I took, and the error messages I get: I have a windows7 laptop with 64bit intel i3. 25Gb hard-drive space left, 5Gb usable RAM space. (at the time of installing Python) 1) on the first attempt I chose the default choice in installer. Installation did not give any errors whatsoever. I then installed PyCharm - again with default choice and successful. When I open PyCharm, it did not locate the Interpreter automatically. When I did guide it to the correct path for Python location, a Python window (labeled Modify Setup) opens with three choices: Modify, Repair, Uninstall. I tried Repair in one try (& repeated it couple of times later), and Modify choice in a later attempt. However every time I open a new Project in PyCharm I could not get past the Modify Setup window. 2) I checked 'Uninstall or Change a Program' window of Windows7 and confirmed Python 3.5.2(32-bit) and Python Launcher installed. I also went to the correct location in C:/Program Files (x86)/ directory and confirmed Python being present. 3) I uninstalled Python and reinstalled. This time I went with customized installation choice. I installed it in C:/Python/. Installation was successful by itself. However same error when I open PyCharm and try to put the actual file location in the Interpreter field of PyCharm. 4) I also went to DOS prompt or CMD screen, went to the directory where Python was located as follows: C:\Python>python exe -v. This returns several lines of information. For example: the first line is import _frozen_importlib # frozen. second line is import _imp # builtin import sys # builtin There are some 15-20 lines like this which start with the term 'import'. There are a few lines that start like this: # C:\Python\lib\__pycache__\codecs.cpython-35.pyc matches C:\Python\lib\codecs.py Thank you in advance for your help. Regards James On Mon, Aug 8, 2016 at 2:08 AM, Joaquin Alzola wrote: > >I am having problems when installing Python on a 64bit windows7 laptop. > >I am guessing that the problem is happening because of the 64bit > architecture. > >Could you please take a look at the attached file that has screen shots > of the problem I am facing? > >Could you tell me how I can fix these issues and get Python and PyCharm > to work? > > Mailing list doesn't allow attachments so please post you error through > writing it into text. > This email is confidential and may be subject to privilege. If you are not > the intended recipient, please do not copy or disclose its content but > contact the sender immediately upon receipt. > -- https://mail.python.org/mailman/listinfo/python-list
Re: api-ms-win-crt-runtime-l1-1-0.dll missing ?
On Sun, Aug 7, 2016 at 8:40 AM, zutix via Python-list wrote: > I installed the version for windows 64. After a succesfull installation, the > same system error occurs on the lounch of the program: > api-ms-win-crt-runtime-l1-1-0.dll is missing. > > Please would you let me know where I can get safely this .dll giving me the > exact address because I'm a beginner ? Thank you. The Universal CRT update [1] should be applied by the installer, but shouldn't even be required on an up-to-date system. Did you disable Windows Update? [1]: https://support.microsoft.com/en-us/kb/2999226 -- https://mail.python.org/mailman/listinfo/python-list
Re: Make sure you removed all debugging print statements error
On Mon, Aug 8, 2016 at 10:20 PM, wrote: > class Person(object): > def __init__(self, name): > self.name = name > try: > firstBlank = name.rindex(' ') > self.lastName = name[firstBlank+1:] > except: > self.lastName = name > self.age = None Please don't EVER do this kind of thing. EVER. Firstly, the bare "except:" clause should basically never be used; instead, catch a very specific exception and figure out what you want to do here - but secondly, don't force people's names to be subdivided. https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ Even if you *must* split the name like this, there are far more Pythonic ways to do so. But I won't tell you about them, because you shouldn't even use a concept of "lastName". > def getLastName(self): > return self.lastName Python is not Java. You don't need a public attribute "self.lastName" and a getter "self.getLastName()". > def setAge(self, age): > self.age = age > def getAge(self): > if self.age == None: > raise ValueError > return self.age Same again - you don't need getters and setters. Please don't write code like this in Python. > def __str__(self): > return self.name Hmm, I'm not sure this is a good idea - you're treating a person as equivalent to his/her name. Normally you'd define the repr and/or str of a class to show exactly what thing this is; it'll make debugging easier. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Make sure you removed all debugging print statements error
On 08/08/2016 06:20 AM, aaryanrevi...@gmail.com wrote: > Hello guys! I was answering a question on a piece of homework of > mine. Sadly I can't answer it correctly due to the repetitive error > being "Make sure you removed all debugging print statements." > Hopefully one of you guys can help me solve this and also make me > understand why I keep on getting this error. Sounds like there's an automatic piece of software running your code and comparing your output with the expected output. Your code must be giving different output than expected by your teacher. The message is simply a reminder that if you had any debugging print()'s in your code that you should remove them before turning in your program. Since you don't have any debug print()'s that I can see, the problem must be that your program is simply outputing something different than expected. What output is expected? What does the assignment say about it? -- https://mail.python.org/mailman/listinfo/python-list
Re: Running Python from the source repo
On Sun, Aug 7, 2016 at 9:11 PM, Steven D'Aprano wrote: > I have cloned the Python source repo, and build CPython, as described here: > > https://docs.python.org/devguide/ > > > Now a little bit later, I want to update the repo, so I run: > > hg fetch According to the hg docs [1], you should probably avoid 'hg fetch'. Use 'hg pull -u' (or 'hg pull && hg update') instead. > to get and apply any changes. How do I know if I need to rebuild Python? I > don't want to have to rebuild after every fetch, because that's quite time > consuming (I estimate about five minutes on my machine, just long enough to > be a distraction but not long enough to get into something else). Plus the > time to run the tests (significantly longer). > > What do others do? I generally assume that if I'm testing a patch, I'm going to need to rebuild regardless of what the patch actually touches. I often wait until the patch is applied before I do the rebuild, or if I'm manually testing a bug I go ahead and do the rebuild immediately. Most make targets (including 'test') will go ahead make sure the build is up to date without your input. Usually the slowest part of a rebuild is rerunning ./configure, which 'make' will do for you if it determines that it should. You can speed up ./configure by passing it the '--config-cache' (or '-C') option. If you're on a multi-core machine, also remember to pass '-j' to make to speed up building, and also to regrtest (which you can do with 'make test TESTOPTS=-j9') to speed up testing. [1]https://www.mercurial-scm.org/wiki/FetchExtension -- Zach -- https://mail.python.org/mailman/listinfo/python-list
Re: Network protocols, sans I/O,(Hopefully) the future of network protocols in Python
On 8-8-2016 12:37, Mark Lawrence wrote: > This may be of interest to some of you > http://www.snarky.ca/network-protocols-sans-i-o > I sure find it interesting. Will also watch Cory's PyCon presentation that is mentioned! Thanks for the link. Irmen -- https://mail.python.org/mailman/listinfo/python-list
RE: python 3.5.2 lounch: api-ms-win-crt-runtime-l1-1-0.dll is missing ?
>I installed the version for windows 64. After a succesfull installation, the >same system error occurs on the lounch of the program: >api-ms-win-crt-runtime-l1-1-0.dll is missing. Sometimes google save you time more than the list: https://www.smartftp.com/support/kb/the-program-cant-start-because-api-ms-win-crt-runtime-l1-1-0dll-is-missing-f2702.html I think from there you can manage This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt. -- https://mail.python.org/mailman/listinfo/python-list
Re: Running Python from the source repo
On 8/8/2016 12:24 PM, Zachary Ware wrote: I generally assume that if I'm testing a patch, I'm going to need to rebuild regardless of what the patch actually touches. I often wait until the patch is applied before I do the rebuild, or if I'm manually testing a bug I go ahead and do the rebuild immediately. Most make targets (including 'test') will go ahead make sure the build is up to date without your input. Usually the slowest part of a rebuild is rerunning ./configure, which 'make' will do for you if it determines that it should. You can speed up ./configure by passing it the '--config-cache' (or '-C') option. If you're on a multi-core machine, also remember to pass '-j' to make to speed up building, and also to regrtest (which you can do with 'make test TESTOPTS=-j9') to speed up testing. [1]https://www.mercurial-scm.org/wiki/FetchExtension Last January, I wrote a batch file to build all three versions with the 'optional' extensions. I started rebuilding more often after this. 36\pcbuild\build.bat -e -d 35\pcbuild\build.bat -e -d 27\pcbuild\build.bat -e -d Thanks for making this possible. It initially worked, but now it stops after the first command, even without errors. Has a flag been changed to treat warnings as errors? How can I change the .bat to wrap each command with the equivalent of try: except: pass? -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and 64bit Windows7
On 08/08/2016 13:44, James Santiago wrote: 4) I also went to DOS prompt or CMD screen, went to the directory where Python was located as follows: C:\Python>python exe -v. This returns several lines of information. I assume you meant "python.exe -v". (But the .exe is not needed.) For example: the first line is import _frozen_importlib # frozen. I get the same sort of stuff. It seems Python is there and it works. What's PyCharm and what error does it give? What does its Help section say about telling it where Python is? You might need support for that application rather than Python. (Perhaps it expects python.exe in a default path. Go to any other location, and type 'python'. If it can't find it, then its path is not set up. You can fix that temporarily by typing: set path=c:\python\;%path% then trying again. However this path variable 'belongs' to this command window and may not be seen by PyCharm if started from elsewhere. Setting it more globally is fiddly but there is plenty of info out there. The problem could be something else of course...) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: Running Python from the source repo
On Mon, Aug 8, 2016 at 2:25 PM, Terry Reedy wrote: > Last January, I wrote a batch file to build all three versions with the > 'optional' extensions. I started rebuilding more often after this. > > 36\pcbuild\build.bat -e -d > 35\pcbuild\build.bat -e -d > 27\pcbuild\build.bat -e -d > > Thanks for making this possible. It initially worked, but now it stops > after the first command, even without errors. Has a flag been changed to > treat warnings as errors? How can I change the .bat to wrap each command > with the equivalent of try: except: pass? I'm not sure why that would have stopped working, but the way to use a .bat from a .bat is to 'call' it: call 36\PCbuild\build.bat -e -d .bat scripts don't care about the exit codes of what they run, errors must be explicitly checked and 'exit' called if you want the script to die early. Try this for an unconditional build on all three branches, with a report at the end if any of them failed: call 36\PCbuild\build.bat -e -d set rc36=%ERRORLEVEL% call 35\PCbuild\build.bat -e -d set rc35=%ERRORLEVEL% call 27\PCbuild\build.bat -e -d set rc27=%ERRORLEVEL% @if %rc36% NEQ 0 ( echo 3.6 build failed, rc: %rc36% ) @if %rc35% NEQ 0 ( echo 3.5 build failed, rc: %rc35% ) @if %rc27% NEQ 0 ( echo 2.7 build failed, rc: %rc27% ) -- Zach -- https://mail.python.org/mailman/listinfo/python-list
Re: Running Python from the source repo
On Mon, Aug 8, 2016, at 15:25, Terry Reedy wrote: > Last January, I wrote a batch file to build all three versions with the > 'optional' extensions. I started rebuilding more often after this. > > 36\pcbuild\build.bat -e -d > 35\pcbuild\build.bat -e -d > 27\pcbuild\build.bat -e -d > > Thanks for making this possible. It initially worked, but now it stops > after the first command, even without errors. Has a flag been changed > to treat warnings as errors? How can I change the .bat to wrap each > command with the equivalent of try: except: pass? I'm not sure how it ever worked, but you have to use "call" to run one batch file from another batch file, otherwise it doesn't start a recursive command interpreter and so it won't run anything else in the outer batch file. I don't know if .cmd files have this limitation. -- https://mail.python.org/mailman/listinfo/python-list
Specify the database for a Django ModelForm instance
Howdy all, How can I specify which database (by its alias name) a Django ModelForm should use? (I've had trouble getting this question in to the Django forum, so I'm trying here as this is still Python-related.) A Django ModelForm knows its corresponding model, and the fields included. The ModelForm instance clearly knows how to specify a database, internally. It can validate its fields against the database, and can save a new model instance to the database. This implies its operations have knowledge of which database to use. What I need is to access that as an external user, when creating the instance. I can't find how to specify any database other than the default, when creating the ModelForm nor when it interacts with the database. What is the equivalent for using='foo' when instantiating a ModelForm for the model, or calling its methods (ModelForm.clean, ModelForm.save, etc.)? -- \ “The sun never sets on the British Empire. But it rises every | `\morning. The sky must get awfully crowded.” —Steven Wright | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Awful code of the week
On Sunday, August 7, 2016 at 1:54:51 AM UTC-5, Steven D'Aprano wrote: > Seen in the office IRC channel: > > > (13:23:07) fred: near_limit = [] > (13:23:07) fred: near_limit.append(1) > (13:23:07) fred: near_limit = len(near_limit) > (13:23:09) fred: WTF Sure, this code smells of nauseous superfluity, but what comes after these three lines? Is this _all_ there is? Or are these three lines merely the initial setup stage for a complex looping algorithm? Cherry picking a few lines from a script and then judging them "unworthy", would not be a fair. We should never attempt to purposely mimic the abysmal state of justice in the USA. -- https://mail.python.org/mailman/listinfo/python-list
Re: Awful code of the week
On Tue, Aug 9, 2016 at 1:46 PM, Rick Johnson wrote: > On Sunday, August 7, 2016 at 1:54:51 AM UTC-5, Steven D'Aprano wrote: >> Seen in the office IRC channel: >> >> >> (13:23:07) fred: near_limit = [] >> (13:23:07) fred: near_limit.append(1) >> (13:23:07) fred: near_limit = len(near_limit) >> (13:23:09) fred: WTF > > Sure, this code smells of nauseous superfluity, but what > comes after these three lines? Is this _all_ there is? Or > are these three lines merely the initial setup stage for a > complex looping algorithm? Cherry picking a few lines from a > script and then judging them "unworthy", would not be a > fair. We should never attempt to purposely mimic the abysmal > state of justice in the USA. I agree. There's nothing wrong with that code. I routinely have constructs like this: def register(self, obj): self.files.append(obj) return None return None # just in case return None def process(self, stuff): files = self.files files = [] # to save memory files = self.files for file in files: file.process(stuff) return 1 It's perfectly good code, and Fred was flat out wrong to say "WTF" about this. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Awful code of the week
On Tuesday 09 August 2016 13:59, Chris Angelico wrote: > On Tue, Aug 9, 2016 at 1:46 PM, Rick Johnson > wrote: >> On Sunday, August 7, 2016 at 1:54:51 AM UTC-5, Steven D'Aprano wrote: >>> Seen in the office IRC channel: >>> >>> >>> (13:23:07) fred: near_limit = [] >>> (13:23:07) fred: near_limit.append(1) >>> (13:23:07) fred: near_limit = len(near_limit) >>> (13:23:09) fred: WTF >> >> Sure, this code smells of nauseous superfluity, but what >> comes after these three lines? Is this _all_ there is? Or >> are these three lines merely the initial setup stage for a >> complex looping algorithm? Cherry picking a few lines from a >> script and then judging them "unworthy", would not be a >> fair. We should never attempt to purposely mimic the abysmal >> state of justice in the USA. > > I agree. There's nothing wrong with that code. I routinely have > constructs like this: > > def register(self, obj): > self.files.append(obj) > return None > return None # just in case > return None That's buggy. It should be: def register(self, obj): self.files.append(obj) return None and None or None return None # just in case return None That way you're protected in case the boolean value of None is ever changed. > def process(self, stuff): > files = self.files > files = [] # to save memory > files = self.files > for file in files: > file.process(stuff) > return 1 def process(self, stuff): try: files = self.files del files # to save memory files = [] # just to be sure files = self.files for file in files: file.process(stuff) return 1 finally: del files del file del stuff del self # this has to come last You can't be too careful with memory management. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Awful code of the week
On Tue, Aug 9, 2016 at 3:20 PM, Steven D'Aprano wrote: >> def process(self, stuff): >> files = self.files >> files = [] # to save memory >> files = self.files >> for file in files: >> file.process(stuff) >> return 1 > > def process(self, stuff): > try: > files = self.files > del files # to save memory > files = [] # just to be sure > files = self.files > for file in files: > file.process(stuff) > return 1 > finally: > del files > del file > del stuff > del self # this has to come last > > > You can't be too careful with memory management. Right. Of course, it gets very onerous, so we tend to use a context manager instead. def process(self, stuff): with deallocate() as cleanup: cleanup(self) cleanup(stuff) files = self.files cleanup(files) del files files = [] cleanup(files) files = self.files cleanup(files) for file in files: cleanup(file) file.process(stuff) return 1 There, isn't that so much better? ChrisA -- https://mail.python.org/mailman/listinfo/python-list