Recursive problem

2014-02-12 Thread ahmed
So we had to do a project for our python class and we came across a recursive 
problem. The code we had to write was as follows:

T(n)
if n == 1
return 1
else
for any number(k) between 1 and n - 1
2 * T(n-k) + 2^i - 1

from this we need to get the minimum number which would be produced depending 
on k. I don't know how to go about doing this. Any help would be appreciated. 
Thanks in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Short-circuit Logic

2013-05-26 Thread Ahmed Abdulshafy
Hi,
I'm having a hard time wrapping my head around short-circuit logic that's used 
by Python, coming from a C/C++ background; so I don't understand why the 
following condition is written this way!>

 if not allow_zero and abs(x) < sys.float_info.epsilon:
print("zero is not allowed")

The purpose of this snippet is to print the given line when allow_zero is False 
and x is 0.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-27 Thread Ahmed Abdulshafy
On Sunday, May 26, 2013 1:11:56 PM UTC+2, Ahmed Abdulshafy wrote:
> Hi,
> 
> I'm having a hard time wrapping my head around short-circuit logic that's 
> used by Python, coming from a C/C++ background; so I don't understand why the 
> following condition is written this way!>
> 
> 
> 
>  if not allow_zero and abs(x) < sys.float_info.epsilon:
> 
> print("zero is not allowed")
> 
> 
> 
> The purpose of this snippet is to print the given line when allow_zero is 
> False and x is 0.

Thank you guys! you gave me valuable insights! But regarding my original post, 
I don't know why for the past two days I was looking at the code *only* this 
way>
 if ( not allow_zero and abs(x) ) < sys.float_info.epsilon:

I feel so stupid now :-/, may be it's the new syntax confusing me :)! Thanks 
again guys.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-27 Thread Ahmed Abdulshafy
On Sunday, May 26, 2013 2:13:47 PM UTC+2, Steven D'Aprano wrote:
> On Sun, 26 May 2013 04:11:56 -0700, Ahmed Abdulshafy wrote:
> 
> 
> 
> > Hi,
> 
> > I'm having a hard time wrapping my head around short-circuit logic
> 
> > that's used by Python, coming from a C/C++ background; so I don't
> 
> > understand why the following condition is written this way!
> 
> > 
> 
> >  if not allow_zero and abs(x) < sys.float_info.epsilon:
> 
> > print("zero is not allowed")
> 
> 
> 
> Follow the logic.
> 
> 
> 
> If allow_zero is a true value, then "not allow_zero" is False, and the 
> 
> "and" clause cannot evaluate to true. (False and X is always False.) So 
> 
> print is not called.
> 
> 
> 
> If allow_zero is a false value, then "not allow_zero" is True, and the 
> 
> "and" clause depends on the second argument. (True and X is always X.) So
> 
> abs(x) < sys.float_info.epsilon is tested, and if that is True, print is 
> 
> called.
> 
> 
> 
> By the way, I don't think much of this logic. Values smaller than epsilon 
> 
> are not necessarily zero:
> 
> 
> 
> py> import sys
> 
> py> epsilon = sys.float_info.epsilon
> 
> py> x = epsilon/1
> 
> py> x == 0
> 
> False
> 
> py> x * 3 == 0
> 
> False
> 
> py> x + epsilon == 0
> 
> False
> 
> py> x + epsilon == epsilon
> 
> False
> 
> 
> 
> The above logic throws away many perfectly good numbers and treats them 
> 
> as zero even though they aren't.
> 
> 
> 
> 
> 
> > The purpose of this snippet is to print the given line when allow_zero
> 
> > is False and x is 0.
> 
> 
> 
> Then the snippet utterly fails at that, since it prints the line for many 
> 
> values of x which can be distinguished from zero. The way to test whether 
> 
> x equals zero is:
> 
> 
> 
> x == 0
> 
> 
> 
> What the above actually tests for is whether x is so small that (1.0+x) 
> 
> cannot be distinguished from 1.0, which is not the same thing. It is also 
> 
> quite arbitrary. Why 1.0? Why not (0.0001+x)? Or (0.0001+x)? Or 
> 
> (1.0+x)?
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

That may be true for integers, but for floats, testing for equality is not 
always precise
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-28 Thread Ahmed Abdulshafy
On Tuesday, May 28, 2013 2:10:05 AM UTC+2, Nobody wrote:
> On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote:
> 
> 
> 
> > On Sunday, May 26, 2013 2:13:47 PM UTC+2, Steven D'Aprano wrote:
> 
> >
> 
> >> What the above actually tests for is whether x is so small that (1.0+x)
> 
> >> cannot be distinguished from 1.0, which is not the same thing. It is
> 
> >> also quite arbitrary. Why 1.0? Why not (0.0001+x)? Or (0.0001+x)?
> 
> >> Or (1.0+x)?
> 
> > 
> 
> > That may be true for integers,
> 
> 
> 
> What may be true for integers?
> 
> 
> 
> > but for floats, testing for equality is not always precise
> 
> 
> 
> And your point is?
> 
> 
> 
> What Steven wrote is entirely correct: sys.float_info.epsilon is the
> 
> smallest value x such that 1.0 and 1.0+x have distinct floating-point
> 
> representations. It has no relevance for comparing to zero.

He just said that the way to test for zero equality is x == 0, and I meant that 
this is true for integers but not necessarily for floats. And that's not 
specific to Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-29 Thread Ahmed Abdulshafy
On Tuesday, May 28, 2013 3:48:17 PM UTC+2, Steven D'Aprano wrote:
> On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote:
> 
> 
> 
> > That may be true for integers, but for floats, testing for equality is
> 
> > not always precise
> 
> 
> 
> Incorrect. Testing for equality is always precise, and exact. The problem 
> 
> is not the *equality test*, but that you don't always have the number 
> 
> that you think you have. The problem lies elsewhere, not equality!
> 
> 
> Steven

Well, this is taken from my python shell>

>>> 0.33455857352426283 == 0.33455857352426282
True

Anyway, man, those were not my words anyway, most programming books I've read 
state so. Here's an excerpt from the Python book, I'm currently reading>

">>> 0.0, 5.4, -2.5, 8.9e-4
(0.0, 5.4004, -2.5, 0.00088995)


The inexactness is not a problem specific to Python—all programming languages 
have this problem with floating-point numbers."
-- 
http://mail.python.org/mailman/listinfo/python-list


Default Value

2013-06-19 Thread Ahmed Abdulshafy
I'm reading the Python.org tutorial right now, and I found this part rather 
strange and incomprehensible to me>

Important warning: The default value is evaluated only once. This makes a 
difference when the default is a mutable object such as a list, dictionary, or 
instances of most classes
def f(a, L=[]):
L.append(a)
return L

print(f(1))
print(f(2))
print(f(3))

This will print
[1]
[1, 2]
[1, 2, 3]

How the list is retained between successive calls? And why?
-- 
http://mail.python.org/mailman/listinfo/python-list


ali

2012-02-21 Thread Umair Ahmed
http://sharecash.org/download.php?file=2652910
-- 
http://mail.python.org/mailman/listinfo/python-list


reading txt file

2012-05-31 Thread Ahmed, Shakir
HI:
I am trying to read a txt file and dump the columns in an access database 
table. But getting problem:

>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "C:\WindDuration\Reading_test.py", line 14, in 
my_length_1 = nmAddrList[1]
IndexError: list index out of range

Getting error when it is reading to second line.

The txt file is attached here and I need only 2,8,11,14,15 columns to dump in 
the table.


Any help is highly appreciated.

Thanks
sa



We value your opinion. Please take a few minutes to share your comments on the 
service you received from the District by clicking on this 
link.
FL Dade   Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  88kt 10/24 07

FL Monroe Existing   Existing   Existing   10/24 11E [04]  
10/24 12E [05]  10/24 15E [08]  94kt 10/24 07

FL CollierExisting   Existing   Existing   10/24 12E [05]  
10/24 13E [06]  10/24 15E [08]  104kt 10/24 0

FL BrowardExisting   Existing   Existing   10/24 13E [06]  
10/24 14E [07]  10/24 16E [09]  93kt 10/24 08

FL LeeExisting   Existing   Existing   10/24 10E [03]  
10/24 12E [05]  10/24 15E [08]  89kt 10/24 07

FL Hendry Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  100kt 10/24 0

FL Palm Beach Existing   Existing   Existing   10/24 14E [07]  
10/24 15E [08]  10/24 17E [10]  93kt 10/24 08

FL Charlotte  Existing   Existing   Existing   10/24 10E [03]  
10/24 12E [05]  10/24 15E [08]  76kt 10/24 07

FL Glades Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  91kt 10/24 09

FL Martin Existing   Existing   Existing   10/24 14E [07]  
10/24 15E [08]  10/24 17E [10]  92kt 10/24 11

FL St Lucie   Existing   Existing   10/24 08E  10/24 14E [06]  
10/24 15E [08]  10/24 17E [10]  89kt 10/24 11

FL Okeechobee Existing   Existing   Existing   10/24 13E [06]  
10/24 15E [08]  10/24 17E [10]  83kt 10/24 09

FL Highlands  Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  74kt 10/24 09

FL Desoto Existing   Existing   Existing   10/24 09E [02]  
10/24 12E [05]  10/24 15E [08]  67kt 10/24 08

