Re: i need advice

2013-03-24 Thread Omer
I know some people will disagree with me, but I recommend on "Dive Into
 Python" by Mark Pilgrim. It assumes no prior knowledge whatsoever, and it
explains all the foundations of the language from the bottom up, without
skipping any steps. It also provides many examples that demonstrate how to
get Python to do things.


On 24 March 2013 19:24, leonardo selmi  wrote:

> dear python programmers,
>
> i am focused on learning to program but i need help from all of you. i am
> a beginner but it is hard to find the right book or website to learn, i
> know that i have to do exercises but so far i found resources with gaps. i
> would be very grateful if you could give me suggestions. for example i have
> "think python" and "learning python the hard way", do you recommend them or
> are there better books?
>
> thanks a lot and sorry for bugging you
>
> best regards
>
> leonardo
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


pickle module doens't work

2012-12-27 Thread Omer Korat
Hi all,

I'm working on a project in Python 2.7. I have a few large objects, and I want 
to save them for later use, so that it will be possible to load them whole from 
a file, instead of creating them every time anew. It is critical that they be  
transportable between platforms. Problem is, when I use the 2.7 pickle module, 
all I get is a file containing a string representing the commands used to 
create the object. But there's nothing I can do with this string, because it 
only contains information about the object's module, class and parameters. And 
that way, they aren't transportable.
In python 3.3 this problem is solved, and the pickle.dump generates a series of 
bytes, which can be loaded in any other module independently of anything. But 
in my project, I need NLTK 2.0, which is written in python 2.7...

Anybody has suggestions? Maybe there is a way to use pickle so that it yields 
the results I need? Or is there any other module that does pickle's job? Or 
perhaps there is a way to mechanically translate between python versions, so 
I'll be able to use pickle from 3.3 inside an application written in 2.7? Or 
perhaps somebody knows of a way to embed a piece of 3.3 code inside a 2.7 
program?

It can't be I'm the only one who wants to save python objects for later use! 
There must be a standard method to do this, but I couldn't find any on the web!
If someone can solve this for me I'll be so grateful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle module doens't work

2012-12-27 Thread Omer Korat
You're probably right in general, for me the 3.3 and 2.7 pickles definitely 
don't work the same:

3.3:
>>> type(pickle.dumps(1))


2.7:
>>> type(pickle.dumps(1, pickle.HIGHEST_PROTOCOL))



As you can see, in 2.7 when I try to dump something, I get useless string. Look 
what I gen when I dump an NLTK object such as the sent_tokenize function:

'\x80\x02cnltk.tokenize\nsent_tokenize\ng\x00'

Now, this is useless. If I try to load it on a platform without NLTK installed 
on it, I get:

ImportError: No module named 'nltk'

So it means the actual sent_tokenizer wasn't saved. Just it's module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle module doens't work

2012-12-27 Thread Omer Korat
I see. In that case, all I have to do is make sure NLTK is available when I 
load the pickled objects. That pretty much solves my problem. Thanks!
So it means pickle doesn't ever save the object's values, only how it was 
created? 

Say I have a large object that requires a lot of time to train on data. It 
means pickle doesn't save its values, so you have to train it every time anew? 
Is there no way to save its trained values?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle module doens't work

2013-01-01 Thread Omer Korat
I am using the nltk.classify.MaxEntClassifier. This object has a set of labels, 
and a set of probabilities: P(label | features). It modifies this probability 
given data. SO for example, if you tell this object that the label L appears 
60% of the time with the feature F, then P(L | F) = 0.6. 
The point is, there is no way to access the probabilities directly. The 
object's 'classify' method uses these probabilities, but you can't call them as 
an object property. 
In order to adjust probabilities, you have to call the object's 'train' method, 
and feed classified data in.
So is there any way to save a MaxEntClassifier object, with its classification 
probabilities, without having to call the 'train' method?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle module doens't work

2013-01-02 Thread Omer Korat
Yeah, right. I didn't think about that. I'll check in the source how the data 
is stored.
Thanks for helping sort it all out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Display Adapter Information from Registry?

2004-12-03 Thread Omer Ahmad
Hi All,

