Wing IDE 101 (new freeware version) works with Python 2.6

2008-10-03 Thread Marius
Wing IDE 101
Version: 3.1.4-1 (rev 18789)
Release Date: September 18, 2008

from http://www.wingware.com/wingide-101
"Wing IDE 101 is a free basic edition of Wing IDE that was designed
with the University of Toronto Computer Science Department for
teaching entry level computer science courses with Python. It omits
much of the feature set of Wing IDE Professional and introduces some
simplifications appropriate for beginners"

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


Execute a list

2005-02-22 Thread Groleo Marius
Hi.
How can i execute a string in python?
For example if I have the variable s, defined below
s = '"print "hello"'
How can I execute the code that "s" keeps inside, considering that the
code is correct?
-- 
http://mail.python.org/mailman/listinfo/python-list


executea string

2005-02-22 Thread Groleo Marius
I have the folowing code:
 c=2
 e=3
 s="12"
 code.append('funtion ("c, e,s")')
 print "\n".join(code) + '\n'

The problem is when i call append.
The variables s, c, e are not replaced with their value, so in the end
i get the result:

funtion(" c, e, s");

The result that i want is :
funtion("2,3,12");



-- 
Regards,
 .''`.   # touch universe
: :'  :  # chmod +rwx universe
`. `'` # ./universe
  `-  Debian - when you have better things to do than fix a system
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python like VB?

2005-03-17 Thread Groleo Marius
Maybe you should ask : Is VB like Python
( remark the  )


On 17 Mar 2005 09:45:22 +0200, Ville Vainio <[EMAIL PROTECTED]> wrote:
> > "Cappy" == Cappy2112  <[EMAIL PROTECTED]> writes:
> 
> Cappy> VB has a much better IDE than the IDE's for Python,
> Cappy> although Eric3 is one of the best, and is absolutely free.
> 
> Eric3 is not easily available for win32, due to current state of Qt
> licensing (will change with Qt4 I think).
> 
> Cappy> There are many gui toolkits/frameworks for Python, but the
> Cappy> foreunners are pyQT, wxPython, pyGTK, and TK/Tkinter.
> 
> On windows it might make sense to choose wxPython, though I've heard
> some good stuff about new versions of pyGTK as well.
> 
> People coming from VB background probably also appreciate the ability
> to draw the UI in point&click style:
> 
> http://gazpacho.sicem.biz/
> http://wxglade.sourceforge.net/
> 
> Unfortunately these seem to still be a tad rough around the edges...
> 
> --
> Ville Vainio   http://tinyurl.com/2prnb
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
Regards, Groleo!

 .''`.   # touch universe