FL Sarasota   Existing   Existing  
10/24 11E [04]  10/24 15E [08]  59kt 10/24 07

FL ManateeExisting   Existing  
10/24 11E [04]  10/24 15E [08]  56kt 10/24 07

FL Hardee Existing   Existing  
10/24 12E [05]  10/24 16E [09]  60kt 10/24 08

FL Pinellas   Existing  
   10/24 13E [06]  43kt 10/24 07

FL HillsborougExisting   Existing  
10/24 08E [01]  10/24 15E [08]  50kt 10/24 07

FL Polk   Existing   Existing  
10/24 13E [06]  10/24 16E [09]  60kt 10/24 09

FL OsceolaExisting   Existing   10/24 10E  10/24 11E [01]  
10/24 14E [07]  10/24 17E [10]  64kt 10/24 10

FL Indian RiveExisting   Existing   10/24 09E  10/24 14E [05]  
10/24 15E [08]  10/24 17E [10]  76kt 10/24 11

FL BrevardExisting   Existing   10/24 10E  10/24 13E [03]  
10/24 15E [08]  10/24 18E [11]  67kt 10/24 11

FL Orange Existing   10/24 09E 
10/24 13E [04]  10/24 17E [10]  53kt 10/24 11

FL Seminole   Existing  
   10/24 17E [10]  48kt 10/24 10

FL Lake   Existing  
   10/24 16E [09]  46kt 10/24 09

FL Sumter Existing  
   10/24 15E [08]  43kt 10/24 08

FL Pasco  Existing  
   10/24 15E [08]  43kt 10/24 08

FL Hernando   Existing  
   10/24 15E [08]  40kt 10/24 08

FL Citrus Existing  
   10/24 13E [06]  37kt 10/24 10

FL Marion Existing  
   10/24 15E [08]  39kt 10/24 10

FL VolusiaExisting  
   10/24 18E [11]  48kt 10/24 10

FL Flagler10/24 08E 
   10/24 16E [08]  40kt 10/24 11

FL Putnam 10/24 09E 
   10/24 16E [07]  38kt 10/24 12

FL St Johns   10/24 11E 
  

unzip problem

2011-06-24 Thread Ahmed, Shakir
Hi,

 

I am getting following error message while unziping a .zip file. Any
help or idea is highly appreciated.

 

Error message>>>

Traceback (most recent call last):

  File "C:\Zip_Process\py\test2_new.py", line 15, in 

outfile.write(z.read(name))

IOError: (22, 'Invalid argument')

 

 

The script is here:

*

fh = open('T:\\test\\*.zip', 'rb')

z = zipfile.ZipFile(fh)

for name in z.namelist():

outfile = open(name, 'wb')

 

outfile.write(z.read(name))

print z

print outfile

outfile.close()

 

fh.close()



 

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


RE: unzip problem

2011-06-24 Thread Ahmed, Shakir
On Fri, 24 Jun 2011 10:55:52 -0400, Ahmed, Shakir wrote:

> Hi,
> 
> 
>  
> I am getting following error message while unziping a .zip file. Any
> help or idea is highly appreciated.

How do you know it is when unzipping the file? Maybe it is, or maybe it 
isn't. The line giving the error has *two* IO operations, a read and a 
write. Either one could give IOError.

outfile.write(z.read(name))
IOError: (22, 'Invalid argument')

The first thing is to isolate what is causing the error:

data = z.read(name)
outfile.write(data)

Now you can be sure whether it is the read or the write  which causes
the 
error.

Secondly, find out what the argument is. Assuming it is the read, try 
this:

print repr(name)

Can you open the zip file in Winzip or some other zip utility? Does it 
need a password? 

I see you do this:

fh = open('T:\\test\\*.zip', 'rb')

Do you really have a file called *.zip? I find that very hard to 
believe... as I understand it, * is a reserved character in Windows and 
you cannot have a file with that name.

My guess is that the actual error is when you try to open the file in
the 
first place, before any unzipping takes place, but you've messed up the 
line numbers (probably by editing the file after importing it).


-- 
Steven

>>
The problem is happening when it is coming to write option.

The * is not the real name of the zip file, I just hide the name.

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


RE: unzip problem

2011-06-24 Thread Ahmed, Shakir


-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Philip Semanchuk
Sent: Friday, June 24, 2011 11:18 AM
To: Lista-Comp-Lang-Python list
Subject: Re: unzip problem


On Jun 24, 2011, at 10:55 AM, Ahmed, Shakir wrote:

> Hi,
> 
> 
> 
> I am getting following error message while unziping a .zip file. Any
> help or idea is highly appreciated.
> 
> 
> 
> Error message>>>
> 
> Traceback (most recent call last):
> 
>  File "C:\Zip_Process\py\test2_new.py", line 15, in 
> 
>outfile.write(z.read(name))
> 
> IOError: (22, 'Invalid argument')


Start debugging with these two steps --
1) Add this just after "for name in z.namelist():"
   print name

That way you can tell which file is failing.

2) You can't tell whether you're getting an error on the write or the
read because you've got two statements combined into one line. Change
this --
   outfile.write(z.read(name))
to this --
   data = z.read(name)
   outfile.write(data)


Good luck
Philip

> 
> 
> 
> 
> 
> The script is here:
> 
> *
> 
> fh = open('T:\\test\\*.zip', 'rb')
> 
> z = zipfile.ZipFile(fh)
> 
> for name in z.namelist():
> 
>outfile = open(name, 'wb')
> 
> 
> 
>outfile.write(z.read(name))
> 
>print z
> 
>print outfile
> 
>outfile.close()
> 
> 
> 
> fh.close()
> 
> 


The problem found in outfile.Write. The error code is here and is
happening when few of the files are already unzipped from the zip file

>>> T:\applications\tst\py\Zip_Process
>>> drg100.aux
>>> 
>>> 
>>> drg100.fgdc.htm
>>> 
>>> 
>>> drg100.htm
>>> 
>>> 
>>> drg100.sdw
>>> 
>>> 
>>> drg100.sid
>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "C:\Zip_Process\py\test2_new.py", line 16, in 
outfile.write(data)
IOError: (22, 'Invalid argument')
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: unzip problem - solved

2011-06-24 Thread Ahmed, Shakir
-Original Message-
From: Ethan Furman [mailto:et...@stoneleaf.us] 
Sent: Friday, June 24, 2011 3:47 PM
To: Ahmed, Shakir
Cc: Python
Subject: Re: unzip problem

Ahmed, Shakir wrote:
> Thanks once again and you are right I am trying to unzip in the
network
> share drive. here is the script now: If I am doing any wrong. :
> ## code start here
> 
> import zipfile
> import os
> import time
> dir1 = "T:\\applications\\tst\\py\\Zip_Process"
> test = '%s/shp'%dir1
> os.chdir(test)
> cwd = os.getcwd()
> print cwd
> 
> 
> CHUNK_SIZE = 10 * 1024 * 1024
> 
> 
> fn = open('T:\\applications\\tst\\py\\Zip_Process\\Zip\\myzip.zip',
> 'rb')
> z = zipfile.ZipFile(fn)
> for name in z.namelist():
> ptr = 0
> data = z.read(name)
> size = len(data)
> print size
> print ptr
> while ptr < size:
> 
> fn.write(data[ptr:ptr+CHUNK_SIZE])
> ptr += CHUNK_SIZE
> 
> fn.close()
> 
> #Code done here.
>  
> But got error as follows:
> 
>>>> T:\applications\tst\py\Zip_Process\shp
> 59160
> 0
> Traceback (most recent call last):
>   File
>
"C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py"
> , line 325, in RunScript
> exec codeObject in __main__.__dict__
>   File "t:\scratch\shahmed\test2_new.py", line 24, in 
> fn.write(data[ptr:ptr+CHUNK_SIZE])
> IOError: [Errno 9] Bad file descriptor

I didn't notice this in your last post, but you are using fn as both the

zipfile name and the name of the file you are writing to.  You'll need 
to create the file you want to write before you write to it (plus any 
intermediate directories).


Here's the (slightly stripped) version I actually use:

8<
import os
from zipfile import  ZipFile

def retrieve_files(zipped, destination, files=None):
 "retrieves files from "
 CHUNK_SIZE = 10 * 1024 * 1024
 try:
 os.makedirs(destination)
 except WindowsError:
 pass
 target = ZipFile(zipped, 'r')
 stored = dict([(k.filename.lower(), k.filename) for k in 
target.infolist()])
 if files is None:
 files = [member.filename.lower() for member in
target.infolist()]
 elif isinstance(files, (str, unicode)):
 files = [files.lower()]
 else:
 files = [f.lower() for f in files]
 for compressed_file in files:
 uncompressed_file = os.path.join(destination, compressed_file)
 path, filename = os.path.split(uncompressed_file)
 if not os.path.exists(path):
 os.makedirs(path)
 if filename == '__empty__':
 continue
 data = target.read(stored[compressed_file])
 fn = open(uncompressed_file, 'wb')
 ptr = 0
 size = len(data)
 while ptr < size:
 fn.write(data[ptr:ptr+CHUNK_SIZE])
 ptr += CHUNK_SIZE
 fn.close()
 target.close()
8<

I convert all filenames to lower case since MS Windows doesn't care, but

Python does.

The test for filename == '__empty__': when I create the zipfile, if the 
directory is empty I store a 0-length file named '__empty__' in that 
subdirectory (actually, it only happens in the zipfile) so that I can 
get the directory back later.

Hope this helps.

~Ethan~

Thanks a lot to Ethan who really helped to find out the clue in the
code.
Here is the final code that worked to unzip a large file in the network
drive.

CHUNK_SIZE = 10 * 1024 * 1024


fh = open('T:\\applications\\tst\\py\\Zip_Process\\Zip\\myzip.zip',
'rb')
z = zipfile.ZipFile(fh)
for name in z.namelist():
fn = open(name, 'wb')
ptr = 0
data = z.read(name)
size = len(name)  
print size
print ptr
while ptr < size:
#fn.write(data)
fn.write(data[ptr:ptr+CHUNK_SIZE])
ptr += CHUNK_SIZE
fn.close()
fh.close()


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


Proxy to open blocked sites

2011-02-26 Thread Ahmed Ragab
Proxy to open blocked sites

http://ppropx.4mtm.net

OR

http://pronet.4mtm.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Include me in the list

2011-04-24 Thread nusrath ahmed
I have written a python script for logging into a website. For the  time being 
I 
have created a login page and a website which I want to log  in. My script 
pulls 
up the  login page but does not post the username  and password and log me in. 
It simple displays the login page. I wanted  my script to log me in also. Can 
some body please go through the script  and correct me/ help me login.

My script is as below


*
import cookielib
import urllib
import urllib2
import httplib

if __name__ == '__main__':
urlLogin = 
'file:///C:/Documents%20and%20Settings/Fat/Desktop/New%20Folder/Login.html'

id= 'u2'
passw = 'p2'

fieldId   = 'username'
fieldPass = 'password'

cj = cookielib.CookieJar()
data = urllib.urlencode({fieldId:id, fieldPass:passw})

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

urllib2.install_opener(opener)

usock = opener.open(urlLogin)
usock = opener.open(urlLogin,  data)

pageSource = usock.read()
usock.close()
print(pageSource)

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


Pls chk my login script

2011-04-24 Thread nusrath ahmed
I have written a python script for logging into a website. My script pulls up a 
browser page but does not log me in. Can any one suggest if I i am wrong in nay 
way,though the script is correct I am sure

My script is as below


*
import cookielib
import urllib
import urllib2
import httplib

if __name__ == '__main__':
urlLogin = 'http://www.gmail.com'

id= 'u2'
passw = 'p2'

fieldId   = 'username'
fieldPass = 'password'

cj = cookielib.CookieJar()
data = urllib.urlencode({fieldId:id, fieldPass:passw})

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

urllib2.install_opener(opener)

usock = opener.open(urlLogin)
usock = opener.open(urlLogin,  data)

pageSource = usock.read()
usock.close()
print(pageSource)

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


Python login script

2011-04-25 Thread nusrath ahmed
I have written a python script that should log me in to a website. For the time 
being I want to login to gmail.com. My script pulls up the gmail webpage but 
does not input the login id and the password in the fields and  does not log me 
in. I assume I am missing on something in my script. Can some body have a look 
as to what I am missing on.

import cookielib
import urllib
import urllib2
import httplib

if __name__ == '__main__':
urlLogin = 'http://www.gmail.com'

id= 'u2'
passw = 'p2'

fieldId   = 'Email'
fieldPass = 'passwd'

cj = cookielib.CookieJar()
data = urllib.urlencode({fieldId:id, fieldPass:passw})

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

urllib2.install_opener(opener)

usock = opener.open(urlLogin)
usock = opener.open(urlLogin,  data)

pageSource = usock.read()
usock.close()
print(pageSource)-- 
http://mail.python.org/mailman/listinfo/python-list


NIST Ihead Image format

2005-06-13 Thread Ahmed Shinwari
Hello Charles,

I am Ahmed, I read your query regarding image reader
for NIST's ihead standard. You mentioned that NIST has
a sample database of such images for downloading,
could please do me a favour,

(i) forward me the link of NIST where sample data of
ihead image is stored, I can not find it.

(ii) if you have obtained the ihead image reader,
please forward it to me,

Thanking in advance,
Ahmed Ali Shinwari.



__ 
Discover Yahoo! 
Stay in touch with email, IM, photo sharing and more. Check it out! 
http://discover.yahoo.com/stayintouch.html
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Who uses Python?

2007-06-04 Thread Ahmed, Shakir



I mean other than sysadmins, programmers, and web-site developers?

I have heard of some DBAs who use a lot of python.

I suppose some scientists. I think python is used in bioinformatics. I
think some math and physics people use python.

I suppose some people use python to learn "programming" in general.
Python would do well as a teaching language.

I would think that python would be a good language for data analysis.

Anything else? Finance? Web-analytics? SEO? Digital art?

>> I use for GIS Data automation in the backend and gradually replacing
all old VBA application with the Python scripts.

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


permission denied in shutil.copyfile

2007-07-13 Thread Ahmed, Shakir
Is there any way to copy a file from src to dst if the dst is
exclusively open by other users.

I am using 

src  = 'c:\mydata\data\*.mdb'
dst = 'v:\data\all\*.mdb'

shutil.copyfile(src,dst)

but getting error message permission denied.

Any help is highly appreciated.

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


shutil.copyfile problem for GIS data

2007-07-16 Thread Ahmed, Shakir

Need help to copy a personal geodatabase from one location to another:


Trying to copy a personal geodatabase from one location to another
location where all the users are retrieving data from the second
location:

1.  I can copy over the updated personal geodatabase to the working
location and overwrite it, though the file is opened by ArcGIS  users
(Local Installation of Arc GIS  on the users computers).


2.  But problem is that  I can't copy over if the same updated
personal geodatabase to the working location,  if users uses that same
geodatabase through CITRIX - ArcGIS ( user does not have  permission to
edit the data)

3.  the python script which I am using as follows:

import shutil
import os

src = "c:\mydata\test\mygeo.mdb"
dst = "v:\updated\data\mygeo.mdb"

shutil.copyfile(src,dst)

I highly appreciate if any one of you can help me and give me a
direction that I can solve this problem.

Thanks in advance.

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


Problem to Download ftp file

2007-05-06 Thread Shakil Ahmed
hi
Actually i need to know that how can i download a ftp file from ncbi by
using python module ftputil.
please help me.

Thanks
regards,
Shakil

import ftputil

host = ftputil.FTPHost('ftp.ncbi.nih.gov/repository/OMIM/morbidmap',
'anonymous', 'password')



 

The Error message is:

raise FTPOSError(ftp_error)

FTPOSError: (11001, 'getaddrinfo failed')

Debugging info: ftputil 2.2.2, Python 2.4.3 (win32)



 

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

Table update

2007-08-28 Thread Ahmed, Shakir

I am trying to use python script to update a table by incremental value
based on struc_No but having problem to get right result on the value
field for the 3rd and 4th same number of struc_no. 

I need to update the Value field only with the incremental value of 15
or so

Any help is highly appreciated.

Thanks
Shak



Input table or source table

ID  struc_idStruc_NoValue   
1   ABC 100110  
2   EFJ 100515  
3   HIK 100310  
4   ILK 100510  
5   PIO 10018   
6   TIN 100112  
7   MNO 100111  
8   POW 100318  


Output Table

ID  struc_idStruc_NoValue   Added value
1   ABC 100125  15
2   EFJ 100530  15
3   HIK 100325  15
4   ILK 100540  30
5   PIO 100138  30
6   TIN 100157  45
7   MNO 100171  60
8   POW 100348  30


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


Copy geodatabase(mdb) if it is locked

2007-03-08 Thread Ahmed, Shakir
I am trying to copy a geodatabase (.mdb) file from source to destination
using

shutil.copyfile(src, dest)

 

It is working fine but the main problem when the destination (.mdb) file
is locked by other users then it's bumped out and not copied over.

 

Is there any way to copy the locked .mdb file and overwrite it.

 

Any help is highly appreciated.

 

shakir

 

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

GIS Shape file upload FTP server

2007-03-01 Thread Ahmed, Shakir
HI Group,

 

As I am very new in python field so this question might be very silly
but If I get any help that is highly appreciated.

 

Problem: 

 

I have a python script which is working fine to upload files to the ftp
server but the problem is it is reducing the actual size after
transferring. I need to upload a GIS Shape file to the ftp server but
want to keep the same size and format. Any idea or help is highly
appreciated.

 

Thanks

Shakir

Staff Geographer

Sfwmd.gov

 

The code is as follows: 

 

 

# Import system modules

 

import os

import sys 

import win32com.client

import zipfile

import os.path

import ftplib

from ftplib import FTP

 

 

ftp=ftplib.FTP("ftp.sfwmd.gov","","")  

ftp.login('sahmed','sa1lf1sh')

#ftp.cwd("/export/pub/sahmed")

 

ffile = open('c:\\test\\wuppnt.shp', 'r')

 

ftp.storbinary("stor wuppnt.shp", ffile)

ffile.close()

 

print "OK"

ftp.quit()

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

GIS Shape file upload to FTP server

2007-03-01 Thread Ahmed, Shakir
HI Group,

As I am very new in python field so this question might be very silly to
you but if I get any help is highly appreciated.

Problem: 