I've been working with python for about 6 months now, and have been
very impressed with the size and scope of the libraries.  I have,
however, run into a bit of a problem.

I discoverred Marc Hammonds PyWin32 extensions, (whcih are awesome)
and Tim Golden's WMI wrapper for accessing the Windows Management
Instrumentation  (Win32_Classes) but now I have been asked to remove
these dependandcies and still obtain machine information from the
registry (Windows only of course) so that we do not have to ship any
extensions to Python with our commercial software.

I need to grab the following information:

CPU(s) Descriptions strings (for multiple processors)  (found in
registry)
Display Adapter description string (found in registry)
Display Adapter Memory (found in registry)

What I'm having trouble with is to grab the DISPLAY ADAPTER version
using python and no Win32com client (i.e. pyWin32).  I thought about
grabbing the file name of the driver from the registry and then
looking up the file and calculating the version number (by parsing the
binary) but this only works if i can find the file.  I tried it out on
a few machines with different video adapters and thsi didn't prove to
be a reliable method.

Any suggestions? Please

Omer Ahmad.

ps: here is the code i'm using right now (minus all the debug strings)


def main():
"""Retrieves Machine information from the registry"""

try:
   hHardwareReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
"HARDWARE")
   hDescriptionReg = _winreg.OpenKey(hHardwareReg, "DESCRIPTION")
   hSystemReg = _winreg.OpenKey(hDescriptionReg, "SYSTEM")
   hCentralProcessorReg = _winreg.OpenKey(hSystemReg,
"CentralProcessor")
   nbProcessors = _winreg.QueryInfoKey(hCentralProcessorReg)[0]

   for idxKey in range(nbProcessors):
   #get a handle to the processor ID key
   hProcessorIDReg = _winreg.OpenKey(hCentralProcessorReg,
str(idxKey))
   processorDescription =
_winreg.QueryValueEx(hProcessorIDReg,"ProcessorNameString")[0]
   mhz = _winreg.QueryValueEx(hProcessorIDReg, "~MHz")[0]
   print "Processor " + str(idxKey) + ": " +
string.lstrip(processorDescription) + " Clock Speed: " + str(mhz)
   
except WindowsError:
   print "Cannot retrieve processor information from registry!"

   #get handle to device map, reusing hardware handle

   try:
   hDeviceMapReg = _winreg.OpenKey(hHardwareReg, "DEVICEMAP")
   hVideoReg = _winreg.OpenKey(hDeviceMapReg, "VIDEO")
   VideoCardString =
_winreg.QueryValueEx(hVideoReg,"\Device\Video0")[0]
   #Get Rid of Registry/Machine from the string
   VideoCardStringSplit = VideoCardString.split("\\")
   ClearnVideoCardString =
string.join(VideoCardStringSplit[3:], "\\")
   #Go up one level for detailed
   VideoCardStringRoot =
string.join(VideoCardStringSplit[3:len(VideoCardStringSplit)-1], "\\")

   #Get the graphics card information
   hVideoCardReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
ClearnVideoCardString)
   VideoCardDescription  = _winreg.QueryValueEx(hVideoCardReg,
"Device Description")[0]
   VideoCardMemorySize = _winreg.QueryValueEx(hVideoCardReg,
"HardwareInformation.MemorySize")[0]

   print "Graphics Card: " + VideoCardDescription
   print "Memory: " +
str(struct.unpack('l',VideoCardMemorySize)[0])

   except WindowsError:
   print "Cannot Retrieve Graphics Card Name and Memory Size!"
-- 
http://mail.python.org/mailman/listinfo/python-list


sys.exit call from pythonw.exe gives error

2006-07-04 Thread Omer KORKMAZ








 

I wrote a python GUI with tkInter and installed it on a windows machinewith the .pyw extension, so it will be executed from pythonw.exe insteadof python.exe, since I didn't want the console window to appear.My application exits with a call to sys.exit. However, when this call isexecuted under pythonw.exe I get an error popup window with thefollowing messeage:  start quote Microsoft Visual C++ Runtime LibraryRuntime Error!Program: C:\Python24\pythonw.exe This application has requested the Runtime to terminate in an unusual way.Please contact the application support team for more information end quote 

 

 