: :'  :  # chmod +rwx universe
`. `'` # ./universe
  `-  Debian - when you have better things to do than fix a system
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2004-12-28 Thread Marius Bernklev
* [EMAIL PROTECTED]

> Perhaps ()'s are a good idea for some other reason I don't know?

One-element tuples are written as (4,).



-- 
Marius Bernklev

http://www.ping.uio.no/~mariube/ >

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


Re: python versions of perl modules

2004-12-30 Thread Marius Bernklev
* [EMAIL PROTECTED]

> So is that a yes or a no to the man's question?

Of course it is.


-- 
Marius Bernklev

Holmgang:  Deodoranter har parfyme, mens folk bare kaster kaffegruten.
  Bør nye PC-er inkludere ekstra USB-kabel?  Vi tar debatten!

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


Re: efficient 'tail' implementation

2005-12-15 Thread Marius Gedminas
Magnus Lycka wrote:
> To read the last x bytes of a file, you could do:
>
>  >>> import os
>  >>> x = 2000 # or whatever...
>  >>> f=open('my_big_file')
>  >>> l=os.fstat(f.fileno()).st_size
>  >>> f.seek(l-x)
>  >>> f.read()

You don't need fstat/st_size, you can ask seek to move to an offset
relative to the end of the file:

>>> x = 2000
>>> f = open('my_big_file')
>>> f.seek(-x, 2)
>>> f.read()

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


Re: python coding contest

2005-12-28 Thread Marius Gedminas
Jean-Paul Calderone wrote:
> On Tue, 27 Dec 2005 14:02:57 -0700, Tim Hochberg <[EMAIL PROTECTED]> wrote:
> >Shane Hathaway wrote:
> >> Paul McGuire wrote:
> >>
> >>
> >> Also, here's another cheat version.  (No, 7seg.com does not exist.)
> >>
> >>import urllib2
> >>def seven_seg(x):return urllib2.urlopen('http://7seg.com/'+x).read()
> >>
> >And another one from me as well.
> >
> >class a:
> >  def __eq__(s,o):return 1
> >seven_seg=lambda i:a()
> >
>
> This is shorter as "__eq__=lambda s,o:1".

Or even

  class seven_seg(str):__eq__=lambda*a:1

39 characters; passes the test suite.  I'm sure it would be
disqualified for cheating, though. :-)

> But I can't find the first post in this thread... What are you
> guys talking about?

http://www.pycontest.net

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


Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot not reach the contest site at since all this morning.  :-(

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


Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot reach the contest site at since all this morning.  :-(

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


Re: python coding contest

2005-12-30 Thread Marius Gedminas
I managed it with vim.

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


Re: understanding stat module names

2006-01-18 Thread Marius Gedminas
David Bear wrote:
> I'm trying to use os.chmod and am refered to the stat module.
>
> Is there are explanation of:
> * S_ISUID
...
> * S_IXOTH

These come from the POSIX standard.  See
http://www.opengroup.org/onlinepubs/007908799/xsh/sysstat.h.html

HTH,
Marius Gedminas

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


Re: How do you use this list ?

2006-06-27 Thread Marius Ursache

Bo Yang wrote:
> Hi everyone ,
> I have join this list for about 4 months , and everyday I receive
> hundreds of
> mails . There is no means to read all of them , so I just read something
> interesting
> for me . But if so , there are too much mails pile up in my inbox , I
> want to ask
> how do you use this list , reading every mail come in or just read what
> you think
> interesting ?
>

I use digest messages on a gmail account. i read the digests whenever i
have time.

--
M.

http://marius.me.uk/

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


Re: days since epoch

2006-02-17 Thread Marius Gedminas
The datetime module is usually more convenient for date/time
arithmetic.  However in your particular case, you may find the
time.time() function convenient.  It returns the number of seconds
since the epoch.  To get the number of days divide the number of
seconds by 86400.

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


Re: *Naming Conventions*

2007-06-11 Thread Marius Gedminas
On Jun 6, 3:18 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> > Since 'i' and 'j' are canonically loop indices, I find it
> > totally confusing to use them to name the iteration variable -
> > which is not an index.
>
> Certainly i and j are just as generic, but they have the
> advantage over 'item' of being more terse.

Python programmers usually prefer readability over terseness. Finding
a variable named 'i' that is not an integer index would be surprising
to me.

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


Re: Collections of non-arbitrary objects ?

2007-06-25 Thread Marius Gedminas
On Jun 24, 2:12 pm, Bjoern Schliessmann  wrote:
> 7stud wrote:
> > if hasattr(elmt, some_func):
> >elmt.some_func()
>
> Personally, I prefer
>
> try:
> elmt.some_func()
> except AttributeError:
> # do stuff

That also hides attribute errors that occur within some_func.  I think
I'd rather know when elmt has an implementation of some_func that is
buggy.  Thus I prefer the hasattr version.

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


Re: md5 from python different then md5 from command line

2006-05-07 Thread Marius Ursache
> echo adds a newline:
>
>>>> import md5
>    >>> test = md5.new("marius\n")
>>>> print test.hexdigest()
>0f0f60ac801a9eec2163083a22307deb
> 
> Just


Thanks, that was it ;)

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


Re: Python Generators

2008-03-18 Thread Marius Gedminas
On Mar 16, 9:24 am, Matt Nordhoff <[EMAIL PROTECTED]> wrote:
> mpc wrote:
> > def concatenate(sequences):
> >     for seq in sequences:
> >         for item in seq:
> >             yield item
>
> You should check out itertools.chain(). It does this. You call it like
> "chain(seq1, seq2, ...)" instead of "chain(sequences)" though, which may
> be a problem for you.

Solved rather easily by chain(*sequences):

>>> from itertools import chain
>>> def concat(sequences):
... return chain(*sequences)
...
>>> concat([[1,2], [3, 4], [5], [6, 7, 8]])

>>> list(concat([[1,2], [3, 4], [5], [6, 7, 8]]))
[1, 2, 3, 4, 5, 6, 7, 8]


wondering if google groups will add a .sig or not-ly,
Marius Gedminas
-- 
http://mail.python.org/mailman/listinfo/python-list


Load / Reload module

2009-02-04 Thread Marius Butuc
Hi,

First I must state that I'm a beginner in Python, so all help would be
more than welcomed.

I want do declare some classes (classes.py) in an external editor,
than import the file and use the classes. After I change the file, I
want to reload the definitions w/o leaving the interactive
interpreter.

So far I have tried
- import classes   # doesn't import my classes
- from classes import * # imports, but I can't reload
- reload(classes)  # I have the same class definition
after this

I've tried the documentation but I got lost, so please help.

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


Re: Q's on my first python script

2009-05-14 Thread Marius Gedminas
On May 11, 12:30 pm, Nick Craig-Wood  wrote:
>     def __init__(self):
>         usage = '''Usage: %prog [options] YYMMDD
>            %prog -h|--help
> '''
>         parser = OptionParser(usage=usage)
>         parser.add_option("-n", "--no-newline", dest="nonl",
>                           action="store_true", help="omit newline in output")
>         (options, args) = parser.parse_args();
>         try:
>             weekday = self.wkday_abbrev(args[0])
>         except BadDateString, e:
>             print usage
>             print e
>             sys.exit(1)

I would recommend printing error messages to sys.stderr.

BTW, in this particular case you may want to use

 parser.error(e)

instead of print + sys.exit.

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


Re: Q's on my first python script

2009-05-14 Thread Marius Gedminas
On May 10, 6:56 pm, Steven D'Aprano  wrote:
> > 4. What's the python way to emit warnings?  (The script below should
> >    warn the user that arguments after the first one are ignored.)
>
> import warnings
> warnings.warn("The end of the world is coming!")

The warnings module is used for warnings about program code, not user
input.

import logging
logging.warn("Oh noes, you passed me two arguments instead of one!")

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


extract to dictionaries

2009-05-28 Thread Marius Retegan
Hello
I have simple text file that I have to parse. It looks something like
this:

parameters1
 key1 value1
 key2 value2
end

parameters2
 key1 value1
 key2 value2
end

So I want to create two dictionaries parameters1={key1:value1,
key2:value2} and the same for parameters2.

I woud appreciate any help that could help me solve this.
Thank you

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


Re: extract to dictionaries

2009-05-29 Thread Marius Retegan
Hi,

On Fri, May 29, 2009 at 2:09 AM, Gary Herron wrote:

> Marius Retegan wrote:
>
>> Hello
>> I have simple text file that I have to parse. It looks something like
>> this:
>>
>> parameters1
>> key1 value1
>> key2 value2
>> end
>>
>> parameters2
>> key1 value1
>> key2 value2
>> end
>>
>> So I want to create two dictionaries parameters1={key1:value1,
>> key2:value2} and the same for parameters2.
>>
>> I would appreciate any help that could help me solve this.
>> Thank you
>>
>>
>
> This looks like a homework problem.


It's not. I'm passed homework age.


>   But even if it's not, you are not likely to find someone who is willing
> to put more work into this problem than you have.
> So  why don't you show us what you've tried, and see if someone is willing
> to make suggestions or answer specific question about your attempt at a
> solution?
>

I don't now if posting a code that gets into a while loop and never stops
would demonstrate to you that I've tried. Be assured that before posting to
the list I did try to solve it myself, because I knew that I might get an
answer like RTFM or similar.
Maybe I'm not smart enough, but I can't make python to start reading after
the "parameter1" line and stop at the "end" line. That's all I want a small
piece of pseudocode to do just that.

Thanks


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


Re: Python and Ruby

2010-02-04 Thread Marius Gedminas
On Feb 4, 1:03 am, John Bokma  wrote:
> Jonathan Gardner  writes:
> > I can explain all of Python in an hour;
>
> OK, in that case I would say give it a go. Put it on YouTube, or write a
> blog post about it (or post it here). I am sure you will help a lot of
> people that way.

Someone already did: "Advanced Python or Understanding Python"
http://video.google.com/videoplay?docid=7760178035196894549
(76 minutes).

Worth watching.

Regards,
--
Marius Gedminas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-URL! - weekly Python news and links (Feb 9)

2010-02-09 Thread Marius Gedminas
The last three URLs are malformed:

On Feb 9, 5:03 pm, "Gabriel Genellina"  wrote:
>     There is no module in the standard library to handle filesystem paths
>     in an OO way - but why?
>        http://groups.google.com/group/comp.lang.pythonf580fb3763208425ece/
>
>     A "History Channel" special: how the way a TAB key was interpreted
>     changed over time
>        http://groups.google.com/group/comp.lang.python82d9181fcd31ffea3f4/
>
>     After a false start, finally we get our first "Is it Call-By-Value or
>     Call-By-Reference?" thread of the year!
>        http://groups.google.com/group/comp.lang.pythonfd36962c4970ac487ea/

Any chance of getting them fixed?

Regards,
--
Marius Gedminas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
On Apr 28, 3:59 pm, Christian Heimes  wrote:
> The trick works only for objects that are tracked by CPython's garbage
> collector. Simple and non-containerish objects like str, int, unicode
> and some other types aren't tracked by the gc.

Yes they are -- have you ever tried

  >>> import gc
  >>> gc.get_referrers(42)

?


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


Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
On Apr 27, 11:45 pm, Michal M  wrote:
> I've just found out that one of objects is not destroyed when it
> should be. This means that something was holding reference to this
> object or part of it (i.e. method). Is there any way to check what
> holds that reference? I am unable to do that just looking to the code
> or debugging it because it is pretty complicated, but I am able to
> invoke this situation again.

I wrote http://pypi.python.org/pypi/objgraph for this purpose.

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


Re: your favorite debugging tool?

2009-09-03 Thread Marius Gedminas
On Aug 25, 2:55 pm, Esmail  wrote:
> Re pdb, if you have a 'pointer' (ie reference) to an object, is there
> an easy way to dump out its contents, ie all of its members short of
> writing a method that does that and then calling it?

Usually

  pp vars(your_object)

does what you want
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Application-global "switches"?

2009-09-17 Thread Marius Gedminas
On Sep 4, 9:29 pm, kj  wrote:
> The only solution I can come up with is to define a "dummy module",
> say _config.py, which contains only upper-case variables representing
> these global switches, and is imported by all the other modules in
> the application with the line "from _config import *".  During the
> early stages of the run, the script inspects the command-line flags,
> and if it finds a --continuing flag, it sets the variable
> _config.CONTINUATION_MODE to True.  (The last point implies that
> these variables are not strictly speaking read-only, since they
> most be set at the beginning of the run.  But after this initial
> setting, they should remain read-only.)

Be very very careful about "from _config import *".  If you import
a module that, in turn, imports _config this way, before you set
the initial values, that module will already have made its own copies
of all the variables and thus will not see the correct values.
-- 
http://mail.python.org/mailman/listinfo/python-list