I wrote a python script which is working fine to upload files to the ftp
server but the problem is it is reducing the actual size after
transferring. I need to upload a GIS Shape file to the ftp server but
want to keep the same size and format. Any idea or help is highly
appreciated.

 
Thanks

Shakir
Staff Geographer
Sfwmd.gov

The code is as follows: 

===
# Import system modules

 

import os
import sys 
import win32com.client
import zipfile
import os.path
import ftplib
from ftplib import FTP


ftp=ftplib.FTP("ftp.sfwmd.gov","","")  
ftp.login('sahmed','sa1lf1sh')
#ftp.cwd("/export/pub/sahmed")
ffile = open('c:/test/wuppnt.shp', 'r')

ftp.storbinary("STOR wuppnt.shp", ffile)
ffile.close()

print "OK"
ftp.quit()
-- 
http://mail.python.org/mailman/listinfo/python-list


please help me is sms with python

2006-05-15 Thread huda ahmed
hi 
please i need your help .

how can i send sms from pc(windows xp)
to mobile symbian 60 6630 by python

i need your help please
i hope you answer me as fast as u can

thanks in advance..
-- 
http://mail.python.org/mailman/listinfo/python-list


Accessing Oracle/Access database py2.4

2008-02-15 Thread Ahmed, Shakir
I was used import odbc  to connect oracle or access table before, now I
switched to python 2.4 and is giving me error message. I appreciate any
help on that. 

 

Thanks

sh

 

 

 

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

Deleting Microsoft access database

2008-03-20 Thread Ahmed, Shakir
I have a Microsoft Access database that I want to delete whether anyone
is using that file. 

The database is already read only mode residing in a server, users are
opening in read only mode. I want to delete that file, I remove read
only check but could not delete that file. 

Getting error message: 
Cannot delete xxx : It is being used by another person or program. 

Any help is highly appreciated.

Thanks
sa


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


date format

2009-01-21 Thread Ahmed, Shakir
I am grabbing few fields from a table and one of the columns is in date
format. The output which I am getting is "Wed Feb 09 00:00:00 2005" but
the data in that column is "02/09/2005" and I need the same format
output to insert those recodes into another table.

print my_service_DATE
Wed Feb 09 00:00:00 2005

Any help is highly appreciated.

sk

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


Python Installation Error

2009-02-05 Thread Ahmed Majeed
Hi,
I am working over a research project and need Python 2.3 or later to
be installed on my Intel Centrino machine, running Fedora 9 as OS. I
have downloaded latest stable release Python 2.6.1 from Python.org,
but when I tried installing it, terminal returned an error on 'make',
saying:

"Failed to find the necessory Bits to build these modules:
_tkinter bsddb185, sunaaudiodev
To find the necessory bits, look in setup.py in detect_modules() for
the module's name."

How should I correct this and go ahead for installation. Anxiously
waiting reply and thanking you in anticiaption.

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


Data uploading to a ftp server

2009-04-16 Thread Ahmed, Shakir

I am getting following error while uploading data to a ftp server. Any
help is highly appreciated.


ftp.storbinary("stor erp.shp", ffile2,8192)
  File "C:\Python24\lib\ftplib.py", line 419, in storbinary
conn.sendall(buf)
  File "", line 1, in sendall
error: (10054, 'Connection reset by peer')

Thanks 
sk

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


Removing Space and "-" from a string

2008-05-20 Thread Ahmed, Shakir
I have thousands of records in MS Access database table, which records I
am fetching using python script. One of the columns having string like 
'8 58-2155-58'

Desired output: '858215558'

I want to remove any spaces between string and any dashes between
strings. I could do it in access manually but want to do from python
script 

Any help is highly appreciated.

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


RE: Removing Space and "-" from a string

2008-05-20 Thread Ahmed, Shakir
Thanks, works exactly what I needed.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, May 20, 2008 12:22 PM
To: python-list@python.org
Subject: Re: Removing Space and "-" from a string

On May 20, 11:02 am, "Ahmed, Shakir" <[EMAIL PROTECTED]> wrote:
> I have thousands of records in MS Access database table, which records
I
> am fetching using python script. One of the columns having string like
> '8 58-2155-58'
>
> Desired output: '858215558'
>
> I want to remove any spaces between string and any dashes between
> strings. I could do it in access manually but want to do from python
> script
>
> Any help is highly appreciated.

string.replace('-', '').replace(' ', '')
--
http://mail.python.org/mailman/listinfo/python-list

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


[no subject]

2008-05-21 Thread ahmed khattab
unsubscribe me form python list plz

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

need to parse html to microsoft access table

2008-06-20 Thread Ahmed, Shakir
I need help to parse html file into Microsoft Access database table.
Right now I could parse it in a csv file but the way it is parsing is
not that I want and I could not import the list into access table as the
information is parsing one after another and it is not a row column
format. 

 

 

Any help is highly appreciated.

 

Thanks in advance

sk

 

 

 

 

 

Name:



 

Registered Office Address:

Xx 

 

 

 

 

 

 

Xxxx

 

 

Telephone:

