threading.Semaphore or gevent.lock.Semaphore

2017-05-24 Thread Sergey
Hello, I'm developing Flask app, processed by gevent.wsgi.WSGIServer. If I need to isolate some pieces of code inside request handlers, can I use threading.Lock? If I need semaphore, must I use threading.Semaphore or gevent.lock.Semaphore? What is the difference between them? Thank you! -- http

Re: [OT] Question about Git branches

2014-09-17 Thread Sergey Organov
7;t be able to ignore it if you ever reabase or merge. > This seems error-prone. Am I missing something? What exactly is error-prone? Are you afraid to commit to a wrong branch? Are you afraid to commit the changes you didn't want to commit? Anyway, if you did a mistake, you should be able to examine situation and fix it rather easily, provided you didn't yet publish your history. HTH, -- Sergey. -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] Question about Git branches

2014-09-17 Thread Sergey Organov
e any policy or particular work-flow on you, so if clones work better for you, using them still follows git philosophy. -- Sergey. -- https://mail.python.org/mailman/listinfo/python-list

Multiprocessing pool with custom process class

2013-12-17 Thread Sergey Fedorov
Hi All, I have a web-service that needs to handle a bunch of work requests. Each job involves IO call (DB, external web-services to fetch some data), so part of the time is spent on the blocking IO call. On the other side, after getting the data the job involves computational part (using numpy/pan

Re: load_module for import entire package

2013-12-12 Thread Sergey
_pkg) pkg = load_package_strict(tmp_pkg, basedir + '/x/' + dir_name) result = pkg.main.TTT() What is the risk of this method? What are 3 methods of doing the same? -- Sergey -- https://mail.python.org/mailman/listinfo/python-list

load_module for loading packages

2013-12-11 Thread Sergey
work with result of load_module, used for loading a package. Regards, Sergey -- https://mail.python.org/mailman/listinfo/python-list

load_module for import entire package

2013-12-10 Thread Sergey
return main.TTT() It is working, but if package code changes on disc at runtime and I call get_obj again, it returns instance of class, loaded for the first time previously. How to replace line "from tmp import main" by getting properties of pkg? Regards, Sergey -- https://mail.python.org/mailman/listinfo/python-list

syntax enhancement

2011-10-04 Thread Valiev Sergey
). What do you think about it? -- Best regards, Valiev Sergey *skype:* *svaliev* *jabber:* *sval...@gmail.com* *phone:* +7 926 233-17-64 -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickling/Unpickling python Exceptions

2011-01-31 Thread Sergey Lukin
Is anybody there to help me out ? On Thu, Jan 27, 2011 at 4:49 PM, Sergey Lukin wrote: > Hi all, > > I'm migrating code from python 2.4 to python 2.6 and I've got into troubles > with pickling/unpickling python Exceptions. > The following code works fine in 2.4 but not

Pickling/Unpickling python Exceptions

2011-01-27 Thread Sergey Lukin
Hi all, I'm migrating code from python 2.4 to python 2.6 and I've got into troubles with pickling/unpickling python Exceptions. The following code works fine in 2.4 but not in 2.6. See Exception1 example I have found on python mail list similar problem http://mail.python.org/pipermail/python-lis

How to parse a text block?

2010-11-26 Thread Sergey Smirnov
dictionary given below? {'Device':'MS1','Time':'Time: 19:57:44.71','CP-User data':{'length':'37','RPDU':{'Message type indicator (MTI)':'(1) RP-DATA'}}} Any other thoughts about reading that kind of text? Thanks, Sergey -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I make python test.py work without a syntax error msg?

2010-08-19 Thread Sergey Smirnov
this is what it looks like > > > On Thu, Aug 19, 2010 at 7:01 PM, Agida Kerimova wrote: > >> Hi, I don't know how to work in a non bash console... I typed python in a >> terminal window and all but it didn't work... >> >> >> >> >> &g

