Search Results

Search found 11482 results on 460 pages for 'style'.

Page 8/460 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Identifying that a variable is a new-style class in Python?

    - by Dave Johansen
    I'm using Python 2.x and I'm wondering if there's a way to tell if a variable is a new-style class? I know that if it's an old-style class that I can do the following to find out. import types class oldclass: pass def test(): o = oldclass() if type(o) is types.InstanceType: print 'Is old-style' else: print 'Is NOT old-style' But I haven't been able to find anything that works for new-style classes. I found this question, but the proposed solutions don't seem to work as expected, because simple values as are identified as classes. import inspect def newclass(object): pass def test(): n = newclass() if inspect.isclass(n): print 'Is class' else: print 'Is NOT class' if inspect.isclass(type(n)): print 'Is class' else: print 'Is NOT class' if inspect.isclass(type(1)): print 'Is class' else: print 'Is NOT class' if isinstance(n, object): print 'Is class' else: print 'Is NOT class' if isinstance(1, object): print 'Is class' else: print 'Is NOT class' So is there anyway to do something like this? Or is everything in Python just a class and there's no way to get around that?

    Read the article

  • Is there any appreciable difference between if and if-else?

    - by Drew
    Given the following code snippets, is there any appreciable difference? public boolean foo(int input) { if(input > 10) { doStuff(); return true; } if(input == 0) { doOtherStuff(); return true; } return false; } vs. public boolean foo(int input) { if(input > 10) { doStuff(); return true; } else if(input == 0) { doOtherStuff(); return true; } else { return false; } } Or would the single exit principle be better here with this piece of code... public boolean foo(int input) { boolean toBeReturned = false; if(input > 10) { doStuff(); toBeReturned = true; } else if(input == 0) { doOtherStuff(); toBeReturned = true; } return toBeReturned; } Is there any perceptible performance difference? Do you feel one is more or less maintainable/readable than the others?

    Read the article

  • Could someone tell me if my C++ indent style is named? (example given)

    - by Maulrus
    I'm learning C++. For me, my programming style is just what looks the best; it doesn't seem to follow the rules of any one particular style. Here's an example void f(int x){ //no space between close-paren and bracket if (!x){ cout << "x is non-zero\n"; } //closing bracket indented to the same level as the original statement } It's only slightly different for something like a class or a namespace: class myClass {}; //space between class name and bracket, otherwise the same as functions K&R style does uses that kind of bracketing for statements, but my style uses it for everything. I'd like to know if there's a name for it so I can say simply what my indent style is without having to explain using examples like these.

    Read the article

  • What is the most frustrating programming style you've encountered?

    - by JaredPar
    When it comes to coding style I'm a pretty relaxed programmer. I'm not firmly dug into a particular coding style. I'd prefer a consistent overall style in a large code base but I'm not going to sweat every little detail of how the code is formatted. Still there are some coding styles that drive me crazy. No matter what I can't look at examples of these styles without reaching for a VIM buffer to "fix" the "problem". I can't help it. It's not even wrong, I just can't look at it for some reason. For instance the following comment style almost completely prevents me from actually being able to read the code. if (someConditional) // Comment goes here { other code } What's the most frustrating style you've encountered?

    Read the article

  • Python indentation in "empty lines"

    - by niscy
    Which is preferred ("." indicating whitespace)? A) def foo(): x = 1 y = 2 .... if True: bar() B) def foo(): x = 1 y = 2 if True: bar() My intuition would be B (that's also what vim does for me), but I see people using A) all the time. Is it just because most of the editors out there are broken?

    Read the article

  • Transform your Oracle Tutor Documents to Your Corporate Standard

    - by mary.keane
    You have all of your company's processes documented in Oracle Tutor, and now you want to get the HTML files to reflect your company's corporate look and feel. How are you going to do this without having an HTML guru to change every HTML page? The good news is you do not need to be an HTML expert to make minor changes to your documents. All Tutor HTML files are attached to a group of style sheets, so any changes you make to the style sheets will immediately be reflected in all of your HTML documents. If you want to give it a try, here's what you do (please note that these tips are applicable to release Oracle Tutor 12.2 and greater): Navigate to your Tutor HTML directory, and copy into a draft folder a representative group of HTML files (don't forget the flowchart image files that are associated with the procedures). You'll also need to copy the following files: tutor.css tutor_notabs.css tutor_scripts.js tutor_tabs.css flow_icon.gif Here's the default look to the Oracle Tutor desk manual. Let's say I want to use my company's corporate style in the HTML documents. At Oracle, we use Oracle Red (FF0000), Oracle Black (000000), and Oracle Gray (666666). So I want to incorporate those colors into the Tutor HTML files. I open tutor.css from the draft folder in a text editor. My preference is to use Notepad, but there are others. Make sure, however, that it is a text editor, and not a word processing program. I want to change the headings to Oracle Red. The desk manual title is listed as the DMPAGETITLE, so I find that in tutor.css. The style names in the style sheets are descriptive, but sometimes you may have to experiment to find the right style (this is why you're working in a draft folder). I change the color attribute to FF00000, and then I save the document. Now I look at one of the desk manuals in my draft folder. I've successfully changed the title of the desk manual, so, now that I have more confidence that I can do this, I start changing other styles. I need to make changes in the tutor_tabs.css file as well, so I open that document. Then I look at one of the procedures. Oops! All that red is distracting, and the users may not be able to follow their procedures. So I go back to the corporate style guide, and I find some shades of gray that have been approved. So I use that, and it is now more readable. It's good enough for a first draft, and I would show it to my colleagues at this point to get their input. On my next blog, I'll discuss how to change the flowchart colors to match your corporate look and feel. Have you used the cascading styles sheets to change the look of your Tutor documents? If so, let us know what you've done in your post. Mary R. Keane Senior Development Manager, Oracle Tutor & UPK Content

    Read the article

  • HTML coding style: attribute starts on a new line

    - by Matty
    sublvl's front end developer seems to have a strange coding style that I've never seen before. Every time they begin a new element, immediately after the element name they insert a line break. The first thing that appears on the next line is the first attribute of the element. For example: id="player-container"><div id="player-bar"><div id="player-controls-wrapper"><div id="player-controls"><div id ="player-controls-buttons"> <a The above code was found here. I've never seen this kind of coding style before. What's going on here? Is this just a quirky style or is there some reasoning behind it?

    Read the article

  • Help migrating from VB style programming to OO programming [closed]

    - by Agent47DarkSoul
    Being a hobbyist Java developer, I quickly took on with OO programming and understood its advantages over procedural code from C, that I did in college. But I couldn't grasp VB event based code (weird, right?). Bottom-line is OOP came natural to me. Curently I work in a small development firm developing C# applications. My peers here are a bit attached to VB style programming. Most of the C# code written is VB6 event handling code in C#'s skin. I tried explaining to them OOP with its advantages but it wasn't clear to them, maybe because I have never been much of a VB programmer. So can anybody provide any resources: books, web articles on how to migrate from VB style to OO style programming ?

    Read the article

  • Command line options style - POSIX or what?

    - by maaartinus
    Somewhere I saw a rant against java/javac allegedly using a mix of Windows and Unix style like java -classpath ... -ea ... Something IMHO, it is no mix, it's just like find works as well, isn't it? AFAIK, according to POSIX, the syntax should be like java --classpath ... --ea ... Something and -abcdef would mean specifying 6 short options at once. I wonder which version leads in general to less typing and less errors. I'm writing a small utility in Java and in no case I'm going to use Windows style /a /b since I'm interested primarily in Unix. What style should I choose?

    Read the article

  • Why is it java code indented as BSD KNF Style and C C++ code indented as Allman or BSD style?

    - by Caffeine
    I do understand that coding convention is a matter of preference, and that different coding conventions have different subtle advantages or shortcomings, and depending on what one wants, one should choose his/her style. But why is usually Java written where the opening brace is on the same line as the function definition of control statement, and in C or C++ the curly braces have a line of their own? BSD KNF style if (data != NULL && res > 0) { if (JS_DefineProperty(cx, o, "data", STRING_TO_JSVAL(JS_NewStringCopyN(cx, data, res)), NULL, NULL, JSPROP_ENUMERATE) != 0) { QUEUE_EXCEPTION("Internal error!"); goto err; } PQfreemem(data); } else { if (JS_DefineProperty(cx, o, "data", OBJECT_TO_JSVAL(NULL), NULL, NULL, JSPROP_ENUMERATE) != 0) { QUEUE_EXCEPTION("Internal error!"); goto err; } } Allman or BSD Style if (x == y) { something(); somethingelse(); } Courtesy: http://en.wikipedia.org/wiki/Indent_style

    Read the article

  • Can coding style cause or influence memory fragmentation?

    - by Robert Dailey
    As the title states, I'd like to know if coding style can cause or influence memory fragmentation in a native application, specifically one written using C++. If it does, I'd like to know how. An example of what I mean by coding style is using std::string to represent strings (even static strings) and perform operations on them instead of using the C Library (such as strcmp, strlen, and so on) which can work both on dynamic strings and static strings (the latter point is beneficial since it does not require an additional allocation to access string functions, which is not the case with std::string). A "forward-looking" attitude I have with C++ is to not use the CRT, since to do so would, in a way, be a step backwards. However, such a style results in more dynamic allocations, and especially for a long living application like a server, this causes some speculation that memory fragmentation might become a problem.

    Read the article

  • How is this paradigm/style called?

    - by McMannus
    I have the following situation: I'm developing an add-in for a UML modeling tool. The models that can be created by the user are stored inside the main application and a limited access to the models is given through its API. However, the add-in has a lot of callbacks for events that are triggered by the main application, when changes to the model occur by the user. Since the models are already stored once in the main application, I considered it not practicable to duplicate the models in the add-in, which leads to the fact that I have only behavior in the add-in, rather than having a state. This behavior is mainly expressed by static functions, that are organized in functional cohesive classes. The callbacks for the events have always references to the model elements relevant for the specifc event that ocurred. First, it seemed to me that this is a procedural style in general, but procedural style doesn't consider events/callbacks, so this boils down to the question. How is this programming style called?

    Read the article

  • How to retrieve a style's value in javascript?

    - by stan
    I am looking for a way to retrieve the style from an element that has a style set upon it by the style tag. <style> #box {width: 100px;} </style> In the body <div id="box"></div> I'm looking for straight javascript without the use of libraries. I tried the following, but keep receiving blanks: alert (document.getElementById("box").style.width); alert (document.getElementById("box").style.getPropertyValue("width")); I noticed that I'm only able to use the above if I have set the style using javascript, but unable to with the style tags.

    Read the article

  • Is there a best coding style for indentations (same line, next line)?

    - by Luis Soeiro
    I prefer Pascal-like coding style, where the beginning and ending of a code block are on the same column. I think that it is easier to read and to handle cut and paste than the other kind of coding style. The style I prefer (Pascal-like): void fooBar(String s) { int a; int length=s.length(); for (int i=0;i<length;i++) { if (i>10) { System.out.println(i); System.out.println(s.charAt(i)); } } } The style that was adopted by the Java community: void fooBar(String s) { int a; int length=s.length(); for (int i=0;i<length;i++){ if (i>10){ System.out.println(i); System.out.println(s.charAt(i)); } } } So why do you use one type or the other (please cite an objective reason)?

    Read the article

  • on coding style

    - by user12607414
    I vastly prefer coding to discussing coding style, just as I would prefer to write poetry instead of talking about how it should be written. Sometimes the topic cannot be put off, either because some individual coder is messing up a shared code base and needs to be corrected, or (worse) because some officious soul has decided, "what we really need around here are some strongly enforced style rules!" Neither is the case at the moment, and yet I will venture a post on the subject. The following are not rules, but suggested etiquette. The idea is to allow a coherent style of coding to flourish safely and sanely, as a humane, inductive, social process. Maxim M1: Observe, respect, and imitate the largest-scale precedents available. (Preserve styles of whitespace, capitalization, punctuation, abbreviation, name choice, code block size, factorization, type of comments, class organization, file naming, etc., etc., etc.) Maxim M2: Don't add weight to small-scale variations. (Realize that Maxim M1 has been broken many times, but don't take that as license to create further irregularities.) Maxim M3: Listen to and rely on your reviewers to help you perceive your own coding quirks. (When you review, help the coder do this.) Maxim M4: When you touch some code, try to leave it more readable than you found it. (When you review such changes, thank the coder for the cleanup. When you plan changes, plan for cleanups.) On the Hotspot project, which is almost 1.5 decades old, we have often practiced and benefited from such etiquette. The process is, and should be, inductive, not prescriptive. An ounce of neighborliness is better than a pound of police-work. Reality check: If you actually look at (or live in) the Hotspot code base, you will find we have accumulated many annoying irregularities in our source base. I suppose this is the normal condition of a lived-in space. Unless you want to spend all your time polishing and tidying, you can't live without some smudge and clutter, can you? Final digression: Grammars and dictionaries and other prescriptive rule books are sometimes useful, but we humans learn and maintain our language by example not grammar. The same applies to style rules. Actually, I think the process of maintaining a clean and pleasant working code base is an instance of a community maintaining its common linguistic identity. BTW, I've been reading and listening to John McWhorter lately with great pleasure. (If you end with a digression, is it a tail-digression?)

    Read the article

  • Tables And Style Sheet Languages Of Website Design

    Style sheet languages such as CSS (Cascading Style Sheets) and XSL (Extensible Stylesheet Langauges) are widely known for their use in website design, particularly in website layouts as well as effec... [Author: Margarette Mcbride - Web Design and Development - June 09, 2010]

    Read the article

  • Non-Standardized Style Sheet Languages

    CSS (Cascading Style Sheets) and XSL (Extensible Stylesheet Language) are considered as the standard style sheet languages used in web development. However, other than CSS and XSL, there has also bee... [Author: Margarette Mcbride - Web Design and Development - May 04, 2010]

    Read the article

  • The Style Sheet Languages Of Then And Now

    One of the most popular style sheet language used across the industry of web designing today is CSS (Cascading Style Sheets). It was once known as the "tableless web design" because it was the only s... [Author: Margarette Mcbride - Web Design and Development - May 17, 2010]

    Read the article

  • Web Design Before The Style Sheet Language

    In today';s trends of website design, the use of style sheet languages such as CSS (Cascading Style Sheets) and XSL (Extensible StyleSheet Languages) are considered necessary to build a successful web... [Author: Margarette Mcbride - Web Design and Development - May 17, 2010]

    Read the article

  • A Powerful Style Sheet Language

    According to many web designers, CSS or Cascading Style Sheets is considered as the most popular type of style sheet language used in the market today. This is because of its simplicity which allows ... [Author: Margarette Mcbride - Web Design and Development - June 09, 2010]

    Read the article

  • Comparison Of The Best Style Sheet Languages

    CSS, Cascading Style Sheets, is one of the most popular types of style sheet languages used by many web developers today. Part of what made it popular is its flexibility in almost all types of browse... [Author: Margarette Mcbride - Web Design and Development - May 05, 2010]

    Read the article

  • Style Sheet Languages Before CSS

    CSS or Cascading Style Sheets is one of the most widely used form of style sheet languages used in the market. According to many professionals, CSS was the perfect move from the use of tables in web ... [Author: Margarette Mcbride - Web Design and Development - May 03, 2010]

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >