(http://stackoverflow.com/questions/5276967/python-in-xcode-4)




I figured it out! The steps look lengthy but it's not that bad at all.


  1. Open Xcode 4.
  2. In the menu bar, click "File" → "New" → "New Project…".
  3. Select "Other" under "Mac OS X".
  4. Select "External Build System" and click "Next".
  5. Enter the product name.
  6. For the "Build Tool" field, type in /usr/local/bin/python3 for Python 3 or /usr/bin/python for Python 2 and then click "Next". Note that this assumes you have Python installed in the typical location(s). if you are unsure as to where your Python executables are enter these commands into Terminal: which python3 and which python.
  7. Choose where to save it and click "Create".
  8. In the menu bar, click "File" → "New" → "New File…".
  9. Select "Other" under "Mac OS X".
  10. Select "Empty" and click "Next".
  11. Navigate to the project folder (it will not work, otherwise), enter the name of the Python file (include the ".py" extension), and click "Save".
  12. In the menu bar, click "Product" → "Edit Scheme…".
  13. Click "Run" in the left column.
  14. In the "Info" tab, click the "Executable" field and then click "Other…".
  15. Navigate to the executable from Step 6. You may need to use ⇧⌘G to type in the directory if it is hidden.
  16. Select the executable and click "Choose".
  17. For the "Debugger" field, select "None".
  18. In the "Arguments" tab, click the "Base Expansions On" field and select the target that is named the same as your project.
  19. Click the "+" icon under "Arguments Passed On Launch". You may have to expand that section by clicking on the triangle pointing to the right.
  20. Type in $(SOURCE_ROOT)/ and then the name of the Python file you want to test. Remember, the Python program must be in the project folder. Otherwise, you will have to type out the full path (or relative path if it's in a subfolder of the project folder) here. If there are spaces anywhere in the full path, you must include quotation marks at the beginning and end of this.
  21. Click "OK".
  22. Start coding.


Note that if you open the "Utilities" panel, with the "Show the File inspector" tab active, the file type is automatically set to "Default - Python script". Feel free to look through all the file type options it has to gain an idea as to what all it is capable of doing. The method above can be applied to any interpreted language. As of right now, I have yet to figure out exactly how to get it to work with Java; then again, I haven't done too much research. Surely there is some documentation floating around on the web about all of this.

Say, "Hello, code completion, auto-indentation, and syntax highlighting." Note that it's not as advanced as it is with C, C++, or Objective-C but it is better than using IDLE in my opinion.



Posted by Jason Ryu
,



'$ SaVvY > » computer' 카테고리의 다른 글

Recursive Function.  (0) 2013.07.10
Pyhon 2.7.3 with Xcode 4  (0) 2013.07.10
문자열검색 알고리즘. KMP  (0) 2013.07.10
Building ACE framework on Mac OS X Mountain Lion.  (0) 2013.07.10
Public DNS server  (0) 2013.07.10
Posted by Jason Ryu
,

검색하면, 문자열비교함수 strcmp() 같은걸 떠올려서 O(m*n) 수준의 알고리즘을 사용하는게 딱 내 수준인데,

세상엔 이런 알고리즘들을 즐비하게 만들어내주신다. 저런 패턴을 찾아낸다는것 자체가 신비롭다.


나같은 범인들은 그냥 잘차려진 밥상에 숟갈 얹어 잘 먹어주기만 하면 되는데,

요즘처럼 호기심 왕성한 시기에는 하나하나 파헤쳐본다. 창조자의 기막힌 발상 자체에 경의를 표하며...


아래소스코드는 개략적인 아이디어를 확인하는 샘플코드. 의사코드로 된 것이 좀 더 정확하지만,

내 눈깔은 다른 언어보다 역시나 C/C++ 스타일에 너무 익숙하다. 때론 일상적인 언어보다 나을때가 있다.

--------------------------------------------------------------------------------

/*

 * KMP algorithm

 * KMP(char *s, char *p)

 * find string p in string s

 * if find p in s, return index of s

 * else return -1

 * set N (max string length)

 */


#include <cstdio>

#include <cstring>


#define N 100


using namespace std;


void make_f(char *p, int *f)

{

    int pl;

    int q, k;

    pl = strlen(p);

    f[0] = -1;

    k = -1;

    for( q=1; q<pl; ++q)

    {

        while( k>=0 && p[k+1] != p[q] ) k = f[k];

        if(p[k+1] == p[q]) k++;

        f[q] = k;

    }

}


int KMP(char *s, char *p) 

{

    int f[ N ];

    int sl, pl;

    int i, q;


    pl = strlen(p);

    sl = strlen(s);

    make_f(p, f);

    q = -1;

    for( i=0; i<sl; ++i)

    {

        while( q >= 0 && p[q+1] != s[i] ) q = f[q];

        if(p[q+1] == s[i]) q++;

        if(q == pl-1) return i-pl+1;

    }

    return -1;

}


Posted by Jason Ryu
,

Download

Source package from ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.1.0.tar.gz

and

Doxygen document from ftp://download.dre.vanderbilt.edu/previous_versions/ACE-html-6.1.0.tar.gz


Edit your shell environment : in case of bash,

export ACE_ROOT={ACE installation path}            // ACE_wrappers directory.
export DYLD_LIBRARY_PATH=$ACE_ROOT/lib:$DYLD_LIBRARY_PATH



Create 2 files


1. $ACE_ROOT/ace/config.h

#include "ace/config-macosx-lion.h"
#define  ACE_NEEDS_DL_UNDERSCORE


2. $ACE_ROOT/include/makeinclude/platform_macros.GNU

include $(ACE_ROOT)/include/makeinclude/platform_macosx_lion.GNU
INSTALL_PREFIX=/usr/local
install_rpath=0



Finally, just execute;

make
make install


The last command, make install, may fails. you may need to run it as a root.


On other platforms, some configurations should be changed.

  • DYLD_LIBRARY_PATH => LD_LIBRARY_PATH, LIBPATH, or SHLIB
  • ace/config-macosx-lion.h => ace/config-{platform}.h
  • $(ACE_ROOT)/include/makeinclude/platform_macosx_lion.GNU => $(ACE_ROOT)/include/makeinclude/platform_{platform}.h
  • install_rpath => {NO NEED}


Enjoy it!!

'$ SaVvY > » computer' 카테고리의 다른 글

C++의 string 클래스 대신 String 클래스를 만들어 쓰기전에...  (0) 2013.07.10
문자열검색 알고리즘. KMP  (0) 2013.07.10
Public DNS server  (0) 2013.07.10
Red-Black Tree flow diagram  (0) 2013.07.09
GDBM User Reference  (0) 2013.07.05
Posted by Jason Ryu
,

SK Broadband :  210.220.163.82    219.250.36.130


KT olleh  : 168.126.63.1    168.126.63.2


LG U+ : 164.124.107.9    203.248.242.2


Dacom : 164.124.101.2    203.248.240.31


두루넷 : 210.117.65.1    210.117.65.2


Google public :   8.8.8.8    8.8.4.4


OpenDNS : 208.67.222.222   208.67.220.220

'$ SaVvY > » computer' 카테고리의 다른 글

문자열검색 알고리즘. KMP  (0) 2013.07.10
Building ACE framework on Mac OS X Mountain Lion.  (0) 2013.07.10
Red-Black Tree flow diagram  (0) 2013.07.09
GDBM User Reference  (0) 2013.07.05
SyncMaster TA531 with Mac OS X  (1) 2013.07.01
Posted by Jason Ryu
,