Re: How do I make python test.py work without a syntax error msg?

2010-08-19 Thread Sergey Smirnov
*when I actually * *type it I get an error msg* Did you type python commands in a bash console? In case you did, you should run python interactive console instead. Just type python in terminal window and than you'll be able interactively run statements. If you have your script saved in a file, f

Re: How to improve this code?

2009-09-18 Thread Sergey Simonenko
match. Is there somehow I can improve code in elementsPresent()? I'm not a very good programmer but I sense that idea of using a variable named 'result' inside elementsPresent() doesn't sound very good. Any ideas will be highly appreciated. Thanks, Oltmans -- Kind regar

Re: Subclass dynamically

2009-08-18 Thread Sergey Simonenko
__init__( self, base ): self.base = base Something like that... and then I would do this: foo = MyDerived( MyBase() ) Note I'm using Python 3.1 on Windows. Thanks in advance. -- Kind regards, Sergey Simonenko. -- http://mail.python.org/mailman/listinfo/python-list

Subclassing Python's dict

2009-08-05 Thread Sergey Simonenko
x27; and 'setdefault' ignore redefined '__setitem__' and use builtin dict's one so dict looks kinda like a black box. Another guy have reported me that he experiences similar problems with subclassing builtin 'list'. Kind regards, Sergey. -- Написано в

PYTHONPATH var

2009-05-29 Thread Sergey Dikovitsky
Hi guys. I have a question regarding runtime definition of the variable PYTHONPATH. Do you know how without modifying of source code change the value for this var. Value stores in the system var sys.path, but the first item of this list, path[0], is the directory containing the script that was used

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Sergey Kishchenko
On 8 янв, 22:03, "Chris Rebert" wrote: > On Thu, Jan 8, 2009 at 5:53 AM, Sergey Kishchenko wrote: > > In Python empty container equals False in 'if' statements: > > > # prints "It's ok" > > if not []: > >    print "It

Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Sergey Kishchenko
In Python empty container equals False in 'if' statements: # prints "It's ok" if not []: print "It's ok" Let's create a simple Foo class: class Foo: pass Now I can use Foo objects in 'if' statements: #prints "Ouch!" f=Foo() if f: print "Ouch!" So, default __nonzero__ impl is to re

Re: Python lex settings

2008-12-18 Thread Sergey Shepelev
On Dec 19, 2:16 am, Robert Kern wrote: > Sergey Shepelev wrote: > > Hello. > > > I'm trying to make almost-Python source to Erlang source translation > > tool. > > > Are there ready ply.lex settings for parsing python source? > > Yes! Andrew Dalke

Python lex settings

2008-12-18 Thread Sergey Shepelev
Hello. I'm trying to make almost-Python source to Erlang source translation tool. Are there ready ply.lex settings for parsing python source? -- http://mail.python.org/mailman/listinfo/python-list

Re: subexpressions

2007-06-01 Thread Sergey Dorofeev
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What syntax would you suggest for a lambda enhanced to cover your use > case? > I suppose you will end up with roughly the same number of characters, all > crammed in one line -- or broken into lines at a random positio

Re: subexpressions

2007-06-01 Thread Sergey Dorofeev
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Please help, is there way to use sub-expressions in lambda? For example, if I want to calculate sin(x^2)+cos(x^2) I must code: lambda x: sin(x*x)+cos(x*x) How to make x*x to be evaluated once? >>> >>

Re: subexpressions

2007-06-01 Thread Sergey Dorofeev
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sergey Dorofeev wrote: > >> Please help, is there way to use sub-expressions in lambda? >> For example, if I want to calculate sin(x^2)+cos(x^2) I must code: >> lambda x: si

subexpressions

2007-06-01 Thread Sergey Dorofeev
Hello all! Please help, is there way to use sub-expressions in lambda? For example, if I want to calculate sin(x^2)+cos(x^2) I must code: lambda x: sin(x*x)+cos(x*x) How to make x*x to be evaluated once? -- http://mail.python.org/mailman/listinfo/python-list