Did you find a solution for this problem?

 

Best Regards,

 

Omer Korkmaz

Ext: 3138

 



Dikkat:Bu elektronik posta mesaji kisisel ve ozeldir. Eger size gonderilmediyse lutfen gondericiyi bilgilendirip mesaji siliniz.Firmamiza gelen ve giden mesajlar virus taramasindan gecirilmekte, guvenlik nedeni ile kontrol edilerek saklanmaktadir.Mesajdaki gorusler  gondericiye ait olup HAVELSAN A.S. resmi gorusu olmak zorunda degildir.Attention:This e-mail message is private and privileged.If you are not the recipient for whom this e-mail message is intended, please notify the sender immediately and delete this e-mail message from your system.All sent and received e-mail messages go through a virus scan in our company, and because of security reasons, they are stored after being controlled.Any opinions presented in this e-mail message are solely those of the author and do not necessarily represent HAVELSAN A.S.'s formal and authorized views.


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

sys.exit call from pythonw.exe gives error

2006-07-04 Thread Omer KORKMAZ








 

I wrote a python GUI with tkInter and installed it on a windows machinewith the .pyw extension, so it will be executed from pythonw.exe insteadof python.exe, since I didn't want the console window to appear.My application exits with a call to sys.exit. However, when this call isexecuted under pythonw.exe I get an error popup window with thefollowing messeage:  start quote Microsoft Visual C++ Runtime LibraryRuntime Error!Program: C:\Python24\pythonw.exe This application has requested the Runtime to terminate in an unusual way.Please contact the application support team for more information end quote 

 

 

Did you find a solution for this problem?

 

Best Regards,

 

Omer Korkmaz

Ext: 3138

 



Dikkat:Bu elektronik posta mesaji kisisel ve ozeldir. Eger size gonderilmediyse lutfen gondericiyi bilgilendirip mesaji siliniz.Firmamiza gelen ve giden mesajlar virus taramasindan gecirilmekte, guvenlik nedeni ile kontrol edilerek saklanmaktadir.Mesajdaki gorusler  gondericiye ait olup HAVELSAN A.S. resmi gorusu olmak zorunda degildir.Attention:This e-mail message is private and privileged.If you are not the recipient for whom this e-mail message is intended, please notify the sender immediately and delete this e-mail message from your system.All sent and received e-mail messages go through a virus scan in our company, and because of security reasons, they are stored after being controlled.Any opinions presented in this e-mail message are solely those of the author and do not necessarily represent HAVELSAN A.S.'s formal and authorized views.


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

sys.exit call from pythonw.exe gives error

2006-07-04 Thread Omer KORKMAZ






I wrote a python GUI with tkInter and installed it on a windows machinewith the .pyw extension, so it will be executed from pythonw.exe insteadof python.exe, since I didn't want the console window to appear.My application exits with a call to sys.exit. However, when this call isexecuted under pythonw.exe I get an error popup window with thefollowing messeage:  start quote Microsoft Visual C++ Runtime LibraryRuntime Error!Program: C:\Python24\pythonw.exe This application has requested the Runtime to terminate in an unusual way.Please contact the application support team for more information end quote 

 

 

Did you find a solution for this problem?

 

Best Regards,

 

Omer Korkmaz

Ext: 3138

 



Dikkat:Bu elektronik posta mesaji kisisel ve ozeldir. Eger size gonderilmediyse lutfen gondericiyi bilgilendirip mesaji siliniz.Firmamiza gelen ve giden mesajlar virus taramasindan gecirilmekte, guvenlik nedeni ile kontrol edilerek saklanmaktadir.Mesajdaki gorusler  gondericiye ait olup HAVELSAN A.S. resmi gorusu olmak zorunda degildir.Attention:This e-mail message is private and privileged.If you are not the recipient for whom this e-mail message is intended, please notify the sender immediately and delete this e-mail message from your system.All sent and received e-mail messages go through a virus scan in our company, and because of security reasons, they are stored after being controlled.Any opinions presented in this e-mail message are solely those of the author and do not necessarily represent HAVELSAN A.S.'s formal and authorized views.


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

