how python dir works

2012-04-18 Thread cheung
how does the function  "dir" works, where can I get the python-c  source of dir 
in py2.7 project.

I looked the python_c source for hours, can't find how dir works. 

for example:
   if a user input a *.py source file like foo.py, i wanna parse the file, and 
find all the functions and all the classes in the foo.py.

i wanna use the python-c source or python Lan. to solve this problem, I've 
tried to view the python-c project, and ask google for help, but doesn't work.

can anyone help me?
-- 
http://mail.python.org/mailman/listinfo/python-list


web browsing short cut

2011-07-02 Thread Dustin Cheung
Hey guys,

I am new to python. I want to make a shortcut that opens my websites
and re-sizes them to  display on different areas on the screen. I looked
around but i had no luck. Is that possible with python? if so can someone
point to to the right direction? Here is what I came up with so far..

Thanks in advance,

--


import webbrowser

# The websites i want to open..
url1 = 'http://www.python.org/'
url2 = 'http://www.google.com/'
url3 = 'http://msn.com/'

# the path to ie
ie = webbrowser.get('c:\\program files\\internet explorer\\iexplore.exe')
ie.open(url1)
ie.open(url2)
ie.open(url3)




-- 
Dustin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: web browsing short cut

2011-07-05 Thread Dustin Cheung
Hey,

I am looking into Tkinter. But i am not sure if it will actually work. This
maybe a crazy idea but i was wondering if i can put a web browser in the
frame. I have tried to use Tkinter to resize and place the windows to
certain areas of the screen but that's not working or the way im approaching
this problem is completely wrong. I want to make a program that will have
websites displayed in specific areas of the screen. I was planning on using
the program on the big screen. So is it possible to put the web browser
inside the frame in Tkinter?


On Sat, Jul 2, 2011 at 7:10 PM, Chris Rebert  wrote:

> On Sat, Jul 2, 2011 at 6:21 PM, Dustin Cheung  wrote:
> > Hey guys,
> > I am new to python. I want to make a shortcut that opens my websites
> > and re-sizes them to  display on different areas on the screen. I looked
> > around but i had no luck. Is that possible with python? if so can someone
> > point to to the right direction? Here is what I came up with so far..
>
> The window positioning+resizing bit will likely require using
> platform-specific APIs. Since you appear to be on Windows, the
> relevant library would be pywin32 (http://pypi.python.org/pypi/pywin32
> ). You would use it to invoke some COM API that does window
> positioning+resizing. I am unable to give more details as I'm on a
> Mac.
>
> Sidenote: Have you tried Firefox's "Bookmark All Tabs" feature?
>
> Cheers,
> Chris
>



-- 
Dustin Cheung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: web browsing short cut

2011-07-06 Thread Dustin Cheung
Okay thanks for the help guys, ill keep you guys posted.

On Wed, Jul 6, 2011 at 1:19 PM, Ian  wrote:

> On 03/07/2011 02:21, Dustin Cheung wrote:
>
>> Hey guys,
>>
>> I am new to python. I want to make a shortcut that opens my websites and
>> re-sizes them to  display on different areas on the screen. I looked around
>> but i had no luck. Is that possible with python? if so can someone point to
>> to the right direction? Here is what I came up with so far..
>>
>>
>>  I suggest you create a dummy page on your disk with an onload event that
> uses javascript to open, size and load all the windows you want.
>
> Then create a short cut to the dummy page.
>
> Regards
>
> Ian
>
>
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>



-- 
Dustin Cheung
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 3.2 Debug build

2011-03-17 Thread Willis Cheung
Hi all,

I'm trying to build the debug version of Python 3.2. I downloaded the py3k
folder from the python SVN. Then I opened the pcbuild.sln and tried to build
the "python" project. However the build failed when I got an error from the
project "pythoncore" which I think "python" depends on? The error is:

Cannot open source file: 'C:\Program
Files\py3k\PCbuild\Win32-temp-Debug\pythoncore\\getbuildinfo2.c': No such
file or directory.



The log also mentioned the following couple lines before:

 

