Re: howto handle nested for

2012-09-28 Thread Wojtek
W dniu 2012-09-28 16:42, Alister pisze: On Fri, 28 Sep 2012 10:39:32 -0400, Neal Becker wrote: I know this should be a fairly basic question, but I'm drawing a blank. I have code that looks like: for s0 in xrange (n_syms): for s1 in xrange (n_syms): for s2 in xrange (

Re: Portable general timestamp format, not 2038-limited

2007-07-05 Thread Wojtek
year as a "magic number", some of you may think that I am repeating the Y2K problem. Hey, if my application is still being used in the year 9998 I am not being paid nearly enough... -- Wojtek :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: what's so difficult about namespace?

2008-11-26 Thread Wojtek
user comes across a site which uses it) The IT community has enough trouble getting a few ISPs to upgrade their DNS software. How are you going to get millions of general users to upgrade? Web stats show that people are still using IE 5... -- Wojtek :-) -- http://mail.python.org/ma

Re: what's so difficult about namespace?

2008-11-26 Thread Wojtek
getting libraries from several sources. Without a generally acknowledged name space scheme different developers will tend to walk all over each others variable/function names. Especially as Javascript has global variables. -- Wojtek :-) -- http://mail.python.org/mailman/listinfo/python-list

Embedding Python's library as zip file

2011-05-04 Thread Wojtek Mamrak
Hello, I spent a lot of time googling for a solution of this problem, with no result. I have a C++ application, in which I would like to embed Python interpreter. I don't want to rely on an interpreter being installed on user machine, instead I would like to distribute all the necessary files wit

Re: Embedding Python's library as zip file

2011-05-05 Thread Wojtek Mamrak
ll the cases so this is not the issue. > Are you getting any sort of error message? When I run my app, it crashes while calling Py_Initialize(). The console closes suddenly. Is it necessary to create zip archive using zipfile.PyZipFile? regards 2011/5/5 Ian Kelly > > On Wed, May 4, 2011

Re: Embedding Python's library as zip file