Re: What was that web interaction library called again?

2007-06-26 Thread Omer Khalid

On the RESTFul web service, I would like to piggy pack my own question two
is there a way to make the connection secure between two Restful service
running on GNU/linux?

Thanks,
Omer

On 6/26/07, Kathryn Van Stone <[EMAIL PROTECTED]> wrote:




So does anyone know of any equivalent library for testing RESTful web
services.

In particular it needs to be able to handle more than 'GET' or "POST"
http calls.

-Kathy Van Stone
[EMAIL PROTECTED]

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





--
--
CERN – European Organization for Nuclear
Research, IT Department,  CH-1211
Geneva 23, Switzerland

Phone: +41 (0) 22 767 2224
Fax: +41 (0) 22 766 8683
E-mail : [EMAIL PROTECTED]
Homepage: http://cern.ch/Omer.Khalid
-- 
http://mail.python.org/mailman/listinfo/python-list

How to do CPU/Memory benchmarking in Python?

2008-08-05 Thread Omer Khalid
Hi,
I have few long running python based scripts which does lots of number
crunching; I would like to bench mark the CPU/Memory/IO for that script. I
am wondering if there is a python benchmarking suite available?

There is pybench but it more or less test the executing script it self from
Python's performance perspective rather than the performance of the system
it self.

Thanks in advance!
Omer
--
http://mail.python.org/mailman/listinfo/python-list

Re: What is Islam?-1

2009-10-21 Thread omer azazi
On 12 أكتوبر, 05:42, TerryP  wrote:
> On Oct 11, 11:25 pm, omer azazi  wrote:
>
> I appologise if I appear _rude_, but this is comp.lang.python -- it is
> for the discussion of Python and related projects that were created by
> men and women. A discussion about faith does not belong in
> comp.lang.python, unless you are writing a program in Python to help
> people study the Qur’an, or some other holy book. .

> Good luck and good bye.
>
>         THANK YOU.





so, if i send programs about islam , will u accept it ?!!

or u just hate the word Islam ???
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is Islam?-1

2009-11-01 Thread omer azazi
from python to exe


py2exe turns Python programs into packages that can be run on other
Windows computers without needing to install Python on those
computers. Python is needed on the computer where py2exe itself is run
because py2exe is a Python program and it includes parts of Python in
the package that is built.

see here

http://www.py2exe.org/index.cgi/Tutorial

http://www.py2exe.org/

http://www.scribd.com/doc/19792648/-python-to-exe


also
eclipse editor>>>
http://www.eclipse.org/downloads/


thank u again







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


device identification

2010-03-21 Thread Omer Ihsan
i have installed pyusb now and run the sample usbenum.pyi have 3
usb ports on my PC but the results show 6 outputs to
dev.filename..they are numbers like 001 or 005 etc and they
changed when i plugged in devices...(i am no good with the usb
standards)i just want to identify each device/port... what
parameter in the example would help me

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


Re: device identification

2010-03-23 Thread Omer Ihsan
On Mar 23, 9:22 am, Tim Roberts  wrote:
> Omer Ihsan  wrote:
>
> >i have installed pyusb now and run the sample usbenum.pyi have 3
> >usb ports on my PC but the results show 6 outputs to
> >dev.filename..they are numbers like 001 or 005 etc and they
> >changed when i plugged in devices...(i am no good with the usb
> >standards)i just want to identify each device/port... what
> >parameter in the example would help me
>
> You can't identify the ports.[1]  What good would it do you?  The ports on
> your PC are not numbered.
>
> You certainly CAN identify the devices, by their VID and PID (or idVendor
> and idProduct).  You identify by function, not by location.  When you plug
> in a USB drive, you don't want to worry about where it's plugged in.
> ===
> [1]: OK, technically, it is not impossible to identify the port numbers,
> but it is quite tedious.  You need to chase through the sysfs expansion of
> your buses hub/port tree and find a match for your device.  It's not worth
> the trouble.
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.