5>"C:\Program Files\TortoiseSVN\bin\subwcrev.exe" ..
..\Modules\getbuildinfo.c "C:\Program
Files\py3k\PCbuild\Win32-temp-Debug\pythoncore\\getbuildinfo2.c"
5>'C:\Program' is not recognized as an internal or external command,


I did get the debug build of python 2.7.1 and 3.1.3 to work successfully so
I'm not quite sure if I'm supposed to do anything different for Python 3.2.
Can anyone guide me on this? Thank you.

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python 3.2 Debug build

2011-03-22 Thread Willis Cheung
Thanks for your answers. Just to make sure I do it correctly, is it the CPython 
package on http://hg.python.org the one which I should be downloading? Thanks 
again

 

Willis

 

From: Santoso Wijaya [mailto:santoso.wij...@gmail.com] 
Sent: Thursday, March 17, 2011 6:05 PM
To: Willis Cheung
Cc: python-list@python.org
Subject: Re: Python 3.2 Debug build

 

Looks like something tripped over whitespaces in path names for svn tools. Try 
checking out a working copy from the hg repository?


 

~/santa



On Thu, Mar 17, 2011 at 3:54 PM, Willis Cheung  wrote:

Hi all,

I'm trying to build the debug version of Python 3.2. I downloaded the py3k 
folder from the python SVN. Then I opened the pcbuild.sln and tried to build 
the "python" project. However the build failed when I got an error from the 
project "pythoncore" which I think "python" depends on? The error is:

Cannot open source file: 'C:\Program 
Files\py3k\PCbuild\Win32-temp-Debug\pythoncore\\getbuildinfo2.c': No such file 
or directory.



The log also mentioned the following couple lines before:

 

5>"C:\Program Files\TortoiseSVN\bin\subwcrev.exe" .. ..\Modules\getbuildinfo.c 
"C:\Program Files\py3k\PCbuild\Win32-temp-Debug\pythoncore\\getbuildinfo2.c"
5>'C:\Program' is not recognized as an internal or external command,


I did get the debug build of python 2.7.1 and 3.1.3 to work successfully so I'm 
not quite sure if I'm supposed to do anything different for Python 3.2. Can 
anyone guide me on this? Thank you.


--
http://mail.python.org/mailman/listinfo/python-list

 

-- 
http://mail.python.org/mailman/listinfo/python-list


Updated Python 2.7.10 and now causing XCode not to build new project?

2015-06-07 Thread Sebastian M Cheung
Updated my anaconda Python to 2.7.10 and now when I start my XCode new project 
i get:

env: python: No such file or directory
Command 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
 failed with exit code 127

Anyone experienced this issue? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Binary file output using python

2007-04-17 Thread Chi Yin Cheung
Hi,
Is there a way in python to output binary files? I need to python to 
write out a stream of 5 million floating point numbers, separated by 
some separator, but it seems that all python supports natively is string 
information output, which is extremely space inefficient.

I'd tried using the pickle module, but it crashed whenever I tried using 
it due to the large amount of data involved.

Thanks for your help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use time.clock() function in python

2007-01-22 Thread samuel . y . l . cheung
Thanks.

I have a fuction called 'func1'.

def func1:
 # logic of the function

When my script just call 'func1()' it works.
func1()

But when put it under timerit.Timer, like this:
t = timeit.Timer("func1()","")
t.repeat(1, 10)

# want to time how long it takes to run 'func1' 10 times, I get an
error like this:
  File "/usr/lib/python2.4/timeit.py", line 188, in repeat
t = self.timeit(number)
  File "/usr/lib/python2.4/timeit.py", line 161, in timeit
timing = self.inner(it, self.timer)
  File "", line 6, in inner
NameError: global name 'func1' is not defined

I don't understand why i can't find 'func1', when I call the function
'func1' directly, it works.
but why when I call it within 'timeit', it can't find it?

Thank you.