2011-05-05 Thread Wojtek Mamrak
ackages directory to the sys.path by myself (yet I don't know why sys.prefix and sys.exec_prefix are empty), however how to deal with the PYTHONPATH, which is required to load site.py and hence has to be defined at the very beginning? thanks for your help 2011/5/5 Ian Kelly : > On Thu, May 5

Re: Embedding Python's library as zip file

2011-05-06 Thread Wojtek Mamrak
> Are you calling Py_SetProgramName? That may help to set sys.prefix > and sys.exec_prefix. However, looking at site.py, it appears that > it's only looking for proper directories. I don't think it will be > able to add a site-packages inside a zip archive at all; you will just > have to add tha

Re: PIL: The _imaging C module is not installed

2011-05-06 Thread Wojtek Mamrak
@Michel use PIL downloaded from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/ regards 2011/5/6 Christian Heimes : > Am 06.05.2011 01:48, schrieb Michel Claveau - MVP: >> Re! >> >> And why the problem no exist with PIL 1.1.6?  (only 1.1.7) >> Is that the version 1.1.6 does not use these librari

Re: Embedding Python's library as zip file

2011-05-06 Thread Wojtek Mamrak
> I used py2exe in the past for that, see > http://www.py2exe.org/index.cgi/ShippingEmbedded Thanks for the advice, py2exe seems to be a great tool. Unfortunately the application stops executing at the same place. It might be the case of PIL library, I found some entries about it on py2exe site.

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Wojtek Mamrak
Is there any special reason you don't want to use QThread? http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qthread.html#details regards 2011/5/11 Chris Angelico : > On Wed, May 11, 2011 at 7:08 PM, vijay swaminathan wrote: >> Sorry. My intention was not to send out a private message.

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Wojtek Mamrak
2011/5/11 Chris Angelico : > On Thu, May 12, 2011 at 1:16 AM, Wojtek Mamrak wrote: >> Is there any special reason you don't want to use QThread? >> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qthread.html#details > > Other than that QThread is part of QT

Re: Python drawing library?

2011-05-15 Thread Wojtek Mamrak
Yes, it is possible with use of PyQt. 2011/5/15 Rafael Durán Castañeda : > On 15/05/11 01:01, OKB (not okblacke) wrote: >> >>        Is there any Python library for interactive drawing?  I've done >> some googling but most searches for "drawing" lead me to libraries for >> programmatic creation of

Compile Python 3 interpreter to force 2-byte unicode

2017-11-25 Thread wojtek . mula
Hi, my goal is to obtain an interpreter that internally uses UCS-2. Such a simple code should print 65535: import sys print sys.maxunicode This is enabled in Windows, but I want the same in Linux. What options have I pass to the configure script? w. -- https://mail.python.org/mailman/listin

Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread wojtek mula
Hi, my goal is to obtain an interpreter that internally uses UCS-2. Such a simple code should print 65535: import sys print sys.maxunicode This is enabled in Windows, but I want the same in Linux. What options have I pass to the configure script? w. -- https://mail.python.org/mailman/listi

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread wojtek . mula
On Sunday, November 26, 2017 at 1:00:19 AM UTC+1, Terry Reedy wrote: > You must be trying to compile 2.7. There may be Linux distributions > that compile this way. You're right, I need 2.7. Any hint which distro has got these settings? > If you want to seriously work with unicode, many recommen

Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread wojtek mula
Hi, my goal is to obtain an interpreter that internally uses UCS-2. Such a simple code should print 65535: import sys print sys.maxunicode This is enabled in Windows, but I want the same in Linux. What options have I pass to the configure script? w. -- https://mail.python.org/mailman/listi

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-27 Thread wojtek mula
On Sunday, November 26, 2017 at 1:00:19 AM UTC+1, Terry Reedy wrote: > You must be trying to compile 2.7. There may be Linux distributions > that compile this way. You're right, I need 2.7. Any hint which distro has got these settings? > If you want to seriously work with unicode, many recommend

Execute python script from VB6 to display Outlook Window

2019-12-22 Thread wojtek . dominicana
de commant to execute my python script. I have no idea how to run python script on my system that works the same as I call it directly from windows command line. regards Wojtek -- https://mail.python.org/mailman/listinfo/python-list

Re: urlparse import Faillure

2008-10-10 Thread Wojtek Walczak
ting rid of this comment? I doubt that the comment is a reason of this error, but it seems that it shadows the real problem. Moreover, try to import urlparse itself and check if you got the pyc file for urlparse.py in your */lib/python2.5/ directory. -- Regards, Wojtek Walczak, http://tosh.pl/g

Re: HTTPError... read the response body?

2009-03-02 Thread Wojtek Walczak
[1] a valid URL? And are you sure that you want to send something to the web serwer? By specifying the second argument (args[3]) you're asking python to send HTTP "POST" request, not "GET". -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Equivalent to C bitmasks and enumerations

2009-04-15 Thread Wojtek Walczak
7;RED') c.set_color('YELLOW') print c.has_color('RED') print c.has_color('BLUE') print c.status_as_string(5) HTH, -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: I'm sort of mystified by the print hex to char conversion

2009-04-18 Thread Wojtek Walczak
slash is left in the string. (This behavior is useful when debugging: if an escape sequence is mistyped, the resulting output is more easily recognized as broken.) So, as long as the escape sequence is recognized it is changed accordingly. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: python alternatives to C structs??

2009-04-18 Thread Wojtek Walczak
ary/struct.html http://www.doughellmann.com/PyMOTW/struct/index.html http://code.activestate.com/recipes/498149/ HTH, -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: HTTP Authentication using urllib2

2009-04-24 Thread Wojtek Walczak
shoot yourself in the foot and check what the exceptions are, i.e.: except: import traceback print traceback.format_exc() Second, better use mechanize: http://wwwsearch.sourceforge.net/mechanize/ HTH, -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.

Re: Check if module is installed

2008-08-04 Thread Wojtek Walczak
s of python. Take a look at this example: http://aima.cs.berkeley.edu/python/utils.html -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: URLs and ampersands

2008-08-05 Thread Wojtek Walczak
;>").replace("<","<") HTMLParser.py:s = s.replace("&", "&") # Must be last pydoc.py:return replace(text, '&', '&', '<', '<', '>', '>') xmlrpclib.py:s = replace(s, "&", "&") So it could be BaseHTTPServer, cgi, cgitb, difflib, HTMLParser, pydoc or xmlrpclib. Do you use any of these? Or maybe some other external module? -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with mechanize

2008-08-06 Thread Wojtek Walczak
it's described in the documentation. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: mktime overflow in March 2008?

2008-08-07 Thread Wojtek Walczak
rflowError: mktime argument out of range >>>> time module is written in C. time.mktime() function is actually only a wrapper for mktime(3) and it also has its limits. Better use datetime module instead. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: HTTP basic authentication with form-based authentication

2008-08-07 Thread Wojtek Walczak
; form-based authentication (using cookies) *and* HTTP basic > authentication? Use ClientCookie or even better - mechanize: http://pypi.python.org/pypi/mechanize/ The docs aren't perfect, but you should easily find what you are searching for. -- Regards, Wojtek Walczak, http://www.stud.umk.p

Re: Books to begin learning Python

2008-08-07 Thread Wojtek Walczak
Dnia Thu, 7 Aug 2008 12:37:55 -0700 (PDT), Samir napisa�(a): > Some good online tutorials that I found really helpful include: You might find it useful: http://linkmingle.com/list/List-of-Free-Online-Python-Books-freebooksandarticles -- Regards, Wojtek Walczak, http://www.stud.umk

Re: Books to begin learning Python

2008-08-07 Thread Wojtek Walczak
ut I wouldn't worry about this. Pythons 2.x will be around for quite some time (just as python 1.5.x is). -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: how to find out if an object is a class?

2008-08-07 Thread Wojtek Walczak
Dnia Thu, 7 Aug 2008 14:36:37 -0700 (PDT), szczepiq napisa�(a): > Pardon me for most likely a dummy question but how do I find out if an > object is a class? Use types.ClassType: >>> class Q: ...pass ... >>> import types >>> isinstance(Q, types.ClassTy

Re: My very first python program, need help

2008-08-10 Thread Wojtek Walczak
# or shadow 'string' module if it's imported. def calculate_sum_1(string): result = '' for i in string: if i.isdigit(): result += i else: result += ' ' return sum([int(i) for i in result.split()]) def calculate_sum_2(string):

Re: Second python program: classes, sorting

2008-08-10 Thread Wojtek Walczak
lf.score > other.score: return 1 return -1 == Should work fine now. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking out a module for Subversion

2008-08-12 Thread Wojtek Walczak
vailable for subversion, out of the box, that I can import > in my script? There is no such module in standard library, but you can try an external one. Check: http://pysvn.tigris.org/ -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: very rare python expression

2008-08-12 Thread Wojtek Walczak
>>> flags_set & flag2 2 >>> flags_set & flag3 0 >>> flags_set & flag4 8 >>> flags_set & flag5 0 -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to use SOCK_RAW yields error "

2008-08-12 Thread Wojtek Walczak
, not AF_INET. Note that you need root privileges to do so. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to use SOCK_RAW yields error "

2008-08-12 Thread Wojtek Walczak
t; File "tcpsrv.py", line 15, in > server.bind((host,port)) > File "", line 1, in bind > socket.error: (19, 'No such device') What's the value of host variable? AFAIR it should be the name of the interface you want to bind to ('eth0', &#x

Re: python interpreter

2008-08-12 Thread Wojtek Walczak
the Programming FAQ: http://www.python.org/doc/faq/programming/ And keep in mind that reload() is removed in Py3k. Hope this helps. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system question

2008-08-12 Thread Wojtek Walczak
and it doesn't > raise any warnings or mention anything in the doc string. I think that the deprecation warnings were added in Python 2.6. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system question

2008-08-13 Thread Wojtek Walczak
opriately. Got to investigate it further. os.popen won't return any deprecation warning in Py2.6beta2 probably because it is defined in Lib/platform.py and not in Lib/os.py and I guess that somebody has forgotten to add the warnings in there. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace Several Items

2008-08-13 Thread Wojtek Walczak
27; >>> Next step would be to define your own replacing function: def my_replace(mystr, mychars, myrepl): """Replace every character from 'mychars' string with 'myrepl' string in 'mystr' string. Example: my_replace('Qwe.Asd/Zxc(', './(', 'XY') -> 'QweXYAsdXYZxcXY'""" for i in mychars: mystr = mystr.replace(i, myrepl) return mystr -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system question

2008-08-13 Thread Wojtek Walczak
ing for os.popen() goes to the bin. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion for improved ImportError message

2008-08-13 Thread Wojtek Walczak
thon/ceval.c My quick attempt: http://www.stud.umk.pl/~wojtekwa/patches/from-import-py2.5.1.patch -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace Several Items

2008-08-13 Thread Wojtek Walczak
ck (lambda m: ""), repeated replace, and repeated use of the form > > if ch in my_string: > my_string = my_string.replace(ch, "") > > on representative data. I don't have to, I can anticipate the results. I mentioned above that using re is the best approach, but if one really wants to use replace() multiple times (which will be slow, of course), it can be done a bit cleaner than with str.replace().replace().replace()... -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion for improved ImportError message

2008-08-13 Thread Wojtek Walczak
Dnia Wed, 13 Aug 2008 22:15:48 + (UTC), Wojtek Walczak napisa�(a): > Then go for it :-) You can prepare a patch and ask on python-dev > if the developers are interested. > > I was never hacking the import things on C level before, > but a hint: you have to modify import_fro

Re: Replace Several Items

2008-08-13 Thread Wojtek Walczak
> > Chances are that you're wrong. At the moment my average is about 0.75 of mistake per post on comp.lang.python (please, bare with me ;-)). I strongly believe that the statement I made above won't make this number rise. :) -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion for improved ImportError message

2008-08-14 Thread Wojtek Walczak
n from >> > Python/ceval.c > > Am I correct in thinking that PyPy would mean low level > stuff like this will be Python instead of C? > That would be nice. I don't know PyPy, but I guess you're right here. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace Several Items

2008-08-14 Thread Wojtek Walczak
pated them correctly/incorrectly."? Don't count on it. I never really cared about being right or wrong and I am not one of those guys who are trying to prove something that actually makes no difference at all. Nice tests, though :) -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: for y in range (0,iNumItems)--> not in order?

2008-08-14 Thread Wojtek Walczak
ses around the print instruction, it's not a function. You could also write: print "%d %d %d" % (x, y, z) -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: negative numbers are not equal...

2008-08-14 Thread Wojtek Walczak
this helps. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: getattr nested attributes

2008-08-15 Thread Wojtek Walczak
r small things and it will like you: >>> getattr(getattr(B, 'a')[0], 'test') 'test' >>> it works because: >>> getattr(B, 'a') == B.a True >>> getattr(B, 'a')[0] == B.a[0] True >>> -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I control output buffering on Win32?

2008-08-15 Thread Wojtek Walczak
ort sys def printf(mystr): print mystr sys.stdout.flush() -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: QT, ctypes dll and SEG Faults

2008-08-17 Thread Wojtek Walczak
the one passed to __init__? Try it in __init__ to make sure: assert filename == 'your_hardcoded_value' And why won't you try to store the filename as an attribute? (even though I doubt it could help). -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: how many nested for can we utilize?