Re: f---ing typechecking

2007-02-14 Thread Sergey Dorofeev
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It's effectively a tuple with field names. I don't know when the switch > occurred (it's in 2.2, as far back as my built interpreter versions > currently go), but back in the day os.stat used to return a plain old > tuple. posix.sta

Re: f---ing typechecking

2007-02-14 Thread Sergey Dorofeev
"James Stroud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >[1]+(1,) >> >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: can only concatenate list (not "tuple") to list >> >> >> Its ugly and boring. > > Agreed. This would be similar to: > > py> 1

f---ing typechecking

2007-02-14 Thread Sergey Dorofeev
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> (1,)+[1] Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate tuple (not "list") to tuple >>> [1]+(1,)

Re: module email

2007-01-25 Thread Sergey Dorofeev
"Rob Wolfe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> p2=email.message.Message() >> p2.set_type("message/rfc822") >> p2.set_payload(m) > > Payload is a _list_ of Message objects (is_multipart() == True) > or a _string_ object (is_multipart() == False) but never just Message

module email

2007-01-24 Thread Sergey Dorofeev
Hello. Why does not work? -- import email.message import smtplib import time m=email.message.Message() m.set_type("multipart/mixed") m["From"]="Sergey Dorofeev <[EMAIL PROTECTED]>" m["To"]="Sergey Dorofeev <[EMAIL PROTECTE

treating MIME messages

2006-12-21 Thread Sergey Dorofeev
Hello all. Anybody who has idle time, please look at my version of MIME tools at http://www.fidoman.ru/prog/mime/. Questions and critical notes are welcome. If somebody will consider that interesting, I will refine these modules and put to pypi. -- http://mail.python.org/mailman/listinfo/pyth

Re: why? [win32com/WMI]

2006-03-02 Thread Sergey
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [Sergey] >| >import wmi >| >c = wmi.WMI (computer="srv", user="[EMAIL PROTECTED]", password="") >| >pid, retval = c.Win32_Process.Create (CommandLin

Re: why? [win32com/WMI]

2006-03-02 Thread Sergey
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [Sergey] >import wmi >c = wmi.WMI (computer="srv", user="[EMAIL PROTECTED]", password="") >pid, retval = c.Win32_Process.Create (CommandLine="notepad.exe"

why? [win32com/WMI]

2006-03-01 Thread Sergey
import win32com.client loc = win32com.client.Dispatch("WbemScripting.SWbemLocator") svc = loc.ConnectServer("srv", "root/cimv2", "[EMAIL PROTECTED]", "**") sys = svc.get("Win32_Process") sys.create("notepad.exe") => Traceback (most recent call last): File "remote.py", line 6, in ? sys.create

module time

2006-02-20 Thread Sergey
There is function mktime() -- convert local time tuple to seconds since Epoch in module time. But how about to convert *GMT time tuple* to seconds since Epoch? Is there such function? -- http://mail.python.org/mailman/listinfo/python-list

Re: file names longer than MAX_PATH under Windows 2003

2006-02-15 Thread Sergey
"Claudio Grondi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sergey wrote: > I don't know if and how it apply and can be of any help here, but in my C > programs in the very past after switching from DOS to > Windows long names a following tr

Re: file names longer than MAX_PATH under Windows 2003

2006-02-15 Thread Sergey
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [Sergey] >Have a look at win32file.FindFilesIterator from the pywin32 extensions. >Maybe that can cope? (I haven't looked at the source). Yeah, it works! THANK YOU! (but now I must have two pi

Re: file names longer than MAX_PATH under Windows 2003

2006-02-15 Thread Sergey
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [Sergey] >I see from another post that CreateFile cannot open your file. >That puts it further away from Python, although it doesn't >explain how some other program can see the files. Can

Re: file names longer than MAX_PATH under Windows 2003

2006-02-14 Thread Sergey
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [Sergey] >Not to state the obvious, but can you cut-and-paste that long >string (the one starting with \\?\e:\...) from the Python >interpreter into the [S]tart [R]un [O]pen field to see what >

Re: file names longer than MAX_PATH under Windows 2003

2006-02-14 Thread Sergey
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Are you passing a unicode object to the function? > > f = file(u"E:\\files\\...\\something.dat", "r") I pass variable c into functions: >>> c u'.\\e:\\files\\\u041f\u0420\u041e\u0414\u041e \u041c\u0435\u043d\u043

Re: file names longer than MAX_PATH under Windows 2003

2006-02-14 Thread Sergey
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [Sergey] >Not to state the obvious, but can you cut-and-paste that long >string (the one starting with \\?\e:\...) from the Python >interpreter into the [S]tart [R]un [O]pen field to see what >

Re: file names longer than MAX_PATH under Windows 2003

2006-02-14 Thread Sergey
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [Sergey] >But note that r prefix to the string. Is it possible >that your string didn't include it? If not, then the >backslash character which Windows uses as a separator >can be sto

file names longer than MAX_PATH under Windows 2003

2006-02-14 Thread Sergey
Hello. I try to open file with pathname length 282 bytes: E:\files\..\something.dat On MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp) described method to access files with path length up to 32000 bytes: just add prefix \\?\ t

Sql Parser

2006-01-29 Thread Sergey Eizner
Does anybody know python module for sql parsing? -- http://mail.python.org/mailman/listinfo/python-list

thread and alarm

2005-12-16 Thread Sergey
How to send alarm to a thread? I can set alarm in main thread, but how then send exception to another thread to wake it if it executes too long? -- http://mail.python.org/mailman/listinfo/python-list

Re: need reading file in binary mode

2005-12-01 Thread Sergey P. Vazulia
Problem solved. "Sergey P. Vazulia" <[EMAIL PROTECTED]> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:[EMAIL PROTECTED] > this part of my code: > > f = file(work_dir + filename,'rb') ^ >

need reading file in binary mode

2005-12-01 Thread Sergey P. Vazulia
this part of my code: f = file(work_dir + filename,'r') n = int(totalSize/recordLenth) i = 0 while i < n: buf = f.read(recordLenth); sometime (when find something like \0A\00\00 in data) returm less bytes then file have. Q: how-to read all data from bi

Python for Gaim

2005-11-15 Thread Boichenko Sergey
, Sergey -- http://mail.python.org/mailman/listinfo/python-list

struct.(un)pack and ASCIIZ strrings

2005-06-18 Thread Sergey Dorofeev
I can use string.unpack if string in struct uses fixed amount of bytes. But is there some extension to struct modue, which allows to unpack zero-terminated string, size of which is unknown? E.g. such struct: long, long, some bytes (string), zero, short, short, short. -- http://mail.python.org/ma

Re: regexp weirdness (bug?)

2005-04-06 Thread Sergey Schetinin
it's line #159 here, but it did work! thanks. so it IS a bug? -- http://mail.python.org/mailman/listinfo/python-list

regexp weirdness (bug?)

2005-04-05 Thread Sergey Schetinin
Here's the session log: >>> _re_pair="(?(plus).|-)" >>> _re1=("(?P\+)"+_re_pair) >>> _re2=("((?P\+))"+_re_pair) >>> _re3=("(?:(?P\+))"+_re_pair) >>> _re4="(%s)"%_re3 >>> import re >>> print [re.match(_re, "+a") and 'match' for _re in [_re1, _re2, _re3, _re4]] ['match', None, 'match', None] this i

ConfigParser

2005-03-17 Thread Sergey
Is there an alternative to standard module ConfigParser, which can use delimitier symbol other than ":" and "=", preferaby just space? I need to parse such configs: [Passwords] 2:5020/758 2:5020/794 ConfigParser is not able to work with option names which contain symbol ':' It is not d