Gabriel Genellina wrote:
> At Monday 22/1/2007 19:05, [EMAIL PROTECTED] wrote:
>
> >I am following this python example trying to time how long does an
> >operation takes, like this:
> >
> >My question is why the content of the file (dataFile) is just '0.0'?
> >I have tried "print >>dataFile, timeTaken" or "print >>dataFile,str(
> >timeTaken)", but gives me 0.0.
> >Please tell me what am I missing?
> >
> >
> > t1 = time.clock()
> > os.system(cmd)
> >
> > outputFile = str(i) + ".png"
> >
> > t2 = time.clock()
> >
> > timeTaken = t2 - t1
> > allTimeTaken += timeTaken
> > print >>dataFile, timeTaken
>
> time.clock() may not give you enough precision; see this recent post
> http://mail.python.org/pipermail/python-list/2007-January/422676.html
> Use the timeit module instead.
>
>
> --
> Gabriel Genellina
> Softlab SRL
>
>
>
>
>
>
> __
> Preguntá. Respondé. Descubrí.
> Todo lo que querías saber, y lo que ni imaginabas,
> está en Yahoo! Respuestas (Beta).
> ¡Probalo ya! 
> http://www.yahoo.com.ar/respuestas

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use cmp() function to compare 2 files?

2007-02-27 Thread samuel . y . l . cheung
On Feb 27, 12:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> wrote:
>
> >   File "./scripts/regressionTest.py", line 30, in getSnapShot
> > if (difflib.context_diff(f1.readlines(), f2.readlines()).len() ==
> > 0):
> >  # no difference
> > else:
> >  # files are different
> > AttributeError: 'generator' object has no attribute 'len'
>
> > Can you please help?
>
> The function returns a generator/iterator over the differences which has
> no `len()` method.  If you just want to know if two files are equal or not
> use `filecmp.cmp()`.  Read the docs about the `shallow` argument of that
> function.
>
> Ciao,
> Marc 'BlackJack' Rintsch

Thanks. I use that before, it does not work for me, since it always
return 1, regardless if the file content of 2 files are different or
not.


-- 
http://mail.python.org/mailman/listinfo/python-list


How to find number of whole weeks between dates?

2015-06-10 Thread Sebastian M Cheung via Python-list
Say in 2014 April to May whole weeks would be 7th, 14th 28th April and  May 
would be 5th, 12th and 19th. So expecting 7 whole weeks in total
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to find number of whole weeks between dates?

2015-06-10 Thread Sebastian M Cheung via Python-list
On Wednesday, June 10, 2015 at 6:06:09 PM UTC+1, Sebastian M Cheung wrote:
> Say in 2014 April to May whole weeks would be 7th, 14th 28th April and  May 
> would be 5th, 12th and 19th. So expecting 7 whole weeks in total

What I mean is given two dates I want to find WHOLE weeks, so if given the 2014 
calendar and function has two inputs (4th and 5th month) then 7th, 14th, 21st 
and 28th from April with 28th April week carrying into May, and then 5th, 12th 
and 19th May to give total of 7 whole weeks, because 26th May is not a whole 
week and will not be counted.

Hope thats clear.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to find number of whole weeks between dates?

2015-06-10 Thread Sebastian M Cheung via Python-list
yes just whole weeks given any two months, I did looked into calendar module 
but couldn't find specifically what i need.
-- 
https://mail.python.org/mailman/listinfo/python-list


How to pretty mathematical formulas in Python? Similar to Mathematica formats.

2015-06-11 Thread Sebastian M Cheung via Python-list
How to pretty mathematical formulas in Python? Similar to Mathematica formats.

Are there good packages to prettify mathematica formulas in Python?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to pretty mathematical formulas in Python? Similar to Mathematica formats.

2015-06-11 Thread Sebastian M Cheung via Python-list
On Thursday, June 11, 2015 at 7:33:12 PM UTC+1, Sebastian M Cheung wrote:
> How to pretty mathematical formulas in Python? Similar to Mathematica formats.
> 
> Are there good packages to prettify mathematica formulas in Python?

Thanks Pythonistas
-- 
https://mail.python.org/mailman/listinfo/python-list


XCode and Python

2015-06-11 Thread Sebastian M Cheung via Python-list
For some reason I cannot build now in XCode:

