Pages

Ads 468x60px

Labels

Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Monday, June 4, 2012

One statement Lambda QuickSort


lst la danh sach can sap xep

http://stackoverflow.com/questions/228181/the-zen-of-python

Saturday, May 12, 2012

Modern Language Wars : Python vs Ruby vs PHP

So sánh này là của trang web Udemy thực hiện : http://www.udemy.com/blog
Đây là 3 ngôn ngữ còn rất trẻ nếu so sánh với C, và đồng trang lứa với C++, Java ...
CLICK VÀO HÌNH ĐỂ PHÓNG TO .

Monday, May 7, 2012

Ubuntu Python MySQL Setuptools

sudo apt-get install python-dev
sudo apt-get install libmysqlclient-dev

sudo python setup.pybuild
sudo python setup.py install

Eclipse - No module named settings.py


ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named settings.py
=> Windows > Preferences > Pydev > Interpreter Python  > Libraries > Add path to folder contains settings.py


or sometimes, it's just about your debugging arguments ...





Friday, May 4, 2012

Download Python Library

http://www.lfd.uci.edu/~gohlke/pythonlibs

Django Eclipse Python MySQL SetupTools Windows Linux

Với Linux => http://pypi.python.org/pypi/setuptools + http://sourceforge.net/projects/mysql-python/
Với Windows => http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

Chay Django Eclipse va PyDev Aptana


  1. Cài đặt Python 2.7
  2. Tải về Eclipse, bản nào cũng được, chọn cái nhiều người tải nhất cho có phong trào :))
  3. Cài đặt Django để tích hợp  vào Python.
  4. Trong Eclipse,  > Help > Install New Software và dựa vào Pydev để cài đặt Aptana (Pydev for Python + Django)
  5. Bước cuối cùng : Tạo project và PHẢI CHỈNH PHẦN DEBUG CONFIGURATION NHƯ SAU 


sau đó chọn Debug thì bạn sẽ được kết quả như khoanh màu vàng phía dưới : Khi đó vào 127.0.0.1:8000 
ta được :



Xem thêm nếu vẫnhttp://vimeo.com/5027645

Thursday, May 3, 2012

Man hinh eclipse mau den black background color

Đó là do Theme của 1 Plugin nào đó, Aptana chẳng hạn.
Cách sửa lại như cũ : Windows > Preferences > Aptana : Theme- chọn cái bạn thích .

Nếu vẫn không được thì có lẽ do bạn lỡ tay chỉnh mục font & color ...

Nguồn : http://stackoverflow.com/questions/7765222/eclipse-console-turned-into-black-background-after-installing-aptana-plugin

"Django not found" Eclipse

Trong luc cau hinh duong dan cho Interpreter :

Windows > Preference > Pydev > Python ... ban phai add Interpreter co chua django

Vi du minh cai dat Python2.6 & 2.7
Khi cai xong django - django se nam trong thu muc Python2.7 => do do phai set duong dan den Python2.7 uu tien hon la Python 2.6

Source : http://stackoverflow.com/questions/3939877/pydev-not-recognizing-python-installation-with-django

Cài đặt modwsgi

Sau khi cài đặt xong Aphache  thì để chạy Web Server Python, các bạn cần ModWSGI :

Các bản cho Windows và Linux : http://code.google.com/p/modwsgi/wiki/DownloadTheSoftware?tm=2

Tải xong chép mod_wsgi.so vào /Program Files/Apache Software Foundation/Apache22/modules là OK.


Chú ý nhỏ : rename mod_wsgi-win32-ap22py27-3.3.so => mod_wsgi.so




(http://code.google.com/p/modwsgi/wiki/InstallationOnWindows
http://brugbart.com/Tutorials/installing-mod-wsgi-apache-windows
)

Cài đặt Eclipse Web Server cho Python


  1. Tải và cài đặt Python 2.7
  2. Tải và cài đặt Eclipse Web Developement
  3. Cài plugin Python cho Eclipse ví dụ Pydev for Python
  4. Tải  và cài modwsgi
  5. Tải và cài đặt Web.py
  6. Tải và cài đặt Apache Web Server
  7. Tham khảo thêm tại :

Cài đặt Web.py trên Windows

Tải cái này về : http://webpy.org/static/web.py-0.36.tar.gz
Giải nén bằng WinRAR.
Copy folder web => python2.7/lib/web


Sử dụng : http://webpy.org/docs/0.3/tutorial

Web.py versus App Engine

Một so sánh rất thú vị : http://stackoverflow.com/questions/4759565/differences-between-webapp-and-web-py