2008-08-17 Thread Wojtek Walczak
> assuming each iteration takes a picosecond, it'll take approx 40 > billion years to run the program. I guess that's exactly why the OP asks the question. He just wants to start as soon as possible ;-) -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: how many nested for can we utilize?

2008-08-17 Thread Wojtek Walczak
t;"The Effects of Moore's Law and Slacking on Large Computations" >http://arxiv.org/abs/astro-ph/9912202 Kinda buddhist approach. Anyway, it might work out, unless the number of for loops is increasing in time and in 18 months it may be - let's say - 20 nested

Re: how to call API Functions in python

2008-08-17 Thread Wojtek Walczak
maybe ctypes module will be helpful for you. -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: like a "for loop" for a string

2008-08-17 Thread Wojtek Walczak
that > gets the same result? What's "that"? Do you mean _this_: >>> somestr = "string1 string2 string3" >>> for i in somestr.split(): ...print i ... string1 string2 string3 >>> ? -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: like a "for loop" for a string

2008-08-17 Thread Wojtek Walczak
hitespace, so it's not the same as str.split(' '). Moreover, specifying maxsplit argument whenever possible seems to be a good practice. Anyway, go ahead with that xsplit thing :-) -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: online tutorials?

2008-08-18 Thread Wojtek Walczak
ne-Python-Books-freebooksandarticles -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: searching through a string and pulling characters

2008-08-18 Thread Wojtek Walczak
tring4)' To save some memory use finditer (as long as you don't have to search for too many of these): >>> for i in enumerate(pat.finditer(a)): ...if i[0] == 2: ... print i[1].group() ... (string3) >>> -- Regards, Wojtek Walczak, http://www.stud.umk.pl/~wojtekwa/ -- http://mail.python.org/mailman/listinfo/python-list

Re: searching through a string and pulling characters

2008-08-18 Thread Wojtek Walczak
On Mon, 18 Aug 2008 21:43:43 + (UTC), Wojtek Walczak wrote: > On Mon, 18 Aug 2008 13:40:13 -0700 (PDT), Alexnb wrote: >> Now, I am talking 1000's of these. I need to do something like this. I will >> have a number, and what I want to do is go through this text file, just

