Questions tagged [linecache]

This tag refers to the Python linecache unit, which allows random access to the lines of a text file.

This tag refers to the Python linecache unit, which allows random access to the lines of a text file. See https://docs.python.org/2/library/linecache.html

54 questions
25
votes
3 answers

Ruby on Rails - linecache error while trying to ' bundle install '

Hi I'm trying to run bundle install on my windows machine it runs fine until it reaches the linecache and then spits out a huge error: Fetching source index for http://rubygems.org/ Using rake (0.8.7) Using abstract (1.0.0) Using activesupport…
Umer Hassam
  • 1,332
  • 5
  • 23
  • 42
20
votes
8 answers

Installing linecache19 for Ruby 1.9.2 via rvm

I am having a problem with installing linecache19(dependency of ruby-debug19) for ruby 1.9.2 Here is my term output $ rvm use 1.9.2 Using /home/bogdan/.rvm/gems/ruby-1.9.2-p180 $ ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] $…
Bogdan Gusiev
  • 8,027
  • 16
  • 61
  • 81
17
votes
4 answers

python - Read file from and to specific lines of text

I'm not talking about specific line numbers because i'm reading multiple files with the same format but vary in length. Say i have this text file: Something here... ... ... ... Start #I want this block of text a b c d e…
BPm
  • 2,924
  • 11
  • 33
  • 51
8
votes
1 answer

Python: Get source code of class (using inspect)

I am using ipython and I want to save a class defined in one of my notebooks. I can do this with functions nicely with %save and inspect.getsource, but I cant seem to get the source of my class. I had a quick look at the methods in inspect and…
Alexander Telfar
  • 559
  • 1
  • 6
  • 7
3
votes
3 answers

`inspect.getsource` from a function defined in a string? `s="def f(): return 5"`

Given a function defined inline, how do I get getsource to provide the output? - This is for a test, here's the kind of thing I'm trying: from importlib.util import module_from_spec, spec_from_loader _locals = module_from_spec( …
3
votes
1 answer

Python: linecache not working as expected?

Hello I have this python script that I need to use to traverse some directories and extract some info within some files within those directories. So I have many directories. Within each one of those directories there are 5 more subdirectories. And…
Atirag
  • 1,660
  • 7
  • 32
  • 60
2
votes
1 answer

something wrong with with open statement which is in while loop

I cut a part of the script that i tried to complete. I am expecting a new result for mylineS.split()[0] after each iteration. outS.txt and outT.txt is result of commandC for each iteration and result is different at each iteration. But…
2
votes
1 answer

Python linecache is not working

In Python, I have an issue where whenever I use the getline() function from linecache module, it won't work at all. Say this was what I had on a text document named hi.txt: Hi And say this is what I had on a python program in the same…
JohnyNich
  • 1,221
  • 3
  • 14
  • 23
2
votes
1 answer

Receiving error on Windows machine when Installing linecache ERROR: Failed to build gem native extension on

When attempting to perform a bundle install of an existing Ruby on Rails project I receive an error when the bundler reaches Installing linecache (0.43) with native extensions. I don't see linecache in the projects Gem file so I can't try bundling…
ahsteele
  • 26,243
  • 28
  • 134
  • 248
2
votes
1 answer

How to efficiently read lines of large text file in Python in different orders: a) random line each time, b) starting in middle...?

I have a large text file (5 million to 10 million lines). Each line has 10 to 5,000 alphanumeric items which are separated from each other by a space or comma. Each line ends with a linebreak. The number of lines is known before runtime and the text…
LunaiThi
  • 111
  • 1
  • 8
2
votes
1 answer

Unnecessary import necessary for proper function

I'm implementing macros in Python (inspired by MacroPy). My project (when 'tests.py' is executed) works very well, but it doesn't work when I comment (or remove) the line import linecache from file 'import_hook.py' (all files are here). The script…
R.O.S.S
  • 605
  • 5
  • 18
2
votes
1 answer

How to use linecache with unicode?

I open my file thus: with open(sourceFileName, 'r', encoding='ISO-8859-1') as sourceFile: but, when I previousLine = linecache.getline(sourceFileName, i - 1) I get an exception "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position…
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
2
votes
2 answers

unable to complete "bundle install" - unable to install linecache19 -v '0.5.12'

On running "bundle install" in the corresponding directory I got hte following error: An error occurred while installing linecache19 (0.5.12), and Bundler cannot continue. Make sure that `gem install linecache19 -v '0.5.12'` succeeds before…
nish
  • 6,952
  • 18
  • 74
  • 128
2
votes
1 answer

Error installing linecache19

I've been trying to run bundle install. What follows is a series of commands I entered and the relevant snippets of the error messages. bundle update An error occurred while installing linecache (0.46), and Bundler cannot continue. Make sure that…
Rose Perrone
  • 61,572
  • 58
  • 208
  • 243
2
votes
1 answer

Why would bundle install try to install linecache19?

I am trying to run "bundle install". It tries to install linecache19 version 0.5.13 which is not yet released. I can't find the linecache19 gem in Gemfile. Its getting installed as a dependency of some other gem. I would like to know what…
usha
  • 28,973
  • 5
  • 72
  • 93
1
2 3 4