using python from c/c++

2005-06-10 Thread alexandr
Is it possible to create a library from my python module that can be
used from c/c++ application?



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


Help to translate simple VBA code to Python

2008-02-10 Thread Alexandr N Zamaraev
I use Bentley MicroStation through Automation interface.
But I do not known how translate some VBA code to Python.
For example ("Copy Element Example" from documentation):


'The following code starts the command
Sub RunCopyElement()
 CommandState.StartLocate New clsCopyElementCommand
End Sub

'This following code must be in a class that implements 
ILocateCommandEvents. In this example, it is in the class 
clsCopyElementCommand.

Implements ILocateCommandEvents

' This is called when the user enters a data point after the
'  LocateFilter has accepted an element
Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, Point 
As Point3d, ByVal View As View)
'skip function body
End Sub

Private Sub ILocateCommandEvents_Cleanup()
End Sub

Private Sub ILocateCommandEvents_Dynamics(Point As Point3d, ByVal View 
As View, ByVal DrawMode As MsdDrawingMode)
'skip function body
End Sub

Private Sub ILocateCommandEvents_LocateFailed()
'skip function body
End Sub


Private Sub ILocateCommandEvents_LocateFilter(ByVal Element As Element, 
   Point As Point3d, Accepted As Boolean)
'skip function body
End Sub

Private Sub ILocateCommandEvents_LocateReset()
'skip function body
End Sub

Private Sub ILocateCommandEvents_Start()
'skip function body
End Sub

Also sample using interface ILocateCommandEvents: 
http://www.la-solutions.co.uk/content/MVBA/MVBA-MeasureArea.htm

All interface derived from IDiapach.

How to realize in Python without external DLL?
-- 
http://mail.python.org/mailman/listinfo/python-list


Why date do not construct from date?

2009-06-01 Thread Alexandr N Zamaraev

Simple example:
[code]
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit 
(Intel)] on win32

>>> import datetime as dt
>>> dt.date(2009, 10, 15)
datetime.date(2009, 10, 15)
>>> d = dt.date(2009, 10, 15)
>>> dt.date(d)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: function takes exactly 3 arguments (1 given)
>>>
[/code]
Why int form int, str from str, Decumal from Decumal can construct bat 
date from date not?

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


Re: ?

2008-05-15 Thread Alexandr N Zamaraev

urikaluzhny wrote:

| It seems that I rather frequently need a list or iterator of the form
| [x for x in <> while <>]
I can think of two ways to interpret that.

I mean like [x for x in  if ], only that it breaks the loop when
the expression  is false.

How do you plan to modify B during iteration?
May be
[x for x in itertools.takewhile(, )]
when  function accept element  and return True or False


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


Re: Simplify Code

2008-07-15 Thread Alexandr N Zamaraev

header_sizes = (36, 26, 22, 18, 14, 12)
if x not in header_sizes:
  raise Exception()
else:
  h36, h26, h22, h18, h14, h12 = tuple(
line if x == size else '' for x in header_sizes)



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


Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Alexandr N Zamaraev

s = '--a href="/browse/brick"--brick--/a--'
s

'--a href="/browse/brick"--brick--/a--'
''.join('<%s>' % l if i % 2 == 1 else l for i, l in 

enumerate(s.split('--')))
'brick'

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


Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Alexandr N Zamaraev

Alexnb wrote:

s = '--a href="/browse/brick"--brick--/a--'
s

'--a href="/browse/brick"--brick--/a--'
''.join('<%s>' % l if i % 2 == 1 else l for i, l in 

enumerate(s.split('--')))
' /browse/brick brick '


I'm sorry, I don't think I was being clear. I replaced the <'s with -- so it
would post online w/o actually making a link. I just need to know how to get
the "brick" out.

1) if string really '--a href="/browse/brick"--brick--/a--'
>>> s.split('--', 3)[2]
brick
2) if string 'brick'
>>> s.split('>', 1)[1].split('<')[0]
brick
--
http://mail.python.org/mailman/listinfo/python-list


Re: common elements between list of lists and lists

2008-07-17 Thread Alexandr N Zamaraev

>>> list4 = [['1', 'a'],['4', 'd'],['8', 'g']]
>>> list5 = [1, 2, 3]
>>> set5 = set(list5)
>>> [x for n, x in list4 if int(n) in set5]
['a']

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


Re: Interbase

2008-07-30 Thread Alexandr N Zamaraev

Mike Hjorleifsson wrote:

Has anyone gotten python working with Interbase database platform ?  I

See KInterbasDB: http://kinterbasdb.sourceforge.net/
--
http://mail.python.org/mailman/listinfo/python-list


py2exe do not compile from mingw

2008-04-28 Thread Alexandr N Zamaraev

OS: WinXP Home Ru + sp2
Python: 2.5.2
py2exe: latest CSV source
gcc (GCC) 3.4.5 (mingw-vista special r2)
GNU ld (GNU Binutils) 2.18.50.20080109

OS: WinXP Home Ru + sp2
Python: 2.5.2
py2exe: latest CSV source
gcc (GCC) 3.4.5 (mingw-vista special r2)
GNU ld (GNU Binutils) 2.18.50.20080109

I have patchs for compile py2exe from latest release mingw.

Correct setup, compile, and run errors.

This patch union 1012785 patch and 1378533 bag patch for latest CSV source.

see alse
http://sourceforge.net/tracker/index.php?func=detail&aid=1953133&group_id=15583&atid=315583, 




http://sourceforge.net/tracker/?func=detail&aid=1378533&group_id=15583&atid=115583, 




http://sourceforge.net/tracker/?func=detail&aid=1012785&group_id=15583&atid=315583


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


strftime() argument 1 must be str, not unicode

2008-05-07 Thread Alexandr N Zamaraev

Subj is bag?

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit 
(Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.today().strftime('%Y_%m_%d %H_%M_%S.csv')
'2008_05_07 12_30_22.csv'
>>> datetime.today().strftime(u'%Y_%m_%d %H_%M_%S.csv')
Traceback (most recent call last):
  File "", line 1, in 
TypeError: strftime() argument 1 must be str, not unicode
--
http://mail.python.org/mailman/listinfo/python-list


Re: strftime() argument 1 must be str, not unicode

2008-05-08 Thread Alexandr N Zamaraev

Tim Roberts wrote:
> I think that's a perfectly reasonable thing to expect.  At the risk of
> over-generalization, there is no good reason why, by this point in time,
> all of the standard library routines that accept strings shouldn't also
> accept Unicode strings.
However, file(fname), open(fname), os .*, os.path .*, 
time.strftime(format) take unicode parameters.

See http://bugs.python.org/issue2782
--
http://mail.python.org/mailman/listinfo/python-list


Path for compile kinterbasdb with mingw32 and python 2.6

2009-10-05 Thread Alexandr N Zamaraev

I write path for compile kinterbasdb with mingw32 and python 2.6 for rev
1038
See
http://sourceforge.net/tracker/?func=detail&aid=2872794&group_id=9913&atid=309913


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