Re: searching through a string and pulling characters

2008-08-19 Thread Wojtek Walczak
On Mon, 18 Aug 2008 15:34:12 -0700 (PDT), Alexnb wrote: > Also, on a side-note, does anyone know a very simple dictionary site, that > isn't dictionary.com or yourdictionary.com. This one is my favourite: http://www.lingro.com/ -- Regards, Wojtek Walczak, http://tosh.pl/gmini

Re: [tarfile] Difficultis catching an exception

2008-08-20 Thread Wojtek Walczak
s EOFError attribute? Try this: ... except (tarfile.TarError, EOFError): ... -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing Passwords

2008-08-20 Thread Wojtek Walczak
led chilkat and it looks like this library provides some 3des functionality. HTH. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: TRying to read sercah results from googles web page

2008-08-20 Thread Wojtek Walczak
eforge.net/mechanize/ FYI and AFAIK, google doesn't allow to use their search engine in this way. They even block certain IP addresses it it's constantly abusing the search engine with too many requests. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess seems to "detach" / ignore wait()

2008-08-20 Thread Wojtek Walczak
pens if you change: fpid.write(child.pid) into: fpid.write('%d\n' % (child.pid)) I think that the problem here is that fpid.write() fails silently (probably TypeError), because it takes string as its first argument, not integer. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: 'While' question

2008-08-21 Thread Wojtek Walczak
o I overcome this, and make the script skip the empty files? > (should I use another command?) > 2) how do I interrupt the code without closing Python? (I have ActivePython) Try the docs first. You need to read about 'continue' and 'break' statements: http://docs.python.org/

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Wojtek Walczak
//www.python.org/doc/faq/general/ Question 4.22. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Wojtek Walczak
ut couldn't find it. YOURFUNCTION.func_globals['YOURFUNCTION'].func_defaults -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Wojtek Walczak
omes on c.l.py and asks about it. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: exception handling in complex Python programs

2008-08-22 Thread Wojtek Walczak
many people, that we should just forget it. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: EOF

2008-08-22 Thread Wojtek Walczak
.write(retval) should do the job. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: 'While' question

2008-08-22 Thread Wojtek Walczak
7;re iterating through the same value in inner and outer loop. Don't do that. It's hard to predict the behavior of such a code. Regarding break statement, it breaks only the inner loop and returns to the outer loop/block. It would be great if you could reduce your code to a short pie

Re: Python one-liner??

2008-08-22 Thread Wojtek Walczak
-c? -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate alphabet?

2008-08-22 Thread Wojtek Walczak
generate something if it's accessible anyway: import string print string.letters -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Generators can only yield ints?

2008-08-22 Thread Wojtek Walczak
port string def letters(): a, B = (string.letters,) * 2 for i in zip(a, B): yield i[0] yield i[1] l = letters() print l.next() print l.next() print l.next() -- and the output: $ python genlet.py a a b $ Is that what you tried to achieve? -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to know a top directory?

2008-08-23 Thread Wojtek Walczak
hat\path" then I need to get "c:\that". > > Does anyone have ideas? Read about os.path module. It's all in there: http://docs.python.org/lib/module-os.path.html -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check in CGI if client disconnected

2008-08-24 Thread Wojtek Walczak
developer, but I think that the only way is to set a timeout on server side. You can't be sure that the client disconnected, but you can stop CGI script if there's no action on client side for too long. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: passing arguments to exec

2008-08-25 Thread Wojtek Walczak
On Mon, 25 Aug 2008 06:31:53 -0700 (PDT), Alexandru Mosoi wrote: > i want to execute a python script using exec open('script.py'). how do > I pass arguments? Take a look at subprocess module. It comes with a set of examples. -- Regards, Wojtek Walczak, http://tosh.pl/

Re: class definition syntax

2008-08-29 Thread Wojtek Walczak
object class. Check out point 9.5 in the tutorial. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing module with name given as a variable

2008-08-30 Thread Wojtek Walczak
the normal import call: import sys is equal to: sys = __import__('sys') If you need, let's say, to search for a module that lies outside sys.module paths, then use imp's functions. HTH. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative imports and "import X as Y"