(xx

 

 

Fax:

(xxx) xxx 

 

 

E-Mail:

[EMAIL PROTECTED] 

 

Website:

 

 

 

 

Status:

X

 

 

County(ies):

x 

 

 

Local Governing Authority:

Xxx 

 

 

Function(s):

X

X

Date Established:

6/15/1953

 

 

 

Creation Documents:

Xxxx

 

Statutory Authority:

 

 

Board Selection:

x

 

 

 

Authority to Issue Bonds:

x

 

 

 

Revenue Source:

 x

 

 

Most Recent Update:



 

 

 

Creation Method:

xxx 

 

 

 

 

 

 

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

parsing incoming emails

2008-07-10 Thread Ahmed, Shakir
HI,

 

I am working on a project where I need to parse incoming emails
(Microsoft outlook)  with a specific subject into an excel file or a
Microsoft access table. 

 

I am using python for my GIS works but not sure how I can use python
script here to work with Microsoft outlook email. 

 

Any help or idea is highly appreciated.

 

Thanks

SA

 

 

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

RE: automating python programs

2008-07-21 Thread Ahmed, Shakir
Windows scheduler is one of the option.

 

 

 

 

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Zach Hobesh
Sent: Monday, July 21, 2008 2:13 PM
To: python-list@python.org
Subject: automating python programs

 

Hi,

I'm trying to figure out how to run a python program on a schedule,
maybe every half an hour...  Is this possible?

Thanks!

-Zach

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

help with parsing email

2008-08-14 Thread Ahmed, Shakir
Hi all,

 

I do appreciate if any one can help me for my following problem:

 

I need to grab/parse numeric numbers such as app number from incoming
emails stored in Microsoft Outlook (Microsoft Exchange server) with
specified subject line. 

 

Any help with the python script is highly appreciated.

 

The email body is like this

 

myregion ; tst ; 11-Aug-2008

http://my.xyz.com//content/ifs/apps/myDocFolder/NoticeOfapplication/
080612-21_test_337683.pdf

 

 

I need to extract 080612-21_ number from above line from incoming
emails.

 

 

Thanks

sk

 

 

 

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

Error Message

2008-04-23 Thread Ahmed, Shakir
I am getting application error message " The instruction at "0x7c910f29"
referenced memory at "0x". The memory could not be "read". I am
running one python script and it is running good without any exception
or error message but getting this message when I am closing python 2.4.1
application. 

 

Any idea or help is highly appreciated.

 

Thanks

sk

 

 

 

 

 

 

 

 

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

RE: Pythonwin

2008-05-09 Thread Ahmed, Shakir
You need to install the same version on your pc, if you have 2.5 already 
installed you need to download 2.5 pythonwin from http://sourceforge.net

Hope it will work for you.
Thanks
sk


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Clive_S
Sent: Friday, May 09, 2008 9:41 AM
To: python-list@python.org
Subject: Re: Pythonwin

Hi all

I downloaded (from Python) and installed python-2.4.4.msi

I have python and pythonw.exe in the Python 24 folder (but not in my
start menu).
When I click on the pythonw.exe it is not launched??

Thanks

Clive


On 9 May, 14:09, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On May 9, 5:30 am, Clive_S <[EMAIL PROTECTED]> wrote:
>
> > Hi
> > I am trying to use Python with ArcGIS.
> > I have installed Python 2.4. I have an icon for IDLE and command line.
> > I do not see Python PythonWin.
> > How do you install or launch pythonwin??
> > Thanks
> > Clive
>
> I have PythonWin installed in my Start Menu --> Programs --> Python
> 2.5. I may have installed the ActiveState version though. Just check
> if it's there on your system and if not, you can follow Niklas's
> advice.
>
> Mike

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

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


RE: help with parsing email

2008-08-18 Thread Ahmed, Shakir
Thanks everyone who tried to help me to parse incoming email from an exchange 
server:

Now, I am getting following error; I am not sure where I am doing wrong. I 
appreciate any help how to resolve this error and extract emails from an 
exchange server. 


First I tried:
>>> mailserver = 'EXCHVS01.my.org'
>>> mailuser = 'myname'
>>> mailpasswd = 'mypass'
>>> mailserver = poplib.POP3(mailserver)
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python24\lib\poplib.py", line 96, in __init__
raise socket.error, msg
error: (10061, 'Connection refused')



The other way:

>>> mailserver = 'pop.EXCHVS01.ad.my.org'
>>> mailuser = '[EMAIL PROTECTED]'
>>> mailpasswd = 'mypass'
>>> mailserver = poplib.POP3(mailserver)
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python24\lib\poplib.py", line 84, in __init__
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
gaierror: (11001, 'getaddrinfo failed')


I tried above ways but getting error

Thanks
sk

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabriel Genellina
Sent: Monday, August 18, 2008 6:43 AM
To: python-list@python.org
Cc: [EMAIL PROTECTED]
Subject: Re: help with parsing email

En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió:

> I need to grab/parse numeric numbers such as app number from incoming
> emails stored in Microsoft Outlook (Microsoft Exchange server) with
> specified subject line.
>
> The email body is like this
>
> myregion ; tst ; 11-Aug-2008
>
> http://my.xyz.com//content/ifs/apps/myDocFolder/NoticeOfapplication/080612-21_test_337683.pdf
>
> I need to extract 080612-21_ number from above line from incoming
> emails.

Help from Maric Michaud [EMAIL PROTECTED]

Three options here :

- dealing directly with outlook mailboxes files, I used some open source code 
to parse .pst files in past, but you'll need some googling to match your 
requirements. Doesn't help if there is an instance of outlook running on the 
box.

- use the outlook COM or even some windows MAPI interface via WIN32 API 
(pywin32), can't help with this one.

- access emails directly on the Exchange server via standard python modules 
poplib or imaplib, my preferred choice if one of these protocols are 
supported by your environment. You won't need no extensions, just a standard 
python installation, and your code will work with most mail delivery agent 
and will run on all python supported platform.


==
Help from Gabriel Genellina

I can't help with the part dealing with Outlook - but once you retrieved the 
email body, it's easy:

import re
re_number = re.compile(r"NoticeOfapplication/([0-9-_]+)")
match = re_number.search(body)
if match:
  print match.group(1)

(this matches any numbers plus "-" and "_" after the words NoticeOfapplication 
written exactly that way)

-- 
Gabriel Genellina

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

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


RE: help with parsing email

2008-08-18 Thread Ahmed, Shakir


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Werner F. Bruhin
Sent: Monday, August 18, 2008 1:04 PM
To: python-list@python.org
Cc: [EMAIL PROTECTED]
Subject: Re: help with parsing email

Ahmed, Shakir wrote:
> Thanks everyone who tried to help me to parse incoming email from an
exchange server:
> 
> Now, I am getting following error; I am not sure where I am doing
wrong. I appreciate any help how to resolve this error and extract
emails from an exchange server. 
> 
> 
> First I tried:
>>>> mailserver = 'EXCHVS01.my.org'
>>>> mailuser = 'myname'
>>>> mailpasswd = 'mypass'
>>>> mailserver = poplib.POP3(mailserver)
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\lib\poplib.py", line 96, in __init__
> raise socket.error, msg
> error: (10061, 'Connection refused')
> 
> 
> 
> The other way:
> 
>>>> mailserver = 'pop.EXCHVS01.ad.my.org'
>>>> mailuser = '[EMAIL PROTECTED]'
>>>> mailpasswd = 'mypass'
>>>> mailserver = poplib.POP3(mailserver)
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\lib\poplib.py", line 84, in __init__
> for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
> gaierror: (11001, 'getaddrinfo failed')
Haven't used poplib myself, but was intrigued.

Did you see this:
http://www.python.org/doc/lib/pop3-example.html

To me it looks like you are not setting the user/password.

So, maybe something like:

M = poplib.POP3(mailserver)
M.user(mailuser)
M.pass_(mailpasswd)


Werner

--

but I am getting error before that point and could not go to the user
account or pass.

M = poplib.POP3(mailserver)
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python24\lib\poplib.py", line 96, in __init__
raise socket.error, msg
error: (10061, 'Connection refused')


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


RE: Using strftime

2008-09-03 Thread Ahmed, Shakir

You can try

Import time
mytimeymd = time.strftime('%y%m%d')

print mytimeymd


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
frankrentef
Sent: Wednesday, September 03, 2008 1:21 PM
To: python-list@python.org
Subject: Using strftime

I have one line of code that put's an old date in my code.


ie.textBoxSet('_ct10_PlaceHolder_txtEnd', '8/15/2008')



What I wish to do in another similiar line is have the field populated
with the current system date?  How best to do this?  I've read some of
the strftime documentation but as of yet I'm unable to get it to work
correctly.


Help is appreciated.

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

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


removing text string

2008-09-10 Thread Ahmed, Shakir
I need to remove text string from the list of the numbers mentioned
below:

080829-7_A
070529-5_c
080824-7_O
070405_6_p

The output will be : 080829-7
 070529-5
 080824-7
 070405-6  

Any idea is highly appreciated.



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


RE: removing text string

2008-09-11 Thread Ahmed, Shakir
Thanks

Actually the number I am getting it is from slicing from a long text
line. I need to slice 10 characters from that line but no string only
numeric numbers. When I am slicing 10 characters those A, c, O is coming
at the end. 

Thanks


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Dennis Lee Bieber
Sent: Wednesday, September 10, 2008 3:45 PM
To: python-list@python.org
Subject: Re: removing text string

On Wed, 10 Sep 2008 11:22:16 -0400, "Ahmed, Shakir" <[EMAIL PROTECTED]>
declaimed the following in comp.lang.python:

> I need to remove text string from the list of the numbers mentioned
> below:
> 
> 080829-7_A
> 070529-5_c
> 080824-7_O
> 070405_6_p
> 
?   Is that last one an error that is supposed to be
...5-6_, not
...5_6_ ?

1)  If the required data is fixed width, just slice it

out = inp[:8]

2)  If the data is variable width but has a fixed delimiter,
find
the delimiter position and then slice (this is the reason for my
question above -- this method) OR just split on the delimiter and take
the part you need.

out = inp.split("_")[0]

3)  If the data is more complex (again if that last line
with two _
is supposed to be trimmed after the second, and the first turned into a
-) you will need to fully define the parsing rules of the data.
-- 
WulfraedDennis Lee Bieber   KD6MOG
[EMAIL PROTECTED]   [EMAIL PROTECTED]
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff:   [EMAIL PROTECTED])
HTTP://www.bestiaria.com/
--
http://mail.python.org/mailman/listinfo/python-list

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


RE: removing text string

2008-09-11 Thread Ahmed, Shakir


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, September 11, 2008 8:54 AM
To: python-list@python.org
Subject: Re: removing text string

Ahmed, Shakir:
> Actually the number I am getting it is from slicing from a long text
> line. I need to slice 10 characters from that line but no string only
> numeric numbers. When I am slicing 10 characters those A, c, O is
coming
> at the end.

It's better to avoid Regular expressions when they aren't necessary,
but once in a while they are the simpler way to solve a problem, you
may create one like this (mostly untested):

\d+?-\d+

Using it like:

>>> import re
>>> patt = re.compile(r"\d+?-\d+")
>>> patt.search("xx080829-7_A ").group()
'080829-7'
>>> re.search(r"\d+?-\d+", "xx080829-7_A ").group()
'080829-7'

Learning Regexps can be useful.

Bye,
Bearophile


Thanks, I got the clue.

Very much appreciated.


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

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


RE: memory error

2009-12-04 Thread Ahmed, Shakir
 

 

From: python-list-bounces+shahmed=sfwmd@python.org 
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of Stephen 
Hansen
Sent: Thursday, December 03, 2009 10:22 PM
To: python-list@python.org
Subject: Re: memory error

 

On Thu, Dec 3, 2009 at 5:51 AM, Ahmed, Shakir  wrote:

I am getting a memory error while executing a script. Any idea is highly
appreciated.

Error message: " The instruction at "0x1b009032" referenced memory at
"0x0804:, The memory could not be "written"

This error is appearing and I have to exit from the script.

 

Vastly insufficient information; that basically is like saying, "Something 
broke." People can't really help you with that. You sorta need to show some 
code and/or at least describe what's going on at the time.

 

But-- the image does say Pythonwin... are you running this from the Pythonwin 
editor/IDE? Does this script crash out if you run it through the normal 
'python'(or pythonw) commands? If not, are you attempting to do any sort of GUI 
work in this script? That rarely works within Pythonwin directly.

 




--S

 

I am using python to do some gp ( geo processing ) for accuracy analysis. This 
analysis is based on application numbers. The script is going through each 
application number to process the data and looping through. The error appears 
after running few loops ( mean it process few applications). There is no 
certainty of how many loops it is going through but stopped with the error 
message and.

 

The code is attached herewith so I  hope it would make more clear to you. Any 
help is highly appreciated.

 

--sk 

 



ReverseBufferOverLay.py
Description: ReverseBufferOverLay.py
-- 
http://mail.python.org/mailman/listinfo/python-list


Passing values from html to python

2009-10-22 Thread Ahmed Barakat
Hi guys,

I am new to python and wed-development, I managed to have some nice example
running up till now.
I am playing with google app engine, I have this situation:

I have a text box in an html page, I want to get the value in it and pass it
to the python script to process it
I can pass values from python to html, but the other way I don't know how to
do that.

appreciate your help.

-- 

Regards,
Ahmed Barakat

http://ahmedbarakat83.blogspot.com/
Even a small step counts
-- 
http://mail.python.org/mailman/listinfo/python-list


