![]() |
| readline inside and outside functions - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: readline inside and outside functions (/thread-33716.html) |
readline inside and outside functions - paul18fr - May-20-2021 Hi Because of the size of files I'm working on (often more than a billion lines for example), and the number of different types of data to be recorded (specific width and so on), I've been using "with open" + "readline" (without the end "s"); The main difficulty I'm confront is that all "readline" must remain into the core of the program (and I've now more than a thousand lines to take into account all specificities even using functions when it's possible). Does it make sense to envisage continuing using "readline" into functions and then returning to the core of the program (? if so, how to proceed? Thanks for your feedback RE: readline inside and outside functions - Gribouillis - May-20-2021 The question is quite unclear. What prevents you from using readline() in functions? RE: readline inside and outside functions - csr - May-20-2021 Do you mean you're using readline() inside the functions? If that is the case, you should only invoke this function in the section of the code that deals with the open file, and pass the functions the line you're reading as a parameter. Granted, it's very likely that you need to evaluate the contents of the line to determine which function to call. |