$ xcodebuild -find python
/Users/sebc/anaconda/bin/python

$python
Python 2.7.10 |Anaconda 2.2.0 (x86_64)| (default, May 28 2015, 17:04:42) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org

But XCode now simply say error

env: python: No such file or directory
Command 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
 failed with exit code 127

I couldn't find anything relating XCode for iPhone related to Python build? I 
am using
anaconda Python

Anyone? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XCode and Python

2015-06-11 Thread Sebastian M Cheung via Python-list
On Thursday, June 11, 2015 at 11:07:59 PM UTC+1, Sebastian M Cheung wrote:
> For some reason I cannot build now in XCode:
> 
> $ xcodebuild -find python
> /Users/sebc/anaconda/bin/python
> 
> $python
> Python 2.7.10 |Anaconda 2.2.0 (x86_64)| (default, May 28 2015, 17:04:42) 
> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> Anaconda is brought to you by Continuum Analytics.
> Please check out: http://continuum.io/thanks and https://binstar.org
> 
> But XCode now simply say error
> 
> env: python: No such file or directory
> Command 
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
>  failed with exit code 127
> 
> I couldn't find anything relating XCode for iPhone related to Python build? I 
> am using
> anaconda Python
> 
> Anyone?

Or I need to configure something in Xcode?
-- 
https://mail.python.org/mailman/listinfo/python-list


Java to Python autoconverters

2015-06-12 Thread Sebastian M Cheung via Python-list
Are these available? Any good ones to recommend?
-- 
https://mail.python.org/mailman/listinfo/python-list


python financial data cleaning

2015-06-15 Thread Sebastian M Cheung via Python-list
How to do financial data cleaning ? Say I assume a list of 1000 finance series 
data in myList = Open, High, Low and Close. For missing Close Price data, What 
is best practice to clean data in Python

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python financial data cleaning

2015-06-15 Thread Sebastian M Cheung via Python-list
On Monday, June 15, 2015 at 11:13:07 AM UTC+1, Sebastian M Cheung wrote:
> How to do financial data cleaning ? Say I assume a list of 1000 finance 
> series data in myList = Open, High, Low and Close. For missing Close Price 
> data, What is best practice to clean data in Python

Thanks Mark just looking into Pandas now



Seb
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python financial data cleaning

2015-06-15 Thread Sebastian M Cheung via Python-list
On Monday, June 15, 2015 at 12:35:18 PM UTC+1, Laura Creighton wrote:
> I don't know anything about this program, and in particular how
> complete it is, but worth a look
> https://github.com/benjaminmgross/clean-fin-data
> 
> Laura

Thanks Laura, I will check it out, but basically it is to clean financial 
series data as sometimes there are missing closing price data, misalignment of 
some sort etc 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python financial data cleaning

2015-06-15 Thread Sebastian M Cheung via Python-list
On Monday, June 15, 2015 at 11:19:48 AM UTC+1, Mark Lawrence wrote:
> On 15/06/2015 11:12, Sebastian M Cheung via Python-list wrote:
> > How to do financial data cleaning ? Say I assume a list of 1000 finance 
> > series data in myList = Open, High, Low and Close. For missing Close Price 
> > data, What is best practice to clean data in Python
> >
> 
> http://pandas.pydata.org/
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> 
> Mark Lawrence


Hi Mark,

Below I read in DirtyData (financial data) from Excel and then find the number 
of NaN missing Closed Pricing data:

xls = pd.ExcelFile('DirtyData.xlsm')
df = xls.parse('Dirty Data', index_col=None, na_values=['NA'])
print(df.isnull().astype(int).sum()) 

So if I were to clean missing Open Price data, I could copy from previous or 
row's Close Price data, but how would I implement it? Thanks

-- 
https://mail.python.org/mailman/listinfo/python-list


anaconda upgrade

2015-06-17 Thread Sebastian M Cheung via Python-list
What is the best way to upgrade an existing virtual environment anaconda from 
2.7.9 to 2.7.10
-- 
https://mail.python.org/mailman/listinfo/python-list