Handling large datastore search

2009-11-03 Thread Ahmed Barakat
In case I have a  huge datastore (1 entries, each entry has like 6
properties), what is the best way
to handle the search within such a huge datastore, and what if I want to
make a generic search, for example
you write a word and i use it to search within all properties I have for all
entries?

Is the conversion to XML a good solution, or it is not?

sorry for being new to web development, and python.

Thanks in advance.

-- 

Regards,
Ahmed Barakat

http://ahmedbarakat83.blogspot.com/
Even a small step counts
-- 
http://mail.python.org/mailman/listinfo/python-list


list from FTP server to a text file

2011-01-06 Thread Ahmed, Shakir
Hi,

I am trying to create a list in a txt file from an ftp server. The
following code is retrieving the list of the files but could not able to
write in a text file. Any help is highly appreciated.

Thanks


 
 
import os
import time
from ftplib import FTP
ftp = FTP("*.org","","")   # connect to host, default port
ftp.login()
ftp.cwd("/pub/remotefolder/")
ftp.retrlines('NLST')
**
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: list from FTP server to a text file

2011-01-06 Thread Ahmed, Shakir


-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Dan M
Sent: Thursday, January 06, 2011 11:06 AM
To: python-list@python.org
Subject: Re: list from FTP server to a text file

On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote:

> Hi,
> 
> I am trying to create a list in a txt file from an ftp server. The
> following code is retrieving the list of the files but could not able
to
> write in a text file. Any help is highly appreciated.
> 
> Thanks
> 
> 
> 
> 
> import os
> import time
> from ftplib import FTP
> ftp = FTP("*.org","","")   # connect to host, default port ftp.login()
> ftp.cwd("/pub/remotefolder/")
> ftp.retrlines('NLST')
> **

WARNING: I am a newbie! Expect more pythonic ways to do this in other 
replies

from ftplib import FTP
ftp = FTP("host", "user", "pass")
ftp.cwd("/pub/myfolder")
files = ftp.nlst(".")
f = open('files.txt', 'w')
for file in files:
f.write('%s\n' % (file,))
f.close()

-- 

It worked 
Thanks, 
shk
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python, CGI and Sqlite3

2010-04-13 Thread Ahmed, Shakir
-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Tim Chase
Sent: Tuesday, April 13, 2010 2:36 PM
To: Majdi Sawalha
Cc: python-list@python.org
Subject: Re: Python, CGI and Sqlite3

On 04/13/2010 12:41 PM, Majdi Sawalha wrote:
> import sqlite3
>
> statement? and it gives the following error
> ImportError: No module named sqlite3,
>
> i tried it on python shell and all statements are work well.

A couple possible things are happening but here are a few that 
pop to mind:

1) you're running different versions of python (sqlite was 
bundled beginning in 2.5, IIRC) so when you run from a shell, you 
get python2.5+ but your CGI finds an older version.  Your CGI can 
dump the value of sys.version which you can compare with your 
shell's version

2) the $PYTHONPATH is different between the two.  Check the 
contents of sys.path in both the shell and the CGI program to see 
if they're the same.  You might also dump the results of 
os.environ.get('PYTHONPATH', None)  to see if an environment 
variable specifies the $PYTHONPATH differently

3) while it reads correctly above, it's theoretically possible 
that you have a spelling error like "import sqllite3"?  I've been 
stung once or twice by this sort of problem so it's not entirely 
impossible :)

-tkc

Tim is right, following import works fine with me.

import sqlite3 






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

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


(snmp code) perl to python

2010-04-25 Thread Shabbir Ahmed
hi hope all are doing good, i have code written in perl which quries
too many devices and then stores the result in mysqldb, whiel shifting
to python and googling i heared of and studied google asynch python
code, now i wanted to use it n convert my perl code to it but i have
some problem.

1. this class creates forks every snmp query and returns un ordered
result without any information that which oid returned which result,
where as in my code i query all only if a parent oid returns true, now
i dont know how to read specific oid.

algo of perl code,

read all the ips and communities from mysql then fork function for
every router so that all the equipment are queried at once, it creates
that much saperate process of equipment ips,

function that is forked:
loop for all the interfaces: check if the inteface is up
-> if so read the interface ips.
-> save result in mysql tables.

kindly help me convert this code to python or make this logic in
python.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Reading data from a Microsoft Access 2003 database

2010-05-19 Thread Ahmed, Shakir

-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Simon Brunning
Sent: Wednesday, May 19, 2010 6:13 AM
To: python-list
Subject: Re: Reading data from a Microsoft Access 2003 database

On 19 May 2010 10:28:15 UTC+1, Jimoid  wrote:
> I use Ubuntu 64 bit and need to develop a programme (ideally in
> Python) to work on data that is contained in a Microsoft Access 2003
> database. I do not need to modify the database, simply read a few
> columns of data from some tables.

mxODBC might well be what you are looking for,

-- 
Cheers,
Simon B.
-- 

Or you can use pyodbc
DBfile = '/path/*.mdb
conn = pyodbc.connect('DRIVER={Microsoft Access Driver
(*.mdb)};DBQ='+DBfile, autocommit=True)
cursor = conn.cursor()

Thanks
Shakir

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


error on exe file

2010-06-16 Thread Ahmed, Shakir
HI,

 

I created a script to do some GIS process ( basic GIS operation exam:
create shape file, project and copy)  and exporting one of the output to
dbf too. The Script is running without any problem where ArcGIS and
python are installed. I need to runt this application where both of the
application is not installed. I created an exe file from the py file,
the file is running perfectly alright in those machines where Arc GIS is
installed locally but the exe file is giving memory error on those
machines where Arc GIS is not installed. 

 

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


need help using Tkinter

2009-07-28 Thread Manzur Ahmed
i wanted to ask you if one of you could help me to use Tkinter. i'm trying
to just create a simple GUI for which I have provided the code for below.

# Simple GUI
# Demonstrates creating a window

from Tkinter import *

# create the root window
root = Tk ()

# modify the window
root.title("Simple GUI")
root.geometry("200x100")

# kick off the window's event loop
root.mainloop()

i saved the file as both simple_gui.py and simple_gui.pyw. when i try to run
simple_gui.pyw i don't get anything and when i try to run simple_gui.py i
get the following:
Traceback (most recent call last):
File "C:\Python-Study\Chapter10\simple_gui.py", line 4, in 
ImportError: No module named Tkinter

i tried to google search this and there were some threads that were saying
to install tcl but that does not work. I did check the Lib directory under
the Python directory and I did not see a Tkinter module anywhere which I
think is the problem. Do you know how I would go about with getting this
module and if that is not the problem or if you think it might be caused by
something else, can you please give me some guidance? i even reinstalled
python 3.1 which i got from www.python.org.  i still do not see the Tkinter
module in the lib directory.  thank you for all your help.

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


Re: need help using Tkinter

2009-07-28 Thread Manzur Ahmed
i figured it out.  its actually because i'm using python 3.1.  for python
3.0+, many of the packages are lowercased, tkinter being one of them and so
thats why i wan getting a module not found error . . .  thanks for getting
back to me.

manzur

On Tue, Jul 28, 2009 at 8:06 PM, Jan Kaliszewski  wrote:

> 28-07-2009 o 17:17 Manzur Ahmed  wrote:
>
> i wanted to ask you if one of you could help me to use Tkinter. i'm trying
>> to just create a simple GUI for which I have provided the code for below.
>>
> [snip]
>
>> i tried to google search this and there were some threads that were saying
>> to install tcl but that does not work. I did check the Lib directory under
>> the Python directory and I did not see a Tkinter module anywhere which I
>> think is the problem. Do you know how I would go about with getting this
>> module and if that is not the problem or if you think it might be caused
>> by
>> something else, can you please give me some guidance?
>>
>
> What operating system do you use?
>
> *j
>
> --
> Jan Kaliszewski (zuo) 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Invitation to connect on LinkedIn

2009-09-08 Thread Manzur Ahmed
LinkedIn


Manzur Ahmed requested to add you as a connection on LinkedIn:
--

Jaime,

I'd like to add you to my professional network on LinkedIn.

- Manzur

Accept invitation from Manzur Ahmed
http://www.linkedin.com/e/I2LlXdLlWUhFABKmxVOlgGLlWUhFAfhMPPF/blk/I316895250_3/6lColZJrmZznQNdhjRQnOpBtn9QfmhBt71BoSd1p65Lr6lOfPdvc3kOdjAUdz4PiiZHemgVd6lkq2YSejkNcj8RczsLrCBxbOYWrSlI/EML_comm_afe/

View invitation from Manzur Ahmed
http://www.linkedin.com/e/I2LlXdLlWUhFABKmxVOlgGLlWUhFAfhMPPF/blk/I316895250_3/0PnP0RczkVe3oNcQALqnpPbOYWrSlI/svi/

--

Why might connecting with Manzur Ahmed be a good idea?

Have a question? Manzur Ahmed's network will probably have an answer:
You can use LinkedIn Answers to distribute your professional questions to 
Manzur Ahmed and your extended network. You can get high-quality answers from 
experienced professionals.

http://www.linkedin.com/e/ash/inv19_ayn/

 
--
(c) 2009, LinkedIn Corporation

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


help wanted with list

