Questions tagged [self-reference]

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Useful Links:

Stanford Encyclopedia 'Self Reference' Entry

Related Tags:

596 questions
324
votes
7 answers

what does the __file__ variable mean/do?

import os A = os.path.join(os.path.dirname(__file__), '..') B = os.path.dirname(os.path.realpath(__file__)) C = os.path.abspath(os.path.dirname(__file__)) I usually just hard-wire these with the actual path. But there is a reason for these…
depling
  • 3,413
  • 2
  • 16
  • 7
229
votes
4 answers

What does __FILE__ mean in Ruby?

I see this all the time in Ruby: require File.dirname(__FILE__) + "/../../config/environment" What does __FILE__ mean?
Josh Moore
  • 13,338
  • 15
  • 58
  • 74
205
votes
8 answers

How to get a reference to a module inside the module itself?

How can I get a reference to a module from within that module? Also, how can I get a reference to the package containing that module?
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
72
votes
4 answers

How to get path to the current vimscript being executed

In my vim plugin, I have two files: myplugin/plugin.vim myplugin/plugin_helpers.py I would like to import plugin_helpers from plugin.vim (using the vim python support), so I believe I first need to put the directory of my plugin on python's…
gfxmonk
  • 8,614
  • 5
  • 42
  • 53
37
votes
4 answers

R self reference

In R I find myself doing something like this a lot: adataframe[adataframe$col==something]<-adataframe[adataframe$col==something)]+1 This way is kind of long and tedious. Is there some way for me to reference the object I am trying to change such…
LostLin
  • 7,762
  • 12
  • 51
  • 73
35
votes
2 answers

How can I achieve a self-referencing many-to-many relationship on the SQLAlchemy ORM back referencing to the same attribute?

I'm trying to implement a self-referential many-to-many relationship using declarative on SQLAlchemy. The relationship represents friendship between two users. Online I've found (both in the documentation and Google) how to make a self-referential…
wocoburguesa
  • 738
  • 1
  • 5
  • 7
34
votes
3 answers

how can I do self-reference with ruby on rails?

I want to self-referentiate a model in a RoR app but, I don't know exactly how. I want to save a linked list where the next node has the id of the previous one. how can I do this rails way? It is a one-to-one relation.
JRafaelM
  • 861
  • 2
  • 10
  • 23
31
votes
2 answers

Self referencing / parent-child relationship in Entity Framework

I read quite a number of posts of programmers that run into the Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values -exception when using…
30
votes
4 answers

c# generic self-referencing declarations

I've been reading Albaharis' "C# 5.0 in A Nutshell" and I've encountered this in Generics section and it is said to be legal: class Bar where T : Bar { ... } And it meant nothing to me, although I've read the whole chapter carefully. I…
emre
  • 363
  • 4
  • 7
26
votes
10 answers

Self-reference for cell, column and row in worksheet functions

In a worksheet function in Excel, how do you self-reference the cell, column or row you're in?
Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
23
votes
3 answers

Python: getting a reference to a function from inside itself

If I define a function: def f(x): return x+3 I can later store objects as attributes of the function, like so: f.thing="hello!" I would like to do this from inside the code of the function itself. Problem is, how do I get a reference to the…
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
23
votes
3 answers

Is self-reference possible in MATLAB?

As noted here, functions in packages, as well as static methods in classes, still need to use a packagename.functionname syntax or import packagename.* for each function (since the imports are part of the function workspace and not global). This…
Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221
21
votes
1 answer

Entity Framework 4.1 Code First Self-Referencing One-to-Many and Many-to-Many Associations

I have a User that can have collection of users he likes... Another user can have collection of users he likes.... If User A likes User B and if User B likes User A, then they get to hang out. I need to send each other their contact info. How do we…
21
votes
6 answers

What is the best way to empty a self-referential MySQL table?

I have a self-referential MySQL table with a recursive parent_id: CREATE TABLE `recursive` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default NULL, `name` varchar(100) NOT NULL, PRIMARY KEY (`id`), KEY…
Mat
  • 82,161
  • 34
  • 89
  • 109
20
votes
4 answers

How can I refer to the class type a interface is implementing in Java?

I came to a problem with interfaces in a program I'm making. I want to create a interface which have one of its methods receiving/returning a reference to the type of the own object. It was something like: public interface I { ?…
Leonardo Raele
  • 2,400
  • 2
  • 28
  • 32
1
2 3
39 40