9
down voteaccepted
web.py experience:
I started to use web.py three years ago when I decided to learn some Python web frameworks.
The first thing I loved of web.py was its simplicity; I was searching for an essential microframework without all the batteries that you can find in other bigger projects like Django or Web2py for example.
So I developed a couple of projects (deployed with fastcgi) and learned all of the web.py library features,Templetor included.
Then I discovered Google App Engine and started to use Webapp; it was a boring process because instead of using python (like Templetor or Mako), it forces you to learn a new templating syntax that it is very restrictive by default.
While Developing StackPrinter I found that Google App Engine was supported by web.py so I removedSqlite, made some minor tweaks and started to use GAE datastore.
Web.py was my first love in term of Python web frameworks and it's fair to say that I'm a little biased to talk about it.
I'm sticking with web.py for my pet-project on GAE because I'm fluent with it and templetor is lightning fast.
I like the fact that I can use Python for templating and the easy way to share some data or functions globally to the views, I like also the rich toolset of utilities for encoding, markdown and so on.
Webapp vs web.py:
I think it's not fair to compare them because Webapp is a simple framework that just provides the minimum easy tools to get started; many features are missing like I18n, validation, processors or even the basic cookies handling.
Check Webapp-improved for something better.
My recommendation:
If your focus is mainly on developing for Google App Engine, I would recommend you to go with some framework made specifically for GAE like Tipfy.
If you are searching for a pythonic web framework to play with on your side-projects, web.py is a good project to study and to follow.


Đọc vô hiểu sơ sơ :))

Tuesday, March 20, 2012

Hosting miễn phí cho Python - Perl - CGI

Đây là 1 trong những Hosting miễn phí tốt nhất mà mình biết : www.frihost.com

Thông Tin  :

- Không có Ads, Cpanel dễ sử dụng .
- Rất nhanh , các bạn có thể truy cập thử demo sau, Web bằng Flash file zip nặng tới 3,6 MB : http://nguyenvulong.frih.org/
- Còn đây là demo Python : http://nguyenvulong.frih.org/cgi-bin/test.py

- Đặc biệt, hỗ trợ Python – điều mà gần như không có ở các Hosting miễn phí nào khác.

- Sau khi đăng nhập, các bạn hãy vào diễn đàn comment khoảng 6-7 bài – Comment dài 1 chút khoảng 3-4 dòng gì đó để được 10 points. Khi đó các bạn vào Account và chọn request Hosting là được (cái này để tránh spam thôi)

 – Admin rất nhiệt tình, mình làm hơn 10 phút là xong xuôi hết rồi . Bạn nào muốn dùng được Python thì nhắn tin cho Admin bảo chuyển qua Server 2 hoặc 3 là xong . Nếu bạn đang ở Server 4 thì chưa chạy   được .
- Ngoài ra nếu các bạn tích cực hoạt động trong forum và website, (chuyện phiếm thôi) thì dựa vào điểm thưởng bạn có thể đổi tên miền miễn phí (Top-Level), disable ads forum ...



fri

Sunday, March 18, 2012

XOR là viết tắt của Exclusive Or

XOR trong ngôn ngữ lập trình là viết tắt của Exclusive Or (Ex phát âm giống X)

Thực hiện phép XOR giữa 2 số nhị phân theo nguyên tắc sau  : số chữ số 1 là chẵn thì kết quả là 0, và lẻ thì kết quả là 1 .

Ví dụ  :

000 XOR 101 XOR 111

viết thành hàng dọc như sau

0 0 0
1 0 1
1 1 1
_______

0 1 0

cột 1 và 3 có số chữ số 1  là CHẴN => kết quả là 0 .

Thursday, February 9, 2012

Saturday, January 7, 2012

Python - Hàm main() không thực thi ?

Đây là lưu ý chung cho các ngôn ngữ thông dịch, hàm main() phải được gọi để có thể thực thi, các bạn xem hình sau :

Wednesday, December 21, 2011

Python WordCount - Đếm số từ trong file Text

Mới học Python, đây là chương trình đầu tay của mình :-D

Đọc số lần xuất hiện của các từ trong 1 đoạn file Text .


Tuesday, November 29, 2011

Cài đặt và sử dụng Python trên Windows [7]

Các bạn download Python tại : http://www.python.org/download/releases/2.7.2/

Sau khi cài vào máy, mặc định sẽ là đường dẫn sau : C:\Python27

Tiếp đó , các bạn làm như hình :


Một lời khuyên là với những ai mới bắt đầu lập trình, thì nên học theo http://learnpythonthehardway.org/book/

*Gợi ý : Các bạn đọc kỹ hướng dẫn  của trang phía trên, nếu các bạn sử dụng command line để gõ lệnh thì mỗi dòng chỉ được 1 lệnh thôi, do đó cần lưu ra file để chạy một khối lệnh. File lưu có dạng tenfile.py , các bạn bỏ trong folder C:\Python27 luôn .
Lúc nào cần chạy file, các bạn gõ trong command line như hình sau :


 

Sample text

Sample Text

Sample Text

Everyday, I wake up asking my-self : what is the purpose of Life ?

 
Blogger Templates