2009-09-24 Thread Ahmed Shamim
list = [ 'a', '1', 'b', '2']
what would be the logic, if I input a to get output 1.
-- 
http://mail.python.org/mailman/listinfo/python-list


Data source path of a lyer file

2010-10-07 Thread Ahmed, Shakir
Hi,

Is there any way that I can read the data source path of a .lyr file
using Arc Object gp processor.

 

Thanks

sa

 

 

 

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


Free E-Books collection

2010-11-09 Thread naveed ahmed
Freeit http://freeit11.blogspot.comis the world's leading online
source of ebooks, with a vast range of

ebooks from academic,
Popular and professional publishers.

Freeit http://freeit11.blogspot.com eBook communicates my vision of
exploring the whole universe to you.

What if you
had a plausible method (based on today's science and technology)
freeit large selection of eBooks. New eBook releases and bestsellers
in
over 40 categories including science fiction, romance, mystery,
for more e-books visit Freeit
-- 
http://mail.python.org/mailman/listinfo/python-list


Write a function sorting(L).

2017-04-21 Thread Mohammed Ahmed
Write a function sorting(L) that takes a list of numbers and returns the list 
with all
elements sorted in ascending order.
Note: do not use the sort built in function

it is a python question
-- 
https://mail.python.org/mailman/listinfo/python-list


Write a function group(L).

2017-04-21 Thread Mohammed Ahmed
Write a function group(L) that takes a list of integers. The function returns a 
list of
two lists one containing the even values and another containing the odd values.

it is a python question
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Write a function sorting(L).

2017-04-21 Thread Mohammed Ahmed
On Friday, April 21, 2017 at 10:01:40 PM UTC+2, alister wrote:
> On Fri, 21 Apr 2017 12:58:52 -0700, Mohammed Ahmed wrote:
> 
> > Write a function sorting(L) that takes a list of numbers and returns the
> > list with all elements sorted in ascending order.
> > Note: do not use the sort built in function
> > 
> > it is a python question
> 
> & the reason for this question is what exactly?
> 
> 
> 
> 
> -- 
> Why isn't there a special name for the tops of your feet?
>   -- Lily Tomlin

i don't understand you
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Write a function sorting(L).

2017-04-21 Thread Mohammed Ahmed
On Friday, April 21, 2017 at 10:02:55 PM UTC+2, Chris Angelico wrote:
> On Sat, Apr 22, 2017 at 5:58 AM, Mohammed Ahmed  wrote:
> > Write a function sorting(L) that takes a list of numbers and returns the 
> > list with all
> > elements sorted in ascending order.
> > Note: do not use the sort built in function
> >
> > it is a python question
> 
> Yes, it is. It looks like the sort of question that you're supposed to
> try to answer in order to learn how to write software. I suggest you
> try to answer it.
> 
> ChrisA

i tried a lot but i can't answer it so i thought of getting some help here
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python setup problems

2019-01-11 Thread Enas Ahmed Zaki
I want help in solving this problem please
thanks
Enas

On Fri, Jan 11, 2019 at 2:36 PM Enas Ahmed Zaki  wrote:

> Dear sir,
> when I setup the python there is a problem in attached file. I hope I
> found the solution of it.
> thanks for attention
> Eng. Enas Ahmed Zaky
>
> عدم التعرض للفيروسات www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#m_6099717795028892700_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python to c++ conversion problem

2005-03-23 Thread Ahmed MOHAMED ALI
Hi,
Convert the string to int then cast the int to enum with static_cast.
Ahmed


"Akdes Serin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have a code in python like
> if eval('player.moveRoom(SeLinuxMud.Direction.' + x + ')'): # moveRoom
> function takes Direction enum as a parameter
>
> When I am trying to write this code in c++
> if (player->moveRoom(s[1])) //s[1] is a string so it outputs an error
> because of not taking enum as a parameter
>
> How can I change string to enum in c++?
> Thanks.
>
>


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


Raise Error in a Module and Try/Except in a different Module

2005-04-04 Thread Issa-Ahmed SIDIBE
I Have a function FUNC1 that is define in ModuleA. This function raise
an exception EXCP1 (raise EXCP1), with EXCP1 a global variable in
ModuleA.

In ModuleB, I have some classes that call FUNC1. I would like to catch
EXCP1 and make some processing. How can I do that.

I tried in Module B

import ModuleA
...
class():
   ...
   try: a = ModuleA.FUNC1
   except ModuleA.EXCP1: print 'catch'

But It does not work. What is wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: introspection and functions

2007-08-22 Thread Ayaz Ahmed Khan
"James Stroud" typed:
> py> def doit(a, b, c, x=14):
> ...   pass
> ...
> py> doit.func_code.co_argcount
> 4
> py> doit.func_code.co_varnames
> ('a', 'b', 'c', 'x')
> py> doit.func_defaults
> (14,)

Neat.

-- 
Ayaz Ahmed Khan

I have not yet begun to byte!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question

2007-03-06 Thread Ayaz Ahmed Khan
"[EMAIL PROTECTED]" typed:
>> Tommy Grav schrieb:
>> For this case, there are list comprehensions (or map, but you shouldn't
>> use it any longer):
>
> I didn't see anything in the docs about this.  Is map going away or is
> it considered un-Pythonic now?

Most everywhere I've read about map() and filter() seemed to
discourage their use stating that they're becoming depreciated (with the
exception of Dive Into Python which advocates use of these two functions
in preference to even list comprehensions, if I've read it properly).

-- 
Ayaz Ahmed Khan

Falling in love makes smoking pot all day look like the ultimate in
restraint.
-- Dave Sim, author of "Cerebus".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in python!? persistent value of an optional parameter in function!

2007-03-08 Thread Ayaz Ahmed Khan
"Gabriel Genellina" typed:
> 
> See  
> http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm

Thanks for the link, Gabriel. I didn't know about this.

-- 
Ayaz Ahmed Khan

Falling in love makes smoking pot all day look like the ultimate in
restraint.
-- Dave Sim, author of "Cerebus".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Ayaz Ahmed Khan
"kyosohma" typed:

> If you want to get really fancy, you could do a list comprehension
> too:
> 
> your_list = ["0024","haha","0024"]
> new_list = [i for i in your_list if i != '0024']

Or, just:

In [1]: l = ["0024","haha","0024"]
In [2]: filter(lambda x: x != "0024", l)
Out[2]: ['haha']

-- 
Ayaz Ahmed Khan

Do what comes naturally now.  Seethe and fume and throw a tantrum.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to remove multiple occurrences of a string within a list?

2007-04-05 Thread Ayaz Ahmed Khan
"Steven Bethard" typed:
>> Or, just:
>> 
>> In [1]: l = ["0024","haha","0024"]
>> In [2]: filter(lambda x: x != "0024", l)
>> Out[2]: ['haha']
> 
> Only if you want to make your code harder to read and slower::

Slower, I can see.  But harder to read? 

> There really isn't much use for filter() anymore.  Even in the one place 
> I would have expected it to be faster, it's slower::
> 
>  $ python -m timeit -s "L = ['', 'a', '', 'b']" "filter(None, L)"
>  100 loops, best of 3: 0.789 usec per loop
> 
>  $ python -m timeit -s "L = ['', 'a', '', 'b']" "[i for i in L if i]"
>  100 loops, best of 3: 0.739 usec per loop

I am getting varying results on my system on repeated runs.  What about
itertools.ifilter()?

$ python -m timeit -s "L = ['0024', 'haha', '0024']; import itertools"
"itertools.ifilter(lambda i: i != '1024', L)" 
10 loops, best of 3: 5.37 usec per loop

$ python -m timeit -s "L = ['0024', 'haha', '0024']" 
"[i for i in L if i != '0024']" 
10 loops, best of 3: 5.41 usec per loop

$ python -m timeit -s "L = ['0024', 'haha', '0024']" "[i for i in L if i]"
10 loops, best of 3: 6.71 usec per loop

$ python -m timeit -s "L = ['0024', 'haha', '0024']; import itertools" 
"itertools.ifilter(None, L)"
10 loops, best of 3: 4.12 usec per loop

-- 
Ayaz Ahmed Khan

Do what comes naturally now.  Seethe and fume and throw a tantrum.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Console UI

2007-04-08 Thread Ayaz Ahmed Khan
"Clement" typed:

> My project is based on console Application. Is there any console UI
> except urwid. If so, can i come to know.

There is ``curses''.

-- 
Ayaz Ahmed Khan

Do what comes naturally now.  Seethe and fume and throw a tantrum.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie question: ftp.storbinary()

2007-02-03 Thread Ayaz Ahmed Khan
"Scott Ballard" typed:

> Sorry for the lame question, I'm still trying to pick up Python and new to 
> the list here.
> 
> Question:
> I'm trying to write a python script that will access an FTP site and upload 
> some files. I've gotten everything working except for the actual uploading 
> of the files.
> 
> I'm assuming that  I should use storbinary( command, file[, blocksize]) to 
> transfer the files. the documentation says "command should be an appropriate 
> "STOR" command: "STOR filename"."
> 
> I can't seem to figure out an `appropriate "STOR" command' is???

It frustrated the hell out of me too until I found this:

http://effbot.org/librarybook/ftplib.htm

The following works:

from ftplib import FTP
ftp = FTP()
ftp.set_debuglevel(2)
ftp.connect(_host, _port)
ftp.login(_user, _pass)
ftp.storbinary('STOR ' + _file, open(_file))
ftp.quit()

-- 
Ayaz Ahmed Khan

A witty saying proves nothing, but saying something pointless gets
people's attention.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Missing member

2007-02-05 Thread Ayaz Ahmed Khan
"Paul McGuire" typed:
> Here's a suggestion: use new-style classes.  Have _BaseEntity inherit
> from object, allows you to use super for invoking methods on super
> classes.  Instead of:
> class Entity(_BaseEntity):
> def __init__(self, type, x = 0, y = 0):
> _BaseEntity.__init__(self, type, x, y)
> 
> You enter:
> class Entity(_BaseEntity):
> def __init__(self, type, x = 0, y = 0):
> super(Entity,self).__init__(type, x, y)
> 
> This makes it easier to update your inheritance hierarchy later.  New-
> style classes have other benefits too.

I am still a beginner to Python, but reading that made me think on
impluse, "What happens in case of one class inheriting from two or more
different classes?"

Having written a small test case and testing it, I find that
super().__init__() calls the __init__() of the first of the class in
the list of classes from which the calling class inherits. For example:

class C(A, B):
def __init__(self):
super(C, self).__init__()

calls A's __init__ explicity when an instance of C is instantiated. I
might be missing something. I didn't know that.

-- 
Ayaz Ahmed Khan

A witty saying proves nothing, but saying something pointless gets
people's attention.

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


Something like the getattr() trick.

2007-02-10 Thread Ayaz Ahmed Khan
I'm working with the following class heirarchy (I've snipped out the code
from the classes):