2008-08-31 Thread Wojtek Walczak
conflicts in who knows what ways. Then you can download tar.gz package, compile it, and try it without installing :-) -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How can we get to the end of a quote inside a string

2008-08-31 Thread Wojtek Walczak
some extent you can use regular expressions: >>> re.findall(re.compile("\".*?\""), s) ['" c1\' d1 \' c2"'] >>> re.findall(re.compile("\'.*?\'"), s) ['\' b1 " c1\'', '\' c2" b2 \''] >>> but it won't work in all cases. You can read more here: http://www.gnosis.cx/TPiP/ -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Processes in Linux from Python

2008-09-01 Thread Wojtek Walczak
in pp.pids: ...if pp.procs[pid]['cmd'] == 'apache2': ... print pp.procs[pid]['tid'] ... 5204 5205 5206 5208 >>> it prints the PIDs of all the apache2 processes on my system. Procpy is fine for my own needs, but if I were about to write a code that is in

Re: list + dictionary searching

2008-09-01 Thread Wojtek Walczak
Give it a try. Try to design some functions that let you view and add new lists/dictionaries to your variables. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: how to find position of dictionary values

2008-09-01 Thread Wojtek Walczak
i change the key to something like 'sabir' and kev['sabir'] = kev['kabir'] del kev['kabir'] > how can i > change the values of kabir? kev['sabir'][0] = '[EMAIL PROTECTED]' *untested* -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Eleganz way to get rid of \n

2008-09-01 Thread Wojtek Walczak
; a="some string\r\n" >>> a.rstrip() 'some string' >>> but be careful, because it will also cut whitespaces: >>> a="some string\t \r\n" >>> a.rstrip() 'some string' >>> so maybe you could do

Re: Getting an objetcs dict?

2008-09-01 Thread Wojtek Walczak
-questions.html HINT: the attribute you're accessing is not a callable. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Algorithm used by difflib.get_close_match

2008-09-02 Thread Wojtek Walczak
es that "look right" to people. HTH. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing Subprocess Results

2008-09-02 Thread Wojtek Walczak
above assigns the output variable with a return code, i.e. 0 in > this case. How can I actually capture the data returned from > subprocess.call, rather than just the return code? Use subprocess.Popen instead of call. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: What is module initialization?

2008-09-02 Thread Wojtek Walczak
On Tue, 2 Sep 2008 15:32:07 +0100, [EMAIL PROTECTED] wrote: > But if I do :- >#question.py > from myglobals import * > myglobals.answer = "WTF ?" > > will this work? Why won't you try? In this case you should receive NameError. -- Regards, Wojtek Walczak

Re: python - mechanize/browser/POST issue

2008-09-03 Thread Wojtek Walczak
ave a short chunk of code that I can observer, that uses the > mechanize.Browser implentation? Take a look at the bottom of this post: http://mail.python.org/pipermail/python-list/2006-June/390037.html It seems that submit does the job. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ --

Re: properties setting each other

2008-09-03 Thread Wojtek Walczak
property(getvalue, setvalue) a = Square(5) print a.square print a.value a.value = 10 print a.square print a.value a.square = 64 print a.square print a.value --- and the result: $ python sqval.py 25 5.0 100.0 10 64 8.0 $ -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: properties setting each other

2008-09-03 Thread Wojtek Walczak
On Wed, 3 Sep 2008 14:31:17 + (UTC), Wojtek Walczak wrote: > class Square(object): >def __init__(self, val): > self._square = pow(val, 2) > self._value = math.sqrt(self.square) ^^ or just: self._value = val :-)

Re: Looking for File comparison utility that produces actual differences

2008-09-03 Thread Wojtek Walczak
or 0 i.e whether the 2 files differ or not? In python it's called difflib. Try to import it. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: overwrite set behavior

2008-09-04 Thread Wojtek Walczak
rcn.com/python/download/Descriptor.htm -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Issue warning if no "return" in function?

2008-09-04 Thread Wojtek Walczak
akes? Check pychecker or figleaf: http://pychecker.sourceforge.net http://darcs.idyll.org/~t/projects/figleaf/doc/ -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list

Re: overwrite set behavior

2008-09-04 Thread Wojtek Walczak
On Thu, 4 Sep 2008 12:06:14 +0200, Marco Bizzarri wrote: >> As far as I understand you, you need descriptors: >> http://users.rcn.com/python/download/Descriptor.htm > I know descriptors a litte, Wojtek, but didn't use them often; can you > elaborate a little more on you

  1   2   >