VID and PID is fair enough. now what i want is that i have a threaded
code that threads two functions to run at the same time. i want each
function to run seperate devices. the problem is if it doesnt identify
the attached devices it might run the code on a single device which
isnt what is required.
how will i be able to run a code on a device of my choice???you
can leave away the threading part for now.
-- 
http://mail.python.org/mailman/listinfo/python-list


nested threading

2010-03-25 Thread Omer Ihsan
is there anything as "nested threading"that is, call a thread from
within a thread.
in this case how will thread locking take place.

for example initially there were two functions that were called using
threading.Thread. these wont get unlocked unless both of them are done
with whatever they need to do. if say function 2 calls another thread.
then what??

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


Very Strange Problem

2009-07-29 Thread Omer Khalid
Hi,

I am having a very strange problem with modifying a variable in a list in my
program. Here is the code:

# a list that contains dictionary objects
jobs = []

index=5
for each in range(index):
 jobs.append({'v':0})

some_function(index):
   if jobs[index]['v'] == 0:
   # set it to 1
   jobs[index]['v'] = 1
   print "Set to 1"
  else:
   print "Already set to 1"

loop():
index=0
for each in range(len(jobs)):
 some_function(index)
 index +=1


Apparently, the jobs[index]['v'] never get updated in the some_function but
the print statement afterwards get printed...

What's really surprising is that there are no errors or exceptions and my my
program runs in a single thread...so i have been unable to explain this
behavior.

Any insight would be much appreciated!

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


Re: Very Strange Problem

2009-07-29 Thread Omer Khalid
Hi Dave,

Thanks for your reply. I actually didn't cut and paste my code as it was
dispersed in different places, i typed the logic behind my code in the email
(and obiviously made some typos, indentations is some thing else) but my
real code does not have these problems as my application runs fine with out
errors...

Except that the line where i want to update the value doesn't get updated
and no exception is thrown. What's surprising for me is that i am doing the
same thing in hundreds of places in my 3k+ line code but by some reason this
part doesn't work...

As far as the global variables are concerned, i am using them in other
places too and didn't see any problems.

I think some thing else is going on here as the statement above and below my
modified lines get executed.

Is there a way in Python to debug memory address or to see where in memory
this object is stored, and is there a lock on it or else?

Thanks,
Omer


**


On Wed, Jul 29, 2009 at 8:56 PM, Dave Angel  wrote:

> Omer Khalid wrote:
>
>> Hi,
>>
>> I am having a very strange problem with modifying a variable in a list in
>> my
>> program. Here is the code:
>>
>> # a list that contains dictionary objects
>> jobs = []
>>
>> index=5
>> for each in range(index):
>> jobs.append({'v':0})
>>
>> some_function(index):
>>   if jobs[index]['v'] == 0:
>>   # set it to 1
>>   jobs[index]['v'] = 1
>>   print "Set to 1"
>>  else:
>>   print "Already set to 1"
>>
>> loop():
>>index=0
>>for each in range(len(jobs)):
>> some_function(index)
>> index +=1
>>
>>
>> Apparently, the jobs[index]['v'] never get updated in the some_function
>> but
>> the print statement afterwards get printed...
>>
>> What's really surprising is that there are no errors or exceptions and my
>> my
>> program runs in a single thread...so i have been unable to explain this
>> behavior.
>>
>> Any insight would be much appreciated!
>>
>> Cheers
>> Omer
>>
>>
>>
> There are four things to fix before the program does anything much at all.
>  Two places you're missing the def, indentation is inconsistent, and you
> never actually call either of the functions.   The first three are syntax
> errors, so presumably your cut/paste in your computer is broken.
>
> Once I make those four corrections, I get the following output:
>
> Set to 1
> Set to 1
> Set to 1
> Set to 1
> Set to 1
>
> But you never said what you got, nor what you expected.  That's certainly
> what I'd expect.  And if you make a second call to loop() in your outer
> code, you get five copies of "Already set to 1"
>
> BTW, there are a number of things that could be done better.  The main one
> I'll point out is that you shouldn't re-use a global variable 'index' as a
> local with different meaning.  As someone else pointed out, since the global
> is a constant, making it all uppercase is the convention.
>
> DaveA
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list