class Vuln:
def __init__(self, url):
pass

def _parse(self):
pass

def get_link(self):
pass

class VulnInfo(Vuln):
pass

class VulnDiscuss(Vuln):
pass

def main(url):
vuln_class = ['Info', 'Discuss']
vuln = Vuln(url)
vuln._parse()
for link in vuln.get_link():
i = VulnInfo(link)
i._parse()
d = VulnDiscuss(link)
d._parse()


Is there a way to get references to VulnInfo and VulnDiscuss objects using
something like the getattr trick? For example, something like:

for _class in vuln_class:
class_obj = getattr('Vuln%s' % (_class,) ..)
a = class_obj(link)
a._parse()

getattr() takes an object as its first argument. I can't seem to figure
out how to make it work here.

-- 
Ayaz Ahmed Khan

A witty saying proves nothing, but saying something pointless gets
people's attention.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTML Parsing

2007-02-10 Thread Ayaz Ahmed Khan
"mtuller" typed:

> I have also tried Beautiful Soup, but had trouble understanding the
> documentation

As Gabriel has suggested, spend a little more time going through the
documentation of BeautifulSoup. It is pretty easy to grasp.

I'll give you an example: I want to extract the text between the
following span tags in a large HTML source file.

Linux Kernel Bluetooth CAPI Packet Remote Buffer Overflow 
Vulnerability

>>> import re
>>> from BeautifulSoup import BeautifulSoup
>>> from urllib2 import urlopen
>>> soup = BeautifulSoup(urlopen('http://www.someurl.tld/')) 
>>> title = soup.find(name='span', attrs={'class':'title'}, 
>>> text=re.compile(r'^Linux \w+'))
>>> title
u'Linux Kernel Bluetooth CAPI Packet Remote Buffer Overflow Vulnerability'

-- 
Ayaz Ahmed Khan

A witty saying proves nothing, but saying something pointless gets
people's attention.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: the annoying, verbose self

2007-11-22 Thread Ayaz Ahmed Khan
braver wrote:

> Is there any trick to get rid of having to type the annoying,
> character-eating "self." prefix everywhere in a class?  Sometimes I
> avoid OO just not to deal with its verbosity.  In fact, I try to use
> Ruby anywhere speed is not crucial especially for @ prefix is better-
> looking than self.

I've never really understood why some people find that annoying to do.  I 
make it a point to use, for example, the `this` operator when writing C++ 
code to avoid implicilty calling/accessing attributes of objects as much 
as possible.

-- 
Ayaz Ahmed Khan



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


Re: md5 wrongness?

2007-11-24 Thread Ayaz Ahmed Khan
John Machin wrote:
> On Nov 24, 1:34 pm, Ron Johnson <[EMAIL PROTECTED]> wrote:
>> Why do Python's md5 and GNU md5sum produce differing results?
> 
> They don't differ. Try feeding them the same input:
> 
>>>> import md5
>>>> md5.new('snagglefrob').hexdigest()
> '9eb2459fcdd9f9b8a9fef7348bcac933'
>>>> md5.new('snagglefrob\n').hexdigest()
> 'f842244d79af85b457811091319d85ff'
>>>>

Or, alternatively:

$ echo -n snagglefrob | md5sum
9eb2459fcdd9f9b8a9fef7348bcac933  -

-- 
Ayaz Ahmed Khan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching a segfault in a Python library

2007-11-24 Thread Ayaz Ahmed Khan
Donn Ingle wrote:
> Already done, the code within PIL is causing the crash. It gets ugly and
> out of my remit. It's a freetype/Pil thing and I simply want to a way to
> catch it when it happens.
>  Since a segfault ends the process, I am asking about "wrappers" around
>  code
> to catch a segfault.
> 
> \d

Wouldn't it be better to narrow down to what in your code is invoking PIL 
in a manner in which PIL exhibits such behaviour, and handle it within 
your code?

Just a thought!

-- 
Ayaz Ahmed Khan
-- 
http://mail.python.org/mailman/listinfo/python-list


EURO NEWS FINALLY LAUNCHED THEIR BLOG

2009-05-12 Thread Aqeel Ahmed Rajpar
TO SUBSCRIBE THE BLOG VIA EMAIL VISIT

www.euronewspk.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Case Solution: A Dark Horse in the Global Smartphone Market Huawei's Smartphone Strategy by Yangao Xiao, Tony Tong, Guoli Chen, Kathy Wu

2017-08-31 Thread ahmed . gamal . omar . 80
On Saturday, 8 July 2017 05:22:24 UTC+2, Case Solution & Analysis  wrote:
> Case Solution and Analysis of A Dark Horse in the Global Smartphone Market: 
> Huawei's Smartphone Strategy by Yangao Xiao, Tony Tong, Guoli Chen, Kathy Wu 
> is available at a lowest price, send email to 
> casesolutionscentre(at)gmail(dot)com 
> 
> Case Study ID: IN1324
> 
> Get Case Study Solution and Analysis of A Dark Horse in the Global Smartphone 
> Market: Huawei's Smartphone Strategy in a FAIR PRICE!! 
> 
> Our e-mail address is CASESOLUTIONSCENTRE (AT) GMAIL (DOT) COM. Please 
> replace (at) by @ and (dot) by . 
> 
> YOU MUST WRITE FOLLOWING WHILE PLACING YOUR ORDER: 
> Complete Case Study Name 
> Authors 
> Case Study ID 
> Publisher of Case Study 
> Your Requirements / Case Questions 
> 
> Note: Do not REPLY to this post because we do not reply to posts here. If you 
> need any Case Solution please send us an email. We can help you to get it.

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


Re: PEP Idea: Extended import syntax for aliasing module attributes

2025-06-18 Thread Omar Ahmed via Python-list
The solution was provided in this thread here:
https://discuss.python.org/t/extended-import-syntax-for-aliasing-module-attributes/95920/3
The correct way to implement is:
import module
from module import optimize, validate as check
-- 
https://mail.python.org/mailman3//lists/python-list.python.org


Re: PEP Idea: Extended import syntax for aliasing module attributes

2025-06-18 Thread Omar Ahmed via Python-list
Thank you. I have posted this idea on https://discuss.python.org/c/ideas/6
I had difficulty trying to find that.
-- 
https://mail.python.org/mailman3//lists/python-list.python.org


Re: PEP Idea: Extended import syntax for aliasing module attributes

2025-06-18 Thread Omar Ahmed via Python-list
Thank you. I have used this link. I had difficulty finding it.
https://discuss.python.org/
-- 
https://mail.python.org/mailman3//lists/python-list.python.org


PEP Idea: Extended import syntax for aliasing module attributes

2025-06-16 Thread Omar Ahmed via Python-list
Hi all,
I would like to propose a potential addition to Python's `import` syntax that 
would improve clarity and ergonomics for cases where developers want both full 
module access *and* a local alias to a specific attribute within that module.

Currently, to get both behaviors, we typically write:
import module
optimize = module.optimize

This works fine, but it is slightly verbose and less explicit in intent.

I would like to explore syntax like:
import module with module.optimize as optimize
or possibly:
import module with (
module.optimize as optimize,
module.validate as check
)

The goal is to import the full module as usual, while simultaneously assigning 
a local name to a chosen sub-attribute all in a single declaration.

This strikes a balance between:
*Readability* (makes intensions clearer)
*Convenience* (avoids repetitive alias assignments)
*Maintainability* (discourages `from module import *`)

I am curious to hear whether this type of syntax has been considered before, or 
if it might be worth formalizing into a PEP. I would be happy to help develop a 
draft proposal if there is interest.

Thank you for reading.
-Omar
-- 
https://mail.python.org/mailman3//lists/python-list.python.org